示例#1
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            string name            = txtAddingName.Text;
            string description     = txtAddingDescription.Text;
            double price           = Convert.ToDouble(numAddingPrice.Value);
            string image           = pbAddingPicture.ImageLocation;
            string backgroundImage = pbAddingPicture.ImageLocation;
            bool   hasMilk         = CheckItem("Contains milk");
            bool   hasSugar        = CheckItem("Contains sugar");
            bool   hasAlcohol      = CheckItem("Contains alcohol");
            bool   hasHoney        = CheckItem("Contains honey");
            bool   hasLemon        = CheckItem("Contains lemon");
            bool   isDiet          = CheckItem("Contains no sugar, is diet");
            bool   hasBubbles      = CheckItem("Is carbonated");
            bool   hasCaffeine     = CheckItem("Contains caffeine");
            bool   hasYoghurt      = CheckItem("Contains yoghurt");
            bool   hasLactose      = CheckItem("Contains no lactose, soy alternative");

            if (rbCoffee.Checked)
            {
                _drink = new Coffee(10, name, description, price, image, backgroundImage, hasMilk, hasSugar, hasAlcohol);
            }
            else if (rbTea.Checked)
            {
                _drink = new Tea(10, name, description, price, image, backgroundImage, hasMilk, hasSugar, hasHoney, hasLemon);
            }
            else if (rbSoda.Checked)
            {
                _drink = new Soda(10, name, description, price, image, backgroundImage, isDiet, hasBubbles, hasCaffeine);
            }
            else if (rbSmoothie.Checked)
            {
                _drink = new Smoothie(10, name, description, price, image, backgroundImage, hasYoghurt, hasMilk, hasLactose);
            }

            _repo.AddDrink(_drink);
        }