private void btmCreate_Click(object sender, RoutedEventArgs e) { try { Payed_ = Convert.ToDecimal(txtToPay.Text); TransDate = Convert.ToDateTime(txtInvDate.Text); OrdNo = this.txtOrdNo.Text; } catch (Exception) { MessageBox.Show("Error: Error with Payed Quantity or Invoice Date! ", "Error", MessageBoxButton.OK, MessageBoxImage.Error); goto ExitIntruction; } //Update Payments By Customer if (!InvoiceClss.UpdatePaymentHistory(InvNo, Payed_, TransDate, false, OrdNo)) { goto ExitIntruction; } //Clear Data Clear(); ExitIntruction :; }
private void btmCreate_Click(object sender, RoutedEventArgs e) { try { Payed_ = Convert.ToDecimal(txtPayed.Text); TransDate = Convert.ToDateTime(txtInvDate.Text); OrdNo = this.txtOrdNo.Text; } catch (Exception) { MessageBox.Show("Error: Error with Payed Quantity or Invoice Date! ", "Error", MessageBoxButton.OK, MessageBoxImage.Error); goto ExitIntruction; } //Review Units by Products are available (Not was edited by other user) var qry = from i in InvDet select new { i.ProdNo, i.WhID, i.TotalUnits }; if (qry.Count() == 0) { MessageBox.Show("Error: Not Invoice Details!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); goto ExitIntruction; } foreach (var item in qry) { decimal SecondUnits = 0; InvoiceClss.GetProdPriceAndAvlQty(ref SecondUnits, item.ProdNo, item.WhID); if (SecondUnits < item.TotalUnits) { MessageBox.Show("Error: Total Units for the Product: " + item.ProdNo.ToString() + " and the Warehouse: " + item.WhID.ToString() + " was reduced to: " + SecondUnits.ToString() + "units by other user! ", "Error", MessageBoxButton.OK, MessageBoxImage.Error); goto ExitIntruction; } } qry = null; //Create Invoice long SecondInv = InvoiceClss.GetInvoiceId(); InvNo = SecondInv; if (CorpoId == 0 || InvNo == 0 || CstNo == 0) { MessageBox.Show("Error:CorpId or InvNo or CstNo is/are equal to 0: Please, try again.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); goto ExitIntruction; } //Create Invoice Details if (InvoiceClss.CreateInvoice(InvDet, CorpoId, InvNo, Payed_, TransDate, OrdNo, CstNo)) { if (InvoiceClss.CreateInvoiceDet(InvDet, InvNo)) { //Update Payments By Customer if (!InvoiceClss.UpdatePaymentHistory(InvNo, Payed_, TransDate, true, OrdNo)) { goto ExitIntruction; } //Update Product Inventory InvoiceClss.UpdateProductInventory(InvDet, InvNo); } else { //Create InvoiceDet Failed goto ExitIntruction; } } else { //Create Invoice Failed goto ExitIntruction; } //Clear Data Clear(); ExitIntruction :; }