private void APSaveButton_Click(object sender, EventArgs e) { if (Convert.ToInt32(APInventoryTextBox.Text) < Convert.ToInt32(APMinTextBox.Text) || Convert.ToInt32(APInventoryTextBox.Text) > Convert.ToInt32(APMaxTextBox.Text)) { MessageBox.Show("Inventory is out of range.", "Error"); return; } if (Convert.ToInt32(APMaxTextBox.Text) > Convert.ToInt32(APMinTextBox.Text)) { if (APInhouseRadio.Checked) { InhousePart newIPart = new InhousePart(); newIPart.PartID = Inventory.createPartID(); newIPart.Name = APNameTextBox.Text; newIPart.InStock = Int32.Parse(APInventoryTextBox.Text); newIPart.Price = Decimal.Parse(APPriceTextBox.Text); newIPart.Max = Int32.Parse(APMaxTextBox.Text); newIPart.Min = Int32.Parse(APMinTextBox.Text); newIPart.MachineID = Int32.Parse(APMachineIDTextBox.Text); Inventory.AddPart(newIPart); } else { OutsourcedPart newOPart = new OutsourcedPart(); newOPart.PartID = Inventory.createPartID(); newOPart.Name = APNameTextBox.Text; newOPart.InStock = Int32.Parse(APInventoryTextBox.Text); newOPart.Price = Decimal.Parse(APPriceTextBox.Text); newOPart.Max = Int32.Parse(APMaxTextBox.Text); newOPart.Min = Int32.Parse(APMinTextBox.Text); newOPart.CompanyName = (APMachineIDTextBox.Text); Inventory.AddPart(newOPart); } } else { MessageBox.Show("Your min value is greater than the max value.", "Error"); return; } 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()); }
public static void UpdatePart(int partID, Part part) { Inventory.DeletePart(part); Inventory.AddPart(part); }