//Button to Open up Menu
        private void Open_Menu(object sender, RoutedEventArgs e)
        {
            string changedNumber = Switcher.GetLanding().tableNumber.Text;

            if (changedNumber != null)
            {
                try
                {
                    int result = Int32.Parse(changedNumber);
                    if (result < 0 || result > 100)
                    {
                        MessageBox.Show("Invalid input.");
                    }
                    else
                    {
                        MainWindow.TableNumber = result;
                        Switcher.GetNewMenu().DisplayTableNumber.Text = "Table: " + result.ToString();
                        Switcher.GetCart().DisplayTableNumber.Text = "Table: " + result.ToString();
                        Switcher.GetCheckout().DisplayTableNumber.Text = "Table " + result.ToString();
                        Switcher.Switch(Switcher.GetNewMenu());
                    }
                }
                catch (FormatException)
                {
                    Console.WriteLine($"Cannot Parse, not a number!");
                    MessageBox.Show("Invald input!");
                }
            }
        }
Exemplo n.º 2
0
        public void RemoveItemCheckout(object sender, RoutedEventArgs e)
        {
            //var cartChildren = Switcher.GetCart().CartItemList.Children;
            foreach (CartItem child in Switcher.GetCart().CartItemList.Children)
            {
                if (child.cart_item_counter == this.checkout_item_counter)
                {
                    //Modify Prices
                    float price      = float.Parse(this.CheckoutItemPrice.Text.Substring(1));
                    float priceTotal = price * float.Parse(this.CheckoutItemQuantity.Text);
                    MainWindow.GlobalSubtotal -= priceTotal;
                    string test = MainWindow.GlobalSubtotal.ToString("0.00");

                    Switcher.GetCart().CartMenuTotal.Text = ("$" + test);
                    Switcher.GetCheckout().Subtotal.Text = ("$" + test);
                    Switcher.GetNewMenu().MenuTotal.Text = ("$" + test);
                    Switcher.GetCheckout().GST.Text = "$" + (MainWindow.GlobalSubtotal * 0.1).ToString("0.00");
                    float gst = float.Parse(Switcher.GetCheckout().GST.Text.Substring(1));
                    float subtotal = float.Parse(Switcher.GetCheckout().Subtotal.Text.Substring(1));
                    Switcher.GetCheckout().Total.Text = "$" + (gst + subtotal).ToString("0.00");


                    Switcher.GetCart().CartItemList.Children.Remove(child);
                    Switcher.GetCheckout().CheckoutItemList.Children.Remove(this);
                    break;  //If we do not break, causes problems with enumerator since we are changing the list we are iterating over
                }
            }
        }
 private void OrderMore(object sender, RoutedEventArgs e)
 {
     Switcher.GetNewMenu().PreviousOrderButton.Opacity = 1;
     Switcher.GetNewMenu().PreviousOrderButton.IsEnabled = true;
     Switcher.GetCart().PreviousOrderButton.Opacity = 1;
     Switcher.GetCart().PreviousOrderButton.IsEnabled = true;
     Switcher.Switch(Switcher.GetNewMenu());
 }
Exemplo n.º 4
0
        private void DecreaseQuantityCart(object sender, RoutedEventArgs e)
        {
            try
            {
                int current = Int32.Parse(this.ItemQuantity.Text);

                if (current != 1)
                {
                    current -= 1;

                    this.ItemQuantity.Text = (current).ToString();

                    float price = float.Parse(this.ItemPrice.Text.Substring(1));
                    MainWindow.GlobalSubtotal -= price;

                    string test = MainWindow.GlobalSubtotal.ToString("0.00");

                    Switcher.GetCart().CartMenuTotal.Text = ("$" + test);
                    Switcher.GetCheckout().Subtotal.Text = ("$" + test);
                    Switcher.GetNewMenu().MenuTotal.Text = ("$" + test);
                    Switcher.GetCheckout().GST.Text = "$" + (MainWindow.GlobalSubtotal * 0.1).ToString("0.00");
                    float gst = float.Parse(Switcher.GetCheckout().GST.Text.Substring(1));
                    float subtotal = float.Parse(Switcher.GetCheckout().Subtotal.Text.Substring(1));
                    Switcher.GetCheckout().Total.Text = "$" + (gst + subtotal).ToString("0.00");

                    foreach (CheckoutItem child in Switcher.GetCheckout().CheckoutItemList.Children)
                    {
                        if (child.checkout_item_counter == this.cart_item_counter)
                        {
                            child.checkout_item_quantity    = (current).ToString();
                            child.CheckoutItemQuantity.Text = (current).ToString();
                            if (child.CheckoutItemQuantity.Text == "1")
                            {
                                child.DecreaseButton.Opacity = 0;
                            }
                            else
                            {
                                child.DecreaseButton.Opacity = 1;
                            }
                            break;  //If we do not break, causes problems with enumerator since we are changing the list we are iterating over
                        }
                    }
                }
                else
                {
                    current = 1;
                }

                if (current == 1)
                {
                    DecreaseButton.Opacity = 0;
                }
            }
            catch (Exception)
            {
                Console.WriteLine("broken");
            }
        }
