Beispiel #1
0
        private void btnSaveCoffee_Click(object sender, EventArgs e)
        {
            Drink drink = (Drink)cmbCoffee.SelectedItem;

            if (drink == null)
            {
                Drink newDrink = new Drink();
                newDrink.DrinkName = cmbCoffee.Text;
                newDrink.BaseCost  = Convert.ToDecimal(txtCost.Text);
                newDrink.AddOn1    = txtAdd1.Text;
                newDrink.AddOn2    = txtAdd2.Text;
                newDrink.AddOn3    = txtAdd3.Text;
                CoffeeDb.AddCoffee(newDrink);
                MessageBox.Show("Coffee Added");
            }

            else
            {
                drink.DrinkName = cmbCoffee.Text;
                drink.BaseCost  = Convert.ToDecimal(txtCost.Text);
                drink.AddOn1    = txtAdd1.Text;
                drink.AddOn2    = txtAdd2.Text;
                drink.AddOn3    = txtAdd3.Text;
                CoffeeDb.Update(drink);
                MessageBox.Show("Coffee Updated");
            }
        }
Beispiel #2
0
        private void btnAddCoffee_Click(object sender, EventArgs e)
        {
            Drink d = new Drink();

            d.DrinkName = "Mocha";
            d.BaseCost  = 7;

            CoffeeDb.AddCoffee(d);
            MessageBox.Show("Coffee Added!");
        }