public FoodMenuWindow() { Pizza pizza = new Pizza(); Burger burger = new Burger(); Sundry sundry = new Sundry(); InitializeComponent(); categoryComboBox.Items.Add("All"); categoryComboBox.Items.Add("Pizza"); categoryComboBox.Items.Add("Burger"); categoryComboBox.Items.Add("Sundry"); categoryComboBox.SelectedValue = "All"; sizeComboBox.Items.Add("All"); sizeComboBox.Items.Add("Regular"); sizeComboBox.Items.Add("Large"); sizeComboBox.Items.Add("Extra-Large"); sizeComboBox.SelectedValue = "All"; }
private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { Menu = window.ReadInInventory(); pizza = window.ReadInPizza(); burger = window.ReadInBurger(); sundry = window.ReadInsundry(); int PizzaLines = pizza.PizzaLineReader(); int BurgerLines = burger.BurgerLineReader(); int SundryLines = sundry.SundryLineReader(); if (listBox.SelectedItem == null) { categoryComboBox.SelectedItem.ToString(); } else { ListBoxItem SelItem = listBox.SelectedItem as ListBoxItem; string item = SelItem.Content.ToString(); int NumOfLines = Menu.LineCheck("inventory.txt"); string[] SplitList = new string[4]; SplitList = item.Split(','); textBox.Text = SplitList[3]; double FoodCost; double TotalCost = 0; for (int i = 0; i < PizzaLines; i++) { if (SplitList[0] == pizza.PizzaName[i]) { if (SplitList[1] == " " + pizza.PizzaType[i] && SplitList[2] == " " + pizza.PizzaSize[i]) { listBox1.Items.Clear(); for (int j = 0; j < NumOfLines; j++) { if (Menu.FoodContents[j] == " dough") { FoodCost = (Menu.FoodPrice[j] * pizza.PDoughQuantity[i]); TotalCost += FoodCost; listBox1.Items.Add(pizza.PizzaDough[i] + ", " + pizza.PDoughQuantity[i].ToString("0.00") + ", " + "£" + FoodCost.ToString("0.00")); } if (Menu.FoodContents[j] == " sauce") { FoodCost = (Menu.FoodPrice[j] * pizza.PSauceQuantity[i]); TotalCost += FoodCost; listBox1.Items.Add(pizza.PizzaSauce[i] + ", " + pizza.PSauceQuantity[i].ToString("0.00") + ", " + "£" + FoodCost.ToString("0.00")); } if (Menu.FoodContents[j] == " mozzarella") { FoodCost = (Menu.FoodPrice[j] * pizza.PCheseCostQuantity[i]); TotalCost += FoodCost; listBox1.Items.Add(pizza.PizzaCheese[i] + ", " + pizza.PCheseCostQuantity[i].ToString("0.00") + ", " + "£" + FoodCost.ToString("0.00")); } } if (i > 2) { for (int j = 0; j < NumOfLines; j++) { if (Menu.FoodContents[j] == pizza.Topping1[i - 3]) { FoodCost = (Menu.FoodPrice[j] * pizza.Topping1Quantity[i - 3]); TotalCost += FoodCost; listBox1.Items.Add(pizza.Topping1[i - 3] + ", " + pizza.Topping1Quantity[i - 3].ToString("0.00") + ", " + "£" + FoodCost.ToString("0.00")); } } } if (i > 5) { for (int j = 0; j < NumOfLines; j++) { if (Menu.FoodContents[j] == pizza.Topping2[i - 6]) { FoodCost = (Menu.FoodPrice[j] * pizza.Topping2Quantity[i - 6]); TotalCost += FoodCost; listBox1.Items.Add(pizza.Topping2[i - 6] + ", " + pizza.Topping2Quantity[i - 6].ToString("0.00") + ", " + "£" + FoodCost.ToString("0.00")); } } } if (i > 8) { for (int j = 0; j < NumOfLines; j++) { if (Menu.FoodContents[j] == pizza.Topping3[i - 9]) { FoodCost = (Menu.FoodPrice[j] * pizza.Topping3Quantity[i - 9]); TotalCost += FoodCost; listBox1.Items.Add(pizza.Topping3[i - 9] + ", " + pizza.Topping3Quantity[i - 9].ToString("0.00") + ", " + "£" + FoodCost.ToString("0.00")); } } } if (i > 11) { for (int j = 0; j < NumOfLines; j++) { if (Menu.FoodContents[j] == pizza.Topping4[i - 12]) { FoodCost = (Menu.FoodPrice[j] * pizza.Topping4Quantity[i - 12]); TotalCost += FoodCost; listBox1.Items.Add(pizza.Topping4[i - 12] + ", " + pizza.Topping4Quantity[i - 12].ToString("0.00") + ", " + "£" + FoodCost.ToString("0.00")); } } } textBox2.Text = "£" + TotalCost.ToString("0.00"); textBox1.Text = "£" + (pizza.PSizeCost[i] - TotalCost).ToString("0.00"); } } } for (int i = 0; i < BurgerLines; i++) { if (SplitList[0] == burger.BurgerName[i]) { if (SplitList[1] == " " + burger.BurgerType[i] && SplitList[2] == " " + burger.BurgerSize[i]) { listBox1.Items.Clear(); for (int j = 0; j < NumOfLines; j++) { if (Menu.FoodContents[j] == burger.BurgerBun[i]) { FoodCost = (Menu.FoodPrice[j] * burger.BurgerBunQuantity[i]); TotalCost += FoodCost; listBox1.Items.Add(burger.BurgerBun[i] + ", " + burger.BurgerBunQuantity[i].ToString("0.00") + ", " + "£" + FoodCost.ToString("0.00")); } } for (int j = 0; j < NumOfLines; j++) { if (Menu.FoodContents[j] == burger.BurgerPatty[i]) { FoodCost = (Menu.FoodPrice[j] * burger.BurgerPattyQuantity[i]); TotalCost += FoodCost; listBox1.Items.Add(burger.BurgerPatty[i] + ", " + burger.BurgerPattyQuantity[i].ToString("0.00") + ", " + "£" + FoodCost.ToString("0.00")); } } textBox2.Text = "£" + TotalCost.ToString("0.00"); textBox1.Text = "£" + (burger.BurgerCost[i] - TotalCost).ToString("0.00"); } } } for (int i = 0; i < SundryLines; i++) { if (SplitList[0] == sundry.SundryName[i]) { if (SplitList[1] == " " + sundry.SundryType[i] && SplitList[2] == " " + sundry.SundrySize[i]) { listBox1.Items.Clear(); for (int j = 0; j < NumOfLines; j++) { if (Menu.FoodContents[j] == sundry.SundryType[i]) { FoodCost = (Menu.FoodPrice[j] * sundry.SundryQuantity[i]); TotalCost += FoodCost; listBox1.Items.Add(sundry.SundryType[i] + ", " + sundry.SundryQuantity[i].ToString("0.00") + ", " + "£" + FoodCost.ToString("0.00")); } } textBox2.Text = "£" + TotalCost.ToString("0.00"); textBox1.Text = "£" + (sundry.SundryCost[i] - TotalCost).ToString("0.00"); } } } } }
/// <summary> /// Uses methods from main window to read in data for /// Pizza, burger and sundry data. Then adds the data to the listbox /// and will display information depending on what the comboboxes /// display. /// </summary> public void AddInventory() { listBox.Items.Clear(); pizza = window.ReadInPizza(); burger = window.ReadInBurger(); sundry = window.ReadInsundry(); int PizzaLines = pizza.PizzaLineReader(); int BurgerLines = burger.BurgerLineReader(); int SundryLines = sundry.SundryLineReader(); for (int i = 0; i < PizzaLines; i++) { ListBoxItem MenuSplit = new ListBoxItem(); if (categoryComboBox.SelectedItem.ToString() == "All" && sizeComboBox.SelectedItem as string == "All") { MenuSplit.Content = pizza.PizzaName[i] + ", " + pizza.PizzaType[i] + ", " + pizza.PizzaSize[i] + ", " + "£" + pizza.PSizeCost[i].ToString("0.00"); listBox.Items.Add(MenuSplit); } if (categoryComboBox.SelectedItem.ToString() == "All" && sizeComboBox.SelectedItem as string == "Regular" && pizza.PizzaSize[i] == " regular") { MenuSplit.Content = pizza.PizzaName[i] + ", " + pizza.PizzaType[i] + ", " + pizza.PizzaSize[i] + ", " + "£" + pizza.PSizeCost[i].ToString("0.00"); listBox.Items.Add(MenuSplit); } if (categoryComboBox.SelectedItem.ToString() == "All" && sizeComboBox.SelectedItem as string == "Large" && pizza.PizzaSize[i] == " large") { MenuSplit.Content = pizza.PizzaName[i] + ", " + pizza.PizzaType[i] + ", " + pizza.PizzaSize[i] + ", " + "£" + pizza.PSizeCost[i].ToString("0.00"); listBox.Items.Add(MenuSplit); } if (categoryComboBox.SelectedItem.ToString() == "All" && sizeComboBox.SelectedItem as string == "Extra-Large" && pizza.PizzaSize[i] == " extra-large") { MenuSplit.Content = pizza.PizzaName[i] + ", " + pizza.PizzaType[i] + ", " + pizza.PizzaSize[i] + ", " + "£" + pizza.PSizeCost[i].ToString("0.00"); listBox.Items.Add(MenuSplit); } if (categoryComboBox.SelectedItem.ToString() == "Pizza" && sizeComboBox.SelectedItem as string == "All") { MenuSplit.Content = pizza.PizzaName[i] + ", " + pizza.PizzaType[i] + ", " + pizza.PizzaSize[i] + ", " + "£" + pizza.PSizeCost[i].ToString("0.00"); listBox.Items.Add(MenuSplit); } if (categoryComboBox.SelectedItem.ToString() == "Pizza" && sizeComboBox.SelectedItem as string == "Regular" && pizza.PizzaSize[i] == " regular") { MenuSplit.Content = pizza.PizzaName[i] + ", " + pizza.PizzaType[i] + ", " + pizza.PizzaSize[i] + ", " + "£" + pizza.PSizeCost[i].ToString("0.00"); listBox.Items.Add(MenuSplit); } if (categoryComboBox.SelectedItem.ToString() == "Pizza" && sizeComboBox.SelectedItem as string == "Large" && pizza.PizzaSize[i] == " large") { MenuSplit.Content = pizza.PizzaName[i] + ", " + pizza.PizzaType[i] + ", " + pizza.PizzaSize[i] + ", " + "£" + pizza.PSizeCost[i].ToString("0.00"); listBox.Items.Add(MenuSplit); } if (categoryComboBox.SelectedItem.ToString() == "Pizza" && sizeComboBox.SelectedItem as string == "Extra-Large" && pizza.PizzaSize[i] == " extra-large") { MenuSplit.Content = pizza.PizzaName[i] + ", " + pizza.PizzaType[i] + ", " + pizza.PizzaSize[i] + ", " + "£" + pizza.PSizeCost[i].ToString("0.00"); listBox.Items.Add(MenuSplit); } } for (int i = 0; i < BurgerLines; i++) { ListBoxItem MenuSplit = new ListBoxItem(); if (categoryComboBox.SelectedItem.ToString() == "All" && sizeComboBox.SelectedItem as string == "All") { MenuSplit.Content = burger.BurgerName[i] + ", " + burger.BurgerType[i] + ", " + burger.BurgerSize[i] + ", " + "£" + burger.BurgerCost[i].ToString("0.00"); listBox.Items.Add(MenuSplit); } if (categoryComboBox.SelectedItem.ToString() == "All" && sizeComboBox.SelectedItem as string == "Regular" && burger.BurgerSize[i] == " regular") { MenuSplit.Content = burger.BurgerName[i] + ", " + burger.BurgerType[i] + ", " + burger.BurgerSize[i] + ", " + "£" + burger.BurgerCost[i].ToString("0.00"); listBox.Items.Add(MenuSplit); } if (categoryComboBox.SelectedItem.ToString() == "All" && sizeComboBox.SelectedItem as string == "Large" && burger.BurgerSize[i] == " large") { MenuSplit.Content = burger.BurgerName[i] + ", " + burger.BurgerType[i] + ", " + burger.BurgerSize[i] + ", " + "£" + burger.BurgerCost[i].ToString("0.00"); listBox.Items.Add(MenuSplit); } if (categoryComboBox.SelectedItem.ToString() == "Burger" && sizeComboBox.SelectedItem as string == "All") { MenuSplit.Content = burger.BurgerName[i] + ", " + burger.BurgerType[i] + ", " + burger.BurgerSize[i] + ", " + "£" + burger.BurgerCost[i].ToString("0.00"); listBox.Items.Add(MenuSplit); } if (categoryComboBox.SelectedItem.ToString() == "Burger" && sizeComboBox.SelectedItem as string == "Regular" && burger.BurgerSize[i] == " regular") { MenuSplit.Content = burger.BurgerName[i] + ", " + burger.BurgerType[i] + ", " + burger.BurgerSize[i] + ", " + "£" + burger.BurgerCost[i].ToString("0.00"); listBox.Items.Add(MenuSplit); } if (categoryComboBox.SelectedItem.ToString() == "Burger" && sizeComboBox.SelectedItem as string == "Large" && burger.BurgerSize[i] == " large") { MenuSplit.Content = burger.BurgerName[i] + ", " + burger.BurgerType[i] + ", " + burger.BurgerSize[i] + ", " + "£" + burger.BurgerCost[i].ToString("0.00"); listBox.Items.Add(MenuSplit); } } for (int i = 0; i < SundryLines; i++) { ListBoxItem MenuSplit = new ListBoxItem(); if (categoryComboBox.SelectedItem.ToString() == "All" && sizeComboBox.SelectedItem as string == "All") { MenuSplit.Content = sundry.SundryName[i] + ", " + sundry.SundryType[i] + ", " + sundry.SundrySize[i] + ", " + "£" + sundry.SundryCost[i].ToString("0.00"); listBox.Items.Add(MenuSplit); } if (categoryComboBox.SelectedItem.ToString() == "All" && sizeComboBox.SelectedItem as string == "Regular" && sundry.SundrySize[i] == " regular") { MenuSplit.Content = sundry.SundryName[i] + ", " + sundry.SundryType[i] + ", " + sundry.SundrySize[i] + ", " + "£" + sundry.SundryCost[i].ToString("0.00"); listBox.Items.Add(MenuSplit); } if (categoryComboBox.SelectedItem.ToString() == "Sundry" && sizeComboBox.SelectedItem as string == "All") { MenuSplit.Content = sundry.SundryName[i] + ", " + sundry.SundryType[i] + ", " + sundry.SundrySize[i] + ", " + "£" + sundry.SundryCost[i].ToString("0.00"); listBox.Items.Add(MenuSplit); } if (categoryComboBox.SelectedItem.ToString() == "Sundry" && sizeComboBox.SelectedItem as string == "Regular" && sundry.SundrySize[i] == " regular") { MenuSplit.Content = sundry.SundryName[i] + ", " + sundry.SundryType[i] + ", " + sundry.SundrySize[i] + ", " + "£" + sundry.SundryCost[i].ToString("0.00"); listBox.Items.Add(MenuSplit); } } }