/// <summary> /// Robert Forbes /// 2017/03/30 /// /// Attempts to update the invoice to use the newly input values. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSubmit_Click(object sender, RoutedEventArgs e) { if (Validate() == true) { try { SupplierInvoice newInvoice = new SupplierInvoice { SupplierInvoiceId = _invoice.SupplierInvoiceId, SupplierId = ((Supplier)cboSupplier.SelectedItem).SupplierID, InvoiceDate = (DateTime)dpInvoiceDate.SelectedDate, SubTotal = decimal.Parse(txtSubTotal.Text), TaxAmount = decimal.Parse(txtTaxAmount.Text), Total = decimal.Parse(txtTotal.Text), AmountPaid = decimal.Parse(txtAmountPaid.Text), Approved = _invoice.Approved, Active = _invoice.Active }; if (_supplierInvoiceManager.UpdateSupplierInvoice(_invoice, newInvoice)) { MessageBox.Show("Invoice Updated Successfully!"); this.Close(); } } catch { MessageBox.Show("There was a problem communicating with the database"); } } else { MessageBox.Show("One or more of the values you have entered are not valid"); } }
public ActionResult Edit([Bind(Include = "SupplierInvoiceId,SupplierId,InvoiceDate,SubTotal,TaxAmount,Total,AmountPaid,Approved,Active")] SupplierInvoice newSupplierInvoice) { if (ModelState.IsValid) { var oldSupplierInvoice = invMgr.RetrieveAllSupplierInvoices().Find(i => i.SupplierInvoiceId == (int?)newSupplierInvoice.SupplierInvoiceId); if (invMgr.UpdateSupplierInvoice(oldSupplierInvoice, newSupplierInvoice) == true) { return(RedirectToAction("Index")); } else { return(new HttpStatusCodeResult(HttpStatusCode.ServiceUnavailable)); } } return(View(newSupplierInvoice)); }