Beispiel #1
0
        /// <summary>
        /// retourne l'id du cdr d'or
        /// </summary>
        /// <returns></returns>
        public string TopCDR()
        {
            string[] ToutCDR = Compte.getdata("select * from client;").Split(',');
            string[] topcdr  = new string[2] {
                ToutCDR[0].Trim(','), "" + 0
            };
            int commandeMax = 0;

            for (int i = 0; i < ToutCDR.Length; i++)
            {
                if (ToutCDR[i] != null)
                {
                    commandeMax = 0;
                    string[] ToutRecetteCDR = Compte.getdata("select NomR from recette where IDcreateur like '" + ToutCDR[i].Trim(',') + "';").Split(',');
                    for (int j = 0; j < ToutRecetteCDR.Length; j++)
                    {
                        if (ToutRecetteCDR[j] != null && ToutRecetteCDR[j] != "")
                        {
                            commandeMax += Compte.GetDataInt("select Nombreplatcommande from recette where NomR like '" + ToutRecetteCDR[j].Trim(',') + "';");
                        }
                    }
                    if (Convert.ToInt32(topcdr[1]) < commandeMax)
                    {
                        topcdr[0] = ToutCDR[i];
                        topcdr[1] = "" + commandeMax;
                    }
                }
            }
            return(topcdr[0]);
        }
Beispiel #2
0
        //COMMANDE


        static void payement(string idclient, string NomR) //id du client et nom de la recette
        {
            int prixr      = Compte.GetDataInt("select Prixplat from recette where NomR like '" + NomR + "';");
            int soldclient = Compte.GetDataInt("select soldeclient from client where IDclient like '" + idclient + "';");
            int diffprix   = soldclient - prixr;

            Compte.lirecommande("update client set soldeclient='" + diffprix + "' where IDclient like'" + idclient + "';"); // on change le montant d'argent du client
        }
Beispiel #3
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(',');
 }
Beispiel #4
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 + "';");
        }
Beispiel #5
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");
        }
Beispiel #6
0
        static void miseajournbrecette(string id, string NomR) // permet de mettre à jour le nombre de plat commandé par recette et la renum en cook && renum cook
        {
            int nbcommandé = Compte.GetDataInt("select Nombreplatcommande from recette where NomR like '" + NomR + "';");

            nbcommandé += 1; // on augmente de 1 car une commande à été faite
            Compte.lirecommande("update recette set Nombreplatcommande='" + nbcommandé + "' where NomR like '" + NomR + "';");
            if (nbcommandé == 10)
            {
                int prixr = Compte.GetDataInt("select Prixplat from recette where NomR like '" + NomR + "';");
                prixr += 2; //on augmente le prix de la recette de 2 cook si elle a été commandé plus de 10 fois
                Compte.lirecommande("update recette set Prixplat='" + prixr + "' where NomR like '" + NomR + "';");
            }
            if (nbcommandé == 50)
            {
                int prixr = Compte.GetDataInt("select Prixplat from recette where NomR like '" + NomR + "';");
                prixr += 3;       //on augmente le prix de la recette de 3 cook si elle a été commandé plus de 50 fois
                Compte.lirecommande("update recette set Prixplat='" + prixr + "' where NomR like '" + NomR + "';");
                int remuncdr = 4; //on augmente la renum du cdr à 4 cook si elle a été commandé plus de 50 fois
                Compte.lirecommande("update recette set Remunerationcdr='" + remuncdr + "' where NomR like '" + NomR + "';");
            }
        }
Beispiel #7
0
        private void Reapprovisionnement_Click(object sender, RoutedEventArgs e)
        {
            string nomfichier = "Commande_" + DateTime.Today.ToString().Remove(10).Replace('/', '.') + ".xml";

            for (int i = 0; i < ProduitReapro.Count; i++)
            {
                if (ProduitReapro[i] != null)
                {
                    int quantiteACommander = ProduitReapro[i].Stockmaxi - ProduitReapro[i].Stock;

                    Compte.lirecommande("update produit set stock='" + ProduitReapro[i].Stockmaxi + "' where IDproduit like '" + ProduitReapro[i].IDproduit + "';");
                    ProduitReapro[i].Stock = ProduitReapro[i].Stockmaxi;
                    Compte.lirecommande("INSERT INTO `cooking`.`fournis` (`numerocommande`,`Reffournisseur`,`IDproduit`,`quantitefournis`,`DateF`) VALUES ('" + (Compte.GetDataInt("select count(numerocommande) from fournis;") + 1) + "','" + ProduitReapro[i].Reffournisseur + "','" + ProduitReapro[i].IDproduit + "','" + quantiteACommander + "','" + DateTime.Today.ToString().Remove(10) + "');");


                    MessageBox.Show("reaprovisionement de " + ProduitReapro[i].Nomproduit + " effectue !");
                    ProduitReapro.Remove(ProduitReapro[i]);
                }
            }

            commandefournisseur("select * from fournis where DateF like '" + DateTime.Today.ToString().Remove(10) + "';", nomfichier);
            RecapCommande.Add(nomfichier);
            ListeProduitRapro.ItemsSource = ProduitReapro;
            int temp = 0;

            for (int i = 0; i < RecapCommande.Count; i++)
            {
                if (nomfichier == RecapCommande[i])
                {
                    temp++;
                    if (temp > 1)
                    {
                        RecapCommande.Remove(RecapCommande[i]);
                    }
                }
            }
            ListeCommande.ItemsSource = RecapCommande;
        }
Beispiel #8
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.");
            }
        }
Beispiel #9
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");
            }
        }