public Outsourced(BasePart b, string companyName) { setPartID(b.partID); setName(b.name); setPrice(b.price); setInStock(b.inStock); setMin(b.min); setMax(b.max); setCompanyName(companyName); }
public Inhouse(BasePart b, int machineID) { setPartID(b.partID); setName(b.name); setPrice(b.price); setInStock(b.inStock); setMin(b.min); setMax(b.max); setMachineID(machineID); }
private void Save_Click(object sender, EventArgs e) { int invInStock = Int32.Parse(InvTextBox.Text); int minStock = 0; try { minStock = Int32.Parse(minTextBox.Text); } catch { MessageBox.Show("Please only type numbers in min field, " + minTextBox.Text + " is not a number", "Min Field Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int maxStock = Int32.Parse(maxTextBox.Text); BasePart b = new BasePart(); b.partID = Inventory.createPartID(); b.name = nameTextBox.Text; b.price = Double.Parse(PriceTextBox.Text); b.min = minStock; b.max = maxStock; if (invInStock <= maxStock && invInStock >= minStock) { b.inStock = Int32.Parse(InvTextBox.Text); } if (inHouseRadioButton.Checked) { Inhouse newPart = new Inhouse(b, Int32.Parse(MachineCompanyIDTextBox.Text)); Inventory.addPart(newPart); mainFormObject.addPartTableRow(newPart); } else { Outsourced newPart = new Outsourced(b, MachineCompanyIDTextBox.Text); Inventory.addPart(newPart); mainFormObject.addPartTableRow(newPart); } Close(); }