Ejemplo n.º 1
0
        private void AddCompleteOrder_Click(object sender, RoutedEventArgs e)
        {
            var screen = new TransactionControl();

            screen.DataContext = this.DataContext;
            swapScreen(screen);
        }
Ejemplo n.º 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;
 }
 /// <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;
 }
        void OnReturnToTransactionButtonClicked(object sender, RoutedEventArgs e)
        {
            var orderInfo   = this.FindAncestor <OrderControl>();
            var transaction = new TransactionControl();

            orderInfo.SwapOrderSum(transaction);
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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;
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
         }
     }
 }
Ejemplo n.º 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);
         }
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 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);
         }
     }
 }
 public CashRegisterControl(TransactionControl transaction)
 {
     InitializeComponent();
     this.transaction = transaction;
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
        }
        ///
        /// <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;
        }
Ejemplo n.º 24
0
 public CashRegisterControl(double subtotal, TransactionControl tc)
 {
     InitializeComponent();
     Subtotal = subtotal;
     this.tc  = tc;
 }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
        }
 /// <summary>
 /// Constructor for the CashRegisterControl User Control
 /// </summary>
 public CashRegisterControl(object Transaction)
 {
     transaction = (TransactionControl)Transaction;
     InitializeComponent();
 }