Ejemplo n.º 1
0
        public User Login(Model.Table.User u)
        {
            String pw = u.userPassword;

            u.userId = "admin";
            //  u.userPassword = "******";
            using (DbClinet db = new DbClinet())
            {
                db.AddParameter("@userId", u.userId);
                List <Dictionary <string, object> > mv = db.Select("select * from SYS_User where userId=@userId");

                if (mv.Count > 0)
                {
                    string userPasswordTemp = mv.FirstOrDefault()["userPassword"] as string;
                    if (userPasswordTemp.Equals(u.userPassword, StringComparison.OrdinalIgnoreCase))
                    {
                        //u.lastLoginIp = mv.FirstOrDefault()["lastLoginIp"] as string;
                        u.State = 1;
                        db.AddParameter("@userId", u.userId);
                        db.AddParameter("@ip", u.lastLoginIp);
                        db.ExecuteNonQuery("update SYS_User set lastLoginTime=GETDATE(),lastLoginIp=@ip  where userId=@userId");
                    }
                    else
                    {
                        //密码错误
                        u.State = -1;
                    }
                }
                else
                {
                    u.State = -2; //不存在用户
                }
            }
            return(u);
        }
Ejemplo n.º 2
0
 public bool UpdatePassword(Model.Table.User u)
 {
     using (DbClinet db = new DbClinet())
     {
         db.AddParameter("@userPassword", u.userPassword);
         db.AddParameter("@userId", u.userId);
         db.ExecuteNonQuery("update SYS_User set userPassword=@userPassword  where userId=@userId");
         return(true);
     }
 }