private void btnSave_Click(object sender, EventArgs e) { try { catalogue cat = new catalogue(); CatalogueDB catDB = new CatalogueDB(); cat.catalogueID = txtID.Text; cat.description = txtDescription.Text; cat.status = ComboFIll.getStatusCode(cmbCatalogueStatus.SelectedItem.ToString()); System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button; string btnText = btn.Text; btnText = btnSave.Text; if (btnText.Equals("Update")) { if (catDB.updateCatalogue(cat)) { MessageBox.Show("Catalogue updated"); closeAllPanels(); ListCatalogue(); } else { MessageBox.Show("Failed to update Catalogue Status"); } } else if (btnText.Equals("Save")) { if (catDB.validateCatalogue(cat)) { if (catDB.insertCatalogue(cat)) { MessageBox.Show("Catalogue Added"); closeAllPanels(); ListCatalogue(); } else { MessageBox.Show("Failed to Insert Catalogue"); } } else { MessageBox.Show("Catalogue Data Validation failed"); } } } catch (Exception) { MessageBox.Show("Failed Adding / Editing User Data"); } }
private void ListCatalogue() { try { grdList.Rows.Clear(); CatalogueDB dbrecord = new CatalogueDB(); List <catalogue> Catalogues = dbrecord.getCatalogues(); foreach (catalogue cat in Catalogues) { grdList.Rows.Add(cat.catalogueID, cat.description, ComboFIll.getStatusString(cat.status)); } } catch (Exception ex) { MessageBox.Show(this.ToString() + "-" + System.Reflection.MethodBase.GetCurrentMethod().Name + "() : Error"); } enableBottomButtons(); pnlCatalogueList.Visible = true; }
private void CreateCataloueButtons() { try { CatalogueDB dbrecord = new CatalogueDB(); List <catalogue> Catalogues = dbrecord.getCatalogues(); int intex = 0; foreach (catalogue cat in Catalogues) { if (cat.status == 1) { addButton(cat.catalogueID, intex); intex++; } } } catch (Exception) { MessageBox.Show("Error in request processing"); } }
public void testsInitialize() { catalogueDB = new CatalogueDB(); }
private void button4_Click(object sender, EventArgs e) { //assign currentLocker if (ShoppingCart.currentLocker == 0) { ShoppingCart.currentLocker = ShoppingCart.cupboardComponentsList.Count; } //get former and cupboard values int width = ShoppingCart.getLockerByID(ShoppingCart.currentLocker).width; int formerHeight = Int32.Parse(dataGridView1[1, ShoppingCart.currentLocker - 1].Value.ToString()); int totalHeight = Int32.Parse(textBox12.Text); int maxHeight = Int32.Parse(textBox14.Text); double formerPrice = Double.Parse(dataGridView1[5, ShoppingCart.currentLocker - 1].Value.ToString()); double cupboardPrice = Double.Parse(textBox16.Text); //verify every box filled if (comboBox5.SelectedItem != null && comboBox6.SelectedItem != null && comboBox7.SelectedItem != null) { //get new values int height = Int32.Parse(comboBox5.SelectedItem.ToString()); string doorsColor = comboBox6.SelectedItem.ToString(); string panelColor = comboBox7.SelectedItem.ToString(); bool doorCup = false; //assign doorcup if (doorsColor != "Glass" && doorsColor != "none") { //TODO check if combobox9 filled if (comboBox9.SelectedItem.ToString() == "yes") { doorCup = true; } } //compute totalHeight and verify max height not reached if (totalHeight - formerHeight - 4 + height < maxHeight) { //save changes totalHeight -= formerHeight; totalHeight += height; textBox12.Text = totalHeight.ToString(); //save locker new variables ShoppingCart.getLockerByID(ShoppingCart.currentLocker).height = height; ShoppingCart.getLockerByID(ShoppingCart.currentLocker).panelColor = EnumParse.parseColorStrToEnum(panelColor); ShoppingCart.getLockerByID(ShoppingCart.currentLocker).setCupOfDoor(doorCup); if (doorsColor != "none") { ShoppingCart.getLockerByID(ShoppingCart.currentLocker).doorsColor = EnumParse.parseColorStrToEnum(doorsColor); } /* * if doorsColor were none then add new doors * if doorsColor were not none then new doors not added (locker definition) */ CatalogueDB catalogueDB = new CatalogueDB(); int doorWidth = 0; if (width >= 62) { if (width == 62) { doorWidth = 31; } else { doorWidth = width / 2 + 2; } } Door door1 = (Door)catalogueDB.createComponents(height, doorWidth, 0, EnumParse.parseColorStrToEnum(doorsColor), doorCup, "Door"); ShoppingCart.getLockerByID(ShoppingCart.currentLocker).addComponent(new List <CatalogueComponents>() { door1, door1 }); //compute newPrice foreach (CatalogueComponents compo in ShoppingCart.getLockerByID(ShoppingCart.currentLocker).componentsList) { compo.price = catalogueDB.newPrice(height, doorsColor, panelColor, compo); } double newPrice = ShoppingCart.getLockerByID(ShoppingCart.currentLocker).price; //display new informations dataGridView1.Rows[ShoppingCart.currentLocker - 1].SetValues(ShoppingCart.currentLocker, height, doorsColor, doorCup, panelColor, newPrice); //TODO mettre yes no plutôt que true false dans l'afficheur //display total lockers price cupboardPrice -= formerPrice; cupboardPrice += newPrice; textBox16.Text = cupboardPrice.ToString(); } else { MessageBox.Show("Maximal height reached"); } } else { MessageBox.Show("Fill every choices"); } }
private void button2_Click(object sender, EventArgs e) { int width = ShoppingCart.widthChosen; int depth = ShoppingCart.depthChosen; int numberOfLocker = ShoppingCart.boxNumberChosen; //TODO check if cups are checked // check that the object fields are filled if (comboBox5.SelectedItem != null && comboBox6.SelectedItem != null && comboBox7.SelectedItem != null) { int height = Int32.Parse(comboBox5.SelectedItem.ToString()); string doorsColor = comboBox6.SelectedItem.ToString(); string panelColor = comboBox7.SelectedItem.ToString(); int doorWidth = 0; bool doorCup = false; if (doorsColor != "none") { if (width >= 62) { if (width == 62) { doorWidth = 31; } else { doorWidth = width / 2 + 2; } } if (doorsColor != "Glass" && comboBox9.SelectedItem != null) { if (comboBox9.SelectedItem.ToString() == "yes") { doorCup = true; } } } Locker locker = new Locker(); CatalogueDB cb = new CatalogueDB(); Cleat cleat1 = (Cleat)cb.createComponents(height, 0, 0, "Cleat"); if (doorsColor != "none") { Door door1 = (Door)cb.createComponents(height, doorWidth, 0, EnumParse.parseColorStrToEnum(doorsColor), doorCup, "Door"); locker.addComponent(new List <CatalogueComponents>() { door1, door1 }); } Panels panelsHL = (Panels)cb.createComponents(0, width, depth, EnumParse.parseColorStrToEnum(panelColor), PanelsType.HL, "Panel"); Panels panelsLR = (Panels)cb.createComponents(height, 0, depth, EnumParse.parseColorStrToEnum(panelColor), PanelsType.LR, "Panel"); Panels panelsB = (Panels)cb.createComponents(height, width, 0, EnumParse.parseColorStrToEnum(panelColor), PanelsType.B, "Panel"); CrossBar crossBarF = (CrossBar)cb.createComponents(0, width, 0, CrossBarType.F, "CrossBar"); CrossBar crossBarB = (CrossBar)cb.createComponents(0, width, 0, CrossBarType.B, "CrossBar"); CrossBar crossBarLR = (CrossBar)cb.createComponents(0, 0, depth, CrossBarType.LR, "CrossBar"); // numéro du casier sur lequel on travail int currentbox = locker.ID; locker.panelColor = EnumParse.parseColorStrToEnum(panelColor); locker.height = height; locker.depth = depth; locker.width = width; if (doorsColor != "none") { locker.doorsColor = EnumParse.parseColorStrToEnum(doorsColor); } locker.addComponent(new List <CatalogueComponents>() { cleat1, cleat1, cleat1, cleat1, panelsHL, panelsHL, panelsLR, panelsLR, panelsB, crossBarF, crossBarF, crossBarB, crossBarB, crossBarLR, crossBarLR, crossBarLR, crossBarLR }); ShoppingCart.addCupboardComponent(locker); //premier essai de calcul de prix double prixTotal = locker.price; // met dans le order preview dataGridView1.Rows.Add(currentbox, height, doorsColor, doorCup, panelColor, prixTotal.ToString()); //TODO remplacer total height par la somme des hauteurs int totalHeight = Int32.Parse(textBox12.Text); totalHeight += height + 4; textBox12.Text = totalHeight.ToString(); if (currentbox == numberOfLocker) { button2.Enabled = false; } else { currentbox++; textBox8.Text = currentbox.ToString(); } //TODO remplacer cupboardPrice par var globale double cupboardPrice = Double.Parse(textBox16.Text); textBox16.Text = (cupboardPrice + prixTotal).ToString(); /* * height choices gestion */ int maxHeight = Int32.Parse(textBox14.Text); List <string> choiceRemove = new List <string>(); foreach (string heightChoice in comboBox5.Items) { int boxHeight = Int32.Parse(heightChoice); if (maxHeight - boxHeight - 4 < totalHeight) { choiceRemove.Add(heightChoice); } } foreach (string heightChoice in choiceRemove) { comboBox5.Items.Remove(heightChoice); } } else { MessageBox.Show("Fill every choices"); } if (!button2.Enabled) { button3.Visible = true; button3.Enabled = true; button5.Visible = true; button5.Enabled = true; } }