Esempio n. 1
0
 public Commande(string idcommande)
 {
     this.iDcommande = idcommande;
     this.dateC      = Compte.getdata("select DateC from commande where IDcommande like '" + idcommande + "';").Trim(',');
     this.quantiteC  = Compte.GetDataInt("select Quantitec from commande where IDcommande like '" + idcommande + "';");
     this.prixC      = Compte.GetDataInt("select prixc from commande where IDcommande like '" + idcommande + "';");
     this.iDclient   = Compte.getdata("select IDclient from commande where IDcommande like '" + idcommande + "';").Trim(',');
     this.nomR       = Compte.getdata("select NomR from commande where IDcommande like '" + idcommande + "';").Trim(',');
 }
Esempio n. 2
0
        static void remunerationcdr(string NomR) // fonction qui rémunère un cdr lorsque ça recette est commandé
        {
            string idcdr = Compte.getdata("select IDcreateur from recette where NomR like '" + NomR + "';").Trim(',');

            int montantcdr = Compte.GetDataInt("select Remunerationcdr from recette where NomR like '" + NomR + "';");
            int soldcdr    = Compte.GetDataInt("select distinct soldeclient from client natural join recette where recette.IDcreateur=client.IDclient and recette.NomR like '" + NomR + "'; ");

            soldcdr += montantcdr;
            Compte.lirecommande("update client set soldeclient='" + soldcdr + "' where IDclient like '" + idcdr + "';");
        }
Esempio n. 3
0
 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.";
     }
 }
Esempio n. 4
0
        private void RecetteCrees(object o, RoutedEventArgs e)
        {
            string rep = "Votre solde cook est de : " + Compte.GetDataInt("select soldeclient from client where IDclient like '" + compte_utilise.Identifiant + "';");

            rep += "\nNombre de recette crée : " + Compte.GetDataInt("select count(IDcreateur) from recette where IDcreateur like '" + compte_utilise.Identifiant + "';") + "\n\nVoici la liste des recttes crées ainsi que le nombre de fois où ces dernière ont été commandé :";
            string[] recettes = Compte.getdata("select NomR from recette R, client C where C.IDclient = R.IDcreateur and C.IDclient like '" + compte_utilise.Identifiant + "';").Split(',');

            for (int i = 0; i < Compte.GetDataInt("select count(IDcreateur) from recette where IDcreateur like '" + compte_utilise.Identifiant + "';"); i++)
            {
                rep += "\n- Nom : " + recettes[i] + " commandé : " + Compte.GetDataInt("select Nombreplatcommande from recette where NomR like '" + recettes[i].Trim(',') + "';") + " fois.";
            }
            MessageBox.Show(rep, "Information CDR");
        }
Esempio n. 5
0
        /// <summary>
        /// retourne la list des tpo recette du cdr or
        /// </summary>
        /// <returns></returns>
        public List <Plat> TopRecetteCdrOr()
        {
            string idcreateur = TopCDR();

            string[]    plats     = Compte.getdata("select NomR from recette where IDcreateur like '" + idcreateur + "';").Split(',');
            List <Plat> listplats = new List <Plat>();

            for (int i = 0; i < plats.Length; i++)
            {
                if (plats[i] != null && plats[i] != "")
                {
                    listplats.Add(new Plat(plats[i]));
                }
            }
            return(listplats);
        }
Esempio n. 6
0
        /// <summary>
        /// retourne la liste des nom de fichier.xml des commandes passé auprès des fournisseurs
        /// </summary>
        /// <returns></returns>
        public List <string> listecommandefournisseur()
        {
            List <string> rep = new List <string>();

            string[] datecommande = Compte.getdata("select distinct DateF from fournis;").Split(',');
            for (int i = 0; i < datecommande.Length; i++)
            {
                if (datecommande[i] != "" && datecommande[i] != "25/02/1999")
                {
                    rep.Add("Commande_" + datecommande[i].Trim(',').Replace('/', '.') + ".xml");
                }
            }


            return(rep);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        /// <summary>
        /// vérifie que le produit dont l'id est pris en entré existe ou non dans la bdd, retourne le résultat de sa présence
        /// </summary>
        /// <param name="produit"></param>
        /// <returns></returns>
        public static bool produitexist(string produit)
        {
            bool   presence  = false;
            string mot       = "select IDproduit from produit where IDproduit like '" + produit + "';";
            string prescemot = Compte.getdata(mot);

            produit = produit + ", ";
            if (prescemot == null)
            {
                presence = false;
            }
            if (prescemot == produit)
            {
                presence = true;
            }
            return(presence);
        }
Esempio n. 9
0
        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é.");
            }
        }
Esempio n. 10
0
        public FenetreCDR(Compte c)
        {
            string[] produitdispo = Compte.getdata("select IDproduit from produit;").Split(',');


            compte_utilise = c;
            for (int i = 0; i < produitdispo.Length; i++)
            {
                if (produitdispo[i] != null && produitdispo[i] != "")
                {
                    produits.Add(new Produit(produitdispo[i].Trim(' ', ',')));
                }
            }
            this.DataContext = this;
            InitializeComponent();
            liste_aliment.ItemsSource = produits;
            Information_client.Text   = "Client : " + compte_utilise.Identifiant + " solde cook : " + compte_utilise.PointCooking;
        }
Esempio n. 11
0
        public MenuPrincipal(Compte compte)
        {
            string[] platsdispo = Compte.getdata("select NomR from recette;").Split(',');


            compte_utilise = compte;
            for (int i = 0; i < platsdispo.Length; i++)
            {
                if (platsdispo[i] != null && platsdispo[i] != "")
                {
                    plats.Add(new Plat(platsdispo[i].Trim(' ', ',')));
                }
            }
            this.DataContext = this;
            InitializeComponent();
            plats_list.ItemsSource = plats;
            Idconnecte.Text        = "Id : " + compte.Identifiant + " | Connection : " + compte.Connecte;
            solde_cook.Text        = "" + compte.PointCooking;
            prixdupanier.Text      = "0";
        }
Esempio n. 12
0
        /// <summary>
        /// retourne l'id du cdr de la semaine
        /// </summary>
        /// <returns></returns>
        public string TopCDRSemaine()
        {
            List <Commande> commande_semaine    = Commande.commandeSurDuree(7);
            List <Plat>     platCommandeSemaine = Commande.ListPlatDansListCommande(commande_semaine);
            Plat            temp = new Plat();

            for (int i = 0; i < platCommandeSemaine.Count; i++)
            {
                if (i == 0 && platCommandeSemaine[i] != null)
                {
                    temp = platCommandeSemaine[i];
                }
                if (platCommandeSemaine[i].Quantite > temp.Quantite)
                {
                    temp.NomR     = platCommandeSemaine[i].NomR;
                    temp.Quantite = platCommandeSemaine[i].Quantite;
                }
            }
            return(Compte.getdata("select IDcreateur from recette where NomR like'" + temp.NomR + "';").Trim(','));
        }
Esempio n. 13
0
        /// <summary>
        /// retourne la liste des commandes des derniers "duree" jour
        /// </summary>
        /// <param name="duree"></param>
        /// <returns></returns>
        static public List <Commande> commandeSurDuree(int duree)
        {
            List <Commande> temp = new List <Commande>();
            DateTime        date = DateTime.Today;

            for (int i = 0; i < duree; i++)
            {
                string[] platCom = Compte.getdata("select IDcommande from commande where Datec like '" + date.ToString().Remove(10) + "' ;").Split(',');

                for (int j = 0; j < platCom.Length; j++)
                {
                    if (platCom[j] != "")
                    {
                        temp.Add(new Commande(platCom[j].Trim(',', ' ')));
                    }
                }
                date = date.AddDays(-1);
            }
            return(temp);
        }
Esempio n. 14
0
        private void MiseAjourStock_Click(object sender, RoutedEventArgs e)
        {
            List <Commande> listcommande = Commande.commandeSurDuree(30);
            List <Plat>     listplat     = Commande.ListPlatDansListCommande(listcommande);
            List <Produit>  listproduit  = Produit.ProduitUtiliserDansPlat(listplat);

            string[] toutproduit = Compte.getdata("select distinct nomproduit from produit;").Split(',');
            for (int i = 0; i < toutproduit.Length; i++)
            {
                if (toutproduit[i] != null && toutproduit[i] != "")
                {
                    Produit temp = new Produit(toutproduit[i]);
                    if (!temp.Contenue(listproduit))
                    {
                        Compte.lirecommande("update produit set stockmini='" + temp.Stockmini / 2 + "' where  IDproduit like'" + temp.IDproduit + "';");
                        Compte.lirecommande("update produit set stockmaxi='" + temp.Stockmaxi / 2 + "' where  IDproduit like'" + temp.IDproduit + "';");
                    }
                }
            }
            MessageBox.Show("Les stocks max et min des produits non utilisé ont été divisé par 2.");
        }
Esempio n. 15
0
        public static int GetDataInt(string commande)
        {
            string test = Compte.getdata(commande).Trim(' ', ',');

            return(Convert.ToInt32(test));
        }
