private void save_Click(object sender, EventArgs e) { if (Temp.Count == 0) { MessageBox.Show("You must associate atleast one part."); } else { this.Hide(); Product newProduct = new Product(nameText.Text, int.Parse(inventoryText.Text), decimal.Parse(priceText.Text), int.Parse(minText.Text), int.Parse(maxText.Text)); Inventory.addProduct(newProduct); for (var i = 0; i < Temp.Count; i++) { var updateAssociated = newProduct.lookupAssociatedPart(i); if (!Temp.Contains(updateAssociated) && updateAssociated != null) { if (!newProduct.removeAssociatedPart(updateAssociated.PartID)) { MessageBox.Show($"Unable to unassociate {updateAssociated.Name}"); } } else if (!newProduct.AssociatedParts.Contains(Temp[i])) { newProduct.addAssociatedPart(Temp[i]); } } MainScreen mainScreen = new MainScreen(); mainScreen.Show(); } }
private void cancel_Click(object sender, EventArgs e) { this.Hide(); MainScreen mainScreen = new MainScreen(); mainScreen.Show(); }
private void save_Click(object sender, EventArgs e) { this.Hide(); if (machineTxt.BackColor == Color.White) { Part newPart = new Inhouse(nameText.Text, int.Parse(inventoryText.Text), decimal.Parse(priceText.Text), int.Parse(minText.Text), int.Parse(maxText.Text), int.Parse(machineTxt.Text)); Inventory.addPart(newPart); } else { Part newPart = new Outsourced(nameText.Text, int.Parse(inventoryText.Text), decimal.Parse(priceText.Text), int.Parse(minText.Text), int.Parse(maxText.Text), companyNameTxt.Text); Inventory.addPart(newPart); } MainScreen mainScreen = new MainScreen(); mainScreen.Show(); }
private void save_Click(object sender, EventArgs e) { this.Hide(); if (machineTxt.Text != "" && companyNameTxt.Text == "") { Part newPart = new Inhouse(nameText.Text, int.Parse(inventoryText.Text), decimal.Parse(priceText.Text), int.Parse(minText.Text), int.Parse(maxText.Text), int.Parse(machineTxt.Text)); Inventory.updatePart(int.Parse(idText.Text), newPart); } else { Part newPart = new Outsourced(nameText.Text, int.Parse(inventoryText.Text), decimal.Parse(priceText.Text), int.Parse(minText.Text), int.Parse(maxText.Text), companyNameTxt.Text); Inventory.updatePart(int.Parse(idText.Text), newPart); } MainScreen mainScreen = new MainScreen(); mainScreen.Show(); }
private void autoPopulate() { var product = Inventory.lookupProduct(Inventory.Products[Inventory.Index].ProductID); if (product != null) { idText.Text = product.ProductID.ToString(); nameText.Text = product.Name; inventoryText.Text = product.InStock.ToString(); priceText.Text = product.Price.ToString(); maxText.Text = product.Max.ToString(); minText.Text = product.Min.ToString(); } else { MessageBox.Show("There is no matching product"); this.Hide(); MainScreen mainScreen = new MainScreen(); mainScreen.Show(); } }