예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //set variables to create new object in Chocolate class
            Console.WriteLine("flavor selected : " + comboBoxChocolateSelection.SelectedItem.ToString());
            //adding new chocolate to list;
            decimal quantity        = numericUpDown1.Value;
            string  chocolateFlavor = comboBoxChocolateSelection.SelectedItem.ToString();
            string  darkChocolate   = "Dark Chocolate";
            string  whiteChocolate  = "White Chocolate";

            //conditional to based on which selection from the flavor drop down
            if (chocolateFlavor.Contains(darkChocolate))
            {
                //choloate object created
                Chocolate newChocolate = new Chocolate(chocolateFlavor, 9.50, quantity);
                //add object to list in the model class
                m_model.AddChocolateInList(newChocolate);
                //hide current form
                this.Hide();
                //pass model information to new main screen... midel info will be reset if we reutrn back to the origional model
                MainNavigation aMainNavigation = new MainNavigation(m_model);
                aMainNavigation.Closed += (s, args) => this.Close();
                aMainNavigation.Show();
            }
            else if (chocolateFlavor.Contains(whiteChocolate))
            {
                Chocolate newChocolate = new Chocolate(chocolateFlavor, 5.00, quantity);
                m_model.AddChocolateInList(newChocolate);

                this.Hide();
                MainNavigation aMainNavigation = new MainNavigation(m_model);
                aMainNavigation.Closed += (s, args) => this.Close();
                aMainNavigation.Show();
            }
            else
            {
                Chocolate newChocolate = new Chocolate(chocolateFlavor, 7.60, quantity);
                m_model.AddChocolateInList(newChocolate);

                this.Hide();
                MainNavigation aMainNavigation = new MainNavigation(m_model);
                aMainNavigation.Closed += (s, args) => this.Close();
                aMainNavigation.Show();
            }
        }
예제 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Console.WriteLine("flavor selected : " + comboBoxLollipopSelection.SelectedItem.ToString());
            //adding new lollipop to list;
            decimal quantity       = numericUpDown1.Value = 1;
            string  lollipopFlavor = comboBoxLollipopSelection.SelectedItem.ToString();
            string  cherry         = "Cherry";
            string  lime           = "Lime";

            if (lollipopFlavor.Contains(cherry))
            {
                Lollipop newLollipop = new Lollipop(lollipopFlavor, 5.30, quantity);
                m_model.AddLollipopInList(newLollipop);

                this.Hide();
                MainNavigation aMainNavigation = new MainNavigation(m_model);
                aMainNavigation.Closed += (s, args) => this.Close();
                aMainNavigation.Show();
            }
            else if (lollipopFlavor.Contains(lime))
            {
                Lollipop newLollipop = new Lollipop(lollipopFlavor, 4.00, quantity);
                m_model.AddLollipopInList(newLollipop);

                this.Hide();
                MainNavigation aMainNavigation = new MainNavigation(m_model);
                aMainNavigation.Closed += (s, args) => this.Close();
                aMainNavigation.Show();
            }
            else
            {
                Lollipop newLollipop = new Lollipop(lollipopFlavor, 3.89, quantity);
                m_model.AddLollipopInList(newLollipop);

                this.Hide();
                MainNavigation aMainNavigation = new MainNavigation(m_model);
                aMainNavigation.Closed += (s, args) => this.Close();
                aMainNavigation.Show();
            }
        }
예제 #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            decimal quantity  = numericUpDown1.Value;
            string  gumFlavor = comboBoxGumSelection.SelectedItem.ToString();
            string  bubble    = "Bubble Gum";
            string  mint      = "Mint";

            if (gumFlavor.Contains(bubble))
            {
                Gum newGum = new Gum(gumFlavor, 3.25, quantity);
                m_model.AddGumInList(newGum);

                this.Hide();
                MainNavigation aMainNavigation = new MainNavigation(m_model);
                aMainNavigation.Closed += (s, args) => this.Close();
                aMainNavigation.Show();
            }
            else if (gumFlavor.Contains(mint))
            {
                Gum newGum = new Gum(gumFlavor, 2.20, quantity);
                m_model.AddGumInList(newGum);

                this.Hide();
                MainNavigation aMainNavigation = new MainNavigation(m_model);
                aMainNavigation.Closed += (s, args) => this.Close();
                aMainNavigation.Show();
            }
            else
            {
                Gum newGum = new Gum(gumFlavor, 2.75, quantity);
                m_model.AddGumInList(newGum);

                this.Hide();
                MainNavigation aMainNavigation = new MainNavigation(m_model);
                aMainNavigation.Closed += (s, args) => this.Close();
                aMainNavigation.Show();
            }
        }