SCLS/SSWCS_JXDL(2019)/ControlSystem/FrmPassword.cs
2025-05-19 09:45:29 +08:00

103 lines
3.8 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 ControlSystem
{
/// <summary>
/// Creator:Richard.liu
/// 修改当前用户密码
/// </summary>
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 ").Tables[0].DefaultView;
if (dv.Count > 0)
{
//this.lblUserID.Text = dv[0]["f_userid"].ToString();
//this.lblUserName.Text = dv[0]["f_username"].ToString();
this.comboBox1.DisplayMember = "f_username";
this.comboBox1.ValueMember = "f_userid";
this.comboBox1.DataSource = dv;
}
}
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 ='" + this.comboBox1.SelectedValue.ToString() + "' 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 ='" + this.comboBox1.SelectedValue.ToString() + "'");
MessageBox.Show("密码修改成功!", "操作提示:", MessageBoxButtons.OK, MessageBoxIcon.Information);
CommonClassLib.CCarryConvert.WriteDarkCasket("Login", "UserID" + this.comboBox1.SelectedValue.ToString() + "的操作日志", "点击【确认】按钮", "修改当前用户密码", "");
this.Close();
}
}
}