private void Button_Click_1(object sender, RoutedEventArgs e) { SQLiteConnection connection = new SQLiteConnection(App.databasePath); connection.CreateTable <Medicament>(); Affichage affichage = new Affichage(); var output = connection.Query <Medicament>("select * from medicament"); if (output.Count > 0) { foreach (var value in output) { string nomDecrypte = HashCode.Decrypt(value.Nom); string moleculeDecrypte = HashCode.Decrypt(value.Molecule); string posologieDecrypte = HashCode.Decrypt(value.Posologie); string contreIndicationDecrypte = HashCode.Decrypt(value.Contre_Indication); affichage.medicaments.Add(new Medicament { Numero = value.Numero, Nom = nomDecrypte, Molecule = moleculeDecrypte, Posologie = posologieDecrypte, Contre_Indication = contreIndicationDecrypte }); } affichage.Show(); } else { MessageBox.Show("Empty Data"); } }
private void Button_Click_2(object sender, RoutedEventArgs e) { _exist = false; Affichage affichage = new Affichage(); SQLiteConnection connection = new SQLiteConnection(App.databasePath); connection.CreateTable <Medicament>(); var output = connection.Query <Medicament>("select * from medicament"); string sql = "DELETE FROM medicament where Medicament.Numero= " + numero.Text; var comm = connection.CreateCommand(sql); try { if (output.Count > 0) { foreach (var value in output) { if (numero.Text == value.Numero.ToString()) { comm.ExecuteNonQuery(); MessageBox.Show("Deleted..."); _exist = true; break; } else { continue; } } if (_exist == false) { MessageBox.Show("input doesnt exist"); } } else { MessageBox.Show("Empty Data"); } } catch (Exception x) { MessageBox.Show("Not Deleted"); } finally { connection.Close(); } numero.Text = string.Empty; }