using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using DBFactory; namespace wcfControlMonitorClient { /// /// Creator:Richard.liu /// 修改当前用户密码 /// public partial class FrmPassword : Form { private static FrmPassword _formInstance; public static FrmPassword FormInstance { get { if (_formInstance == null) { _formInstance = new FrmPassword(); } return _formInstance; } set { _formInstance = value; } } DBOperator dbo =CStaticClass.dbo; public FrmPassword() { InitializeComponent(); _formInstance=this; } private void button2_Click(object sender, EventArgs e) { this.Close(); } private void FrmPassword_Load(object sender, EventArgs e) { DataView dv = dbo.ExceSQL("select * from t_base_users where f_userid ='"+CStaticClass.UserID+"'").Tables[0].DefaultView; if (dv.Count > 0) { this.lblUserID.Text = dv[0]["f_userid"].ToString(); this.lblUserName.Text = dv[0]["f_username"].ToString(); } } private void button1_Click(object sender, EventArgs e) { if (MessageBox.Show("您确认要保存您的登录密码吗?", "操作提示:", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK) { return; } if (this.tbPassword.Text.Trim()=="") { MessageBox.Show("旧密码不允许是空值!", "误操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.tbPassword.Focus(); return; } if (this.tbPassword1.Text.Trim() == "") { MessageBox.Show("新密码不允许是空值!", "误操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.tbPassword1.Focus(); return; } if (this.tbPassword2.Text.Trim() == "") { MessageBox.Show("确认密码不允许是空值!", "误操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.tbPassword2.Focus(); return; } if (this.tbPassword1.Text.Trim() != this.tbPassword2.Text.Trim()) { MessageBox.Show("新密码和确认密码不一致!", "误操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.tbPassword2.Focus(); return; } DataView dv = dbo.ExceSQL("select * from t_base_users where f_userid ='" + CStaticClass.UserID + "' and f_password ='"+this.tbPassword.Text.Trim() +"'").Tables[0].DefaultView; if (dv.Count <= 0) { MessageBox.Show("旧密码不正确!", "误操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.tbPassword.Focus(); return; } dbo.ExceSQL("update t_base_users set f_password='" + this.tbPassword2.Text.Trim() + "' where f_userid ='" + CStaticClass.UserID + "'"); MessageBox.Show("密码修改成功!", "操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Information); CommonClassLib.CCarryConvert.WriteDarkCasket("Login", "UserID:" + CStaticClass.UserID + "的操作日志", "点击【确认】按钮", "修改当前用户密码", ""); this.Close(); } private void FrmPassword_FormClosing(object sender, FormClosingEventArgs e) { _formInstance = null; } } }