Esempio n. 1
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;
         }
     }
 }
Esempio n. 2
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);
     }
 }
Esempio n. 3
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;
         }
     }
 }