예제 #1
0
        private void save_btn_Click(object sender, EventArgs e)
        {
            Dish         dish         = new Dish();
            MealTime     ml           = new MealTime();
            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();
        }
예제 #2
0
        private void del_aft_dish_btn_Click(object sender, EventArgs e)
        {
            DishMealTime obj = (DishMealTime)aft_dish_list.SelectedItem;

            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
        private void del_din_dish_btn_Click(object sender, EventArgs e)
        {
            try
            {
                DishMealTime obj = (DishMealTime)din_dish_list.SelectedItem;

                din_norm -= obj.Dish.Calories;
                sum      -= obj.Dish.Calories;

                rec_din_kal_lbl.Text = din_norm.ToString();

                earn_day_kal_lbl.Text = sum.ToString();

                din_dish_list.Items.RemoveAt(din_dish_list.SelectedIndex);
            }

            catch
            {
                MessageBox.Show("Выберите блюдо для удаления");
            }
        }
예제 #4
0
        private void add_aft_dish_btn_Click(object sender, EventArgs e)
        {
            DishMealTime obj = (DishMealTime)all_dish_list.SelectedItem;

            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();
        }