Esempio n. 1
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            string account  = accountBox.Text;
            string password = passwordbox.Password;

            using (SQLiteConnection conn = UserDatabase.GetDbConnection())
            {
                TableQuery <UserAccount> t = conn.Table <UserAccount>();
                var q = from s in t
                        orderby s.user_id
                        select s;

                if (q.Any(temp => account == temp.user_id && password == temp.password))
                {
                    await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        ((Frame)Window.Current.Content).Navigate(typeof(MainPage)
                                                                 , account);
                    });
                }
                else
                {
                    accountBox.Text      = "";
                    passwordbox.Password = "";
                    new MessageDialog("账户或密码错误").ShowAsync();
                }
            }
        }
Esempio n. 2
0
        private void Usertest() //用户数据库测试
        {
            using (SQLiteConnection conn = UserDatabase.GetDbConnection())
            {
                Debug.WriteLine(conn.DatabasePath.ToString());//找出数据库位置
                TableQuery <UserAccount> t = conn.Table <UserAccount>();
                var q = from s in t.AsParallel <UserAccount>()
                        orderby s.user_id
                        select s;

                useracccount.Clear();

                foreach (var temp in q)
                {
                    useracccount.Add(temp);
                }

                //StringBuilder msg = new StringBuilder();
                //msg.AppendLine($"数据库中总共 {useracccount.Count()} 个 user 对象。");

                /////测试数据库出来的实例location转换

                //foreach (var item in useracccount)
                //{
                //    msg.AppendLine($"Id:{item.user_id};Name:{item.name}");
                //}

                //new MessageDialog(msg.ToString()).ShowAsync();
            }
        }
Esempio n. 3
0
        private void reNameBox_Loaded(object sender, RoutedEventArgs e)
        {
            using (SQLiteConnection conn = UserDatabase.GetDbConnection())
            {
                TableQuery <UserAccount> t = conn.Table <UserAccount>();
                var q = from s in t.AsParallel <UserAccount>()
                        orderby s.user_id
                        where s.user_id == this_account
                        select s;

                ///如何将用户登陆后的账户通信到这些页面呢??这个分支采用导航传参数

                foreach (var item in q)
                {
                    reNameBox.Text = item.nickname.ToString();
                }
            }
        }
Esempio n. 4
0
        private void dataload() //用于打开页面加载路程数据等方法
        {
            using (SQLiteConnection conn = UserDatabase.GetDbConnection())
            {
                TableQuery <UserAccount> t = conn.Table <UserAccount>();
                var q = from s in t.AsParallel <UserAccount>()
                        orderby s.user_id
                        where s.user_id == this_account
                        select s;


                foreach (var item in q)
                {
                    nicknameText.Text = item.nickname.ToString();
                    nameText.Text     = item.name.ToString();
                    phoneText.Text    = item.phonenumber.ToString();
                    //headpictureE  如何设置头像?
                }
            }
        }
Esempio n. 5
0
        //private void Ellipse_PointerPressed(object sender, PointerRoutedEventArgs e)
        //{

        //}



        private void dataload() //用于打开页面加载路程数据等方法
        {
            using (SQLiteConnection conn = UserDatabase.GetDbConnection())
            {
                TableQuery <UserAccount> t = conn.Table <UserAccount>();
                var q = from s in t.AsParallel <UserAccount>()
                        orderby s.user_id where s.user_id == this_account
                        select s;

                ///如何将用户登陆后的账户通信到这些页面呢??这个分支采用导航传参数

                foreach (var item in q)
                {
                    distanceText.Text   = item.in_distance.ToString();
                    savecarbonText.Text = item.carbon_save.ToString();
                    calText.Text        = item.calorie_cousume.ToString();
                    numberText.Text     = item.phonenumber.ToString();
                }
            }
        }
Esempio n. 6
0
        private void SaveB_Click(object sender, RoutedEventArgs e)
        {
            using (SQLiteConnection conn = UserDatabase.GetDbConnection())
            {
                TableQuery <UserAccount> t = conn.Table <UserAccount>();
                var q = (from s in t
                         orderby s.user_id
                         where s.user_id == this_account
                         select s).SingleOrDefault();

                q.nickname = reNameBox.Text;
                conn.Update(q);
                //q.First().nickname = reNameBox.Text;

                //conn.InsertOrReplace(q);
            }
            if (this.Frame.CanGoBack)
            {
                Frame.GoBack();
            }
        }