コード例 #1
0
ファイル: Frm_EditPwd.cs プロジェクト: sanlone/xyht
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_Save_Click(object sender, EventArgs e)
        {
            string pwd_old  = textBox_Pwd_Old.Text;
            string pwd_new  = textBox_Pwd_New.Text;
            string pwd_new2 = textBox_Pwd_New2.Text;

            label_Err_Pwd_Old.Text  = "";
            label_Err_Pwd_New.Text  = "";
            label_Err_Pwd_New2.Text = "";

            #region 密码验证

            if (string.IsNullOrEmpty(pwd_old))
            {
                label_Err_Pwd_Old.Text = "原密码不能为空";
                return;
            }
            label_Err_Pwd_Old.Text = "";

            if (string.IsNullOrEmpty(pwd_new))
            {
                label_Err_Pwd_New.Text = "新密码不能为空";
                return;
            }
            label_Err_Pwd_New.Text = "";

            if (pwd_new != pwd_new2)
            {
                label_Err_Pwd_New2.Text = "两次密码不一致";
                return;
            }
            label_Err_Pwd_New2.Text = "";



            pwd_old = _usersBll.GetMD5(pwd_old);

            if (pwd_old != _curUser.Password)
            {
                label_Err_Pwd_Old.Text = "原密码错误";
                return;
            }
            label_Err_Pwd_Old.Text = "";

            #endregion

            pwd_new = _usersBll.GetMD5(pwd_new);

            if (_usersBll.EditPwd(_curUser, pwd_new) > 0)
            {
                _curUser.Password = pwd_new;
                this.Dispose();
            }
            else
            {
                label_Err_Pwd_New.Text = "密码修改失败";
            }
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_Add_Click(object sender, EventArgs e)
        {
            Users model = null;

            if (_userID > 0)
            {
                //不修改用户密码
                model = _usersBll.GetModel(_userID);

                model.UserAccount  = textBox_UserAccount.Text;
                model.UserName     = textBox_UserName.Text;
                model.Sex          = radioButton_Man.Checked ? 0 : 1;
                model.Birthday     = Convert.ToDateTime(dateTimePicker__Birthday.Text);
                model.Phone        = textBox_Phone.Text;
                model.Email        = textBox_Email.Text;
                model.EmployeeID   = textBox_EmployeeID.Text;
                model.DepartmentID = 1;
                model.UserType     = CommonClass.GetUserType(Convert.ToInt32(((ListItem)comboBox_UserType.SelectedItem).Value));
                model.Remark       = textBox_Remark.Text;

                //修改
                if (_usersBll.EditModel(model) > 0)
                {
                    MessageBox.Show("修改成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.None);
                }
                else
                {
                    MessageBox.Show("修改失败", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                model = new Users();

                model.UserAccount = textBox_UserAccount.Text;
                //加密
                model.Password     = _usersBll.GetMD5(textBox_Password.Text);
                model.UserName     = textBox_UserName.Text;
                model.Sex          = radioButton_Man.Checked ? 0 : 1;
                model.Birthday     = Convert.ToDateTime(dateTimePicker__Birthday.Text);
                model.Phone        = textBox_Phone.Text;
                model.Email        = textBox_Email.Text;
                model.EmployeeID   = textBox_EmployeeID.Text;
                model.DepartmentID = 1;
                model.UserType     = CommonClass.GetUserType(Convert.ToInt32(((ListItem)comboBox_UserType.SelectedItem).Value));
                //查询服务器时间
                model.EntryDate = _usersBll.GetDBTime();
                model.Remark    = textBox_Remark.Text;

                //添加
                if (_usersBll.AddModel(model) > 0)
                {
                    MessageBox.Show("添加成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.None);
                }
                else
                {
                    MessageBox.Show("添加失败", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #3
0
ファイル: Frm_Login.cs プロジェクト: sanlone/xyht
        /// <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();
        }
コード例 #4
0
ファイル: UC_UserManage.cs プロジェクト: sanlone/xyht
        /// <summary>
        /// 重置密码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridViewButtonColumn_Reset_Click(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex > -1)
            {
                int userID = Convert.ToInt32(dataGridView_Users.Rows[e.RowIndex].Cells["UserID"].Value);

                Users model = _userBll.GetModel(userID);

                model.Password = _userBll.GetMD5("123456");

                if (_userBll.EditModel(model) > 0)
                {
                    MessageBox.Show("操作成功", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.None);
                }
                else
                {
                    MessageBox.Show("操作失败", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }