private void pbxLogin_Click(object sender, EventArgs e) { //登陆 if (!IsNullJudge()) { return; } string userName = wtbUsername.Text.Trim(); string userPass = Tool.MD5(wtbPassword.Text.Trim()); int roleId = 1; SetMessageShow(true); mUser umodel = ilogin.LoginUserInfo(userName, userPass, 1); if (umodel.PassWord == userPass && umodel.UserName == userName) { if (umodel.UserRoleId == roleId) { UserInfo.RoleId = umodel.UserRoleId; FrmMain frmmain = new FrmMain(umodel.UserName); frmmain.Show(); Hide(); } else { lblMessage.Text = "此账号没有权限登录审批版本"; } } else { lblMessage.Text = "用户名或者密码错误!"; } }
public ActionResult UserLogin(UserViewModel model) { mUser umodel = new mUser(); ResultBase result = new ResultBase(); try { model.UserName = HttpUtility.UrlDecode(model.UserName); model.UserPass = Tool.MD5(HttpUtility.UrlDecode(model.UserPass)); int roleId = 2; umodel = ilogin.LoginUserInfo(model.UserName, model.UserPass, roleId); if (umodel.PassWord == model.UserPass && umodel.UserName == model.UserName) { if (umodel.UserRoleId == 2) { HttpContext.Session["LoginUser"] = umodel; result.Msg = "登陆成功"; result.Result = ResultCode.Ok; } else { result.Msg = "此账号没有权限登录议员版本"; result.Result = ResultCode.ClientError; } } else { result.Msg = "用户名和密码错误"; result.Result = ResultCode.ClientError; } } catch (Exception ex) { result.Msg = "服务器错误"; result.Result = ResultCode.ServerError; LogHelper.Error("UserLogin-" + DateTime.Now.ToString(), ex); } return(Json(result)); }