Пример #1
0
        /// <summary>
        /// 登录验证
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dmButton1_Click(object sender, EventArgs e)
        {
            if (!IsConnection())
            {
                return;
            }
            //验证
            //获取密码和账号值
            string loginname = tbLoginName.Text.Trim();
            string password  = tbPassword.Text.Trim();

            //首先判断账号是否为空
            if (loginname == string.Empty)
            {
                MessageBox.Show("账号不能为空", "提示", MessageBoxButtons.OK);
            }
            else
            {
                //判断账号是否存在,根据账号查询数据
                if (!sll.IsExist(loginname))
                {
                    MessageBox.Show("账号不存在,请重新输入", "提示", MessageBoxButtons.OK);
                }
                else
                {
                    //验证密码
                    ErrorInfo error = frmFuncLib.IsValidPassword(password);
                    if (error.HasError)
                    {
                        MessageBox.Show(error.ErrorMessage, "提示", MessageBoxButtons.OK);
                    }
                    else
                    {
                        //匹配账号和密码,应对密码进行加密之后再匹配
                        bool isMatch = sll.LoginNameAndPasswordIsMatch(loginname, MD5Encrypt.GetMD5Hash(password));
                        if (isMatch)
                        {
                            GetUserInfo(loginname);
                            //显示主界面
                            frmMain main = new frmMain();
                            main.Show();
                            //隐藏登陆窗体
                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show("密码不正确,请重新输入");
                            tbPassword.Clear();
                        }
                    }
                }
            }
        }
Пример #2
0
        private void btnResetPassword_Click(object sender, EventArgs e)
        {
            //将密码重置为123456
            string resetpassword = MD5Encrypt.GetMD5Hash("admin123456");

            sl.Id        = Convert.ToInt32(dgvAccountSetting.CurrentRow.Cells[0].Value.ToString());
            sl.LoginName = dgvAccountSetting.CurrentRow.Cells[1].Value.ToString();
            sl.Password  = resetpassword;
            sl.IsLock    = Convert.ToInt32(dgvAccountSetting.CurrentRow.Cells[2].Value.ToString());

            if (sll.Update(sl) == 1)
            {
                MessageBox.Show("重置成功!", "提示", MessageBoxButtons.OK);
            }
            else
            {
                MessageBox.Show("重置失败!", "提示", MessageBoxButtons.OK);
            }
        }
Пример #3
0
        public void UpdateUserInfo(string loginname)
        {
            if (tbUserName.Text != null && cbSex.Text != null &&
                cbRoleName.Text != null && tbAge.Text != null && loginname != null)
            {
                //修改
                int result = sul.Update(GetUpdateUserInfo());
                //添加账号信息,使用默认指定密码,

                if (result != 0)
                {
                    //查询指定账号的用户Id
                    int uid = sul.GetId(loginname);
                    sl.LoginName = loginname;
                    sl.IsLock    = 1;
                    //对初始密码加密
                    string pass = MD5Encrypt.GetMD5Hash("123456admin");
                    sl.Password = pass;
                    sl.UserId   = uid;
                    if (sl != null)
                    {
                        sll.Update(sl);
                        MessageBox.Show("修改成功!", "提示", MessageBoxButtons.OK);
                        RefreshUserList();
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("修改失败!", "提示", MessageBoxButtons.OK);
                }
            }
            else
            {
                titlePromptInfo.Text    = "姓名、性别、角色、账号是必填项,不能为空!";
                titlePromptInfo.Visible = true;
            }
        }