コード例 #1
0
        private void AddCompleteOrder_Click(object sender, RoutedEventArgs e)
        {
            var screen = new TransactionControl();

            screen.DataContext = this.DataContext;
            swapScreen(screen);
        }
コード例 #2
0
 /// <summary>
 /// Initialize the TransactionControl
 /// </summary>
 /// <param name="order">The transaction control that order links to</param>
 public TransactionControl(Order order)
 {
     InitializeComponent();
     control      = this;
     currentOrder = new CurrentOrder(order);
     DataContext  = currentOrder;
 }
コード例 #3
0
 /// <summary>
 /// Initialize the TransactionControl
 /// </summary>
 /// <param name="order">The transaction control that order links to</param>
 public TransactionControl(Order order)
 {
     InitializeComponent();
     control     = this;
     current     = new OrderNow(order);
     DataContext = current;
 }
コード例 #4
0
        void OnReturnToTransactionButtonClicked(object sender, RoutedEventArgs e)
        {
            var orderInfo   = this.FindAncestor <OrderControl>();
            var transaction = new TransactionControl();

            orderInfo.SwapOrderSum(transaction);
        }
コード例 #5
0
        /// <summary>
        /// Click event handler for the Complete Order button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CompleteOrderButton_Click(object sender, RoutedEventArgs e)
        {
            var mainWindow = this.FindAncestor <MainWindow>();
            TransactionControl transaction = new TransactionControl();

            transaction.DataContext          = DataContext;
            mainWindow.WindowContainer.Child = transaction;
        }
コード例 #6
0
        /// <summary>
        /// Event handler for button that completes the order
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void CompleteOrderButton(object sender, RoutedEventArgs e)
        {
            object             dc = DataContext;
            TransactionControl tc = new TransactionControl(this);

            tc.DataContext  = this;
            Container.Child = tc;
        }
コード例 #7
0
        private void CompleteOrderButton_Click(object sender, RoutedEventArgs e)
        {
            var main = this.FindAncestor <MainWindow>();
            TransactionControl transaction = new TransactionControl(drawer);

            transaction.setDataContext(this.DataContext);
            main.Display(transaction);
        }
コード例 #8
0
 /// <summary>
 /// Contains the behavior after the complete order button is pressed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void OnCompleteOrderButtonClicked(object sender, RoutedEventArgs e)
 {
     if (DataContext is Order data)
     {
         //this.DataContext = new Order();
         var transaction = new TransactionControl();
         SwapScreen(transaction);
     }
 }
コード例 #9
0
        /// <summary>
        /// Initialize the CashPaymentControl with order
        /// </summary>
        public CashPaymentControl(double total, TransactionControl control)
        {
            InitializeComponent();

            transaction = control;
            money       = new Handler();
            DataContext = money;
            money.Total = total;
        }
コード例 #10
0
        /// <summary>
        /// Click action for CompleteOrderButton
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CompleteOrderButton_Click(object sender, RoutedEventArgs e)
        {
            var trans = new TransactionControl();

            trans.DataContext = this.DataContext;

            var mainWindow = this.FindAncestor <MainWindow>();

            mainWindow.SwapScreenMain(trans);
        }
コード例 #11
0
        /// <summary>
        /// Completes the order and begins a new one
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CompleteOrder_Click(object sender, RoutedEventArgs e)
        {
            var screen = new TransactionControl();

            if (DataContext is Order order)
            {
                screen.DataContext = order;
                this.Content       = screen;
            }
        }
コード例 #12
0
        /// <summary>
        /// Click event for cpmplete order
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void CompleteOrderClick(object sender, RoutedEventArgs e)
        {
            var mainWindow = this.FindAncestor <MainWindow>();

            var order = this.DataContext;

            var screen = new TransactionControl();

            screen.DataContext = order;

            mainWindow.SwapScreen(screen);
        }
コード例 #13
0
 /// <summary>
 /// Handles the click event for the complete order button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void OnCompleteOrderClick(object sender, RoutedEventArgs e)
 {
     if (this.DataContext is Order o)
     {
         if (o.Subtotal > 0)
         {
             var transactionControl = new TransactionControl();
             SwapScreen(transactionControl);
             ButtonContainer.Visibility = Visibility.Collapsed;
             Container2.Visibility      = Visibility.Collapsed;
         }
     }
 }
コード例 #14
0
 /// <summary>
 /// Event for when the Complete Order Button is selected, creates a new order
 /// </summary>
 /// <param name="sender">The button being selected</param>
 /// <param name="e">The event args</param>
 private void CompleteOrderButton_Click(object sender, RoutedEventArgs e)
 {
     if (DataContext is Order data)
     {
         if (sender is Button button)
         {
             CompleteOrderButton.Visibility = Visibility.Hidden;
             transactionControl             = new TransactionControl();
             transactionControl.DataContext = data;
             SwapScreen(transactionControl);
         }
     }
 }
