private void button4_Click(object sender, EventArgs e) { platDAO acces = new platDAO(); listeP = acces.GetAllPlats(); TousPlatsView monForm = new TousPlatsView(listeP); monForm.Show(); }
static Plat Rechercher(List <Plat> pl, String nom) { platDAO acces = new platDAO(); pl = acces.GetAllPlats(); foreach (Plat p in pl) { if (p.Nom == nom) { return(p); } } return(null); }
private void button2_Click(object sender, EventArgs e) { //Plat p = new Plat(nomAj.Text, prixAj.Text, qteAj.Text); //listeP.Add(p); //MessageBox.Show(p.Quantite + " plats " + p.Nom + " au prix de " + p.Prix + " ont bien été enregistrés."); platDAO plat = new platDAO(); int result = plat.addPlat(nomAj.Text, prixAj.Text, qteAj.Text); if (result == -1) { MessageBox.Show("Erreur ajout du plat."); } else { MessageBox.Show("Le plat a bien été ajouté."); } }
private void button3_Click(object sender, EventArgs e) { /*if(Rechercher(listeP,nomSup.Text) != null) * { * listeP.Remove(Rechercher(listeP, nomSup.Text)); * MessageBox.Show("Le plat a été supprimé"); * } * else * { * MessageBox.Show("Impossible de supprimé le plat car il n'existe pas"); * }*/ platDAO acces = new platDAO(); int result = acces.deletePlat(nomSup.Text); if (result == -1) { MessageBox.Show("Erreur de suppression."); } else { MessageBox.Show("Le plat a bien été supprimé."); } }