コード例 #1
0
ファイル: FrmLogin.cs プロジェクト: seezeef/YS_ERP
 public FrmLogin(FrmMain caller)
 {
     _mainWin = caller;
     InitializeComponent();
 }
コード例 #2
0
ファイル: FrmLogin.cs プロジェクト: seezeef/YS_ERP
        /// <summary>
        /// 登录验证
        /// </summary>
        private void login()
        {
            this.Cursor = Cursors.WaitCursor;
            string strErrorlog = string.Empty;
            string _errorLog   = string.Empty;

            try
            {
                BUser         buser = new BUser();
                BaseUserTable tuser = new BaseUserTable();
                if (string.IsNullOrEmpty(this.txtLoginUserCode.Text.Trim()))
                {
                    strErrorlog = "登录名不能为空!";
                    this.txtLoginUserCode.Focus();
                    this.txtLoginUserCode.Select();
                    MessageBox.Show(strErrorlog, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Cursor = Cursors.Default;
                    return;
                }
                tuser = buser.GetModel(CConvert.ToString(cboCompany.SelectedValue) + this.txtLoginUserCode.Text.Trim(), CConvert.ToString(cboCompany.SelectedValue));
                //用户名验证
                if (null == tuser)
                {
                    strErrorlog = "登录名不存在或密码错误!";
                    _errorLog   = "登录名不存在!";
                    this.txtLoginUserCode.Focus();
                }
                //公司验证
                else if (tuser.COMPANY_CODE != CConvert.ToString(cboCompany.SelectedValue))
                {
                    strErrorlog = "登录名不存在或密码错误!";
                    _errorLog   = "公司与登录名不符合!";
                    this.txtLoginUserCode.Focus();
                }
                else
                {
                    //密码验证
                    if (DESEncrypt.Encrypt(this.txtLoginPassword.Text.Trim()) != tuser.PASSWORD)
                    {
                        strErrorlog = "登录名不存在或密码错误!";
                        _errorLog   = "密码错误!";
                        this.txtLoginPassword.Focus();
                    }
                }
                if (!string.IsNullOrEmpty(strErrorlog))
                {
                    MessageBox.Show(strErrorlog, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    strErrorlog += "  " + this.txtLoginUserCode.Text.Trim();
                }
                else
                {
                    if (null != _mainWin)
                    {
                        _mainWin.Die();
                        if (_mainWin.IsHandleCreated)
                        {
                            this.Hide();
                            return;
                        }
                    }

                    FrmMain mainForm = new FrmMain(tuser);
                    this.Hide();
                    mainForm.Show();
                    _mainWin  = mainForm;
                    _errorLog = "登录成功!";
                }
                //new BBaseLogs().Info(UserConstants.LOG_MODE_LOGIN, strErrorlog, tuser.USERID);
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); //
                Logger.Error("数据库连接失败!", err);
                this.Cursor = Cursors.Default;
                ShowDBConfig();
            }
            this.Cursor = Cursors.Default;
        }