public void AddLocker(Locker locker) { lockerList.Add(locker); }
private void AddLocker_Click(object sender, EventArgs e) { if (ColorBox.Text == "" || comboHeight.Text == "") { MessageBox.Show("Select a value please!"); } if (cupBoard.GetLockerList().Count() == 7) { MessageBox.Show("You have reached the maximum number of lockers"); } else { } int row = 0; dataGridView1.Rows.Add(); row = dataGridView1.Rows.Count - 2; List <Accessory> accList = new List <Accessory>(); HBpanel HBpanell = new HBpanel(ColorGet(), DepthGet(), WidthGet()); accList.Add(HBpanell); GDpanel GDpanell = new GDpanel(ColorGet(), DepthGet(), HeightGet()); accList.Add(GDpanell); ARpanel ARpanell = new ARpanel(ColorGet(), WidthGet(), HeightGet()); accList.Add(ARpanell); ARrail ARraill = new ARrail(WidthGet()); accList.Add(ARraill); AVrail AVraill = new AVrail(WidthGet()); accList.Add(AVraill); GDrail GDraill = new GDrail(DepthGet()); //x2 accList.Add(GDraill); Cleat cleat = new Cleat(HeightGet()); //x4 accList.Add(cleat); //Add door (if there is one) if (list.Count() != 0) { if (list[0] == "wood") { NormalDoor door = new NormalDoor(HeightGet(), WidthGet(), list[1]); accList.Add(door); } if (list[0] == "glass") { GlassDoor door = new GlassDoor(HeightGet(), WidthGet()); accList.Add(door); } } // création d'un nouvel objet locker Kitbox.Locker locker = new Kitbox.Locker(accList, LockerHeightGet(), ColorGet(), 0); // ajout de mon casier à la liste de casier statique existante dans le Form1 // Form1.listOfLocker.Add(locker); //methode qui modifie la listOfLocker si modify cupBoard.AddLocker(locker); //Vérifier si un suplément devras être payé double extrusionHeight = cupBoard.GetTotalHeight(); if (cupBoard.GetExtrusion().IsCut(extrusionHeight)) { textBox1.Visible = true; } else { textBox1.Visible = false; } // on ajoute dans le datagrid les infos dataGridView1["ColorLocker", row].Value = ColorGet(); dataGridView1["HeightLocker", row].Value = LockerHeightGet(); //Si la porte est en bois if (list.Count() != 0) { dataGridView1["DoorType", row].Value = list[0]; if (list[0] == "wood") { dataGridView1["ColorDoor", row].Value = list[1]; } } // verification availability form.OpenConnection(); foreach (Accessory accessory in locker.GetAccessoryList()) { double instock = accessory.GetInstock(form.connection); if (instock < 1) { MessageBox.Show("Some items are sold out , a 7 days delay is neccessary to get them. "); dataGridView1["Disponibility", row].Value = "Not Available"; break; } else { dataGridView1["Disponibility", row].Value = "Available"; } } form.CloseConnection(); //Comme "list" est une variable static, il faut la réinitialiser pour le prochain door list.Clear(); }