private void supprimer_btn_Click(object sender, EventArgs e) { try { string id = categorie_code_box.Text; //verifier si le text box est non vide || verifier si le code existe if (string.IsNullOrWhiteSpace(id)) { throw new Ex("vous devez selectionner la categorie\nque vous voulez supprimer!"); } //verifier si la categorie ne contient aucun plat int verify = db.Verify_Empty_Categorie(id); if (verify != 0) { throw new Ex("la categorie que vous voulez supprimer contient des plats!"); } else { if (MessageBox.Show("Voulez vous vraiment supprimer cette Categorie ?", "Supprimer Categorie", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int code = int.Parse(id); db.Supprimer_Categorie(code); ClearTextBoxes(); db.Afficher_Categorie(Categorie_grid); } else { MessageBox.Show("Categorie non Supprimée !", "Spprimer Categorie", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { } }