Ejemplo n.º 1
0
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();
            var dc = new CashRegisterModelView();

            this.DataContext = dc;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructor that takes in the total cost as a string and the order summary from previous controls
 /// </summary>
 /// <param name="total"></param>
 /// <param name="osc"></param>
 public CashControl(string total, OrderSummaryControl osc)
 {
     InitializeComponent();
     this.orderSummary.DataContext = osc.DataContext;
     DataContext           = new CashRegisterModelView(Convert.ToDouble(total.Remove(0, 1)));
     TotalTextBox.Text     = total;
     GivenChangeTitle.Text = "Given Change:\n";
 }
Ejemplo n.º 3
0
 private void PayWithCash_Click(object sender, RoutedEventArgs e)
 {
     if (DataContext is Order order)
     {
         var screen = new CashRegisterModelView(order);
         this.Content = screen;
     }
 }
        public CashRegisterControl()
        {
            InitializeComponent();
            CashRegisterModelView crmv = new CashRegisterModelView();

            this.DataContext = crmv;

            ReturnToTransactionButton.Click += OnReturnToTransactionButtonClicked;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Constructor for Order Control
        /// </summary>
        public OrderControl()
        {
            InitializeComponent();
            var order = new Order();

            Register = new CashRegisterModelView();

            this.DataContext = order;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// When complete button is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnCompleteClicked(object sender, RoutedEventArgs e)
        {
            CashRegisterModelView cr = (CashRegisterModelView)DataContext;

            cr.complete();
            var          orderInfo = this.FindAncestor <OrderControl>();
            OrderControl o         = new OrderControl();

            orderInfo.SwapOrderSum(o);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Event handler for when the Cash Payment Button is clicked
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CashPaymentButton_Click(object sender, RoutedEventArgs e)
 {
     credit = false;
     if (DataContext is Order order)
     {
         var mainWindow            = this.FindAncestor <MainWindow>();
         var cashRegisterControl   = new CashRegisterControl(this);
         var cashRegisterModelView = new CashRegisterModelView();
         cashRegisterModelView.RunningTotal = Math.Round(order.Total, 2);
         cashRegisterControl.DataContext    = cashRegisterModelView;
         mainWindow.WindowContainer.Child   = cashRegisterControl;
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Specifies Cash Payment
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnPaymentCash_Click(object sender, RoutedEventArgs e)
 {
     if (DataContext is Order)
     {
         var orderControl = this.FindAncestor <OrderControl>();
         orderControl.ItemSelectionButton.IsEnabled = false;
         orderControl.CompleteOrderButton.IsEnabled = false;
         savedOrder = DataContext as Order;
         var cashRegister = new CashRegisterModelView();
         this.DataContext       = cashRegister;
         btnCashPay1.IsEnabled  = false;
         btnCreditPay.IsEnabled = false;
     }
 }
Ejemplo n.º 9
0
        /// <summary>
        /// helper method that empties drawer of current register
        /// </summary>
        private void ClearDrawer()
        {
            CashRegisterModelView register = new CashRegisterModelView();

            register.Pennies     = 0;
            register.Nickels     = 0;
            register.Dimes       = 0;
            register.Quarters    = 0;
            register.HalfDollars = 0;
            register.Dollars     = 0;
            register.Ones        = 0;
            register.Twos        = 0;
            register.Fives       = 0;
            register.Tens        = 0;
            register.Twenties    = 0;
            register.Fifties     = 0;
            register.Hundreds    = 0;
            DataContext          = register;
        }
        /// <summary>
        /// When customer pays with cash, generates cash register UI and controls the amounts in the cashdrawer
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void OnPayWithCashButtonClicked(object sender, RoutedEventArgs e)
        {
            string cash = "Cash";

            Order o = (Order)DataContext;

            var orderInfo = this.FindAncestor <OrderControl>();

            CashRegisterControl crc = new CashRegisterControl();

            CashPaymentDetails.orderTotal = o.TotalWithTax;
            CashPaymentDetails.orderNum   = o.OrderNumber;

            CashRegisterModelView cashreg = new CashRegisterModelView();

            crc.DataContext = cashreg;

            orderInfo.SwapOrderSum(crc); // swaps whole screen to cash register

            PrintTheReceipt(o, cash);
        }
 public CashRegisterView(Order order)
 {
     InitializeComponent();
     DataContext = new CashRegisterModelView(order);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// A constructor that takes in 2 parameters
 /// </summary>
 /// <param name="cd">The cash drawer</param>
 /// <param name="ord">The order</param>
 public CashDrawerControl(CashDrawer cd, Order ord)
 {
     crmv        = new CashRegisterModelView(cd, ord);
     DataContext = crmv;
     InitializeComponent();
 }
Ejemplo n.º 13
0
 /// <summary>
 /// 1-arg constructor
 /// </summary>
 /// <param name="mv"></param>
 public ChangeControl(CashRegisterModelView mv)
 {
     InitializeComponent();
     DataContext = mv;
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Handles computation between cash inputed and order total, along with handling change
        /// </summary>
        /// <param name="sender">button</param>
        /// <param name="e">event args</param>
        private void CompleteTransaction_Click(object sender, RoutedEventArgs e)
        {
            if (Total < TargetTotal)
            {
                ErrorMessageText.Text = "Insufficient amount entered. Please insert more.";
            }
            else
            {
                decimal tempChange             = Convert.ToDecimal(String.Format("{0:0.##}", Total)) - Convert.ToDecimal(String.Format("{0:0.##}", TargetTotal));
                double  change                 = Convert.ToDouble(tempChange);
                double  endChange              = change;
                CashRegisterModelView register = (DataContext as CashRegisterModelView);
                orderControl.Register.AddCoin(Coins.Penny, register.Pennies);
                orderControl.Register.AddCoin(Coins.Nickel, register.Nickels);
                orderControl.Register.AddCoin(Coins.Dime, register.Dimes);
                orderControl.Register.AddCoin(Coins.Quarter, register.Quarters);
                orderControl.Register.AddCoin(Coins.HalfDollar, register.HalfDollars);
                orderControl.Register.AddCoin(Coins.Dollar, register.Dollars);

                orderControl.Register.AddBill(Bills.One, register.Ones);
                orderControl.Register.AddBill(Bills.Two, register.Twos);
                orderControl.Register.AddBill(Bills.Five, register.Fives);
                orderControl.Register.AddBill(Bills.Ten, register.Tens);
                orderControl.Register.AddBill(Bills.Twenty, register.Twenties);
                orderControl.Register.AddBill(Bills.Fifty, register.Fifties);
                orderControl.Register.AddBill(Bills.Hundred, register.Hundreds);

                ClearDrawer();
                register = (DataContext as CashRegisterModelView);
                CashRegisterModelView tempRegister     = register;
                CashRegisterModelView tempMainRegister = orderControl.Register;
                try
                {
                    while (change >= .01)
                    {
                        if (change >= 100 && orderControl.Register.Hundreds > 0)
                        {
                            register.AddBill(Bills.Hundred, 1);
                            change -= 100;
                            orderControl.Register.RemoveBill(Bills.Hundred, 1);
                        }
                        else if (change >= 50 && orderControl.Register.Fifties > 0)
                        {
                            register.AddBill(Bills.Fifty, 1);
                            change -= 50;
                            orderControl.Register.RemoveBill(Bills.Fifty, 1);
                        }
                        else if (change >= 20 && orderControl.Register.Twenties > 0)
                        {
                            register.AddBill(Bills.Twenty, 1);
                            change -= 20;
                            orderControl.Register.RemoveBill(Bills.Twenty, 1);
                        }
                        else if (change >= 10 && orderControl.Register.Tens > 0)
                        {
                            register.AddBill(Bills.Ten, 1);
                            change -= 10;
                            orderControl.Register.RemoveBill(Bills.Ten, 1);
                        }
                        else if (change >= 5 && orderControl.Register.Fives > 0)
                        {
                            register.AddBill(Bills.Five, 1);
                            change -= 5;
                            orderControl.Register.RemoveBill(Bills.Five, 1);
                        }
                        else if (change >= 2 && orderControl.Register.Twos > 0)
                        {
                            register.AddBill(Bills.Two, 1);
                            change -= 2;
                            orderControl.Register.RemoveBill(Bills.Two, 1);
                        }
                        else if (change >= 1 && orderControl.Register.Ones > 0)
                        {
                            register.AddBill(Bills.One, 1);
                            change -= 1;
                            orderControl.Register.RemoveBill(Bills.One, 1);
                        }
                        else if (change >= 1 && orderControl.Register.Dollars > 0)
                        {
                            register.AddCoin(Coins.Dollar, 1);
                            change -= 1;
                            orderControl.Register.RemoveCoin(Coins.Dollar, 1);
                        }
                        else if (change >= .50 && orderControl.Register.HalfDollars > 0)
                        {
                            register.AddCoin(Coins.HalfDollar, 1);
                            change -= .50;
                            orderControl.Register.RemoveCoin(Coins.HalfDollar, 1);
                        }
                        else if (change >= .25 && orderControl.Register.Quarters > 0)
                        {
                            register.AddCoin(Coins.Quarter, 1);
                            change -= .25;
                            orderControl.Register.RemoveCoin(Coins.Quarter, 1);
                        }
                        else if (change >= .10 && orderControl.Register.Dimes > 0)
                        {
                            register.AddCoin(Coins.Dime, 1);
                            change -= .10;
                            orderControl.Register.RemoveCoin(Coins.Dime, 1);
                        }
                        else if (change >= .05 && orderControl.Register.Nickels > 0)
                        {
                            register.AddCoin(Coins.Nickel, 1);
                            change -= .05;
                            orderControl.Register.RemoveCoin(Coins.Nickel, 1);
                        }
                        else if (change >= .01 && orderControl.Register.Pennies > 0)
                        {
                            register.AddCoin(Coins.Penny, 1);
                            change -= .01;
                            orderControl.Register.RemoveCoin(Coins.Penny, 1);
                        }
                        else
                        {
                            throw new DrawerOverdrawException();
                        }
                    }
                    ChangeView changeControl = new ChangeView(orderControl, endChange);
                    changeControl.DataContext = register;
                    orderControl.SwapScreen(changeControl);
                }
                catch (DrawerOverdrawException)
                {
                    ErrorMessageText.Text = "ERROR, Insufficient funds in the register!";
                }
            }
        }
 /// <summary>
 /// 2-arg constructor
 /// </summary>
 /// <param name="drawer"></param>
 /// <param name="data"></param>
 public CashRegisterControl(CashDrawer drawer, Order data)
 {
     InitializeComponent();
     mv          = new CashRegisterModelView(drawer, data);
     DataContext = mv;
 }