private void SupprimerClient_Click(object sender, RoutedEventArgs e) { string[] recetteClient = Compte.getdata("select NomR from recette where IDcreateur like'" + Compte.Verifcommande(ClientSuppr.Text) + "';").Split(','); if (recetteClient != null) { for (int i = 0; i < recetteClient.Length; i++) { string[] produitRecette = Compte.getdata("select keyutilise from utilise where NomR like'" + recetteClient[i].Trim(',', ' ') + "';").Split(','); if (produitRecette != null) { for (int j = 0; j < produitRecette.Length; j++) { if (produitRecette[j] != null && produitRecette[j] != "") { Compte.lirecommande("delete from utilise where keyutilise like '" + produitRecette[j].Trim(',', ' ') + "';"); } } Compte.lirecommande("delete from recette where NomR like '" + recetteClient[i] + "';"); } } } Compte.lirecommande("delete from client where IDclient like '" + Compte.Verifcommande(ClientSuppr.Text) + "';"); MessageBox.Show("Le compte a bien été supprimé ainsi ces recettes associé."); }
private void CreerRecette(object sender, RoutedEventArgs e) { if (liste_aliment_recette.Items.Count != 0) { bool rep = true; for (int i = 0; i < PrixVente.Text.Length; i++) { if (!char.IsDigit(PrixVente.Text[i])) { rep = false; } } if (rep && NomRecette.Text != "" && NomRecette.Text != null && PrixVente.Text != "" && PrixVente.Text != null && DescriptionProduit.Text != "" && DescriptionProduit.Text != null && DescriptionProduit.Text.Length <= 256 && Compte.GetDataInt("select count(NomR) from recette where NomR like '" + Compte.Verifcommande(NomRecette.Text) + "';") == 0) { if (!produitexist(Compte.Verifcommande(NomRecette.Text))) { if (Convert.ToInt32(PrixVente.Text) >= 10 && Convert.ToInt32(PrixVente.Text) <= 40) { Compte.lirecommande("INSERT INTO `cooking`.`recette` (`NomR`,`Type`,`Descriptif`,`Prixplat`,`Remunerationcdr`,`Nombreplatcommande`,`IDcreateur`) VALUES('" + Compte.Verifcommande(NomRecette.Text) + "', '" + Compte.Verifcommande(typedeplat.Text) + "', '" + Compte.Verifcommande(DescriptionProduit.Text) + "', " + PrixVente.Text + ", '2', '0', '" + Compte.Verifcommande(compte_utilise.Identifiant) + "');"); //RECETTE CREER foreach (Produit p in liste_aliment_recette.Items) { if (p != null) { p.Stockmini = (p.Stockmini / 2) + (3 * p.Quantite); p.Stockmaxi += (2 * p.Quantite); Compte.lirecommande("INSERT INTO `cooking`.`utilise` (`keyutilise`,`quantitep`,`IDproduit`,`NomR`) VALUES ('" + p.IDproduit + Compte.Verifcommande(NomRecette.Text) + "','" + p.Quantite + "','" + p.IDproduit + "','" + Compte.Verifcommande(NomRecette.Text) + "');"); Compte.lirecommande("update produit set stockmini='" + p.Stockmini + "' where IDproduit like '" + p.IDproduit + "';"); Compte.lirecommande("update produit set stockmaxi='" + p.Stockmaxi + "' where IDproduit like '" + p.IDproduit + "';"); } } MessageBox.Show("Félicitation, vous venez de créer votre recette !\n\nResume :Nom de la recette :" + Compte.Verifcommande(NomRecette.Text) + "\nProduit utilise avec quantite : " + Compte.getdata("select IDproduit,quantitep from utilise where NomR like '" + Compte.Verifcommande(NomRecette.Text) + "'; ") + "\nType de produit : " + Compte.Verifcommande(typedeplat.Text) + "\n Prix :" + PrixVente.Text); ViderRecette(sender, e); } else { MessageBox.Show("Le prix de vente n'est pas correcte, veuillez recommencer"); } } else { MessageBox.Show("Ce produit existe déjà veuillez changer de nom."); } } else { MessageBox.Show("Erreur, veuillez compléter correctement toutes les données demandés svp."); } } else { MessageBox.Show("Veuillez ajouter des produits à votre recette."); } }
public static bool compteexist(string id) // FONCTION POUR SAVOIR SI L ID EST BIEN DANS LA DATABASE via ID { bool presence = false; string mot = "select IDclient from client where IDclient like '" + Compte.Verifcommande(id) + "';"; string prescemot = Compte.getdata(mot); id = id + ","; //on ajoute un ", " car le sql nous renvoie des infos de ce type ce qui rend impossible la comapraison sans cet ajout sur le mot de base if (prescemot == id) { presence = true; } return(presence); }
private void Se_Connecter(object Connexion, RoutedEventArgs e) { if (Compte.logcompte(Compte.Verifcommande(identifiant.Text), Compte.Verifcommande(motdepasse.Password))) { Compte test = new Compte(identifiant.Text, motdepasse.Password); compte_utilise = test; compte_utilise.Identifiant = identifiant.Text; Continuer(test); } else { MessageBox.Show("L'identifiant et/ou mot de passe inccorect, veuillez recommencer"); } }
private void SupprimerRecette_Click(object sender, RoutedEventArgs e) { string[] produitRecette = Compte.getdata("select keyutilise from utilise where NomR like'" + Compte.Verifcommande(RecetteSuppr.Text) + "';").Split(','); if (produitRecette != null) { for (int j = 0; j < produitRecette.Length; j++) { if (produitRecette[j] != null && produitRecette[j] != "") { Compte.lirecommande("delete from utilise where keyutilise like '" + produitRecette[j].Trim(',', ' ') + "';"); } } Compte.lirecommande("delete from recette where NomR like '" + Compte.Verifcommande(RecetteSuppr.Text) + "';"); MessageBox.Show("La recette a bien été supprimé."); } }
private void Valider(object sender, RoutedEventArgs e) { if (Compte.getdata("select NomR, quantitep from utilise where IDproduit like '" + Compte.Verifcommande(entre.Text) + "';") != null) { EntreTexte.Text = "\n\n" + Compte.getdata("select NomR, quantitep from utilise where IDproduit like '" + entre.Text + "';"); } else { EntreTexte.Text = "Veuillez rentrer un aliment présent dans la base de donnée svp."; } }
/// <summary> /// fonction pour créer un compte dans la bdd /// </summary> /// <param name="nom"></param> /// <param name="prenom"></param> /// <param name="id"></param> /// <param name="mdp"></param> static void creacompte(string nom, string prenom, string id, string mdp) { string requetecrea = "INSERT INTO `cooking`.`client` (`IDclient`,`Nom`,`prenom`,`MDPcompte`,`soldeclient`) VALUES('" + Compte.Verifcommande(id) + "','" + Compte.Verifcommande(nom) + "','" + Compte.Verifcommande(prenom) + "','" + Compte.Verifcommande(mdp) + "','0');"; Compte.lirecommande(requetecrea); }