private void Modifier_Cmd_Click(object sender, EventArgs e) { try { int cmd_Code = 0; string nom_plat = ""; int quantite = 0; float prix = 0; int id_table = 0; if (string.IsNullOrWhiteSpace(code_cmd_box.Text)) { throw new Ex("Veuillez selectionner la commande \n que vous voulez modifier !!"); } else { cmd_Code = int.Parse(code_cmd_box.Text); } if (string.IsNullOrWhiteSpace(plat_box.Text)) { throw new Ex("Veuillez selectionner un plat !!"); } else { nom_plat = plat_box.Text; } if (quantite_num.Value == 0) { throw new Ex("Veuillez choisir une quantité !!"); } else { quantite = Convert.ToInt32(quantite_num.Value); } if (id_table_box.SelectedIndex == -1 || string.IsNullOrWhiteSpace(id_table_box.SelectedItem.ToString())) { throw new Ex("Selectionnez une table !!"); } else { id_table = int.Parse(id_table_box.SelectedItem.ToString()); } db.cmd = new SqlCommand("SELECT * FROM Plat where nom_plat = '" + nom_plat + "'", db.conn); SqlDataAdapter da = new SqlDataAdapter(db.cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count == 1) { prix = dt.Rows[0].Field <float>("prix"); db.Modifier_Cmd(cmd_Code, nom_plat, quantite, prix, id_table); MessageBox.Show("Commande bien modifiée !!", "Succès"); db.Afficher_Cmd(Commande_grid); } ClearTextBoxes(); } catch (Exception ex) { } }