private void modfiypartSave_Click(object sender, EventArgs e) { int partMachineID; int partMax; int partMin; int partInventory; decimal partPrice; int partID; int.TryParse(mppartid.Text, out partID); string partName = mpname.Text; decimal.TryParse(mpprice.Text, out partPrice); int.TryParse(mpinventory.Text, out partInventory); int.TryParse(mpmin.Text, out partMin); int.TryParse(mpmax.Text, out partMax); int.TryParse(mpmachineid.Text, out partMachineID); string partCompanyName = mpcompanyname.Text; if (addPartInHouse.Checked == true) { Part part = new InHouse(partID, partName, partPrice, partInventory, partMin, partMax, partMachineID); Inventory.updatePart(partID, part); Close(); } else { Part part = new Outsource(partID, partName, partPrice, partInventory, partMin, partMax, partCompanyName); Inventory.updatePart(partID, part); Close(); } }
public ModifyPart(Part part) { InitializeComponent(); mppartid.Text = part.PartID.ToString(); mpname.Text = part.Name; mpinventory.Text = part.InStock.ToString(); mpprice.Text = part.Price.ToString(); mpmax.Text = part.Max.ToString(); mpmin.Text = part.Min.ToString(); if (part is Outsource) { addPartOutSource.Checked = true; addPartInHouse.Checked = false; mpmachineid.Text = null; mpmachineid.Hide(); label8.Hide(); mpcompanyname.Show(); label7.Show(); Outsource os = (Outsource)part; mpcompanyname.Text = os.CompanyName; } else if (part is InHouse) { addPartInHouse.Checked = true; addPartOutSource.Checked = false; mpcompanyname.Text = null; mpcompanyname.Hide(); label7.Hide(); mpmachineid.Show(); label8.Show(); InHouse ih = (InHouse)part; mpmachineid.Text = ih.MachineID.ToString(); } else { //something went very wrong here } label9.Hide(); label10.Hide(); label11.Hide(); label12.Hide(); label13.Hide(); label14.Hide(); label15.Hide(); label17.Hide(); }
public static void updatePart(int PartID, Part prelimObj) { Part part = lookupPart(PartID); if (prelimObj is InHouse) { InHouse obj = (InHouse)prelimObj; deletePart(part); InHouse ih = new InHouse(obj.PartID, obj.Name, obj.Price, obj.InStock, obj.Min, obj.Max, obj.MachineID); addPart(ih); } else { Outsource obj = (Outsource)prelimObj; deletePart(part); Outsource os = new Outsource(obj.PartID, obj.Name, obj.Price, obj.InStock, obj.Min, obj.Max, obj.CompanyName); addPart(os); } }
private void addpartSave_Click(object sender, EventArgs e) { int partMachineID; int partMax; int partMin; int partInventory; decimal partPrice; int partID; int.TryParse(addPartID.Text, out partID); string partName = addPartName.Text; decimal.TryParse(addPartPrice.Text, out partPrice); int.TryParse(addPartInventory.Text, out partInventory); int.TryParse(addPartMin.Text, out partMin); int.TryParse(addPartMax.Text, out partMax); string partCompanyName = addPartCompanyName.Text; int.TryParse(addPartMachineID.Text, out partMachineID); try { //int partMachineID = int.Parse(addPartMachineID.Text); if (partCompanyName == "") { Part part = new InHouse(partID, partName, partPrice, partInventory, partMin, partMax, partMachineID); Inventory.AllParts.Add(part); } else { Part part = new Outsource(partID, partName, partPrice, partInventory, partMin, partMax, partCompanyName); Inventory.AllParts.Add(part); } } catch (Exception) { } Close(); }