public void InsertClientData(ClientRecord record) { Database db = new Database(context); bool check = db.CheckRecord(record.id.ToString(), "client"); var conn = new SqliteConnection(connectionString); conn.Open(); var cmd = conn.CreateCommand(); if (check) { cmd.CommandText = $"UPDATE client " + $"SET achternaam = '{record.achternaam}', voornaam = '{record.voornaam}', adres = '{record.adres}', postcode = '{record.postcode}', woonplaats = '{record.woonplaats}', telefoonnummer = '{record.telefoonnummer}' " + $"WHERE id = {record.id}"; } else { cmd.CommandText = "INSERT INTO client (id, achternaam, voornaam, adres, postcode, woonplaats, telefoonnummer) " + $"VALUES ({record.id}, '{record.achternaam}', '{record.voornaam}', '{record.adres}', '{record.postcode}', '{record.woonplaats}', '{record.telefoonnummer}')"; } cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); conn.Close(); }
private void displayClientForTask(string clientId) { ClientRecord client = Config.getClient(clientId, this); var imageBitmap = GetImageBitmapFromUrl(client.getMap()); FindViewById <TextView>(Resource.Id.textViewAddress).Text = "🗺 - " + client.getAddress(); FindViewById <TextView>(Resource.Id.textViewTelephone).Text = "📞 - " + client.getTelephone(); FindViewById <TextView>(Resource.Id.textViewPlanning).Text = "📝 - " + client.getPlanning(); FindViewById <ImageView>(Resource.Id.imageViewMap).SetImageBitmap(imageBitmap); }
public ClientRecord GetClientById(string id) { var conn = new SqliteConnection(connectionString); conn.Open(); var cmd = conn.CreateCommand(); cmd.CommandText = $"SELECT * FROM client WHERE id = {id}"; cmd.CommandType = CommandType.Text; SqliteDataReader reader = cmd.ExecuteReader(); ClientRecord record = new ClientRecord(reader); conn.Close(); return(record); }
public static ClientRecord getClient(string clientId, Activity activity) { ClientRecord client = null; try { client = Config.getClient(clientId); } catch (Exception) { AlertDialog.Builder alert = new AlertDialog.Builder(activity); alert.SetMessage("Inconsistent database, non-existent client"); Dialog dialog = alert.Create(); dialog.Show(); return(null); } return(client); }
public override View GetView(int position, View view, ViewGroup parent) { var item = items[position]; if (view == null) { view = context.LayoutInflater.Inflate(Resource.Layout.ListRow, null); } ClientRecord client = Config.getClient(item.client_id, Config.getActivity(view)); if (client != null) { view.FindViewById <TextView>(Resource.Id.Text1).Text = item.taskName; } view.FindViewById <TextView>(Resource.Id.Text2).Text = client.getAddress(); view.FindViewById <TextView>(Resource.Id.Text3).Text = item.taskDate; return(view); }
public void DownloadData(string id) { var webClient = new WebClient() { Encoding = Encoding.UTF8 }; string personalisedUrl = url + id; try { byte[] myDataBuffer = webClient.DownloadData(personalisedUrl); string download = Encoding.ASCII.GetString(myDataBuffer); JsonValue value = JsonValue.Parse(download); foreach (JsonObject result in value) { DatabaseClient dbc = new DatabaseClient(context); ClientRecord clientRecord = new ClientRecord(result); dbc.InsertClientData(clientRecord); DatabaseZorgmoment dbz = new DatabaseZorgmoment(context); ZorgmomentRecord momentRecord = new ZorgmomentRecord(result); dbz.InsertZorgmomenten(momentRecord); DatabaseTaak dbt = new DatabaseTaak(context); foreach (JsonObject taak in result["taken"]) { TaakRecord taakRecord = new TaakRecord(taak); dbt.InsertTaken(taakRecord); } } } catch (WebException e) { Console.WriteLine("exception: " + e.Message); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); DatabaseClient dbc = new DatabaseClient(this); ClientRecord client = dbc.GetClientById(Global.zorgmoment.client_id.ToString()); SetContentView(Resource.Layout.DetailAdres); FindViewById <TextView>(Resource.Id.Naam).Text = $"{client.voornaam} {client.achternaam}"; FindViewById <TextView>(Resource.Id.Adres).Text = $"{client.adres}"; FindViewById <TextView>(Resource.Id.PostcodeWoonplaats).Text = $"{client.postcode} {client.woonplaats}"; FindViewById <TextView>(Resource.Id.Telefoonnummer).Text = $" Telefoonnummer: {client.telefoonnummer}"; FindViewById <TextView>(Resource.Id.Opmerkingen).Text = Global.zorgmoment.opmerkingen; ListView aanwezigbtn = FindViewById <ListView>(Resource.Id.AanwezigButton); aanwezigbtn.Adapter = new PresentButtonAdapter(this); Button homebtn = FindViewById <Button>(Resource.Id.HomeButton); homebtn.Click += (object sender, EventArgs e) => { StartActivity(typeof(Home)); }; Button takenbtn = FindViewById <Button>(Resource.Id.TakenButton); takenbtn.Click += (object sender, EventArgs e) => { StartActivity(typeof(DetailTaken)); OverridePendingTransition(0, 0); }; Button kaartbtn = FindViewById <Button>(Resource.Id.KaartButton); kaartbtn.Click += (object sender, EventArgs e) => { StartActivity(typeof(DetailKaart)); OverridePendingTransition(0, 0); }; }
public ClientRecord getClient(string dbPath, string client_id) { ClientRecord client = null; var connectionString = String.Format("Data Source={0};Version=3;", dbPath); using (var conn = new SqliteConnection(connectionString)) { conn.Open(); using (var cmd = conn.CreateCommand()) { cmd.CommandText = "SELECT * FROM client WHERE (id) = @client_id"; cmd.Parameters.Add(new SqliteParameter("@client_id", client_id)); cmd.CommandType = CommandType.Text; using (var reader = cmd.ExecuteReader()) { int i = 0; while (reader.Read()) { i++; client = new ClientRecord(reader); } if (i > 1) { Config.log("ERROR MORE CLIENT RECORDS THAN EXPECTED!!"); } if (client == null) { throw new ArgumentException("No such client! ", client_id); } } } conn.Close(); } return(client); }