Example #1
0
 private async void BtnAdd_Click(object sender, RoutedEventArgs e)
 {
     if (txtAddmima.Text != "" && txtAdduser.Text != "")
     {
         string user = txtAdduser.Text;
         string mima = txtAddmima.Text;
         using (var conn = AppDatabase.GetDbConnection())
         {
             // 需要添加的 Person 对象。
             var addLoginuser = new Login()
             {
                 LoginUser = user, Mima = mima
             };
             var    count = conn.Insert(addLoginuser);
             string msg   = $"新用户创建成功!\n用户名:{addLoginuser.LoginUser}\n 密码:{addLoginuser.Mima}";
             await new MessageDialog(msg).ShowAsync();
         }
     }
     if (txtAdduser.Text == "")
     {
         txtAdduser.PlaceholderText = "不能为空";
     }
     if (txtAddmima.Text == "")
     {
         txtAddmima.PlaceholderText = "不能为空";
     }
 }
Example #2
0
        internal List <UserData> CheckData(string conditions)
        {
            var temSTR = "%" + conditions + "%";

            using (var conn = AppDatabase.GetDbConnection())
            {
                return(conn.Query <UserData>("select * from UserData where Name like ? or Phonenumber like ? or Birthday like ? or City like ? or Email like ?;", temSTR, temSTR, temSTR, temSTR, temSTR));
            }
        }
Example #3
0
        internal int UpadateData(UserData updataAccourt)
        {
            int result = 0;

            DbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "Phonebook.db");
            using (var conn = AppDatabase.GetDbConnection())
            {
                result = conn.Update(updataAccourt);
            }
            return(result);
        }
Example #4
0
 internal ObservableCollection <UserData> ReadData(ObservableCollection <UserData> accourt)
 {
     accourt.Clear();
     DbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "Phonebook.db");
     using (var conn = AppDatabase.GetDbConnection())
     {
         var dbAccourt = conn.Table <UserData>();
         foreach (var item in dbAccourt)
         {
             accourt.Add(item);
         }
     }
     return(accourt);
 }
Example #5
0
        internal int DeleteData(UserData AccourtUID)
        {
            int result = 0;

            DbPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "Phonebook.db");
            using (var conn = AppDatabase.GetDbConnection())
            {
                if (AccourtUID != null)
                {
                    result = conn.Delete(AccourtUID);
                }
                else
                {
                    return(result);
                }
            }
            return(result);
        }
Example #6
0
        public static List <ListviewSelect> Getuser()
        {
            var users = new List <ListviewSelect>();

            using (var conn = AppDatabase.GetDbConnection())
            {
                StringBuilder msg      = new StringBuilder();
                var           dbPerson = conn.Table <UserData>();
                //msg.AppendLine($"数据库中总共 {dbPerson.Count()} 个 userdata对象。");
                foreach (var userdata in dbPerson)
                {
                    users.Add(new ListviewSelect {
                        Userid = userdata.Name, Bir = userdata.Birthday, Phonenumber = userdata.Phonenumber, Coveimage = userdata.Image, City = userdata.City, Mail = userdata.Email
                    });
                }
            }
            return(users);
        }
Example #7
0
        private async void BtnAdd_Click(object sender, RoutedEventArgs e)
        {
            string name   = txtAddName.Text;
            string number = txtAddnum.Text;
            string bir    = txtAddbir.Text;
            string mail   = txtAddmail.Text;
            string city   = txtAddcity.Text;
            string image  = AddImage.Text;

            if (image != "")
            {
                using (var conn = AppDatabase.GetDbConnection())
                {
                    // 需要添加的 Person 对象。
                    var adduserdata = new UserData()
                    {
                        Name = name, Phonenumber = number, Birthday = bir, City = city, Email = mail, Image = image
                    };

                    // 受影响行数。
                    var    count = conn.Insert(adduserdata);
                    string msg   = $"新增的 Person 对象的 Id 为 {adduserdata.Id},Name 为 {adduserdata.Name},Phonenumber为 {adduserdata.Phonenumber},Birthday为 {adduserdata.Birthday},City为 {adduserdata.City},Email为 {adduserdata.Email}";
                    await new MessageDialog(msg).ShowAsync();
                }
            }
            if (image == "")
            {
                using (var conn = AppDatabase.GetDbConnection())
                {
                    // 需要添加的 Person 对象。
                    var adduserdata = new UserData()
                    {
                        Name = name, Phonenumber = number, Birthday = bir, City = city, Email = mail, Image = @"C:\\\" + image
                    };

                    // 受影响行数。
                    var    count = conn.Insert(adduserdata);
                    string msg   = $"新增的 Person 对象的 Id 为 {adduserdata.Id},Name 为 {adduserdata.Name},Phonenumber为 {adduserdata.Phonenumber},Brithday为 {adduserdata.Birthday},City为 {adduserdata.City},Email为 {adduserdata.Email}";
                    await new MessageDialog(msg).ShowAsync();
                }
            }
        }
Example #8
0
        private async void denglu_Click(object sender, RoutedEventArgs e)
        {
            using (var conn = AppDatabase.GetDbConnection())
            {
                StringBuilder msg     = new StringBuilder();
                var           dbLogin = conn.Table <Login>();
                int           a       = 1;
                foreach (var login in dbLogin)
                {
                    if (suser.Text == login.LoginUser && smima.Password == login.Mima)
                    {
                        a = 0;
                        break;
                    }
                    if (suser.Text != login.LoginUser || smima.Password != login.Mima)
                    {
                        a = 1;
                    }
                    //if (smima.Password != login.Mima)
                    //{
                    //    a = 2;
                    //}
                }
                if (a == 0)
                {
                    Frame.Navigate(typeof(NavigationFace));
                }
                if (a == 1)
                {
                    msg.AppendLine($"账户或密码错误\n请重新输入");
                    await new MessageDialog(msg.ToString()).ShowAsync();
                }

                //if (a == 2)
                //{
                //    await new MessageDialog(msg.ToString()).ShowAsync();
                //    msg.AppendLine($"密码错误");
                //    await new MessageDialog(msg.ToString()).ShowAsync();
                //}
            }
        }