Exemple #1
0
        /* HAHAHAHAHAHA going below here is confusing. I do alot of jumping through switch cases. If you go past here
         *  take your time to read line by line and follow the jumps. Its the only way you'll make it though :) */


        /// <summary>
        /// The consumer is wanting to pay by card
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PaybyCardButton_Click(object sender, RoutedEventArgs e)
        {
            CardTerminal ct = new CardTerminal();
            ResultCode   rc = ct.ProcessTransaction(TotalWithTax);

            switch (rc)
            {
            case ResultCode.Success:
                PrintReceipt(0);
                break;

            case ResultCode.InsufficentFunds:
                MessageBox.Show("Error: No funds on card\n\tPlease try swiping card again");
                ErrorText.Text = "Error: No funds";
                break;

            case ResultCode.CancelledCard:
                MessageBox.Show("Error: Cancelled Card\n\tPlease try swiping card again");
                ErrorText.Text = "Error: Card Cancelled";
                break;

            case ResultCode.ReadError:
                MessageBox.Show("Error: Card Read Error\n\tPlease try swiping card again");
                ErrorText.Text = "Error: Read Error";
                break;

            case ResultCode.UnknownErrror:
                MessageBox.Show("Error: Unknown Error\n\tPlease try swiping card again");
                ErrorText.Text = "Error: Unknown";
                break;

            default:
                throw new NotImplementedException("Should never be reached");
            }
        }
Exemple #2
0
        /// <summary>
        /// Attempt to pay with credit
        /// </summary>
        /// <param name="sender">Sending object</param>
        /// <param name="e">Event arguments</param>
        private void OnPayWithCredit(object sender, RoutedEventArgs e)
        {
            CardTerminal cardTerminal = new CardTerminal();

            ResultCode code = cardTerminal.ProcessTransaction(Transaction.Total);

            switch (code)
            {
            case ResultCode.Success:
                Transaction.PaymentMethod = PaymentMethod.Credit;
                Transaction.AmountPaid    = Transaction.Total;
                MessageBox.Text           = "";
                FinishTransaction();
                break;

            case ResultCode.CancelledCard:
                MessageBox.Text = "Error: Cancelled Card";
                break;

            case ResultCode.InsufficentFunds:
                MessageBox.Text = "Error: Insufficent Funds";
                break;

            case ResultCode.ReadError:
                MessageBox.Text = "Error: Read Error";
                break;

            case ResultCode.UnknownErrror:
                MessageBox.Text = "Error: Unknown Error";
                break;
            }
        }
        private void CardPayment(object sender, RoutedEventArgs e)
        {
            var oc = this.FindAncestor<OrderControl>();
            if(oc.DataContext is Order order)
            {
                var reader = new CardTerminal();
                var printer = new ReceiptPrinter();
                var result = reader.ProcessTransaction(order.Total);

                switch (result)
                {
                    case ResultCode.Success:
                        Display.Text = "Success.";
                        printer.Print(CreateCardReceipt(order));
                        oc.SwapScreen(new MenuItemSelectionControl());
                        oc.DataContext = new Order();
                        break;

                    case ResultCode.CancelledCard:
                    case ResultCode.InsufficentFunds:
                    case ResultCode.ReadError:
                    case ResultCode.UnknownErrror:
                        string r = result.ToString();
                        Display.Text = r;
                        oc.SwapScreen(new TransactionControl());
                        break;
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Sends inputted payment value to charge the card.
        /// </summary>
        /// <param name="sender">Button</param>
        /// <param name="e">Event arguments</param>
        void onSendClick(object sender, RoutedEventArgs e)
        {
            if (DataContext is Order order)
            {
                if (sender is Button button)
                {
                    if (inputValue > order.Owed)
                    {
                        errorDisplay("OVERCHARGE");
                    }
                    else
                    {
                        var terminal    = new CardTerminal();
                        var swipeResult = terminal.ProcessTransaction(inputValue);
                        switch (swipeResult)
                        {
                        case ResultCode.Success:
                            order.Paid += inputValue;
                            printer.Print(order.FormatCardReceipt());
                            DisplayAmountOwed();
                            break;

                        case ResultCode.ReadError:
                            errorDisplay("READ ERROR");
                            break;

                        case ResultCode.InsufficentFunds:
                            errorDisplay("INSUFFICIENT FUNDS");
                            break;

                        case ResultCode.CancelledCard:
                            errorDisplay("CANCELLED CARD");
                            break;

                        case ResultCode.UnknownErrror:
                            errorDisplay("UNKNOWN ERROR");
                            break;
                        }
                    }
                }
            }
        }
Exemple #5
0
        void onPayWithCardButtonClicked(object sender, RoutedEventArgs e)
        {
            CardTerminal cardTerminal = new CardTerminal();

            if (DataContext is Order order)
            {
                ResultCode resultCode = cardTerminal.ProcessTransaction(order.total);

                switch (resultCode)
                {
                case ResultCode.Success:
                    PrintRecipt();
                    MessageBox.Show("Transaction Complete!");
                    SwapScreenOrderControl();
                    break;

                default:
                    MessageBox.Show(resultCode.ToString());
                    break;
                }
            }
        }
        /// <summary>
        /// Lets you pay with Card
        /// </summary>
        /// <param name="sender">button</param>
        /// <param name="e">click</param>
        private void CardPay(object sender, RoutedEventArgs e)
        {
            var ordercontrol = this.FindAncestor <OrderControl>();

            if (DataContext is Order data)
            {
                var item   = data;
                var result = card.ProcessTransaction(item.Total);
                switch (result)
                {
                case ResultCode.Success:
                    string print = Print(item.OrderNumber, item.Items, item.Subtotal, item.Total, "Credit/Debit Card");
                    receipt.Print(print);
                    data             = new Order();
                    this.DataContext = data;
                    var screen = new MenuItemSelectionControl();
                    ordercontrol.SwapScreen(screen);
                    ordercontrol.DataContext = data;
                    break;

                case ResultCode.UnknownErrror:
                    MessageBox.Show("Unknown Card Error");
                    break;

                case ResultCode.CancelledCard:
                    MessageBox.Show("Cancelled Card");
                    break;

                case ResultCode.InsufficentFunds:
                    MessageBox.Show("Insufficent Funds");
                    break;

                case ResultCode.ReadError:
                    MessageBox.Show("Card Reading Error");
                    break;
                }
            }
        }