123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Linq;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using DevExpress.XtraEditors;
- using ProjectBase.Util;
- using SIMDP.BLL;
- using System.Collections;
- using ProjectBase.Data.Encrypt;
- using ProjectBase.Data.Logs;
- using SIMDP.Model;
- using ProjectBase.Data.BaseDAL;
- namespace SIMDP.View
- {
- public partial class FormChangePassWord : DevExpress.XtraEditors.XtraForm
- {
- //BlAuthoryUser blUser = new BlAuthoryUser();
- public FormChangePassWord()
- {
- InitializeComponent();
- InitControls();
- }
- private void InitControls()
- {
- if (!string.IsNullOrEmpty(SysEnvironment.CurrentLoginID))
- {
- this.txt_Account.Text = SysEnvironment.CurrentLoginID;
- }
- //if (string.IsNullOrEmpty(SysEnvironment.passWordMD5))
- //{
- // this.txt_OldPassWord.Text = "000000";
- //}
- }
- private void btn_Cancel_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void btn_Rest_Click(object sender, EventArgs e)
- {
- if (DevExpress.XtraEditors.XtraMessageBox.Show("您确定要重置密码吗?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
- {
- return;
- }
- if (string.IsNullOrEmpty(txt_Account.Text))
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("请输入账号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- try
- {
- MoAuthoryUser user = BLLFactory<BlAuthoryUser>.Instance.FindByID(txt_Account.Text);
- if (user == null)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("该账号不存在,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- Hashtable hash = new Hashtable();
- hash.Add("login_passwd", EncodeHelper.EncryptString("000000"));
- bool flag = BLLFactory<BlAuthoryUser>.Instance.Update(txt_Account.Text, hash, "authory_user", null);
- if (flag)
- {
- if (SysEnvironment.CurrentLoginID == null)
- {
- MoLogLogIn moLogIn = new MoLogLogIn
- {
- Account = user.LoginAccount,
- Name = user.UserName,
- GroupId = user.GroupId,
- Description = "用户重置登录密码!",
- Ip = SysEnvironment.Ip,
- Mac = SysEnvironment.Mac,
- Time = DateTime.Now
- };
- BLLFactory<BlLogLogIn>.Instance.Insert(moLogIn);
- }
- else
- {
- MoLogLogIn moLogIn = new MoLogLogIn
- {
- Account = SysEnvironment.CurrentLoginID,
- Name = SysEnvironment.CurrentLoginName,
- GroupId = SysEnvironment.CurrentLoginGroupId,
- Description = SysEnvironment.CurrentLoginName + "重置用户【" + user.UserName + "】的登录密码!",
- Ip = SysEnvironment.Ip,
- Mac = SysEnvironment.Mac,
- Time = DateTime.Now
- };
- BLLFactory<BlLogLogIn>.Instance.Insert(moLogIn);
- }
- DevExpress.XtraEditors.XtraMessageBox.Show("重置密码成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.DialogResult = DialogResult.OK;
- this.Close();
- }
- else
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("重置密码失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- catch (Exception ex)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("重置密码失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- LogHelper.log.Error(string.Format("修改数据库authory_user出现错误:{0}", ex.ToString()));
- }
- }
- private void btn_Ok_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(txt_Account.Text))
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("请输入账号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (string.IsNullOrEmpty(txt_OldPassWord.Text))
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("请输入原密码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (string.IsNullOrEmpty(txt_NewPassWord.Text))
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("请输入新密码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (string.IsNullOrEmpty(txt_ConfirmPassWord.Text))
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("请输入确认新密码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (txt_OldPassWord.Text == txt_NewPassWord.Text)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("输入的原密码与新密码相同,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (txt_ConfirmPassWord.Text != txt_NewPassWord.Text)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("确认新密码与新密码不一致,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- try
- {
- MoAuthoryUser user = BLLFactory<BlAuthoryUser>.Instance.FindByID(txt_Account.Text);
- if (user == null)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("该账号不存在,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (EncodeHelper.DecryptString(user.LoginPasswd,true) != txt_OldPassWord.Text)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("原密码不正确,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- Hashtable hash = new Hashtable();
- hash.Add("login_passwd", EncodeHelper.EncryptString(txt_ConfirmPassWord.Text));
- bool flag = BLLFactory<BlAuthoryUser>.Instance.Update(txt_Account.Text, hash, "authory_user", null);
- if (flag)
- {
- if (SysEnvironment.CurrentLoginID == null)
- {
- MoLogLogIn moLogIn = new MoLogLogIn
- {
- Account = user.LoginAccount,
- Name = user.UserName,
- GroupId = user.GroupId,
- Description = "用户修改登录密码!",
- Ip = SysEnvironment.Ip,
- Mac = SysEnvironment.Mac,
- Time = DateTime.Now
- };
- BLLFactory<BlLogLogIn>.Instance.Insert(moLogIn);
- }
- else
- {
- MoLogLogIn moLogIn = new MoLogLogIn
- {
- Account = SysEnvironment.CurrentLoginID,
- Name = SysEnvironment.CurrentLoginName,
- GroupId = SysEnvironment.CurrentLoginGroupId,
- Description = SysEnvironment.CurrentLoginName + "修改用户【" + user.UserName + "】的登录密码!",
- Ip = SysEnvironment.Ip,
- Mac = SysEnvironment.Mac,
- Time = DateTime.Now
- };
- BLLFactory<BlLogLogIn>.Instance.Insert(moLogIn);
- }
- DevExpress.XtraEditors.XtraMessageBox.Show("修改密码成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.DialogResult = DialogResult.OK;
- this.Close();
- }
- else
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("修改密码失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- catch (Exception ex)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show("修改密码失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- LogHelper.log.Error(string.Format("修改数据库authory_user出现错误:{0}", ex.ToString()));
- }
- }
- }
- }
|