public JsonResult ResetPassword(FormCollection fc) { var json = new JsonData(); try { //获取参数 var id = Convert.ToInt32(fc["id"].Trim()); //默认密码 var defaultPwd = CEncryptHelper.DesEncrypt(DefaultPassword); if (dalEmployee.UpdatePassword(id, defaultPwd) > 0) { json.Status = true; json.Msg = "重置成功!"; } else { json.Status = false; json.Msg = "重置失败!"; } } catch (Exception ex) { json.Status = false; json.Msg = "重置失败!Error:" + ex.Message; } return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult Create(FormCollection fc) { var json = new JsonData(); try { //获取参数 var account = fc["emp_account"].Trim(); var name = fc["emp_name"].Trim(); var desc = fc["emp_desc"].Trim(); if (!dalEmployee.GetEmployeeAccountIsExists(0, account)) { json.Status = false; json.Msg = "员工账号不能重覆!"; } else { //默认密码 var pwd = DefaultPassword; pwd = CEncryptHelper.DesEncrypt(pwd); if (dalEmployee.Create(account, name, pwd, desc) > 0) { json.Status = true; json.Msg = "新增成功!"; } else { json.Status = false; json.Msg = "新增失败!"; } } } catch (Exception ex) { json.Status = false; json.Msg = "新增失败!Error:" + ex.Message; } return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult Login(FormCollection fc) { var json = new JsonData(); try { string userName = fc["username"].Trim(); string userPwd = CEncryptHelper.DesEncrypt(fc["userpwd"].Trim()); //获取登录对象 var loginEmployee = ComHelper.ReaderToModel <ModEmployee>(dalAuth.GetEmployeeData(userName, userPwd)); if (loginEmployee != null) //登录成功 { //判断用户是否重复登录 Authentication.SingleUserCheck(userName); //此语句是为了解决无任何权限的用户登录后不按退出按钮而再次跳转进入登录页面以登录其它有权限的用户后依然显示无权限 this.Session.RemoveAll(); //设置登录用户票据信息 Authentication.RedirectFromLoginPage(userName, loginEmployee.Id + "#" + userName, false); //存储登录用户对象到session Authentication.WebAccount = loginEmployee; json.Status = true; json.Msg = "登录成功!"; } else { json.Status = false; json.Msg = "登录失败,用户名或密码错误!"; } } catch (Exception ex) { json.Status = false; json.Msg = "登录失败,Error:" + ex.Message; } return(Json(json, JsonRequestBehavior.AllowGet)); }
public JsonResult UpdatePassword(FormCollection fc) { var json = new JsonData(); try { //获取当前登录用户ID var employeeId = Authentication.WebAccount.Id; var pwd = CEncryptHelper.DesEncrypt(fc["pwd"].Trim()); var newPwd = CEncryptHelper.DesEncrypt(fc["pwdNew"].Trim()); if (dalEmployee.CheckOldPwd(pwd, employeeId)) { if (dalEmployee.UpdatePassword(employeeId, newPwd) > 0) { json.Status = true; json.Msg = "修改成功!"; } else { json.Status = false; json.Msg = "修改失败!"; } } else { json.Status = false; json.Msg = "修改失败,原密码错误!"; } } catch (Exception ex) { json.Status = false; json.Msg = "修改失败!Error:" + ex.Message; } return(Json(json)); }