/// <summary>
        ///
        /// </summary>
        private bool CheckPassword()
        {
            var password = txt_Password.Text.Trim();

            if (password == "")
            {
                MsgBox.ShowInfo("旧密码不能为空");
                return(false);
            }
            var dictpass = new EmployeeDao().GetModel(Program.CurrentEmployee.EmployeeID);

            if (Salt.Encrypt(password).Equals(dictpass.Password))
            {
                if (txt_NewPassword.Text.Trim() == "")
                {
                    MsgBox.ShowInfo("新密码不能为空");
                    return(false);
                }
                else if (txt_NewPassword.Text.Trim() != txt_NewPassword2.Text.Trim())
                {
                    MsgBox.ShowInfo("两次输入的密码不相同,请重新输入");
                    return(false);
                }
                return(true);
            }
            else
            {
                MsgBox.ShowInfo("原密码不正确");
                return(false);
            }
            return(true);
        }
Beispiel #2
0
 /// <summary>
 /// 确认保存
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void btnOK_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(oldPassword))
     {
         if (string.IsNullOrEmpty(ValueConvert.ToString(textOld.EditValue)))
         {
             MessageBox.Show("请输入原密码");
             return;
         }
         string old = Salt.Encrypt(ValueConvert.ToString(textOld.EditValue));
         if (old != oldPassword)
         {
             MessageBox.Show("原密码错误!");
             return;
         }
         string newPassword1 = ValueConvert.ToString(textNow1.EditValue);
         string newPassword2 = ValueConvert.ToString(textNow2.EditValue);
         if (newPassword1 != newPassword2)
         {
             MessageBox.Show("两次输入新密码需相同!");
             return;
         }
         string newPassword = Salt.Encrypt(newPassword1);
         if (new EmployeeDao().ChangePassword(newPassword, curData.EmployeeID))
         {
             MessageBox.Show("密码修改成功!");
             this.DialogResult = DialogResult.OK;
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// 确认保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void btnOK_Click(object sender, EventArgs e)
        {
            if (textEmployeeName.EditValue == null)
            {
                MessageBox.Show("请输入姓名");
                return;
            }
            if (textEmployeeCode.EditValue == null)
            {
                MessageBox.Show("请输入工号");
                return;
            }
            Employee model = new Employee
            {
                EmployeeCode      = textEmployeeCode.Text.Trim(),
                EmployeeName      = ValueConvert.ToString(textEmployeeName.EditValue),
                DepartmentID      = ValueConvert.ToNullableInt32(clDepartmentID.EditValue),
                Email             = textEmail.Text.Trim(),
                IdentityNo        = textIdentityNo.Text.Trim(),
                DimissionDate     = ValueConvert.ToNullableDateTime(dateDimissionDate.EditValue),
                QQ                = ValueConvert.ToString(textQQ.EditValue),
                EntryDate         = ValueConvert.ToNullableDateTime(dateEntryDate.EditValue),
                Sex               = comSex.Text.Trim(),
                Birthday          = ValueConvert.ToNullableDateTime(dateBirthday.EditValue),
                Degree            = comDegree.Text.Trim(),
                Cellphone         = ValueConvert.ToString(textCellphone.EditValue),
                Note              = ValueConvert.ToString(memoNote.EditValue),
                DriverLicense     = ValueConvert.ToString(textDriverLicense.EditValue),
                FileNumber        = ValueConvert.ToString(textFileNumber.EditValue),
                DriverLicenseType = comDriverLicenseType.Text.Trim(),
                OperateID         = Program.CurrentEmployee.EmployeeID,
                OperateTime       = DateTime.Now
            };

            if (!string.IsNullOrEmpty(comStatus.SelectedIndex.ToString()))
            {
                model.Status = comStatus.SelectedIndex;
            }
            bool result = false;

            if (FormState == DS.MSClient.FormState.Modify)
            {
                model.EmployeeID = curData.EmployeeID;
                result           = new EmployeeDao().Update(model);
            }
            else
            {
                model.EmployeeID = new CommonDAO().GetIntUniqueNumber("t_employee");
                model.Password   = Salt.Encrypt("123");
                result           = new EmployeeDao().Add(model);
            }
            if (result)
            {
                MessageBox.Show("保存成功");
                this.DialogResult = DialogResult.OK;
            }
        }
Beispiel #4
0
        /// <summary>
        ///     登陆
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                var userName = textUserName.Text = textUserName.Text.Trim();
                var password = textPassWord.Text = textPassWord.Text.Trim();
                if (userName == "" || password == "")
                {
                    MessageBox.Show("用户名或密码不能为空!");
                    return;
                }

                var user = new Employee
                {
                    EmployeeCode = userName,
                    Password     = Salt.Encrypt(password)
                };

                try
                {
                    string          sqlLogin = string.Format("select * from t_employee where EmployeeCode like '%{0}%'", ValueConvert.ToString(textUserName.EditValue));
                    List <Employee> _list    = new EmployeeDao().QueryGetList(sqlLogin);
                    if (!_list.Any())
                    {
                        MessageBox.Show("用户不存在!");
                        return;
                    }
                    else
                    {
                        Employee model = _list[0];
                        if (model.Password == user.Password) //密码验证正确
                        {
                            Program.CurrentEmployee = model; //当前用户

                            Ini.WriteItem("Login", "UserName", textUserName.Text.Trim());
                            Program.MFormMain.Init();
                            Hide();
                            Program.MFormMain.Show();
                        }
                        else
                        {
                            MessageBox.Show("密码错误!");
                            return;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
 private void ButtonOK_Click(object sender, EventArgs e)
 {
     if (CheckPassword())
     {
         string password = Program.CurrentEmployee.Password;
         Program.CurrentEmployee.Password = Salt.Encrypt(txt_NewPassword.Text.Trim());
         if (new EmployeeDao().UpdatePWD(Program.CurrentEmployee))
         {
             MsgBox.ShowInfo("密码修改成功");
             this.DialogResult = DialogResult.Yes;
             this.Close();
         }
         else
         {
             MsgBox.ShowInfo("密码修改失败");
         }
     }
 }
Beispiel #6
0
        /// <summary>
        ///     登陆
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                if (new CommonDAO().GetServerTime().ToString("yy-MM-dd") != DateTime.Now.ToString("yy-MM-dd"))
                {
                    MsgBox.ShowWarn("请设置本地电脑时间!");
                    return;
                }
                var userName = txtUserName.Text = txtUserName.Text.Trim();
                var password = txtPassword.Text = txtPassword.Text.Trim();
                if (userName == "" || password == "")
                {
                    MsgBox.ShowInfo("用户名、密码不能为空!");
                    return;
                }
                LockControl(true);
                //_waitForm = new WaitDialogForm("请稍后......", "系统加载中");
                ShowTip("系统正在加载,请稍后……", "系统加载中");
                var i = 5;
                for (var j = 1; j < i - 1; j++)
                {
                    Thread.Sleep(10);
                    //_waitForm.SetCaption("执行进度(" + j + "/" + i + ")");
                    ShowTip("加载进度(" + j + "/" + i + ")");
                }
                if (!ThreadExcuteNoShade(() =>
                {
                    var user = new Employee
                    {
                        EmployeeCode = userName,
                        Password = Salt.Encrypt(password)
                    };
                    _checkLoginEmployee = new EmployeeDao().Exist(user);
                    Program.CurrentEmployee = _checkLoginEmployee;
                }))
                {
                    return;
                }

                if (_checkLoginEmployee == null)
                {
                    MsgBox.ShowInfo("用户名或密码不正确\r\n\r\n或该账户禁止登陆系统!\r\n\r\n如有疑问请联系系统管理员!");
                    //_waitForm.Close();
                    ShowTip();
                    return;
                }
                Program._employeeRight     = new EmployeeRightDao().GetList(_checkLoginEmployee.EmployeeID);
                Program._employeeroleRight = new RoleRightDao().GetRightIDByEmployeeID(_checkLoginEmployee.EmployeeID);
                if (Program._employeeRight == null)
                {
                    Program._employeeRight = new List <EmployeeRight>();
                }
                if (Program._employeeroleRight == null)
                {
                    Program._employeeroleRight = new List <Right>();
                }
                PreDownloadLargeData();
                Thread.Sleep(10);
                //_waitForm.SetCaption("初始化主界面(5" + "/" + i + ")");
                ShowTip("初始化主界面(5" + "/" + i + ")");
                Program.MFormMain.Init();

                Hide();
                Ini.WriteItem("Login", "UserName", txtUserName.Text.Trim());
                Program.MFormMain.Show();
            }
            catch (Exception ex)
            {
                //_waitForm.Close();
            }
            finally
            {
                ShowTip();
                LockControl(false);
            }
        }