Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            form.OpenConnection();
            //supprime les pièces dans la base de donnée
            DeleteParts();
            //renvoie la facture

            CupBoard cupBoard       = form.GetCupBoard(form.connection, GetFkOrder());
            int      lockerNumber   = cupBoard.GetLockerList().Count();
            string   colorExtrusion = cupBoard.GetExtrusion().GetColor();

            string path = @"/Users/Fatine/source/Bill.txt";

            using (StreamWriter sw = File.CreateText(path))
            {
                sw.WriteLine("BILL"); //ajouter le prénom et la date?
                sw.WriteLine(" ");
                sw.WriteLine("You bought 1 cupboard with " + lockerNumber + " locker(s).");
                sw.WriteLine(" ");

                int i = 1;
                foreach (Locker locker in cupBoard.GetLockerList())
                {
                    sw.WriteLine("Locker n°" + i + ": ");
                    sw.WriteLine("Color: " + locker.GetColor() + "   Price: " + locker.GetPrice(form.connection));
                    if (locker.HasDoor())
                    {
                        if (locker.GetDoor().GetColor() == "glass")
                        {
                            sw.WriteLine(" This locker has 2 glass doors");
                        }
                        else
                        {
                            sw.WriteLine(" This locker has 2 " + locker.GetDoor().GetColor() + " wood doors ");
                        }
                    }
                    else
                    {
                        sw.WriteLine(" ");
                    }

                    sw.WriteLine(" ");
                    i++;
                }

                sw.WriteLine("Corner : ");
                sw.WriteLine("Color: " + colorExtrusion + "   Price : " + cupBoard.GetExtrusion().GetPrice(form.connection));

                sw.WriteLine(" ");

                sw.WriteLine("Total : " + cupBoard.GetPrice(form.connection) + "euros");
            }

            form.CloseConnection();
        }
Exemple #2
0
        public CupBoard GetCupBoard(MySqlConnection connection, int FkOrder)
        {
            List <Locker> lockerList = GetLockerList(connection, FkOrder);
            List <int>    idLockers  = GetLockersID(connection, FkOrder);
            int           idLocker   = idLockers[0];

            Dictionary <string, string> lockerAttribute = GetLockerAttribute(connection, FkOrder, idLocker);

            string color = lockerAttribute["color"];
            double width = Convert.ToDouble(lockerAttribute["width"]);
            double depth = Convert.ToDouble(lockerAttribute["depth"]);

            Extrusion extrusion       = GetExtrusion(FkOrder, idLocker);
            CupBoard  cupBoard        = new CupBoard(width, depth, lockerList, extrusion);
            double    extrusionHeight = cupBoard.GetTotalHeight();

            cupBoard.GetExtrusion().SetHeight(extrusionHeight);

            return(cupBoard);
        }
Exemple #3
0
        private void button4_Click(object sender, EventArgs e)
        {
            form.OpenConnection();

            CupBoard cupBoard       = form.GetCupBoard(form.connection, GetFkOrder());
            int      lockerNumber   = cupBoard.GetLockerList().Count();
            string   colorExtrusion = cupBoard.GetExtrusion().GetColor();

            string path = @"/Users/Fatine/source/DetailParts.txt";

            using (StreamWriter sw = File.CreateText(path))
            {
                sw.WriteLine("DETAIL PARTS");
                sw.WriteLine(" ");
                sw.WriteLine("there is in this order:  1 cupboard with " + lockerNumber + " locker(s).");
                sw.WriteLine(" ");

                int i = 1;
                foreach (Locker locker in cupBoard.GetLockerList())
                {
                    sw.WriteLine("Locker n°" + i + " ");
                    sw.WriteLine("Color: " + locker.GetColor() + "   Price: " + locker.GetPrice(form.connection) + " euros");
                    sw.WriteLine("   Parts : ");

                    foreach (Accessory access in locker.GetAccessoryList())
                    {
                        string availability;
                        if (access.GetInstock(form.connection) > 1)
                        {
                            availability = "available";
                        }
                        else
                        {
                            availability = "not available";
                        }

                        sw.WriteLine("    Type : " + access.GetAccessType() + "   color : " + GetRealColor(access.GetColor()) + "   dimensions : " + GetDimension(access.GetHeight(), access.GetWidth(), access.GetDepth()) + "   price : " + access.GetPrice(form.connection) + " euros" + "   " + availability);
                    }

                    sw.WriteLine(" ");
                    i++;
                }

                Extrusion extrusion = cupBoard.GetExtrusion();
                string    availabilityC;
                if (extrusion.GetInstock(form.connection) > 1)
                {
                    availabilityC = "available";
                }
                else
                {
                    availabilityC = "not available";
                }

                sw.WriteLine("Corner ");
                sw.WriteLine("Color: " + colorExtrusion + "   height : " + extrusion.GetHeight() + "   Price : " + extrusion.GetPrice(form.connection) + " euros " + "   " + availabilityC);

                sw.WriteLine(" ");

                sw.WriteLine("Total : " + cupBoard.GetPrice(form.connection) + " euros");
            }

            form.CloseConnection();
        }
