Beispiel #1
0
        // Passing the line to be updated to the respective form
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (lbMeals.SelectedItem != null || lbDrinks.SelectedItem != null)
            {
                try
                {
                    for (int i = 0; i < MenuWorker.foodList.Count; i++)
                    {
                        if (lbMeals.SelectedIndex == i)
                        {
                            FoodItem foodItem = new FoodItem(MenuWorker.foodList[i].Id, MenuWorker.foodList[i].ItemName, MenuWorker.foodList[i].Description,
                                                             MenuWorker.foodList[i].Price, MenuWorker.foodList[i].CostPrice, MenuWorker.foodList[i].FoodType,
                                                             MenuWorker.foodList[i].Cuisine, MenuWorker.foodList[i].UserName);

                            this.Hide();
                            AddFood add = new AddFood(foodItem, lbMeals.SelectedIndex, username);
                            add.ShowDialog();
                        }
                    }
                    for (int i = 0; i < MenuWorker.drinkList.Count; i++)
                    {
                        if (lbDrinks.SelectedIndex == i)
                        {
                            DrinkItem drinkItem = new DrinkItem(MenuWorker.drinkList[i].Id, MenuWorker.drinkList[i].ItemName, MenuWorker.drinkList[i].Description,
                                                                MenuWorker.drinkList[i].Price, MenuWorker.drinkList[i].CostPrice, MenuWorker.drinkList[i].Container,
                                                                MenuWorker.drinkList[i].DrinkType, MenuWorker.drinkList[i].UserName);

                            this.Hide();
                            AddDrink add = new AddDrink(drinkItem, lbDrinks.SelectedIndex, username);
                            add.ShowDialog();
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
            else
            {
                MessageBox.Show("Please Select an item you Wish to Update from the List");
            }
        }
Beispiel #2
0
 // Validating which item needs to be added to the Menu
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (radFood.Checked)
     {
         this.Hide();
         AddFood add1 = new AddFood(username);
         add1.ShowDialog();
     }
     else if (radDrink.Checked)
     {
         this.Hide();
         AddDrink add2 = new AddDrink(username);
         add2.ShowDialog();
     }
     else if (radDrink.Checked == false && radFood.Checked == false)
     {
         MessageBox.Show("Please Select the item you would like to Add !");
     }
 }