public AddPart(Inhouse inPart) { InitializeComponent(); textBoxAddPartID = inPart.PartID; textBoxAddPartName = inPart.Name; textBoxAddPartInv = inPart.InStock; textBoxAddPartPriceCost = inPart.Price; textBoxAddPartMin = inPart.Min; textBoxAddPartMax = inPart.Max; textBoxAddPartMachineID = inPart.MachineID.ToString(); if (Inventory.CurrentPart is Inhouse) { Inhouse e = (Inhouse)Inventory.CurrentPart; BoxAddPartMachineID.Text = e.MachineID.ToString(); isInHouse = true; radioAddPartInHouse.Checked = true; } else { Outsourced e = (Outsourced)Inventory.CurrentPart; BoxAddPartMachineID.Text = e.CompanyName; isInHouse = false; radioAddPartOutsourced.Checked = true; } }
//Save Button private void buttonModifyPartSave_Click(object sender, EventArgs e) { //Exception if (textBoxModifyPartMax < textBoxModifyPartMin) { MessageBox.Show("Minimum must not exceed maximum"); return; } if (textBoxModifyPartInv < textBoxModifyPartMin || textBoxModifyPartInv > textBoxModifyPartMax) { MessageBox.Show("Inventory must be between minimum and maximum"); return; } if (radioModifyPartInHouse.Checked) { Inhouse inhouse = new Inhouse(Convert.ToInt32(BoxModifyPartID.Text), BoxModifyPartName.Text, Convert.ToDouble(BoxModifyPartPriceCost.Text), Convert.ToInt32(BoxModifyPartInv.Text), Convert.ToInt32(BoxModifyPartMin.Text), Convert.ToInt32(BoxModifyPartMax.Text), Convert.ToInt32(BoxModifyPartMachineID.Text)); Inventory.UpdateInHouse(Convert.ToInt32(BoxModifyPartID.Text), inhouse); radioModifyPartInHouse.Checked = true; } else { Outsourced outsourced = new Outsourced(Convert.ToInt32(BoxModifyPartID.Text), BoxModifyPartName.Text, Convert.ToDouble(BoxModifyPartPriceCost.Text), Convert.ToInt32(BoxModifyPartInv.Text), Convert.ToInt32(BoxModifyPartMin.Text), Convert.ToInt32(BoxModifyPartMax.Text), BoxModifyPartMachineID.Text); Inventory.UpdateOutsourced(Convert.ToInt32(BoxModifyPartID.Text), outsourced); radioModifyPartOutsourced.Checked = true; } this.Hide(); MainScreen f1 = new MainScreen(); f1.Show(); }
public AddPart(Outsourced outPart) { InitializeComponent(); textBoxAddPartID = outPart.PartID; textBoxAddPartName = outPart.Name; textBoxAddPartInv = outPart.InStock; textBoxAddPartPriceCost = outPart.Price; textBoxAddPartMin = outPart.Min; textBoxAddPartMax = outPart.Max; textBoxAddPartMachineID = outPart.CompanyName; radioAddPartOutsourced.Checked = true; }
//Part Modify Button private void buttonModifyPart_Click(object sender, EventArgs e) { this.Hide(); if (dataGridViewParts.CurrentRow.DataBoundItem.GetType() == typeof(DeanKellyInventorySystem.Inhouse)) { Inhouse inPart = (Inhouse)dataGridViewParts.CurrentRow.DataBoundItem; new ModifyPart(inPart).ShowDialog(); } else { Outsourced outPart = (Outsourced)dataGridViewParts.CurrentRow.DataBoundItem; new ModifyPart(outPart).ShowDialog(); } }
public static void UpdateOutsourced(int partID, Outsourced outPart) { for (int i = 0; i < AllParts.Count; i++) { if (AllParts[i].GetType() == typeof(DeanKellyInventorySystem.Outsourced)) { Outsourced newPart = (Outsourced)AllParts[i]; if (newPart.PartID == partID) { newPart.Name = outPart.Name; newPart.InStock = outPart.InStock; newPart.Price = outPart.Price; newPart.Min = outPart.Min; newPart.Max = outPart.Max; newPart.CompanyName = outPart.CompanyName; } } } }
// //Save Button private void buttonAddPartSave_Click(object sender, EventArgs e) { try { //Exception Min must not exceed Max if (textBoxAddPartMax < textBoxAddPartMin) { MessageBox.Show("Minimum must not exceed maximum"); return; } } catch (FormatException formatException) { MessageBox.Show("Please enter a numeric value for Min and Max."); } try { //Exception Inventory must be between min and max if (textBoxAddPartInv < textBoxAddPartMin || textBoxAddPartInv > textBoxAddPartMax) { MessageBox.Show("Inventory must be between minimum and maximum"); return; } } catch (FormatException formatException) { MessageBox.Show("Please enter a numeric value for Inv."); } try { if (radioAddPartInHouse.Checked) { Inhouse inHouse = new Inhouse((Inventory.AllParts.Count + 1), textBoxAddPartName, textBoxAddPartPriceCost, textBoxAddPartInv, textBoxAddPartMin, textBoxAddPartMax, int.Parse(textBoxAddPartMachineID)); Inventory.AddPart(inHouse); } else { //Exception Min must not exceed Max if (textBoxAddPartMax < textBoxAddPartMin) { MessageBox.Show("Minimum must not exceed maximum"); return; } //Exception Inventory must be between min and max if (textBoxAddPartInv < textBoxAddPartMin || textBoxAddPartInv > textBoxAddPartMax) { MessageBox.Show("Inventory must be between minimum and maximum"); return; } Outsourced outsourced = new Outsourced((Inventory.AllParts.Count + 1), textBoxAddPartName, textBoxAddPartPriceCost, textBoxAddPartInv, textBoxAddPartMin, textBoxAddPartMax, textBoxAddPartMachineID); Inventory.AddPart(outsourced); } } catch (FormatException formatException) { MessageBox.Show("Price must be a numeric value"); } this.Hide(); MainScreen f1 = new MainScreen(); f1.Show(); }