Exemple #4
0
        public void DeleteParts()
        {
            CupBoard cupBoard     = form.GetCupBoard(form.connection, GetFkOrder());
            string   idPart       = "";
            int      numberOfPart = 0;
            int      InStock      = 0;

            foreach (Kitbox.Locker locker in cupBoard.GetLockerList())
            {
                foreach (Accessory access in locker.GetAccessoryList())
                {
                    //Prendre les references de toutes les parts d'un locker

                    MySqlDataReader reader;
                    MySqlCommand    command = new MySqlCommand("SELECT Idpart FROM `kitboxdb2.0`.`parts` WHERE ref='" + access.GetRefDB() + "'AND height='" + Convert.ToString(access.GetHeight()) + "'AND width='" + Convert.ToString(access.GetWidth()) + "'AND depth='" + Convert.ToString(access.GetDepth()) + "'AND color='" + access.GetColorDB(access.GetColor()) + "'", form.connection);
                    reader = command.ExecuteReader();


                    if (reader.HasRows)
                    {
                        while (reader.Read())

                        {
                            idPart = reader.GetString(0);
                        }
                    }
                    else
                    {
                        MessageBox.Show("there is no idPart in the datareader");
                    }

                    reader.Close();
                }
            }
            foreach (Kitbox.Locker locker in cupBoard.GetLockerList())
            {
                foreach (Accessory access in locker.GetAccessoryList())
                {
                    MySqlDataReader reader3;
                    MySqlCommand    command3 = new MySqlCommand("SELECT PartForLocker FROM `kitboxdb2.0`.`parts` WHERE ref='" + access.GetRefDB() + "'AND height='" + Convert.ToString(access.GetHeight()) + "'AND width='" + Convert.ToString(access.GetWidth()) + "'AND depth='" + Convert.ToString(access.GetDepth()) + "'AND color='" + access.GetColorDB(access.GetColor()) + "'", form.connection);
                    reader3 = command3.ExecuteReader();

                    if (reader3.HasRows)
                    {
                        while (reader3.Read())

                        {
                            numberOfPart = Convert.ToInt32(reader3.GetString(0));
                        }
                    }
                    else
                    {
                        MessageBox.Show("there is no idPart in the datareader");
                    }

                    reader3.Close();
                }
            }
            foreach (Kitbox.Locker locker in cupBoard.GetLockerList())
            {
                foreach (Accessory access in locker.GetAccessoryList())
                {
                    MySqlDataReader reader4;
                    MySqlCommand    command4 = new MySqlCommand("SELECT Instock FROM `kitboxdb2.0`.`parts` WHERE ref='" + access.GetRefDB() + "'AND height='" + Convert.ToString(access.GetHeight()) + "'AND width='" + Convert.ToString(access.GetWidth()) + "'AND depth='" + Convert.ToString(access.GetDepth()) + "'AND color='" + access.GetColorDB(access.GetColor()) + "'", form.connection);
                    reader4 = command4.ExecuteReader();

                    if (reader4.HasRows)
                    {
                        while (reader4.Read())

                        {
                            InStock = Convert.ToInt32(reader4.GetString(0));
                        }
                    }
                    else
                    {
                        MessageBox.Show("there is no idPart in the datareader");
                    }

                    reader4.Close();
                }
            }

            //retirer les parts liés à la commande.
            MySqlCommand command2 = new MySqlCommand("Update `kitboxdb2.0`.`parts` SET Instock= '" + (InStock - numberOfPart) + "' WHERE Idpart='" + idPart + "'", form.connection);

            command2.ExecuteNonQuery();
        }
