Esempio n. 1
0
        public void CreateSalesTransaction()
        {
            if (!CheckData())
            {
                string customerID = CustomerIDTextBox.Text;
                string saleDate = GetSalesDate();
                string invoiceNumber = "S" + CreateInvoiceNumber();
                Dictionary<int, double> soldProducts = GetSalesInformation();
                DataManager dataManager = new DataManager(connectionString);
                foreach (KeyValuePair<int, double> pair in soldProducts)
                {
                    dataManager.SaveSaleData(customerID, pair.Key.ToString(), pair.Value.ToString(), saleDate, invoiceNumber);
                    dataManager.UpdateProductStatus(pair.Key.ToString(), saleDate);
                }

                string totalSale = TotalLabel.Text;
                string salesTax = TaxLabel.Text;
                string grandTotal = GrandTotalLabel.Text;
                dataManager.SaveInvoiceData(invoiceNumber, totalSale, salesTax, saleDate, customerID, grandTotal);
                SalesInvoice salesInvoice = new SalesInvoice();
                salesInvoice.InvoiceNumberValue = invoiceNumber;
                salesInvoice.CustomerIDValue = customerID;
                salesInvoice.InvoiceDollarValue = invoiceNumber;
                salesInvoice.Show();
            }
            else
            {
                MessageBox.Show("Either the customer ID is blank, you did not select a product, or there is no total");
            }
        }
Esempio n. 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");
            }
        }