示例#1
0
        // ENTRE LA COMMANDE DANS LA BDD
        public void CommandeToBdd(Commande commande, string nature, Client client, Cdr cdr)
        {
            this.connection.Open();

            // ENTREE DE LA COMMAND EN BDD
            MySqlCommand command = this.connection.CreateCommand();

            command.CommandText = "insert into commande values ('" + Convert.ToString(commande.IdCommande) + "','" + Convert.ToString(commande.Prix) + "','" + commande.Adresse + "','" + commande.Date.ToString() + "');";
            command.ExecuteNonQuery();

            // MISE EN RELATION DU CLIENT ET DE LA COMMANDE
            MySqlCommand command2 = this.connection.CreateCommand();

            command2.CommandText = "insert into passe values ('" + Convert.ToString(client.IdClient) + "','" + Convert.ToString(commande.IdCommande) + "');";
            command2.ExecuteNonQuery();


            // MISE EN RELATION PLAT ET COMMANDE
            //MySqlCommand command3 = this.connection.CreateCommand();
            foreach (Plat p in commande.ListePlats.Distinct())
            {
                MySqlCommand command3 = this.connection.CreateCommand();
                command3.CommandText = "insert into contient values ('" + Convert.ToString(commande.IdCommande) + "','" + Convert.ToString(p.IdPlat) + "','" + Convert.ToString(commande.CompteurPlat(p)) + "');";
                command3.ExecuteNonQuery();
            }
            this.connection.Close();
        }
示例#2
0
        //PAYE UNE COMMANDE SELON SA LISTE DE PLAT
        public void Payement(Commande commande, string nature, Client client, Cdr cdr)
        {
            int prix = commande.GetPrix();

            if (nature == "client")
            {
                this.connection.Open();
                MySqlCommand comand = this.connection.CreateCommand();

                comand.CommandText = "update client set Cooks='" + Convert.ToString(client.Cooks - prix) + "' where IdClient='" + Convert.ToString(client.IdClient) + "' ;";
                comand.ExecuteNonQuery();
                client.Cooks = client.Cooks - prix;
                this.connection.Close();
            }
            else
            {
                this.connection.Open();
                MySqlCommand comand = this.connection.CreateCommand();

                comand.CommandText = "update client set Cooks='" + Convert.ToString(client.Cooks - prix) + "' where IdClient='" + Convert.ToString(client.IdClient) + "' ;";
                comand.ExecuteNonQuery();
                client.Cooks = client.Cooks - prix;
                this.connection.Close();

                this.connection.Open();
                MySqlCommand comand1 = this.connection.CreateCommand();

                comand1.CommandText = "update cdr set Cooks='" + Convert.ToString(cdr.Cooks - prix) + "' where IdCdr='" + Convert.ToString(cdr.IdCdr) + "' ;";

                comand1.ExecuteNonQuery();
                cdr.Cooks = cdr.Cooks - prix;
                this.connection.Close();
            }
        }
示例#3
0
        public void AffichageAdmin(BDD cooking, Cdr cdr)
        {
            Console.WriteLine(idCdr + " " + nom + " " + prenom);
            int         nombre   = 0;
            List <Plat> recettes = cooking.PlatsCreesCdr(cdr);

            nombre = recettes.Count;
            Console.WriteLine("Recettes crées : " + Convert.ToString(nombre) + " \n");
        }
示例#4
0
        // AJOUTER CDR A PARTIR DE C# SUR LA BASE DE DONNEE
        public void AddCdrToBDD(Cdr cdr, Client client)
        {
            this.connection.Open();

            MySqlCommand command = this.connection.CreateCommand();

            command.CommandText = "insert into cdr values ('" + Convert.ToString(cdr.IdCdr) + "','" + Convert.ToString(cdr.IdClient) + "','" + Convert.ToString(client.Nom) + "','" + client.Prenom + "','" + client.Username + "','" + client.Password + "','" + client.NumeroTel + "','" + Convert.ToString(cdr.Cooks) + "','" + cdr.CodeBancaire + "');";
            command.ExecuteNonQuery();

            this.connection.Close();
        }
示例#5
0
        public void DeleteCdrFromBDD(Cdr cdr)
        {
            this.connection.Open();

            MySqlCommand command = this.connection.CreateCommand();

            command.CommandText = "delete from cdr where IdCdr = '" + cdr.IdCdr + "';";
            int row = command.ExecuteNonQuery();


            this.connection.Close();
        }
示例#6
0
        // AJOUTER UN CDR SPECIFIQUE EN TANT QUE OBJET A PART D'UN USERNAME ET D'UN PASSWORD
        public Cdr GenererCdr(string username, string password)
        {
            this.connection.Open();
            MySqlCommand command = this.connection.CreateCommand();

            command.CommandText = "select * from cdr where username='******' and password='******';";
            MySqlDataReader reader = command.ExecuteReader();
            Cdr             cdr    = new Cdr();

            while (reader.Read())
            {
                cdr = new Cdr(reader);
            }
            this.connection.Close();
            return(cdr);
        }
