public static Boolean SupprimerGamme(string id) { foreach (Gamme item in BDDExterne.GetAllGammes()) { if (item.gamId.ToString() == id) { NpgsqlConnection conn; conn = new NpgsqlConnection(chaineConnection); conn.Open(); NpgsqlCommand MyCmd = null; // id, nom ,tel,numrue,codepostal,ville,pays,mail,nom rue string query = @"DELETE FROM ""Gamme"" CASCADE WHERE id = '" + id + "'"; Debug.WriteLine(query); MyCmd = new NpgsqlCommand(query, conn); MyCmd.ExecuteNonQuery(); //Exécution conn.Close(); return(true); } } return(false); }
public void reloadGammes() { // vidage des combobox comboBox1.Items.Clear(); comboBox2.Items.Clear(); comboBox1.Text = ""; comboBox2.Text = ""; // ajout des valeurs ComboxItem item; foreach (Gamme g in BDDExterne.GetAllGammes()) { item = new ComboxItem(g.gamLibelle, g.gamId); comboBox1.Items.Add(item); comboBox2.Items.Add(item); } // sélection du 1er élément //comboBox1.SelectedIndex = 0; //comboBox2.SelectedIndex = 0; }