コード例 #15
0
        /// <summary>
        /// Handles the Complete Order Button click, swaps the Container to the TranscationControl, calculates the tax and total of the current
        /// transaction, and sets the drawer variable of the TransactionControl to this control's drawer variable
        /// </summary>
        /// <param name="sender">The Complete Order button</param>
        /// <param name="e">The event arguments</param>
        void OnCompleteOrderButtonClicked(object sender, RoutedEventArgs e)
        {
            var screen = new TransactionControl();

            var orderControl = this;

            if (orderControl == null)
            {
                throw new Exception("An ancestor of OrderControl expected be an OrderControl instead of null");
            }

            screen.DataContext = this.DataContext;
            screen.CalculateTaxAndTotal();
            screen.drawer = drawer;
            orderControl.SwapScreen(screen);
        }
コード例 #16
0
        /// <summary>
        /// Button event swaps back to the MenuItemSelectionControl
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnPayWithCardClicked(object sender, RoutedEventArgs e)
        {
            FrameworkElement screen = null;

            if (DataContext is Order order)
            {
                switch (cardterminal.ProcessTransaction(order.Total))
                {
                case ResultCode.Success:
                    receiptprinter.Print(order.Receipt(false, 0, 0));
                    screen       = new OrderControl();
                    this.Content = screen;
                    break;

                case ResultCode.InsufficentFunds:
                    MessageBox.Show("Insifficient Funds. Try again...");
                    screen             = new TransactionControl();
                    screen.DataContext = order;
                    this.Content       = screen;
                    break;

                case ResultCode.CancelledCard:
                    MessageBox.Show("Card Cancelled. Try again...");
                    screen             = new TransactionControl();
                    screen.DataContext = order;
                    this.Content       = screen;
                    break;

                case ResultCode.ReadError:
                    MessageBox.Show("Card Read Error. Try again...");
                    screen             = new TransactionControl();
                    screen.DataContext = order;
                    this.Content       = screen;
                    break;

                default:
                case ResultCode.UnknownErrror:
                    MessageBox.Show("Error unknown. Try again...");
                    screen             = new TransactionControl();
                    screen.DataContext = order;
                    this.Content       = screen;
                    break;
                }
            }
        }
コード例 #17
0
        /// <summary>
        /// Allows the user to pay with credit.
        /// </summary>
        /// <param name="sender">The user's interaction.</param>
        /// <param name="e">Event data.</param>
        private void CreditPaymentButton_Clicked(object sender, RoutedEventArgs e)
        {
            FrameworkElement screen = null;

            if (DataContext is Order order)
            {
                switch (cardTerminal.ProcessTransaction(order.TotalWithTax))
                {
                case ResultCode.Success:
                    receiptPrinter.Print(order.Receipt(true, 0, 0));
                    MessageBox.Show("Transaction Was a success.");
                    screen       = new OrderControl();
                    this.Content = screen;
                    break;

                case ResultCode.InsufficentFunds:
                    MessageBox.Show("Insufficient Funds.");
                    screen             = new TransactionControl();
                    screen.DataContext = order;
                    this.Content       = screen;
                    break;

                case ResultCode.CancelledCard:
                    MessageBox.Show("Card Denied.");
                    screen             = new TransactionControl();
                    screen.DataContext = order;
                    this.Content       = screen;
                    break;

                case ResultCode.ReadError:
                    MessageBox.Show("Error reading card.");
                    screen             = new TransactionControl();
                    screen.DataContext = order;
                    this.Content       = screen;
                    break;

                case ResultCode.UnknownErrror:
                    MessageBox.Show("Unknown Error.");
                    screen             = new TransactionControl();
                    screen.DataContext = order;
                    this.Content       = screen;
                    break;
                }
            }
        }
コード例 #18
0
        private void PayWithCredit_Click(object sender, RoutedEventArgs e)
        {
            FrameworkElement screen = null;

            if (DataContext is Order order)
            {
                switch (card.ProcessTransaction(order.SubtotalwTax))
                {
                case ResultCode.InsufficentFunds:
                    screen = new TransactionControl();
                    MessageBox.Show("Insufficient funds");
                    screen.DataContext = order;
                    this.Content       = screen;
                    break;

                case ResultCode.ReadError:
                    screen = new TransactionControl();
                    MessageBox.Show("The card could not be read");
                    screen.DataContext = order;
                    this.Content       = screen;
                    break;

                case ResultCode.UnknownErrror:
                    screen = new TransactionControl();
                    MessageBox.Show("An unknown error occured");
                    screen.DataContext = order;
                    this.Content       = screen;
                    break;

                case ResultCode.CancelledCard:
                    screen = new TransactionControl();
                    MessageBox.Show("Card was cancelled");
                    screen.DataContext = order;
                    this.Content       = screen;
                    break;

                case ResultCode.Success:
                    r.Print(order.Receipt(true, order.SubtotalwTax, 0));
                    MessageBox.Show("Transaction accepted");
                    screen       = new OrderControl();
                    this.Content = screen;
                    break;
                }
            }
        }
