} // End BtnCancelPartAdd_Click() private void BtnSubmitNewPart_Click(object sender, RoutedEventArgs e) { if (txtNewPartNumber.Text.ToString() == "") { MessageBox.Show("You must enter a Part Number"); txtAddPartNumber.Focus(); return; } if (txtNewPartName.Text.ToString() == "") { MessageBox.Show("You must enter a Part Name"); txtAddPartQuantity.Focus(); return; } if (txtNewPartCost.Text.ToString() == "") { MessageBox.Show("You must enter a Cost of the new Part"); txtAddPartLocation.Focus(); return; } if (txtNewPartDescription.Text.ToString() == "") { MessageBox.Show("You must enter a Description of the new Part"); txtAddPartLocation.Focus(); return; } Part part = new Part() { PartNumber = txtNewPartNumber.Text.ToString(), PartName = txtNewPartName.Text.ToString(), Cost = Convert.ToDecimal(txtNewPartCost.Text), Description = txtNewPartDescription.Text.ToString() }; try { _partManager.AddNewPart(part); MessageBox.Show("Part Added to the System"); txtNewPartNumber.Text = ""; txtNewPartName.Text = ""; txtNewPartCost.Text = ""; txtNewPartDescription.Text = ""; txtNewPartNumber.Focus(); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n\n" + ex.InnerException.Message); } } // End BtnSubmitNewPart_Click()
public ActionResult Create(Part newPart) { if (ModelState.IsValid) { try { _partManager.AddNewPart(newPart); return(RedirectToAction("Index")); } catch (Exception) { return(View()); } } return(View()); }