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 PopulateCoffeeList()
        {
            List <Drink> drink = CoffeeDb.GetAllCoffee();

            cmbCoffee.DataSource    = drink;
            cmbCoffee.DisplayMember = nameof(Drink.DrinkName);
        }
Beispiel #3
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!");
        }
Beispiel #4
0
        public void PopluateCoffeeList()
        {
            cboCoffee.DataSource = null;
            List <Drink> coffee = CoffeeDb.GetAllCoffee();

            //throw new NotImplementedException();
            cboCoffee.DataSource    = coffee;
            cboCoffee.DisplayMember = nameof(Drink.DrinkName);
            chkPopulate();
        }