private void btn_crypter_Click(object sender, RoutedEventArgs e) { DatabaseHelperClass dbHelper; Button btn = (Button)sender; String typeCrypt; switch (btn.Name) { case "btn_crypter": typeCrypt = CRYPTER; break; case "btn_decrypter": typeCrypt = DECRYPTER; break; default: typeCrypt = ""; break; } if (txt_text.Text != "" & txt_password.Text != "" & typeCrypt!="" ) { dbHelper = new DatabaseHelperClass();//Creating object for DatabaseHelperClass.cs from ViewModel/DatabaseHelperClass.cs Record record = new Record(txt_text.Text, txt_password.Text, typeCrypt); dbHelper.Insert(record); txt_result.Text = record.result; //after add contact redirect to contact listbox page //Frame.Navigate(typeof(ReadContactList)); } else { //await new MessageDialog(ERREUR).ShowAsync(); } }
// Insert the new record in the Record table. public void Insert(Record newRecord) { using (var dbConn = new SQLiteConnection(App.DB_PATH)) { dbConn.RunInTransaction(() => { dbConn.Insert(newRecord); }); } }
//Delete specific record public void DeleteRecord(Record record) { using (var dbConn = new SQLiteConnection(App.DB_PATH)) { if (record.id != null) { dbConn.RunInTransaction(() => { dbConn.Delete(record); }); } } }