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");
            }
        }