private void btnLogin_Click(object sender, EventArgs e) { try { if (txtOperCode.Text == "") { MessageHelper.ShowError("请输入人员编号!"); txtOperCode.Focus(); return; } string operCode = txtOperCode.Text; string password = EncryptHelper.Encrypt(txtPassword.Text); using (PowerEntities db = EntitiesFactory.CreatePowerInstance()) { var oper = OperController.CheckUser(db, operCode, password); if (oper == null) { MessageHelper.ShowError("错误的用户名或密码,登录失败!"); txtOperCode.Focus(); txtOperCode.SelectAll(); } else { this.DialogResult = DialogResult.OK; GlobalVar.InitGlobalVar(db, oper); } } } catch (Exception ex) { MessageHelper.ShowError(ex); } }
public void ModifyPassword(TS_OPERATOR oper) { PowerEntities db = EntitiesFactory.CreatePowerInstance(); OperController.AddOrModify(db, oper); EntitiesFactory.SaveDb(db); }
public TS_OPERATOR Login(string operCode, string password) { PowerEntities db = EntitiesFactory.CreatePowerInstance(); var oper = OperController.Login(db, operCode, password); // if (oper != null) oper.State = LoginState.Online.ToString(); EntitiesFactory.SaveDb(db); return(oper); }
public static void InitGlobalVar(PowerEntities db, TS_OPERATOR oper) { Oper = oper; DataStateStringList = Enum.GetNames(typeof(DataState)).ToList(); DeptList = DeptController.GetList(db); RoleList = RoleController.GetList(db); MenuList = MenuController.GetList(db); PortalList = PortalControler.GetList(db); OperList = OperController.GetList(db); OperRoleList = OperRoleController.GetList(db); }
private void btnLogin_Click(object sender, EventArgs e) { try { if (txtOperCode.Text == "") { MessageHelper.ShowError("请输入人员编号!"); txtOperCode.Focus(); return; } TS_OPERATOR oper = new TS_OPERATOR(); string operCode = txtOperCode.Text; string password = EncryptHelper.Encrypt(txtPassword.Text); using (PowerEntities powerdb = EntitiesFactory.CreatePowerInstance()) { oper = OperController.Login(powerdb, operCode, password); if (oper == null) { MessageHelper.ShowError("错误的用户名或密码,登录失败!"); txtOperCode.Focus(); txtOperCode.SelectAll(); return; } this.DialogResult = DialogResult.OK; //EntitiesFactory.SaveDb(powerdb); GlobalVar.Oper = oper; GlobalVar.PowerMenuList = PowerController.GetPowerMenuList(powerdb, GlobalVar.PortalCode, oper.OperCode); GlobalVar.NotifytypeList = PowerController.GetNotiFyTypeList(powerdb, GlobalVar.PortalCode, oper.OperCode); GlobalBuffer.FactoryCode = GlobalVar.Oper.DeptCode; } using (SpareEntities wmsdb = EntitiesFactory.CreateSpareInstance()) { OperLogController.AddLog(wmsdb, LogType.Login, oper.OperName, operCode, "登录成功"); EntitiesFactory.SaveDb(wmsdb); GlobalVar.InitGlobalVar(wmsdb, GlobalVar.Oper); } } catch (WmsException ex) { MessageHelper.ShowInfo(ex.ToString()); } catch (Exception ex) { var inner = ex.InnerException; MessageHelper.ShowError((string.IsNullOrEmpty(inner?.Message)) ? ex : inner); } }
private void btnModify_Click(object sender, EventArgs e) { if (txtOldPwd.Text.Trim() == string.Empty) { MessageHelper.ShowInfo("原密码不能为空"); return; } if (txtNewPwd.Text.Trim() == string.Empty) { MessageHelper.ShowInfo("新密码不能为空"); return; } if (txtNewPwd.Text.Length < 6 || txtNewPwd.Text.Length > 20) { MessageHelper.ShowInfo("新密码长度应该在6到20位之间"); return; } if (txtNewPwd.Text != txtNewPwd2.Text) { MessageHelper.ShowInfo("两次输入的新密码不一致,请重新输入"); return; } string enOldPwd = EncryptHelper.Encrypt(txtOldPwd.Text); if (enOldPwd != GlobalVar.Oper.OperPassword) { MessageHelper.ShowInfo("原密码输入错误"); return; } if (enOldPwd == txtNewPwd.Text) { MessageHelper.ShowInfo("新密码不能与原密码相同"); return; } string enNewPwd = EncryptHelper.Encrypt(txtNewPwd.Text); GlobalVar.Oper.OperPassword = enNewPwd; using (PowerEntities db = EntitiesFactory.CreatePowerInstance()) { var oper_B = new TS_OPERATOR(); oper_B.OperCode = GlobalVar.Oper.OperCode; oper_B.OperName = GlobalVar.Oper.OperName; oper_B.OperPassword = GlobalVar.Oper.OperPassword; OperController.AddOrModify(db, oper_B); MessageHelper.ShowInfo("密码修改成功"); EntitiesFactory.SaveDb(db); } Close(); }