Exemplo n.º 1
0
        private void UpdateAge()
        {
            try
            {
                if (Up_Age == String.Empty || Up_Age == null)
                {
                    ErrorMes = Properties.Resources.emptyfield;
                }
                else if (activUser.Age == Convert.ToInt16(Up_Age))
                {
                    ErrorMes = Properties.Resources.olddata;
                }
                else
                {
                    if (dbu.UpdateAgeUser(ID_user, Convert.ToInt16(Up_Age)))
                    {
                        activUser.Age = Convert.ToInt16(Up_Age);
                        int remain_cal  = db.GetDailyCal(ID_user, today.ToString());
                        int new_cal     = 0;
                        int now_day_cal = activUser.D_Cal;
                        int eat_cal     = now_day_cal - remain_cal;

                        new_cal = GetNewDayCal(activUser.Gender, activUser.Purpose_of_Use, this.GetActivity(activUser.Activity), activUser.Height, activUser.Weight, activUser.Age);
                        db.UpdateDailyCal(ID_user, today.ToString(), new_cal - eat_cal);
                        if (dbu.UpdateDailyCalUser(ID_user, new_cal))
                        {
                            Close();
                        }
                    }
                }
            }
            catch (SystemException e)
            {
                ErrorMes = Properties.Resources.errordata;
            }
        }
Exemplo n.º 2
0
        //  public int cal;

        public MainPageViewModel()
        {
            Name_food_breakfast = new ObservableCollection <Food>();
            Name_food_breakfast = GetNameFood(1);
            Name_food_lunch     = new ObservableCollection <Food>();
            Name_food_lunch     = GetNameFood(2);
            Name_food_dinner    = new ObservableCollection <Food>();
            Name_food_dinner    = GetNameFood(3);
            Name_food_snack     = new ObservableCollection <Food>();
            Name_food_snack     = GetNameFood(4);
            daily_cal           = new int();
            daily_cal           = db.GetDailyCal(id_user, today.ToString());
            // cal = db.GetDailyCal(id_user, today.ToString());
            //daily_cal = cal;
        }