private void InsertRackElements()
 {
     //Create Elements for Order   = > this function needs to be added to Rack class in future!!!
     foreach (Element element in db.List_of_stock)
     {
         //Identify Handle Element
         if (element.Reference == "Coupelles")
         {
             //Set flag appropriately depending on inventory
             element.CheckifAvailable();
             if (checkBx_rackhandles4.Checked == true)
             {
                 //Create and add handles
                 Handle handle    = new Handle();
                 int    rackindex = rackcounter;
                 rackindex--;
                 handle.SetValues(element.Code, element.Price_client, element.Dimensions_cm, element.Quantity_per_rack,
                                  element.Available, element.Price_fournisseur1, element.Delay_fournisseur1,
                                  element.Price_fournisseur2, element.Delay_fournisseur2);
                 for (int counter = 1; counter <= element.Quantity_per_rack; counter++)
                 {
                     rack.AddElements(handle);
                 }
             }
         }
         if (element.Reference == "Traverse Av")
         {
             if (element.Width == rack.Width)
             {
                 element.CheckifAvailable();
                 //Create Crossbeam
                 Frontal_crossbeam frontal_crossbeam = new Frontal_crossbeam(rack.Width, "Frontal Crossbeam");
                 //Set Price and dimensions from stock table
                 frontal_crossbeam.SetValues(element.Code, element.Price_client, element.Dimensions_cm, element.Quantity_per_rack,
                                             element.Available, element.Price_fournisseur1, element.Delay_fournisseur1,
                                             element.Price_fournisseur2, element.Delay_fournisseur2);
                 for (int counter = 1; counter <= element.Quantity_per_rack; counter++)
                 {
                     rack.AddElements(frontal_crossbeam);
                 }
             }
         }
         if (element.Reference == "Traverse Ar")
         {
             if (element.Width == rack.Width)
             {
                 element.CheckifAvailable();
                 //Create Crossbeams
                 Rear_crossbeam rear_crossbeam = new Rear_crossbeam(rack.Width, "Rear Crossbeam");
                 rear_crossbeam.SetValues(element.Code, element.Price_client, element.Dimensions_cm, element.Quantity_per_rack,
                                          element.Available, element.Price_fournisseur1, element.Delay_fournisseur1,
                                          element.Price_fournisseur2, element.Delay_fournisseur2);
                 for (int counter = 1; counter <= element.Quantity_per_rack; counter++)
                 {
                     rack.AddElements(rear_crossbeam);
                 }
             }
         }
         if (element.Reference == "Traverse GD")
         {
             if (element.Depth == rack.Depth)
             {
                 element.CheckifAvailable();
                 //Create Crossbeams
                 Left_Right_crossbeam left_right_crossbeam1 = new Left_Right_crossbeam(rack.Depth, "Left Crossbeam");
                 left_right_crossbeam1.SetValues(element.Code, element.Price_client, element.Dimensions_cm, element.Quantity_per_rack,
                                                 element.Available, element.Price_fournisseur1, element.Delay_fournisseur1,
                                                 element.Price_fournisseur2, element.Delay_fournisseur2);
                 for (int counter = 1; counter <= element.Quantity_per_rack - 2; counter++)
                 {
                     rack.AddElements(left_right_crossbeam1);
                 }
                 Left_Right_crossbeam left_right_crossbeam2 = new Left_Right_crossbeam(rack.Depth, "Right Crossbeam");
                 left_right_crossbeam2.SetValues(element.Code, element.Price_client, element.Dimensions_cm, element.Quantity_per_rack,
                                                 element.Available, element.Price_fournisseur1, element.Delay_fournisseur1,
                                                 element.Price_fournisseur2, element.Delay_fournisseur2);
                 for (int counter = 1; counter <= element.Quantity_per_rack - 2; counter++)
                 {
                     rack.AddElements(left_right_crossbeam2);
                 }
             }
         }
         if (element.Reference == "Tasseau")
         {
             if (element.Height == rack.Height)
             {
                 element.CheckifAvailable();
                 //Create WoodenBattens
                 WoodenBatten woodenBatten = new WoodenBatten(rack.Height);
                 woodenBatten.SetValues(element.Code, element.Price_client, element.Dimensions_cm, element.Quantity_per_rack,
                                        element.Available, element.Price_fournisseur1, element.Delay_fournisseur1,
                                        element.Price_fournisseur2, element.Delay_fournisseur2);
                 for (int counter = 1; counter <= element.Quantity_per_rack; counter++)
                 {
                     //Add these elements to list contained in rack
                     rack.AddElements(woodenBatten);
                 }
             }
         }
         if (element.Reference == "Porte")
         {
             //1 ou 2 cm maximum de marge pour la largeur
             if (((element.Width == rack.Width / 2 + 1) || (element.Width == rack.Width / 2 + 2)) && (element.Height == rack.Height) && (element.Color == comboBx_doorcolor4.Text))
             {
                 element.CheckifAvailable();
                 //Doors
                 if (checkBx_rackdoors4.Checked == true)
                 {
                     //Create and add doors
                     Left_Door  leftdoor  = new Left_Door(rack.Height, rack.Width, comboBx_doorcolor4.Text);
                     Right_Door rightdoor = new Right_Door(rack.Height, rack.Width, comboBx_rightdoor.Text);
                     leftdoor.SetValues(element.Code, element.Price_client, element.Dimensions_cm, element.Quantity_per_rack,
                                        element.Available, element.Price_fournisseur1, element.Delay_fournisseur1,
                                        element.Price_fournisseur2, element.Delay_fournisseur2);
                     rightdoor.SetValues(element.Code, element.Price_client, element.Dimensions_cm, element.Quantity_per_rack,
                                         element.Available, element.Price_fournisseur1, element.Delay_fournisseur1,
                                         element.Price_fournisseur2, element.Delay_fournisseur2);
                     rack.AddElements(leftdoor);
                     rack.AddElements(rightdoor);
                 }
             }
         }
         if (element.Reference == "Panneau HB")
         {
             if ((element.Depth == rack.Depth) && (element.Width == rack.Width) && (element.Color == comboBx_topPanel.Text))
             {
                 element.CheckifAvailable();
                 //Create Panels
                 name = "Top Panel";
                 PanelTB toppanel = new PanelTB(name, comboBx_topPanel.Text, cabinetkit.Width, cabinetkit.Depth); //Premier panneauHB
                 toppanel.SetValues(element.Code, element.Price_client, element.Dimensions_cm, element.Quantity_per_rack,
                                    element.Available, element.Price_fournisseur1, element.Delay_fournisseur1,
                                    element.Price_fournisseur2, element.Delay_fournisseur2);
                 //Add these elements to list contained in rack
                 rack.AddElements(toppanel);
                 rack.Colors[1] = comboBx_topPanel.Text;
             }
         }
         if (element.Reference == "Panneau HB")
         {
             if ((element.Depth == rack.Depth) && (element.Width == rack.Width) && (element.Color == comboBx_BottmPanel.Text))
             {
                 element.CheckifAvailable();
                 name = "Bottom Panel";
                 PanelTB bottompanel = new PanelTB(name, comboBx_BottmPanel.Text, cabinetkit.Width, cabinetkit.Depth); //Deuxieme panneauHB
                 bottompanel.SetValues(element.Code, element.Price_client, element.Dimensions_cm, element.Quantity_per_rack,
                                       element.Available, element.Price_fournisseur1, element.Delay_fournisseur1,
                                       element.Price_fournisseur2, element.Delay_fournisseur2);
                 //Add these elements to list contained in rack
                 rack.AddElements(bottompanel);
                 rack.Colors[2] = comboBx_BottmPanel.Text;
             }
         }
         if (element.Reference == "Panneau GD")
         {
             if ((element.Depth == rack.Depth) && (element.Height == rack.Height) && (element.Color == comboBx_LPanel4.Text))
             {
                 element.CheckifAvailable();
                 //Create Panels
                 name = "Left Panel";
                 PanelLR leftpanel = new PanelLR(name, comboBx_LPanel4.Text, cabinetkit.Depth);  //Premier panneauGD
                 leftpanel.SetValues(element.Code, element.Price_client, element.Dimensions_cm, element.Quantity_per_rack,
                                     element.Available, element.Price_fournisseur1, element.Delay_fournisseur1,
                                     element.Price_fournisseur2, element.Delay_fournisseur2);
                 //Add these elements to list contained in rack
                 rack.AddElements(leftpanel);
                 rack.Colors[3] = comboBx_LPanel4.Text;
             }
         }
         if (element.Reference == "Panneau GD")
         {
             if ((element.Depth == rack.Depth) && (element.Height == rack.Height) && (element.Color == comboBx_Rpanel4.Text))
             {
                 element.CheckifAvailable();
                 name = "Right Panel";
                 PanelLR rightpanel = new PanelLR(name, comboBx_Rpanel4.Text, cabinetkit.Depth);  //Deuxieme panneauGD
                 rightpanel.SetValues(element.Code, element.Price_client, element.Dimensions_cm, element.Quantity_per_rack,
                                      element.Available, element.Price_fournisseur1, element.Delay_fournisseur1,
                                      element.Price_fournisseur2, element.Delay_fournisseur2);
                 //Add these elements to list contained in rack
                 rack.AddElements(rightpanel);
                 rack.Colors[4] = comboBx_Rpanel4.Text;
             }
         }
         if (element.Reference == "Panneau Ar")
         {
             if ((element.Width == rack.Width) && (element.Height == rack.Height) && (element.Color == comboBx_RearPanel4.Text))
             {
                 element.CheckifAvailable();
                 name = "Rear Panel";
                 RearPanel rearpanel = new RearPanel(name, comboBx_RearPanel4.Text, cabinetkit.Width);  //1 Panneau Arriere
                 rearpanel.SetValues(element.Code, element.Price_client, element.Dimensions_cm, element.Quantity_per_rack,
                                     element.Available, element.Price_fournisseur1, element.Delay_fournisseur1,
                                     element.Price_fournisseur2, element.Delay_fournisseur2);
                 rack.AddElements(rearpanel);
                 rack.Colors[0] = comboBx_RearPanel4.Text;
             }
         }
     }
 }