Exemplo n.º 5
0
        private void Confirm_Order2(object sender, RoutedEventArgs e)
        {
            float addReviewOrderSubtotal = 0.00f;

            //Clear Checkout UC Children
            Switcher.GetReviewOrder().ReviewItemList.Children.Clear();

            foreach (CheckoutItem child in Switcher.GetCheckout().CheckoutItemList.Children)
            {
                ReviewOrderItem reviewOrderItem = new ReviewOrderItem();
                reviewOrderItem.ReviewOrderItemName.Text     = child.CheckoutItemName.Text;
                reviewOrderItem.ReviewOrderItemPrice.Text    = child.CheckoutItemPrice.Text;
                reviewOrderItem.ReviewOrderItemQuantity.Text = child.CheckoutItemQuantity.Text;
                reviewOrderItem.ReviewOrderSR.Text           = child.CheckoutItemSR.Text;

                Switcher.GetReviewOrder().ReviewItemList.Children.Add(reviewOrderItem);


                //Adding Prices for Review Page
                string temp           = reviewOrderItem.ReviewOrderItemPrice.Text.Substring(1);
                float  itemPrice      = float.Parse(temp);
                float  totalItemPrice = itemPrice * (float.Parse(reviewOrderItem.ReviewOrderItemQuantity.Text));

                addReviewOrderSubtotal += totalItemPrice;
            }

            //Last Calculation for Prices
            float addReviewOrderGST   = addReviewOrderSubtotal * MainWindow.GST;
            float addReviewOrderTotal = addReviewOrderSubtotal + addReviewOrderGST;

            //Set Calculation Prices on ReviewOrder
            Switcher.GetReviewOrder().ReviewOrderSubtotal.Text = "$" + addReviewOrderSubtotal.ToString("0.00");
            Switcher.GetReviewOrder().ReviewOrderGST.Text = "$" + addReviewOrderGST.ToString("0.00");
            Switcher.GetReviewOrder().ReviewOrderTotal.Text = "$" + addReviewOrderTotal.ToString("0.00");

            if (MainWindow.hasAlcohol == true)
            {
                this.Confirm_Alcohol.Text = "Alcohol";
            }

            //Clear Checkout and Cart
            Switcher.GetCheckout().CheckoutItemList.Children.Clear();
            Switcher.GetCart().CartItemList.Children.Clear();

            //Clear Pricing
            MainWindow.GlobalSubtotal = 0;

            //Prices
            Switcher.GetCart().CartMenuTotal.Text = "$0.00";
            Switcher.GetCheckout().Subtotal.Text = ("$0.00");
            Switcher.GetNewMenu().MenuTotal.Text = ("$0.00");
            Switcher.GetCheckout().GST.Text = "$0.00";
            Switcher.GetCheckout().Total.Text = "$0.00";
        }
        private void AddToCart(object sender, RoutedEventArgs e)
        {
            CartItem cartItem = new CartItem();

            cartItem.cart_item_counter = MainWindow.GlobalCounter;
            MainWindow.GlobalCounter++;
            cartItem.ItemName.Text     = DisplayItemName.Text;
            cartItem.ItemPrice.Text    = DisplayItemPrice.Text;
            cartItem.ItemQuantity.Text = DisplayItemQuantity.Text;
            cartItem.CartItemSR.Text   = SpecialRequest.Text;
            cartItem.cart_alcohol      = ia_alcohol;

            if (cartItem.ItemQuantity.Text == "1")
            {
                cartItem.DecreaseButton.Opacity = 0;
            }
            else
            {
                cartItem.DecreaseButton.Opacity = 1;
            }

            Switcher.GetCart().CartItemList.Children.Add(cartItem);
            AddToCheckout(sender, e, cartItem);
            string tempPrice = cartItem.ItemPrice.Text.Substring(1);
            float  price     = float.Parse(tempPrice);
            float  total     = price * (float.Parse(cartItem.ItemQuantity.Text));

            MainWindow.GlobalSubtotal += total;

            string test = MainWindow.GlobalSubtotal.ToString("0.00");

            //Prices
            Switcher.GetCart().CartMenuTotal.Text = "$" + test;
            Switcher.GetCheckout().Subtotal.Text = ("$" + test);
            Switcher.GetNewMenu().MenuTotal.Text = ("$" + test);
            Switcher.GetCheckout().GST.Text = "$" + (MainWindow.GlobalSubtotal * 0.1).ToString("0.00");
            float gst      = float.Parse(Switcher.GetCheckout().GST.Text.Substring(1));
            float subtotal = float.Parse(Switcher.GetCheckout().Subtotal.Text.Substring(1));

            Switcher.GetCheckout().Total.Text = "$" + (gst + subtotal).ToString("0.00");

            Close_ItemAddition(sender, e);
        }
Exemplo n.º 7
0
 //Button to Open up Cart
 private void Open_Cart(object sender, RoutedEventArgs e)
 {
     Switcher.Switch(Switcher.GetCart());
 }
        //Button to Open up Cart
        private void Open_Cart(object sender, RoutedEventArgs e)
        {
            string changedNumber = Switcher.GetChangeTable().ChangeTableTextBox.Text;

            Switcher.Switch(Switcher.GetCart());
        }