Exemple #5
0
        public void CompleteLinkedTable()
        {
            CupBoard cupBoard = Form1.GetCupBoard();

            foreach (Kitbox.Locker locker in cupBoard.GetLockerList())
            {
                foreach (Accessory access in locker.GetAccessoryList())
                {
                    //Prendre les references de toutes les parts d'un locker

                    MySqlDataReader reader;
                    MySqlCommand    command = new MySqlCommand("SELECT Idpart FROM `kitboxdb2.0`.`parts` WHERE ref='" + access.GetRefDB() + "'AND height='" + Convert.ToString(access.GetHeight()) + "'AND width='" + Convert.ToString(access.GetWidth()) + "'AND depth='" + Convert.ToString(access.GetDepth()) + "'AND color='" + access.GetColorDB(access.GetColor()) + "'", form.connection);
                    reader = command.ExecuteReader();

                    string idPart = "";

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            idPart = reader.GetString(0);
                        }
                    }
                    else
                    {
                        MessageBox.Show("there is no idPart in the datareader");
                    }

                    reader.Close();

                    //insérer les IDPARTS dans la table linked, ainsi on sait quel type de part est concerné pour chaque locker --> facile pour faire -1
                    MySqlCommand command2 = new MySqlCommand("INSERT INTO `kitboxdb2.0`.`linked` (FkkOrder, FkkLocker,`FkkPart`) VALUES ('" + order.GetIdOrder() + " ', '" + Convert.ToString(locker.GetID()) + "', '" + idPart + "');", form.connection);
                    command2.ExecuteNonQuery();
                }
            }



            //Ajout de extrusion dans linked : une seule fois
            Extrusion extrusion       = cupBoard.GetExtrusion();
            double    extrusionHeight = 0;

            if (extrusion.IsCut(extrusion.GetHeight()))
            {
                extrusionHeight = extrusion.GetExistingTopHeight(extrusion.GetHeight());
            }
            else
            {
                extrusionHeight = extrusion.GetHeight();
            }

            string          refcor = "Cornières";
            MySqlDataReader reader3;
            MySqlCommand    command3 = new MySqlCommand("SELECT Idpart FROM `kitboxdb2.0`.`parts` WHERE ref='" + refcor + "'AND height='" + Convert.ToString(extrusionHeight) + "'AND color='" + extrusion.GetColorDB(extrusion.GetColor()) + "'", form.connection);

            reader3 = command3.ExecuteReader();

            string idCor = "";

            if (reader3.HasRows)
            {
                while (reader3.Read())
                {
                    idCor = reader3.GetString(0);
                }
            }
            else
            {
                MessageBox.Show("there is no extrusion in the datareader");
            }

            reader3.Close();

            //prendre nptqel id de locker
            int          fkkLocker = cupBoard.GetLockerList()[0].GetID();
            MySqlCommand command4  = new MySqlCommand("INSERT INTO `kitboxdb2.0`.`linked` (FkkOrder, FkkLocker,`FkkPart`) VALUES ('" + order.GetIdOrder() + "', '" + fkkLocker + "', '" + idCor + "');", form.connection);

            command4.ExecuteNonQuery();
        }