Exemplo n.º 1
0
 //Load Corporation Code; Developer: Dennis
 private void LoadCorporation()
 {
     txtInvno.IsEnabled = false; txtInvno.Visibility = Visibility.Visible;
     txtPrice.IsEnabled = false;
     this.InvNo         = InvoiceClss.GetInvoiceId();
     txtInvno.Text      = InvNo.ToString("00000");
     Classes.InvoiceClss.LoadCorpCmb(ref cmbCorp);
     txtPayed.Text           = "0"; this.txtInvDate.Text = DateTime.Now.ToString();
     txtGrossSales.Text      = string.Format("{0:C}", "0");
     txtSalesTax.Text        = string.Format("{0:C}", "0");
     txtPayed.Text           = string.Format("{0:C}", "0");
     txtPendingPayment.Text  = string.Format("{0:C}", "0");
     cmbCustomer.ItemsSource = null;
     txtOrdNo.Text           = null;
 }
Exemplo n.º 2
0
        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 :;
        }