Ejemplo n.º 1
0
        private void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            if(user == null)
            {
                user = new User();
            }

            user.Name = this.txtName.Text;
            user.Age = Convert.ToInt32(this.txtAge.Text);
            user.Height = Convert.ToInt32(this.txtHeight.Text);
            user.Weight = Convert.ToDouble(this.txtWeight.Text);

            user.WakeUpTime = Convert.ToInt32(this.timeWakeUpTime.Time.TotalMinutes);
            user.BreakfestTime = Convert.ToInt32(this.timeBreakfestTime.Time.TotalMinutes);
            user.LunchTime = Convert.ToInt32(this.timeLunchTime.Time.TotalMinutes);
            user.DinnerTime = Convert.ToInt32(this.timeDinnerTime.Time.TotalMinutes);
            user.BedTime = Convert.ToInt32(this.timeBedTime.Time.TotalMinutes);

            user.Ref_energy = Convert.ToInt32(this.txtEnergy.Text);
            user.Ref_fat = Convert.ToInt32(this.txtFat.Text);
            user.Ref_saturates = Convert.ToInt32(this.txtSaturates.Text);
            user.Ref_sugar = Convert.ToInt32(this.txtSugar.Text);
            user.Ref_salt = Convert.ToInt32(this.txtSalt.Text);

            UserDB udb = new UserDB(user);
            udb.save();

            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            localSettings.Values["userID"] = user.UserID;

            Frame.Navigate(typeof(MainPage));


        }
Ejemplo n.º 2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var parameter = e.Parameter as User;
            // a simple controller that adds a string to a List<string>
            user = parameter;

            if (user != null)
            {
               
                this.txtName.Text = user.Name;
                this.txtAge.Text = user.Age.ToString();
                this.txtHeight.Text = user.Height.ToString();
                this.txtWeight.Text = user.Weight.ToString();

                this.timeWakeUpTime.Time = getTimeFromTotal(user.WakeUpTime);
                this.timeBreakfestTime.Time = getTimeFromTotal(user.BreakfestTime);
                this.timeLunchTime.Time = getTimeFromTotal(user.LunchTime);
                this.timeDinnerTime.Time = getTimeFromTotal(user.DinnerTime);
                this.timeBedTime.Time = getTimeFromTotal(user.BedTime);

                this.txtEnergy.Text = user.Ref_energy.ToString();
                this.txtFat.Text = user.Ref_fat.ToString();
                this.txtSaturates.Text = user.Ref_saturates.ToString();
                this.txtSugar.Text = user.Ref_sugar.ToString();
                this.txtSalt.Text = user.Ref_salt.ToString();

            }
        }
Ejemplo n.º 3
0
        public static User getByUserID(int userID)
        {
            var path = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
            User user = new User();

            using (SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), path))
            {
                user = (from u in conn.Table<User>()
                         where u.UserID == userID
                         select u
                         ).ToList().FirstOrDefault();
            }
            return user;
        }
Ejemplo n.º 4
0
 public UserDB(User user)
 {
     this._user = user;
 }
Ejemplo n.º 5
0
        public void getStorageInfo()
        {

            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            if (localSettings.Values["userID"] != null)
            {
                int userID = (int)localSettings.Values["userID"];
                user = UserDB.getByUserID(userID);
            }
            if (localSettings.Values["dayID"] != null)
            {
                int dayID = (int)localSettings.Values["dayID"];
                _day = DayDB.getByDayID(dayID);
            }


            if (user != null)
                helloUser.Text = "Hello, " + user.Name + "!";

        }