示例#1
0
        public void CreateLayawayTransaction()
        {
            if (!CheckData())
            {
                string      productID   = GetSelectedProductID();
                double      downPayment = Convert.ToDouble(DownPaymentLabel.Text);
                double      salesTax    = Convert.ToDouble(SalesTaxLabel.Text);
                double      owed        = Convert.ToDouble(StillOwedLabel.Text);
                double      principal   = owed + salesTax + downPayment;
                double      totalSale   = downPayment + owed;
                DataManager dataManager = new DataManager(connectionString);

                string invoiceNumber = pONumber;
                string customerID    = CustomerIDTextBox.Text;

                string principalAmount = principal.ToString();
                string owedAmount      = StillOwedLabel.Text;
                string layawayDate     = GetLayawayDate();
                string status          = "Open";
                string dateDefaulted   = DateTime.MinValue.ToShortDateString();
                string defaultDate     = DateTime.Today.AddDays(90).ToShortDateString();

                Dictionary <int, double> products = GetSalesInformation();

                foreach (KeyValuePair <int, double> pair in products)
                {
                    string productDescription = dataManager.GetProductDescription(pair.Key.ToString());

                    dataManager.InsertLayaway(invoiceNumber, customerID, productDescription, principalAmount,
                                              owedAmount, layawayDate, status, dateDefaulted, defaultDate);

                    dataManager.SaveInvoiceData(invoiceNumber, totalSale.ToString(), salesTax.ToString(),
                                                layawayDate, customerID, principal.ToString());

                    dataManager.UpdateStatusLayaway(pair.Key.ToString());
                    UpdateSaleDate(productID);
                }

                LayawayReceipt layawayReceipt = new LayawayReceipt();
                layawayReceipt.InvoiceNumberValue = invoiceNumber;
                layawayReceipt.ProductData        = products;
                layawayReceipt.CustomerIDValue    = customerID;
                layawayReceipt.TotalSale          = totalSale.ToString();
                layawayReceipt.SalesTax           = salesTax.ToString();
                layawayReceipt.GrandTotal         = principalAmount;
                layawayReceipt.SaleDate           = layawayDate;
                layawayReceipt.Show();
            }
            else
            {
                MessageBox.Show("Either the customer ID is blank, you did not select a product, or there is no total");
            }
        }
示例#2
0
        public void CreateLayawayTransaction()
        {
            if (!CheckData())
            {
                string productID = GetSelectedProductID();
                double downPayment = Convert.ToDouble(DownPaymentLabel.Text);
                double salesTax = Convert.ToDouble(SalesTaxLabel.Text);
                double owed = Convert.ToDouble(StillOwedLabel.Text);
                double principal = owed + salesTax + downPayment;
                double totalSale = downPayment + owed;
                DataManager dataManager = new DataManager(connectionString);

                string invoiceNumber = pONumber;
                string customerID = CustomerIDTextBox.Text;

                string principalAmount = principal.ToString();
                string owedAmount = StillOwedLabel.Text;
                string layawayDate = GetLayawayDate();
                string status = "Open";
                string dateDefaulted = DateTime.MinValue.ToShortDateString();
                string defaultDate = DateTime.Today.AddDays(90).ToShortDateString();

                Dictionary<int, double> products = GetSalesInformation();

                foreach (KeyValuePair<int, double> pair in products)
                {
                    string productDescription = dataManager.GetProductDescription(pair.Key.ToString());

                    dataManager.InsertLayaway(invoiceNumber, customerID, productDescription, principalAmount,
                     owedAmount, layawayDate, status, dateDefaulted, defaultDate);

                    dataManager.SaveInvoiceData(invoiceNumber, totalSale.ToString(), salesTax.ToString(),
                    layawayDate, customerID, principal.ToString());

                    dataManager.UpdateStatusLayaway(pair.Key.ToString());
                    UpdateSaleDate(productID);
                }

                LayawayReceipt layawayReceipt = new LayawayReceipt();
                layawayReceipt.InvoiceNumberValue = invoiceNumber;
                layawayReceipt.ProductData = products;
                layawayReceipt.CustomerIDValue = customerID;
                layawayReceipt.TotalSale = totalSale.ToString();
                layawayReceipt.SalesTax = salesTax.ToString();
                layawayReceipt.GrandTotal = principalAmount;
                layawayReceipt.SaleDate = layawayDate;
                layawayReceipt.Show();
            }
            else
            {
                MessageBox.Show("Either the customer ID is blank, you did not select a product, or there is no total");
            }
        }