コード例 #1
0
        /// <summary>
        /// Finalizes the sale and prints a receipt.txt
        /// Bound to a button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void finalizeSale(object sender, RoutedEventArgs e)
        {
            if ((DataContext as CashPaymentIntermediary).AmountDue > 0.00)
            {
                MessageBox.Show("The customer has not provided enough cash.");
                return;
            }
            OrderComponent w = Window.GetWindow(this).Content as OrderComponent;
            Order          o = (w.DataContext as Order);

            printLine($"Order Number {o.Number + 1}");
            printLine($"{DateTime.Now}");
            printLine($"Order Details:");
            foreach (IOrderItem i in o)
            {
                printLine($"{i.Name}     {i.Price:C2}");
                foreach (string s in i.SpecialInstructions)
                {
                    printLine($"     -{s}");
                }
            }
            printLine($"Subtotal: {o.Subtotal:C2}");
            printLine($"Tax: {o.Tax:C2}");
            printLine($"total: {o.Total:C2}");
            printLine($"Payment Method: Cash");
            printLine($"Change Owed: {(DataContext as CashPaymentIntermediary).ReceiptChangeOwed:C2}");
            RecieptPrinter.CutTape();

            w.cancelOrder(sender, e);
            w.changePrimaryMenu("Selection");
            w.OrderListView.SelectedItem = null;
        }
コード例 #2
0
        public void PayWithCard(object sender, RoutedEventArgs e)
        {
            Order o = DataContext as Order;

            switch (CardReader.RunCard((DataContext as Order).Total))
            {
            case (CardTransactionResult.Approved):
            {
                printLine($"Order Number {o.Number + 1}");
                printLine($"{DateTime.Now}");
                printLine($"Order Details:");
                foreach (IOrderItem i in o)
                {
                    printLine($"{i.Name}     {i.Price:C2}");
                    foreach (string s in i.SpecialInstructions)
                    {
                        printLine($"     -{s}");
                    }
                }
                printLine($"Subtotal: {o.Subtotal:C2}");
                printLine($"Tax: {o.Tax:C2}");
                printLine($"total: {o.Total:C2}");
                printLine($"Payment Method: Card");
                printLine($"Change Owed: $0.00");
                RecieptPrinter.CutTape();
                OrderComponent w = Window.GetWindow(this).Content as OrderComponent;
                w.cancelOrder(sender, e);
                cancelCustomizing(sender, e);
                break;
            }

            case (CardTransactionResult.Declined):
            {
                MessageBox.Show("Error Processing Payment: Card Declined");
                break;
            }

            case (CardTransactionResult.IncorrectPin):
            {
                MessageBox.Show("Error Processing Payment: Incorrect Pin");
                break;
            }

            case (CardTransactionResult.InsufficientFunds):
            {
                MessageBox.Show("Error Processing Payment: Insufficient Funds");
                break;
            }

            case (CardTransactionResult.ReadError):
            {
                MessageBox.Show("Error Reading Card: Swipe Again");
                break;
            }
            }
        }