コード例 #1
0
        private void Ajouter_btn_Click(object sender, EventArgs e)
        {
            bool verify2;

            try
            {
                string nom            = "";
                float  prix           = 0;
                string categorie      = "";
                int    var_disponible = 1;


                if (string.IsNullOrWhiteSpace(nom_plat_box.Text))
                {
                    throw new Ex("vous devez remplir le champ nom!!");
                }
                else
                {
                    nom = nom_plat_box.Text;
                }
                verify2 = float.TryParse(prix_plat_box.Text, out prix); if (!verify2)
                {
                    throw new Ex("le prix doit etre un nombre reel ! ");
                }
                if (categorie_box.SelectedIndex == -1 || string.IsNullOrWhiteSpace(categorie_box.SelectedItem.ToString()))
                {
                    throw new Ex("vous devez remplir le champ categorie !!");
                }
                else
                {
                    categorie = categorie_box.SelectedItem.ToString();
                }

                // si l'admin coche la case non-disponible c'est bon, sinon la disponibilte du plat est tjrs true
                if (disponible_combo.Text == "non disponible")
                {
                    var_disponible = 0;
                }


                if (db.check_Existence("Plat", code_plat_box.Text))
                {
                    MessageBox.Show("le Plat du code " + code_plat_box.Text + " existe deja \n pour la modifier cliquer sur Modifier !");
                }
                else
                {
                    db.Ajouter_Plat(nom, prix, var_disponible, categorie);
                    MessageBox.Show("succes!!");

                    ClearTextBoxes();
                    db.Afficher_Plat(plat_grid);
                    db.Fill_Disponible(disponible_combo);
                }
            }
            catch (Exception ex)

            {
            }
        }
コード例 #2
0
 public Plats()
 {
     InitializeComponent();
     db = new DBConnect();
     db.Fill_Categorie(categorie_box);
     db.Fill_Categorie(filtre_combobox);
     db.Afficher_Plat(plat_grid);
     db.Fill_Disponible(disponible_combo);
 }