protected override void OnNavigatedTo(NavigationEventArgs e) { Selected_ContactId = int.Parse(e.Parameter.ToString()); currentcontact = Db_Helper.ReadContact(Selected_ContactId);//Read selected DB contact NametxtBx.Text = currentcontact.Name;//get contact Name PhonetxtBx.Text = currentcontact.PhoneNumber;//get contact PhoneNumber }
//Update existing conatct public void UpdateContact(Contacts contact) { using (var dbConn = new SQLiteConnection(App.DB_PATH)) { var existingconact = dbConn.Query<Contacts>("select * from Contacts where Id =" + contact.Id).FirstOrDefault(); if (existingconact != null) { existingconact.Name = contact.Name; existingconact.PhoneNumber = contact.PhoneNumber; existingconact.CreationDate = contact.CreationDate; dbConn.RunInTransaction(() => { dbConn.Update(existingconact); }); } } }
// Insert the new contact in the Contacts table. public void Insert(Contacts newcontact) { using (var dbConn = new SQLiteConnection(App.DB_PATH)) { dbConn.RunInTransaction(() => { dbConn.Insert(newcontact); }); } }