public ActionResult Edit(string partNumber, Part part)
 {
     if (ModelState.IsValid)
     {
         try
         {
             part.PartNumber = partNumber;
             _partManager.EditPartInformation(part);
             return(RedirectToAction("Index"));
         }
         catch (Exception)
         {
             return(View());
         }
     }
     return(View());
 }
Example #2
0
        }        // End Window_Loaded()

        private void BtnSubmitUpdatedPart_Click(object sender, RoutedEventArgs e)
        {
            if (txtUpdatePartName.Text == "")
            {
                MessageBox.Show("You must enter a Part Name.");
                txtUpdatePartName.Focus();
                return;
            }
            if (txtUpdatePartDescription.Text == "")
            {
                MessageBox.Show("You must enter a Description.");
                txtUpdatePartName.Focus();
                return;
            }
            if (txtUpdatePartCost.Text == "")
            {
                MessageBox.Show("You must enter a Cost.");
                txtUpdatePartName.Focus();
                return;
            }

            Part part = new Part()
            {
                PartNumber  = txtUpdatePartNumber.Text.ToString(),
                PartName    = txtUpdatePartName.Text.ToString(),
                Cost        = decimal.Parse(txtUpdatePartCost.Text),
                Description = txtUpdatePartDescription.Text.ToString()
            };

            try
            {
                if (_partManager.EditPartInformation(part))
                {
                    this.DialogResult = true;
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n\n" + ex.InnerException.Message);
            }
        }        // End BtnSubmitUpdatedPart_Click()