public static bool ModifierPlat(Plat p) { MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "UPDATE plat SET categorie = @categorie, nbcalories = @nbcalories, glutenFree = @glutenFree, vegan = @vegan WHERE nom = @nom"; cmd.Parameters.Add("@nom", MySqlDbType.VarChar).Value = p.GetNom(); cmd.Parameters.Add("@categorie", MySqlDbType.Enum).Value = p.GetCategorie(); cmd.Parameters.Add("@prix", MySqlDbType.Int32).Value = p.GetPrix(); cmd.Parameters.Add("@nbcalories", MySqlDbType.Int32).Value = p.GetNbcalories(); cmd.Parameters.Add("@glutenFree", MySqlDbType.Int32).Value = p.GetGlutenFree(); cmd.Parameters.Add("@vegan", MySqlDbType.Int32).Value = p.GetVegan(); return(cmd.ExecuteNonQuery() == 1); }
public static bool AjouterPlat(Plat p) { if (EstPlatExistant(p.GetNom())) { return(false); } MySqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "INSERT INTO plat(nom, categorie, prix, nbcalories, glutenFree, vegan) VALUES(@nom, @categorie, @prix, @nbcalories, @glutenFree, @vegan)"; cmd.Parameters.Add("@nom", MySqlDbType.VarChar).Value = p.GetNom(); cmd.Parameters.Add("@categorie", MySqlDbType.Enum).Value = p.GetCategorie(); cmd.Parameters.Add("@prix", MySqlDbType.Int32).Value = p.GetPrix(); cmd.Parameters.Add("@nbcalories", MySqlDbType.Int32).Value = p.GetNbcalories(); cmd.Parameters.Add("@glutenFree", MySqlDbType.Int32).Value = p.GetGlutenFree(); cmd.Parameters.Add("@vegan", MySqlDbType.Int32).Value = p.GetVegan(); return(cmd.ExecuteNonQuery() == 1); }