コード例 #1
0
        private void AddToCheckout(object sender, RoutedEventArgs e, CartItem cartItem)
        {
            CheckoutItem checkoutItem = new CheckoutItem();

            checkoutItem.checkout_item_counter     = cartItem.cart_item_counter;
            checkoutItem.CheckoutItemName.Text     = cartItem.ItemName.Text;
            checkoutItem.CheckoutItemQuantity.Text = cartItem.ItemQuantity.Text;
            checkoutItem.CheckoutItemPrice.Text    = cartItem.ItemPrice.Text;
            checkoutItem.CheckoutItemSR.Text       = cartItem.CartItemSR.Text;
            checkoutItem.checkout_item_alcohol     = cartItem.cart_alcohol;

            if (checkoutItem.CheckoutItemQuantity.Text == "1")
            {
                checkoutItem.DecreaseButton.Opacity = 0;
            }
            else
            {
                checkoutItem.DecreaseButton.Opacity = 1;
            }

            if (checkoutItem.CheckoutItemSR.Text == "")
            {
                checkoutItem.SRLabel.Text = "";
            }


            Switcher.GetCheckout().CheckoutItemList.Children.Add(checkoutItem);
        }
コード例 #2
0
        //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!");
                }
            }
        }
コード例 #3
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
                }
            }
        }
コード例 #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");
            }
        }
コード例 #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";
        }
コード例 #6
0
        private void Open_Finalized(object sender, RoutedEventArgs e)
        {
            if (MainWindow.GlobalSubtotal != 0)
            {
                //Check if Order has Alcohol
                foreach (CheckoutItem child in Switcher.GetCheckout().CheckoutItemList.Children)
                {
                    if (child.checkout_item_alcohol == true)
                    {
                        MainWindow.hasAlcohol = true;
                    }
                }

                //Order has Alcohol
                if (MainWindow.hasAlcohol == true)
                {
                    Switcher.GetConfirmCheckout().OrderConfirmVerify.Text = "Enter Verification No. :";
                    Switcher.GetConfirmCheckout().VerifyNo.Visibility = Visibility.Visible;
                    Switcher.GetConfirmCheckout().VerifyBorder.Visibility = Visibility.Visible;
                    Switcher.GetConfirmCheckout().VerifyNo.Text = "";
                }
                else
                {
                    Switcher.GetConfirmCheckout().OrderConfirmVerify.Text = "";
                    Switcher.GetConfirmCheckout().VerifyNo.Visibility = Visibility.Hidden;
                    Switcher.GetConfirmCheckout().VerifyBorder.Visibility = Visibility.Hidden;
                    Switcher.GetConfirmCheckout().VerifyNo.Text = "1234";
                }

                Window window = new Window
                {
                    Title   = "Confirm Checkout",
                    Content = Switcher.GetConfirmCheckout(),
                    Height  = 400,
                    Width   = 300
                };

                MainWindow.hasAlcohol = false;

                window.ShowDialog();
            }
            else
            {
                MessageBox.Show("Please order select our food items!");
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
0
 private void Open_Checkout(object sender, RoutedEventArgs e)
 {
     Switcher.Switch(Switcher.GetCheckout());
 }