private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { this.Invoke((MethodInvoker) delegate { lbStatus.Text = "正在登陆..."; }); //获取用户权限列表,保存登录用户信息 PaCSGlobal.FunctionDict = lp.GetFuncListByUser(verfiedUser); PaCSGlobal.LoginUserInfo = verfiedUser; //保存用户信息到注册表 PaCSGlobal.SetRegistryValue("loginName", name, ""); //初始化主界面菜单 clientMain.Init(); }
private void btnLogin_Click(object sender, EventArgs e) { try { btnLogin.Enabled = false; name = tbName.Text.Trim(); string pwd = tbPwd.Text.Trim(); if (string.IsNullOrEmpty(name)) { XtraMessageBox.Show("请输入 用户名!", "提示"); tbName.Focus(); btnLogin.Enabled = true; return; } if (string.IsNullOrEmpty(pwd)) { XtraMessageBox.Show("请输入 密码!", "提示"); tbPwd.Focus(); btnLogin.Enabled = true; return; } User user = new User();//登录人信息 user.Name = name; user.Password = pwd; verfiedUser = lp.VerifyUser(user);//验证后信息 if (!string.IsNullOrEmpty(verfiedUser.Id)) { List <string> fctList = lp.GetFactoryListByUser(verfiedUser); if (fctList.Count > 1) { SelectFactory frm = new SelectFactory(fctList); DialogResult dg = frm.ShowDialog(); if (dg == DialogResult.OK) { verfiedUser.Fct_code = frm.ReturnValue["fct_code"]; } } //获取用户权限列表,保存登录用户信息 PaCSGlobal.FunctionDict = lp.GetFuncListByUser(verfiedUser); PaCSGlobal.LoginUserInfo = verfiedUser; //保存用户信息到注册表 PaCSGlobal.SetRegistryValue("loginName", name, ""); //写入 登录日志 lp.WriteLoginLog(); this.DialogResult = DialogResult.OK; this.Close(); } else { XtraMessageBox.Show("用户名或密码错误!", "提示"); tbPwd.Text = ""; tbPwd.Focus(); btnLogin.Enabled = true; return; } } catch (Exception btnLogin_Click) { XtraMessageBox.Show(this, "System error[btnLogin_Click]: " + btnLogin_Click.Message); } }