Example #1
0
        private void btnChangeMenu_Click(object sender, System.EventArgs e)
        {
            string name = txbName.Text;

            string stockText = txbStock.Text;
            bool   parsable  = int.TryParse(stockText, out int stock);

            MenuItem menuItem = (MenuItem)lvwItemOverview.SelectedItems[0].Tag;

            if (name != string.Empty)
            {
                menuItem.ItemName = name;
                menuItemService.ChangeName(menuItem);
            }

            if (parsable)
            {
                menuItem.InStock = stock;
                menuItemService.ChangeStock(menuItem);
            }

            txbName.Text  = string.Empty;
            txbStock.Text = string.Empty;
            DisplayItemOverview();
        }
Example #2
0
        private void MenuItem_Click(object sender, EventArgs e)
        {
            Button   button   = (Button)sender;
            MenuItem menuItem = (MenuItem)button.Tag;

            if (menuItem.InStock > 0)
            {
                AddOrderItem(menuItem);
                menuItem.InStock--;
                menuItemService.UpdateStock(menuItem);
            }
            else
            {
                errorBox.Show($"'{menuItem.ItemName}' is out of stock!");
            }
        }
Example #3
0
        private void AddOrderItem(MenuItem menuItem)
        {
            // Check if menu item is in the order list
            int index = Order.OrderItems.FindIndex(orderItem =>
                                                   orderItem.MenuItem.ItemID == menuItem.ItemID);

            if (index < 0)
            {
                OrderItem orderItem = orderItemService.CreateOrderItem(1, menuItem, Order.OrderID, OrderState.unready);
                Order.OrderItems.Add(orderItem);
            }
            else
            {
                Order.OrderItems[index].Quantity++;
                orderItemService.UpdateQuantity(Order.OrderItems[index]);
            }

            DisplayItemOverview();
        }