private void PrintItem_Click(object sender, RoutedEventArgs e)
        {
            Transaction transaction = lvList.SelectedItem as Transaction;

            transaction.payment = new ObservableCollection <Transaction>(payments);
            MessageBox.Show(transaction.items[0].name + " " + transaction.date.ToShortDateString());

            MessageBoxResult result = MessageBox.Show("Print this transaction?", "Print transaction?", MessageBoxButton.YesNo);

            if (result != MessageBoxResult.Yes)
            {
                return;
            }



            ReceiptGenerator receiptGen = new ReceiptGenerator(transaction);
            ReceiptPrinter   printer    = new ReceiptPrinter(receiptGen.flowDoc);

            printer.PrintSilently();
        }
Exemplo n.º 2
0
        private async void btnCheckout_Click(object sender, RoutedEventArgs e)
        {
            if (cart.Count == 0)
            {
                MessageBox.Show("There is nothing in the cart.");
                return;
            }
            Checkout checkout = new Checkout(total);

            if (checkout.ShowDialog() == true)
            {
                MessageBox.Show("Great.");
                // Log transaction

                DateTime date = DateTime.Now;
                int      transactionNumber = DBAccess.GetNextUnusedTransactionNumber();
                foreach (Item item in cart)
                {
                    DBAccess.AddTransaction(item, TransactionTypes.SALE, transactionNumber, date.ToString("MM/dd/yyyy hh:mm tt"));
                    if (Settings.Default.deductSalesFromInventory)
                    {
                        await DBAccess.IncrementQuantities(item.SQLid, 0 - item.quantity[0], ColumnNames.STORE);
                    }
                }
                DBAccess.IncrementTransactionNumber();

                // Print Receipt
                if (Settings.Default.printReceipts)
                {
                    ReceiptGenerator generator = new ReceiptGenerator(cart.ToList <Item>(), checkout.checkout.ToList <Item>(), date.ToString("MM/dd/yyyy hh:mm tt"), transactionNumber.ToString());
                    ReceiptPrinter   printer   = new ReceiptPrinter(generator.flowDoc);
                    printer.PrintSilently();
                }
                checkout.Close();
                cart.Clear();
            }
        }