public static bool CheckLogin(LoginModel lm) { string sql = "select count(*) from UserProfile where username='******' and password='******'"; int reval =Convert.ToInt16( SqlHelper.ExecuteScalarText(sql, null)); if (reval > 0) { return true; } else return false; }
public static bool Login(LoginModel userInfo,out string errorMsg) { errorMsg = ""; LoginModel loginInfo = new LoginModel() { UserName = userInfo.UserName, Password = SecurityHelper.Encrypt(userInfo.Password) }; //验证登录信息 bool loginstate; try { return loginstate = UserProfileData.CheckLogin(loginInfo); } catch (Exception ex) { errorMsg ="用户登录出错"+ex.ToString(); return false; } }
public ActionResult Login(LoginModel userInfo) { string errorMsg = ""; bool success = UserHelper.Login(userInfo,out errorMsg); return Json(new { success = success, msg = errorMsg }, JsonRequestBehavior.AllowGet); }