Пример #1
0
        private void add_aft_dish_btn_Click(object sender, EventArgs e)
        {
            DishMealTime obj = (DishMealTime)all_dish_list.SelectedItem;

            if (obj == null)
            {
                MessageBox.Show("Выберите блюдо из списка!");
            }
            else
            {
                aft_norm += obj.Dish.Calories;
                sum      += obj.Dish.Calories;

                if (Convert.ToDouble(aft_day_kal_lbl.Text) < aft_norm)
                {
                    aft_norm -= obj.Dish.Calories;
                    sum      -= obj.Dish.Calories;

                    MessageBox.Show("Вы превысили норму ккал!!!");
                }

                else
                {
                    aft_dish_list.Items.Add(all_dish_list.SelectedItem);

                    rec_aft_kal_lbl.Text = aft_norm.ToString();
                }

                earn_day_kal_lbl.Text = sum.ToString();
            }
        }
Пример #2
0
        private void del_aft_dish_btn_Click(object sender, EventArgs e)
        {
            DishMealTime obj = (DishMealTime)aft_dish_list.SelectedItem;

            if (obj == null)
            {
                MessageBox.Show("Выберите блюдо для удаления!");
            }
            else
            {
                aft_norm -= obj.Dish.Calories;
                sum      -= obj.Dish.Calories;

                earn_day_kal_lbl.Text = sum.ToString();

                rec_aft_kal_lbl.Text = aft_norm.ToString();

                aft_dish_list.Items.RemoveAt(aft_dish_list.SelectedIndex);
            }
        }
Пример #3
0
        public void Save()
        {
            Dish         dish         = new Dish();
            DishMealTime dishMealTime = new DishMealTime();

            dish.Calories      = Convert.ToDouble(cal_txtb.Text);
            dish.DishName      = dish_txtb.Text;
            dish.Carbohydrates = Convert.ToDouble(carb_txtb.Text);
            dish.Descr         = desc_txtb.Text;
            dish.Fats          = Convert.ToDouble(fat_txtb.Text);
            dish.Weight        = Convert.ToDouble(gram_txtb.Text);
            dish.Protein       = Convert.ToDouble(prot__txtb.Text);

            DBConnection.Entities.Dishes.Add(dish);
            DBConnection.Entities.SaveChanges();

            dishMealTime.DishId   = dish.DishId;
            dishMealTime.MealTime = meal_combox.Text;

            DBConnection.Entities.DishMealTimes.Add(dishMealTime);
            DBConnection.Entities.SaveChanges();

            this.Close();
        }