private void btnLogin_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; this.SetButtonEnable(false); this.Update();//必须 this.ShowLoginInfo("正在验证用户名及密码"); bllUser.ValidateLogin(txtUser.Text, txtPwd.Text);//检查登录信息 string userID = txtUser.Text; string password = CEncoder.Encode(txtPwd.Text); /*常规加密*/ string dataSetID = cmbDataset.EditValue.ToString(); //帐套编号 string dataSetDB = GetDataSetDBName(); string DbType = GetDataDbType(); string dbName = GetDBName(); LoginUser loginUser = new LoginUser(userID, password, dataSetID, dataSetDB); loginUser.DbType = DbType; loginUser.DBName = dbName; Loginer.CurrentUser.DbType = DbType; Loginer.CurrentUser.DBName = dbName; if (_CurrentAuthorization.Login(loginUser)) //调用登录策略 { //if (chkSaveLoginInfo.Checked) this.SaveLoginInfo(); //跟据选项保存登录信息 SystemAuthentication.Current = _CurrentAuthorization; //授权成功, 保存当前授权模式 Program.MainForm = new frmMain(); //登录成功创建主窗体 Program.MainForm.InitUserInterface(new LoadStatus(lblLoadingInfo)); this.DialogResult = DialogResult.OK; //成功 this.Close(); //关闭登陆窗体 } else { this.ShowLoginInfo("登录失败,请检查用户名和密码!"); Msg.Warning("登录失败,请检查用户名和密码!"); } } catch (CustomException ex) { this.SetButtonEnable(true); this.ShowLoginInfo(ex.Message); Msg.Warning(ex.Message); } catch (Exception ex) { this.SetButtonEnable(true); this.ShowLoginInfo("登录失败,请检查用户名和密码!" + ex.Message); Msg.Warning("登录失败,请检查用户名和密码!" + ex.Message); } this.Cursor = Cursors.Default; }
private void btnLogin_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; this.SetButtonEnable(false); this.Update();//必须 this.ShowLoginInfo("正在验证用户名及密码"); bllUser.ValidateLogin(txtUser.Text, txtPwd.Text);//检查登录信息 string userID = txtUser.Text; string password = CEncoder.Encode(txtPwd.Text); /*常规加密*/ string dataSetID = txtDataset.EditValue.ToString(); //帐套编号 string dataSetDB = GetDataSetDBName(); LoginUser loginUser = new LoginUser(userID, password, dataSetID, dataSetDB); if (_CurrentAuthorization.Login(loginUser)) //调用登录策略 { if (chkSaveLoginInfo.Checked) { this.SaveLoginInfo(); //跟据选项保存登录信息 } SystemAuthentication.Current = _CurrentAuthorization; //授权成功, 保存当前授权模式 frmBoot form1 = new frmBoot(); form1.StartPosition = FormStartPosition.CenterScreen; form1.Show(); Application.DoEvents(); Program.MainForm = new frmMain(); //登录成功创建主窗体 Program.MainForm.InitUserInterface(new LoadStatus(form1.lblLoadingInfo, form1.progressBarControl1)); this.DialogResult = DialogResult.OK; //成功 this.Hide(); this.Close(); //关闭登陆窗体 while (form1.Opacity > 0) { form1.Opacity = form1.Opacity - 0.05; Application.DoEvents(); Thread.Sleep(100); } form1.Close(); } else { this.ShowLoginInfo("登录失败,请检查用户名和密码!"); Msg.Warning("登录失败,请检查用户名和密码!"); } } catch (CustomException ex) { this.SetButtonEnable(true); this.ShowLoginInfo(ex.Message); Msg.Warning(ex.Message); } catch (Exception ex) { this.SetButtonEnable(true); this.ShowLoginInfo("登录失败,请检查用户名和密码!"); Msg.Warning("登录失败,请检查用户名和密码!"); } this.Cursor = Cursors.Default; }
bool LoginAuthor(Common.LoginUser LoginUser, ILoginAuthorization login) { return(login.Login(LoginUser)); }