} // End BtnAllParts_Click() private void BtnAdd_Click(object sender, RoutedEventArgs e) { if (txtAddPartNumber.Text.ToString() == "") { MessageBox.Show("You must enter a valid Part Number"); txtAddPartNumber.Focus(); return; } if (txtAddPartQuantity.Text.ToString() == "") { MessageBox.Show("You must enter a Quantity"); txtAddPartQuantity.Focus(); return; } if (txtAddPartLocation.Text.ToString() == "") { MessageBox.Show("You must enter a valid Location"); txtAddPartLocation.Focus(); return; } Part part = new Part() { PartNumber = txtAddPartNumber.Text.ToString(), Quantity = Convert.ToInt32(txtAddPartQuantity.Text), Location = txtAddPartLocation.Text.ToString() }; try { _partManager.AddPart(part); MessageBox.Show("Added " + txtAddPartNumber.Text + " pieces of " + txtAddPartNumber.Text + " to Location " + txtAddPartLocation.Text); txtAddPartNumber.Text = ""; txtAddPartQuantity.Text = ""; txtAddPartLocation.Text = ""; } catch (Exception ex) { MessageBox.Show(ex.Message + "\n\n" + ex.InnerException.Message); } } // EndBtnAdd_Click()
public ActionResult Recieve(Part part) { // Could not get this to work with the Model State, I think it is because a couple of my values were null. PartName and Description // are already in the database and I could not figure out how to populate them. //if (ModelState.IsValid) //{ try { _partManager.AddPart(part); TempData["successMessage"] = string.Format("Part Added to System."); return(RedirectToAction("Index")); } catch (Exception) { TempData["errorMessage"] = string.Format("Part Not Added to System."); return(View()); } //} //TempData["errorMessage"] = string.Format("Model State NOT Valid."); //return View(); //return View(); }