示例#7
0
        // RECETTES QUE LE CDR A CREE
        public List <Plat> PlatsCreesCdr(Cdr cdr)
        {
            this.connection.Open();

            MySqlCommand command = this.connection.CreateCommand();

            command.CommandText = "select p.* from plat p,inventé_par o where o.idPlat = p.IdPlat and o.idCdr ='" + Convert.ToString(cdr.IdCdr) + "';";
            MySqlDataReader reader = command.ExecuteReader();

            List <Plat> plats = new List <Plat>();

            while (reader.Read())
            {
                plats.Add(new Plat(reader));
            }
            this.connection.Close();
            return(plats);
        }
示例#8
0
        // RENVOIE LE NOMBRE DE FOIS OU ON A COMMANDER SES RECETTES QUELQUE SOIT LES RECETTES
        public int NbRecettesCommandees(Cdr cdr)
        {
            this.connection.Open();
            List <Cdr>   listeCdr = new List <Cdr>();
            MySqlCommand command  = this.connection.CreateCommand();

            command.CommandText = "select sum(cont.quantite) from cdr c join inventé_par inv on c.IdCdr = inv.IdCdr join plat p on inv.IdPlat=p.IdPlat join contient cont on p.IdPlat=cont.IdPlat where c.IdCdr=" + cdr.IdCdr + ";";
            int row = command.ExecuteNonQuery();

            MySqlDataReader reader = command.ExecuteReader();
            int             nb     = 0;

            while (reader.Read())
            {
                nb = reader.GetInt32(0);
            }
            this.connection.Close();
            return(nb);
        }
示例#9
0
        public Cdr GoldenCdr()
        {
            this.connection.Open();

            MySqlCommand command = this.connection.CreateCommand();

            command.CommandText = "select c.* from cdr c join inventé_par inv on c.IdCdr = inv.IdCdr join plat p on inv.IdPlat=p.IdPlat join contient cont on p.IdPlat=cont.IdPlat having sum(cont.quantite) >= All(select sum(cont1.quantite) from contient cont1 join plat p1 on p1.IdPlat=cont1.IdPlat group by p1.IdPlat);";
            MySqlDataReader reader = command.ExecuteReader();
            Cdr             cdr    = new Cdr();

            while (reader.Read())
            {
                cdr = new Cdr(reader);
            }

            this.connection.Close();

            Console.WriteLine("Et l'oscar du Cdr d'Or est attribué à ..." + cdr.ToString());
            Console.WriteLine("\n");

            return(cdr);
        }
示例#10
0
        //CREATION DE RECETTE DANS LA BDD
        public void CreationRecette(Plat plat, List <Produit> listeProduit, List <double> quantite, Cdr cdr)
        {
            //ENTREE DU PLAT EN  BDD
            this.connection.Open();
            DateTime     date   = DateTime.Now;
            MySqlCommand comand = this.connection.CreateCommand();

            comand.CommandText = "insert into plat values ( '" + Convert.ToString(plat.IdPlat) + "','" + Convert.ToString(plat.Nom) + "','" + plat.Recette + "','" + plat.Description + "','" + Convert.ToString(plat.Prix) + "','2','" + date.ToString() + "','0');";
            comand.ExecuteNonQuery();


            //MISE EN RELATION CREATEUR ET PLAT

            MySqlCommand command2 = this.connection.CreateCommand();

            command2.CommandText = "insert into inventé_par values ('" + Convert.ToString(plat.IdPlat) + "','" + Convert.ToString(cdr.IdCdr) + "');";
            command2.ExecuteNonQuery();


            //PEUPLEMENT COMPOSE DE
            int compteur = 0;

            foreach (Produit p in listeProduit)
            {
                MySqlCommand comand3 = this.connection.CreateCommand();
                comand3.CommandText = "insert into composé_de values ('" + Convert.ToString(plat.IdPlat) + "','" + Convert.ToString(p.IdProduit) + "','" + Convert.ToString(quantite[compteur]) + "');";
                comand3.ExecuteNonQuery();
                compteur += 1;
            }
            this.connection.Close();
        }
示例#11
0
        //RENVOIE UN BOOL SI LE PAYEMENT EST POSSIBLE
        public bool PayementPossible(Commande commande, string nature, Client client, Cdr cdr)
        {
            bool possible = false;
            int  prix     = commande.GetPrix();

            if (nature == "client")
            {
                if (client.Cooks >= prix)
                {
                    possible = true;
                }
            }
            else
            {
                if (cdr.Cooks >= prix)
                {
                    possible = true;
                }
            }
            return(possible);
        }