コード例 #19
0
 /// <summary>
 /// Sends the current order and creates new empty order.
 /// </summary>
 /// <param name="sender">Button</param>
 /// <param name="e">Argument</param>
 private void CompleteOrderButton_Click(object sender, RoutedEventArgs e)
 {
     if (DataContext is Order order)
     {
         if (order.Items.Any())
         {
             var screen = new TransactionControl();
             //screen.DataContext = order;
             //screen.InitializeContext();
             SwapScreen(screen);
         }
         else
         {
             SummaryControlScreen.ItemListView.BorderBrush     = Brushes.Red;
             SummaryControlScreen.ItemListView.BorderThickness = new Thickness(3);
         }
     }
 }
コード例 #20
0
 public CashRegisterControl(TransactionControl transaction)
 {
     InitializeComponent();
     this.transaction = transaction;
 }
コード例 #21
0
        /// <summary>
        /// Completes the order
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void CompleteOrderButton_Clicked(object sender, RoutedEventArgs e)
        {
            var screen = new TransactionControl();

            SwapScreen(screen);
        }
コード例 #22
0
        /// <summary>
        /// Click event handler for Complete Order Button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnCompleteOrderButtonClicked(object sender, RoutedEventArgs e)
        {
            var screen = new TransactionControl(drawer);

            Main.Child = screen;
        }
コード例 #23
0
        ///
        /// <summary>
        /// Button event for Cancelling an order. Sets DataContext to a new instance.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnCancelOrderButtonClicked(object sender, RoutedEventArgs e)
        {
            var screen = new TransactionControl();

            this.Content = screen;
        }
コード例 #24
0
 public CashRegisterControl(double subtotal, TransactionControl tc)
 {
     InitializeComponent();
     Subtotal = subtotal;
     this.tc  = tc;
 }
コード例 #25
0
        private void CheckTypeAndLoadScreen(object item) // too many if statements :-(
        {
            var orderControl = this.FindAncestor <OrderControl>();

            if (item is AngryChicken)
            {
                var screen = new AngryChickenCustomization();
                screen.DataContext = item;
                orderControl?.SwapScreen(screen);
            }
            if (item is BakedBeans)
            {
                var screen = new BakedBeansCustomization();
                screen.DataContext = item;
                orderControl?.SwapScreen(screen);
            }
            if (item is ChiliCheeseFries)
            {
                var screen = new ChiliCheeseFriesCustomization();
                screen.DataContext = item;
                orderControl?.SwapScreen(screen);
            }
            if (item is CornDodgers)
            {
                var screen = new CornDodgersCustomization();
                screen.DataContext = item;
                orderControl?.SwapScreen(screen);
            }
            if (item is CowboyCoffee)
            {
                var screen = new CowboyCoffeeCustomization();
                screen.DataContext = item;
                orderControl?.SwapScreen(screen);
            }
            if (item is CowpokeChili)
            {
                var screen = new CowPokeChiliCustomization();
                screen.DataContext = item;
                orderControl?.SwapScreen(screen);
            }
            if (item is DakotaDoubleBurger)
            {
                var screen = new DakotaDoubleBurgerCustomization();
                screen.DataContext = item;
                orderControl?.SwapScreen(screen);
            }
            if (item is JerkedSoda)
            {
                var screen = new JerkedSodaCustomization();
                screen.DataContext = item;
                orderControl?.SwapScreen(screen);
            }
            if (item is PanDeCampo)
            {
                var screen = new PanDeCampoCustomization();
                screen.DataContext = item;
                orderControl?.SwapScreen(screen);
            }
            if (item is PecosPulledPork)
            {
                var screen = new PecosPulledPorkCustomization();
                screen.DataContext = item;
                orderControl?.SwapScreen(screen);
            }
            if (item is TexasTea)
            {
                var screen = new TexasTeaCustomization();
                screen.DataContext = item;
                orderControl?.SwapScreen(screen);
            }
            if (item is TexasTripleBurger)
            {
                var screen = new TexasTripleBurgerCustomization();
                screen.DataContext = item;
                orderControl?.SwapScreen(screen);
            }
            if (item is TrailBurger)
            {
                var screen = new TrailBurgerCustomization();
                screen.DataContext = item;
                orderControl?.SwapScreen(screen);
            }
            if (item is TransactionControl)
            {
                var screen = new TransactionControl();
                screen.DataContext = item;
                orderControl?.SwapScreen(screen);
            }
        }
コード例 #26
0
        /// <summary>
        /// Event handler for the CompleteOrderButton, creates a new order.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void OnCompleteOrderButton(object sender, RoutedEventArgs e)
        {
            var transactionScreen = new TransactionControl();

            SwapScreen(transactionScreen);
        }
コード例 #27
0
 /// <summary>
 /// Constructor for the CashRegisterControl User Control
 /// </summary>
 public CashRegisterControl(object Transaction)
 {
     transaction = (TransactionControl)Transaction;
     InitializeComponent();
 }