private void Ajouter_btn_Click(object sender, EventArgs e) { bool verify1; try { int id = 0; verify1 = int.TryParse(table_code_box.Text, out id); if (!verify1) { throw new Ex("le code doit etre un nombre entier ! "); } if (db.check_Existence("Tablee", id.ToString())) { MessageBox.Show("la table du code " + id + " existe deja !"); } else { db.Ajouter_Table(id); MessageBox.Show("Succes!"); table_code_box.Clear(); db.Afficher_Table(Table_grid); } } catch (Exception ex) { } }
private void Ajouter_btn_Click(object sender, EventArgs e) { try { string nom = ""; if (string.IsNullOrWhiteSpace(categorie_nom_box.Text)) { throw new Ex("vous devez remplir le champ nom!!"); } else { nom = categorie_nom_box.Text; } if (db.check_Existence("Categorie", categorie_code_box.Text)) { MessageBox.Show("la Categorie du code " + categorie_code_box.Text + " existe deja \n pour la modifier cliquer sur Modifier !"); } else { db.Ajouter_Categorie(nom); MessageBox.Show("Succes!"); ClearTextBoxes(); db.Afficher_Categorie(Categorie_grid); } } catch (Exception ex) { } }
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) { } }
private void Confirmer_Click(object sender, EventArgs e) { try { string nom_plat = ""; int quantite = 0; float prix = 0; int id_table = 0; 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()); } if (db.check_Existence("Commande", code_cmd_box.Text)) { MessageBox.Show("La Commande du code " + code_cmd_box.Text + " existe deja \n pour la modifier cliquer sur Modifier !"); } else { 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.Ajouter_Cmd(nom_plat, quantite, prix, id_table); MessageBox.Show("Commande bien ajoutée !!", "Succès"); db.Afficher_Cmd(Commande_grid); } ClearTextBoxes(); db.Fill_Table(filtre_combobox); db.Fill_Table(facture_box); } } catch (Exception ex) { } }