Example #1
0
 public bool Register(string userName, string psw)
 {
     if (userName != "" && psw != "")
     {
         using (var con = new UserEntities())
         {
             Login ad = new Login()
             {
                 UserName = userName,
                 Password = psw
             };
             try
             {
                 con.Login.Add(ad);
                 con.SaveChanges();
                 return(true);
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message + "添加失败!");
                 return(false);
             }
         }
     }
     else
     {
         MessageBox.Show("所填内容不能为空!");
         return(false);
     }
 }
Example #2
0
        public List <string> FriendList(string userName)
        {
            List <string> friend = new List <string>();

            using (var con = new UserEntities())
            {
                var q = from t in con.Friend
                        where t.Uname == userName
                        select t;
                try
                {
                    if (q.Count() != 0)
                    {
                        foreach (var v in q)
                        {
                            friend.Add(v.Fname);
                        }
                    }
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message);
                }
                return(friend);
            }
        }
Example #3
0
 public void MessageOk(string userName, int age1, string sex1, string country1)
 {
     using (var con = new UserEntities())
     {
         var q = from t in con.Login
                 where t.UserName == userName
                 select t;
         try
         {
             if (q.Count() != 0)
             {
                 foreach (var v in q)
                 {
                     v.age     = age1;
                     v.sex     = sex1;
                     v.country = country1;
                 }
                 con.SaveChanges();  //将更改后的用户数据库进行保存
             }
         }
         catch (Exception ee)
         {
             MessageBox.Show(ee.Message);
             return;
         }
     }
 }
Example #4
0
 public void PerMessage(string userName, ref int age1, ref string sex1, ref int price1, ref string country1)
 {
     using (var con = new UserEntities())
     {
         var q = from t in con.Login
                 where t.UserName == userName
                 select t;
         try
         {
             if (q.Count() != 0)
             {
                 foreach (var v in q)
                 {
                     age1     = v.age;
                     sex1     = v.sex.ToString();
                     country1 = v.country.ToString();
                     price1   = v.Price;
                 }
             }
         }
         catch (Exception ee)
         {
             MessageBox.Show(ee.Message);
             return;
         }
     }
 }
Example #5
0
 public static void fail(string userName)
 {
     using (var con = new UserEntities())
     {
         var q = from t in con.Login
                 where t.UserName == userName
                 select t;
         try
         {
             if (q.Count() != 0)
             {
                 foreach (var v in q)
                 {
                     v.Price -= 10;
                 }
                 con.SaveChanges();  //将更改后的用户数据库进行保存
             }
         }
         catch (Exception ee)
         {
             MessageBox.Show(ee.Message);
             return;
         }
     }
 }
Example #6
0
 public bool Login(string userName, string psw)
 {
     foreach (var user in CC.Users)
     {
         if (userName == user.UserName)
         {
             MessageBox.Show("您已登录!");
             return(false);
         }
     }
     using (var con = new UserEntities())
     {
         var q1 = from t in con.Login
                  where t.UserName.Equals(userName) == true && t.Password.Equals(psw) == true
                  select t;
         if (q1.Count() != 0)
         {
             return(true);
         }
         else
         {
             MessageBox.Show("登录失败\n输入有错误!或所填内容有空!");
             return(false);
         }
     }
 }