Example #2
0
        private void btn_Client_signup_Click(object sender, EventArgs e)
        {
            if (txtBx_Code.Text.Equals("") || txtBx_Type.Text.Equals("") || txtBx_Width.Text.Equals("") || txtBx_Depth.Equals("") || txtBx_Height.Equals("") || Colors.Equals("") || textBox1_CustomerPrice.Equals("") || textBox1_InStock.Equals("") || textBox1MinStock.Equals("") || textBox1_NumberOfPart.Equals("") || textBox1_SupplierPrice1.Equals("") || textBox1_SupplierPrice2.Equals("") || textBox1_SupplierTime1.Equals("") || textBox1_SupplierTime2.Equals(""))
            {
                // On ajoute une icône : celle d'une erreur ...
                MessageBox.Show("!!! Veuillez indiquer tous les champs !!!! ",
                                "Titre",
                                MessageBoxButtons.RetryCancel,
                                MessageBoxIcon.Error);
            }
            else
            {
                //Fields
                try
                {
                    Convert.ToDouble(txtBx_Height.Text);
                    Convert.ToDouble(txtBx_Depth.Text);
                    Convert.ToDouble(txtBx_Width.Text);
                    Convert.ToDouble(textBox1_CustomerPrice.Text);
                    Convert.ToInt32(textBox1_InStock.Text);
                    Convert.ToInt32(textBox1MinStock.Text);
                    Convert.ToInt32(textBox1_NumberOfPart.Text);
                    Convert.ToDouble(textBox1_SupplierPrice1.Text);
                    Convert.ToDouble(textBox1_SupplierPrice2.Text);
                    Convert.ToInt32(textBox1_SupplierTime1.Text);
                    Convert.ToInt32(textBox1_SupplierTime2.Text);

                    string name              = txtBx_Type.Text;
                    string reference         = txtBx_Type.Text;
                    string code              = txtBx_Code.Text;
                    double height            = Convert.ToDouble(txtBx_Height.Text);
                    double depth             = Convert.ToDouble(txtBx_Depth.Text);
                    double width             = Convert.ToDouble(txtBx_Width.Text);
                    string color             = Colors.Text;
                    double price_client      = Convert.ToDouble(textBox1_CustomerPrice.Text);
                    string dimensions_cm     = "";
                    int    quantity_in_stock = Convert.ToInt32(textBox1_InStock.Text);
                    //bool available = true;
                    int    minimum_stock      = Convert.ToInt32(textBox1MinStock.Text);
                    int    quantity_per_rack  = Convert.ToInt32(textBox1_NumberOfPart.Text);
                    double price_fournisseur1 = Convert.ToDouble(textBox1_SupplierPrice1.Text);
                    double price_fournisseur2 = Convert.ToDouble(textBox1_SupplierPrice2.Text);
                    int    delay_fournisseur1 = Convert.ToInt32(textBox1_SupplierTime1.Text);
                    int    delay_fournisseur2 = Convert.ToInt32(textBox1_SupplierTime2.Text);

                    if (reference == "Cornieres")
                    {
                        Steel_CornerBar steel_Corner_Bars = new Steel_CornerBar(reference, code, dimensions_cm, height, depth, width, color, quantity_in_stock, minimum_stock, price_client, quantity_per_rack, price_fournisseur1, delay_fournisseur1, price_fournisseur2, delay_fournisseur2);
                        db.List_of_stock.Add(steel_Corner_Bars);
                        Infos = "Successful update";
                    }
                    else if (reference == "Coupelles")
                    {
                        Handle Handles = new Handle(reference, code, dimensions_cm, height, depth, width, color, quantity_in_stock, minimum_stock, price_client, quantity_per_rack, price_fournisseur1, delay_fournisseur1, price_fournisseur2, delay_fournisseur2);
                        db.List_of_stock.Add(Handles);
                        Infos = "Successful update";
                    }
                    else if (reference == "Panneau Ar")
                    {
                        RearPanel rear_panels = new RearPanel(reference, code, dimensions_cm, height, depth, width, color, quantity_in_stock, minimum_stock, price_client, quantity_per_rack, price_fournisseur1, delay_fournisseur1, price_fournisseur2, delay_fournisseur2);
                        db.List_of_stock.Add(rear_panels);
                        Infos = "Successful update";
                    }
                    else if (reference == "Panneau GD")
                    {
                        PanelLR left_right_panels = new PanelLR(reference, code, dimensions_cm, height, depth, width, color, quantity_in_stock, minimum_stock, price_client, quantity_per_rack, price_fournisseur1, delay_fournisseur1, price_fournisseur2, delay_fournisseur2);
                        db.List_of_stock.Add(left_right_panels);
                        Infos = "Successful update";
                    }
                    else if (reference == "Panneau HB")
                    {
                        PanelTB top_bottom_panels = new PanelTB(reference, code, dimensions_cm, height, depth, width, color, quantity_in_stock, minimum_stock, price_client, quantity_per_rack, price_fournisseur1, delay_fournisseur1, price_fournisseur2, delay_fournisseur2);
                        db.List_of_stock.Add(top_bottom_panels);
                        Infos = "Successful update";
                    }
                    else if (reference == "Porte")
                    {
                        Door doors = new Door(reference, code, dimensions_cm, height, depth, width, color, quantity_in_stock, minimum_stock, price_client, quantity_per_rack, price_fournisseur1, delay_fournisseur1, price_fournisseur2, delay_fournisseur2);
                        db.List_of_stock.Add(doors);
                        Infos = "Successful update";
                    }
                    else if (reference == "Tasseau")
                    {
                        WoodenBatten wooden_battens = new WoodenBatten(reference, code, dimensions_cm, height, depth, width, color, quantity_in_stock, minimum_stock, price_client, quantity_per_rack, price_fournisseur1, delay_fournisseur1, price_fournisseur2, delay_fournisseur2);
                        db.List_of_stock.Add(wooden_battens);
                        Infos = "Successful update";
                    }

                    else if (reference == "Traverse Ar")
                    {
                        Rear_crossbeam rear_crossbeams = new Rear_crossbeam(reference, code, dimensions_cm, height, depth, width, color, quantity_in_stock, minimum_stock, price_client, quantity_per_rack, price_fournisseur1, delay_fournisseur1, price_fournisseur2, delay_fournisseur2);
                        db.List_of_stock.Add(rear_crossbeams);
                        Infos = "Successful update";
                    }
                    else if (reference == "Traverse Av")
                    {
                        Frontal_crossbeam frontal_crossbeams = new Frontal_crossbeam(reference, code, dimensions_cm, height, depth, width, color, quantity_in_stock, minimum_stock, price_client, quantity_per_rack, price_fournisseur1, delay_fournisseur1, price_fournisseur2, delay_fournisseur2);
                        db.List_of_stock.Add(frontal_crossbeams);
                        Infos = "Successful update";
                    }
                    else if (reference == "Traverse GD")
                    {
                        Left_Right_crossbeam left_right_crossbeams = new Left_Right_crossbeam(reference, code, dimensions_cm, height, depth, width, color, quantity_in_stock, minimum_stock, price_client, quantity_per_rack, price_fournisseur1, delay_fournisseur1, price_fournisseur2, delay_fournisseur2);
                        db.List_of_stock.Add(left_right_crossbeams);
                        Infos = "Successful update";
                    }
                    else
                    {
                        // On ajoute une icône : celle d'une erreur ...
                        MessageBox.Show("!!! Error 103 aucun type ne correspond !!!! ",
                                        "Titre",
                                        MessageBoxButtons.RetryCancel,
                                        MessageBoxIcon.Error);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("!!! Oups :( !!!! " + ex,
                                    "Titre",
                                    MessageBoxButtons.RetryCancel,
                                    MessageBoxIcon.Error);
                    Infos = "!!! ERROR !!!";
                }


                if (mode == "Add")
                {
                    db.List_of_stock = db.List_of_stock;
                    this.Hide(); // retourne à la page précédente
                    Sudo_Catalog_management Catalog_management = new Sudo_Catalog_management(db, Infos);
                    Catalog_management.ShowDialog();
                }
                if (mode == "Edit")
                {
                    db.List_of_stock.RemoveAt(Convert.ToInt32(ID.Text)); // on supprime la ligne la dataBase
                    db.List_of_stock = db.List_of_stock;
                    this.Hide();                                         // retourne à la page précédente
                    Sudo_Catalog_management Catalog_management = new Sudo_Catalog_management(db, Infos);
                    Catalog_management.ShowDialog();
                }
            }
        }