示例#1
0
        public void btnAddItem_Click(object sender, EventArgs e)
        {
            if (listMenu.SelectedIndex < 0)
            {
                MessageBox.Show("Please select the menu item to add");
                return;
            }

            totalcost = 0;

            if (menuitem == null)
            {
                menuitem = listMenu.SelectedItem as CoffeShop.Lib.MenuItem;
            }

            menuitems.Add(menuitem);

            foreach (CoffeShop.Lib.MenuItem menuItem in menuitems)
            {
                if (menuItem != null)
                {
                    totalcost = totalcost + menuItem.BaseCost;
                }
            }

            txtTotalCost.Text = Convert.ToString(totalcost);

            menuitem = null;
        }
示例#2
0
        private void btnAddAdditions_Click_1(object sender, EventArgs e)
        {
            if (menuitem == null)
            {
                menuitem = listMenu.SelectedItem as CoffeShop.Lib.MenuItem;
            }

            string text = lbxMenuAdditions.GetItemText(lbxMenuAdditions.SelectedItem);

            if (text == "Milk")
            {
                menuitem = new Milk(menuitem);
            }

            if (text == "Sugar")
            {
                menuitem = new Suggar(menuitem);
            }

            if (text == "Sweetener")
            {
                menuitem = new Sweetener(menuitem);
            }

            if (text == "Cheese")
            {
                menuitem = new Cheese(menuitem);
            }

            if (text == "Lettuce")
            {
                menuitem = new Lettuce(menuitem);
            }

            if (text == "Mayo")
            {
                menuitem = new Mayo(menuitem);
            }

            if (text == "Tomato")
            {
                menuitem = new Tomato(menuitem);
            }
        }