Beispiel #1
0
        void frmMain_UserLogout(object sender, EventArgs e)
        {
            Frm_Main frmMain = (Frm_Main)sender;

            frmMain.Dispose();
            this.Show();
        }
Beispiel #2
0
        /// <summary>
        /// 登录事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_Login_Click(object sender, EventArgs e)
        {
            //登录
            string account = textBox_Account.Text.Trim();
            string pwd     = textBox_PassWord.Text;

            if (account.Length < 2)
            {
                label_AccountErr.Text = "账号错误";
                label_PwdErr.Text     = "";
                return;
            }

            if (string.IsNullOrEmpty(pwd))
            {
                label_AccountErr.Text = "";
                label_PwdErr.Text     = "密码不能为空";
                return;
            }

            Users curUser = _usersBll.GetModel(account);

            if (curUser == null || curUser.UserAccount == null)
            {
                label_AccountErr.Text = "账号错误";
                label_PwdErr.Text     = "";
                return;
            }

            pwd = _usersBll.GetMD5(textBox_PassWord.Text);
            //对比加密密码
            if (pwd.Length != curUser.Password.Length || !pwd.Equals(curUser.Password))
            {
                label_AccountErr.Text = "";
                label_PwdErr.Text     = "密码错误";
                return;
            }

            if (!GetUserRoleMenus(curUser.UserID))
            {
                MessageBox.Show("用户状态有误,请联系管理员", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            this.Hide();

            Frm_Main frmMain = new Frm_Main(curUser, _dicRoleMenus);

            frmMain.UserLogout += new EventHandler(frmMain_UserLogout);
            frmMain.Show();
        }