private void AProdSaveButton_Click(object sender, EventArgs e) { if (Convert.ToInt32(AProdInventoryTextBox.Text) < Convert.ToInt32(AProdMinTextBox.Text) || Convert.ToInt32(AProdInventoryTextBox.Text) > Convert.ToInt32(AProdMaxTextBox.Text)) { MessageBox.Show("Inventory is out of range.", "Error"); return; } if (Convert.ToInt32(AProdMaxTextBox.Text) < Convert.ToInt32(AProdMinTextBox.Text)) { MessageBox.Show("Your min value must be less than the max value.", "Error"); } else { Inventory.CurrentProduct.ProductID = Inventory.createProductID(); Inventory.CurrentProduct.Name = AProdNameTextBox.Text; Inventory.CurrentProduct.InStock = Int32.Parse(AProdInventoryTextBox.Text); Inventory.CurrentProduct.Price = Decimal.Parse(AProdPriceTextBox.Text); Inventory.CurrentProduct.Max = Int32.Parse(AProdMaxTextBox.Text); Inventory.CurrentProduct.Min = Int32.Parse(AProdMinTextBox.Text); Inventory.AddProduct(Inventory.CurrentProduct); Close(); Mainscreen p = new Mainscreen(); p.Show(); } }
static void Main() { //// Populate the parts and product lists Inventory.AddProduct(new Product(0, "Red Bike", 15, 11.44M, 25, 1)); Inventory.AddProduct(new Product(1, "Yellow Bike", 19, 9.66M, 20, 1)); Inventory.AddProduct(new Product(2, "Blue Bike", 5, 12.77M, 25, 1)); Inventory.AddPart(new InhousePart(0, "Wheel", 12.11M, 15, 25, 5, 4571)); //machine id Inventory.AddPart(new OutsourcedPart(1, "Pedal", 8.22M, 11, 25, 5, "Pedal Company")); //company name Inventory.AddPart(new InhousePart(2, "Chain", 8.33M, 12, 25, 5, 8647)); //machine id Inventory.AddPart(new OutsourcedPart(3, "Seat", 4.55M, 8, 25, 5, "Bikes For All, Inc.")); //company name //end populate list Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Mainscreen()); }
//Update Product public static void UpdateProduct(int productID, Product updatedProduct) { Inventory.RemoveProduct(CurrProductIndex); Inventory.AddProduct(CurrentProduct); }