Esempio n. 16
0
        public Fenetre_test()
        {
            InitializeComponent();
            string rep = "";

            rep += "\n\n- Nombre de client : select count(IDclient) from client   :" + Compte.getdata("select count(IDclient) from client;");

            rep += "\n\n- Nombre de CDR :  select count(IDcreateur)from recette    :" + Compte.getdata("select count(IDcreateur)from recette;");
            rep += "\n\n- Noms des CdR et pour chaque CdR : nombre total de ses recettes commandée  :  \n\n select Nom,Prenom,sum(R.Nombreplatcommande) from client C join recette R on C.IDclient = R.IDcreateur group by C.IDclient:\n" + Compte.getdata("select Nom,Prenom,sum(R.Nombreplatcommande) from client C join recette R on C.IDclient = R.IDcreateur group by C.IDclient; ");

            rep += "\n\n- Nombre de recettes  :  select count(NomR) from recette    :" + Compte.getdata("select count(NomR) from recette;");

            rep += "\n\n- Liste des produits ayant une quantité en stock <= 2 * leur quantité minimal  :  \n\nselect IDproduit from produit where stock <= 2* stockmini    :" + Compte.getdata("select IDproduit from produit where stock <= 2* stockmini;");


            rep        += "\n\n- Saisie au clavier (par l'évaluateur) d'un des produits de la liste précédente puis affichage de la liste des recettes(leur nom) utilisant ce produit et de la quantité utilisée dans cette recette :\n\nselect NomR, quantitep from utilise where IDproduit like 'nom de la recette entré'     : ";
            preuve.Text = rep;
        }
Esempio n. 17
0
        private void Commander(object sender, RoutedEventArgs e)
        {
            if (liste_panier.Items.Count != 0)
            {
                bool           quantiteok    = true;
                List <Produit> produit_stock = new List <Produit>();
                foreach (Plat o in liste_panier.Items)
                {
                    if (o != null)
                    {
                        List <Produit> produitaajouter = Produit.ProduitUtiliserDansPlat(o);
                        foreach (Produit pro in produitaajouter)
                        {
                            if (o != null)
                            {
                                produit_stock.Add(pro);
                            }
                        }
                    }
                }
                List <Produit> produit_utilise = Produit.FusionListeProduit(produit_stock);
                for (int i = 0; i < produit_utilise.Count; i++)
                {
                    if (Compte.GetDataInt("select stock from produit where IDproduit like'" + produit_utilise[i].IDproduit + "';") < produit_utilise[i].Stock)
                    {
                        quantiteok = false;
                    }
                }
                int diffprix = compte_utilise.PointCooking - prix_total;
                if (diffprix >= 0 && quantiteok)
                {
                    for (int i = 0; i < produit_utilise.Count; i++)
                    {
                        Compte.lirecommande("update produit set stock='" + (Compte.GetDataInt("select stock from produit where IDproduit like '" + produit_utilise[i].IDproduit + "';") - produit_utilise[i].Stock) + "' where IDproduit like '" + produit_utilise[i].IDproduit + "';");
                    }

                    MessageBox.Show("Commande réussie ! \nNous procédons à la livraison de suite !", "Etat de la commande");
                    foreach (Plat o in liste_panier.Items)
                    {
                        if (o != null)
                        {
                            payement(compte_utilise.Identifiant, o.NomR);
                            miseajournbrecette(compte_utilise.Identifiant, o.NomR);
                            o.Renomme = Compte.getdata("select Nombreplatcommande from recette where NomR like '" + o.NomR + "';").Trim(',');
                            o.Prix    = Compte.GetDataInt("select Prixplat from recette where NomR like '" + o.NomR + "';");
                            remunerationcdr(o.NomR);
                            if (Compte.getdata("select IDcreateur from recette where NomR like '" + o.NomR + "';").Trim(',') == compte_utilise.Identifiant)
                            {
                                compte_utilise.PointCooking = Compte.GetDataInt("select soldeclient from client where IDclient like '" + compte_utilise.Identifiant + "'; ");
                            }
                            Compte.lirecommande("INSERT INTO `cooking`.`commande` (`IDcommande`,`Datec`,`Quantitec`,`prixc`,`IDclient`,`NomR`) VALUES ('" + +(Compte.GetDataInt("select count(IDcommande)from commande;") + 1) + "','" + DateTime.Today.ToString().Remove(10) + "','1','" + o.Prix + "','" + compte_utilise.Identifiant + "','" + o.NomR + "');");
                        }
                    }

                    compte_utilise.PointCooking = diffprix;
                    solde_cook.Text             = "" + compte_utilise.PointCooking;


                    ViderPanier(sender, e);
                }
                else
                {
                    if (diffprix < 0)
                    {
                        MessageBox.Show("Vous ne disposez pas assez de crédit cooking pour effectuer l'achat.");
                    }
                    else
                    {
                        MessageBox.Show("Rupture de stock d'un ou plusieur aliments compris dans vos plats.\nDésolé pour la gêne occasionné, veuillez recommencer plus tard svp.");
                    }
                }
            }
            else
            {
                MessageBox.Show("Votre panier est vide");
            }
        }
Esempio n. 18
0
        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.");
            }
        }