// Cancel button click event. private void CancelButton_Click(object sender, EventArgs e) { this.Hide(); IMS updatedMain = new IMS(); updatedMain.Show(); }
// CancelButton click event. Cancel changes to Products partlist and do not save. private void CancelButton_Click(object sender, EventArgs e) { this.Close(); IMS updatedMain = new IMS(); updatedMain.Show(); Inventory.PartList.Clear(); }
// Save Button click Event. private void SaveButton_Click(object sender, EventArgs e) { // if Min and Max is validated and Inventory is validated Clear error provider and allow save. if ((MinMaxValidation() == true) && (InventoryValidation() == true)) { errorProvider1.Clear(); if (isInHouse) { // Save inhouse part. Part part = new InHousePart(Convert.ToInt32(partIDTextBox.Text), partNametextBox.Text.ToString(), Convert.ToInt32(inventoryTextBox.Text), Convert.ToDouble(priceCostTextBox.Text), Convert.ToInt32(maxTextBox.Text), Convert.ToInt32(minTextBox.Text), Convert.ToInt32(compMachTextBox.Text)); // If isNewPart true - Add part. if (isNewPart) { Inventory.AddPart(part); MessageBox.Show("In-House Part Added!"); } // If isNewPart is false - Swap part. else { Inventory.SwapPart(part); MessageBox.Show("Part Updated!"); } } // Else Save Outsourced part. else { Part part = new OutSourcedPart(Convert.ToInt32(partIDTextBox.Text), partNametextBox.Text.ToString(), Convert.ToInt32(inventoryTextBox.Text), Convert.ToDouble(priceCostTextBox.Text), Convert.ToInt32(maxTextBox.Text), Convert.ToInt32(minTextBox.Text), compMachTextBox.Text.ToString()); // If isNewPart true - Add part. if (isNewPart) { Inventory.InsertPart(part); MessageBox.Show("Out-Sourced Part Added!"); } // If isNewPart is false - Swap part. else { Inventory.SwapPart(part); MessageBox.Show("Part Updated!"); } } this.Hide(); IMS updatedMain = new IMS(); updatedMain.Show(); } }
// Save button click event. private void SaveButton_Click(object sender, EventArgs e) { if ((MinMaxvalidation() == true) && (InventoryValidation() == true)) /* && (validation3() == true))*/ { errorProvider1.Clear(); if (isNewProduct) { Product product = new Product(Convert.ToInt32(productIDTextBox.Text), productNameTextBox.Text.ToString(), Convert.ToInt32(inventoryTextBox.Text), Convert.ToDouble(priceCostTextBox.Text), Convert.ToInt32(maxTextBox.Text), Convert.ToInt32(minTextBox.Text), Inventory.PartList); Inventory.InsertProduct(product); MessageBox.Show("Product Added!"); //Create new PartList for CurrentProducts AssociatedParts. Inventory.Restore(); } else { Product product = new Product(Convert.ToInt32(productIDTextBox.Text), productNameTextBox.Text.ToString(), Convert.ToInt32(inventoryTextBox.Text), Convert.ToDouble(priceCostTextBox.Text), Convert.ToInt32(maxTextBox.Text), Convert.ToInt32(minTextBox.Text), Inventory.PartList); Inventory.SwapProduct(product); MessageBox.Show("Product Updated!"); //Create new PartList for CurrentProducts AssociatedParts. Inventory.Restore(); } // Copy Current PartList to AssociatedParts Inventory.AssociatedPartsReStore(); this.Hide(); IMS updatedMainScreen = new IMS(); updatedMainScreen.Show(); } }