frmpasswordset.cs
来自「小区物业管理:管理小区的费用、小区工作人员的编排和工资管理、小区的运作、对住户资」· CS 代码 · 共 333 行
CS
333 行
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace WindowsApplication1
{
/// <summary>
/// frmpasswordset 的摘要说明。
/// </summary>
public class frmpasswordset : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private SqlConnection objSqlConn;
private SqlDataReader objSqlDataReader;
private SqlCommand objSqlCmd;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
string username;
public frmpasswordset(String Uname)
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
username=Uname;
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmpasswordset));
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label1.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.label1.Location = new System.Drawing.Point(64, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(88, 24);
this.label1.TabIndex = 0;
this.label1.Text = "帐号";
//
// label2
//
this.label2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label2.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.label2.Location = new System.Drawing.Point(64, 64);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(88, 24);
this.label2.TabIndex = 1;
this.label2.Text = "原密码";
//
// label3
//
this.label3.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label3.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.label3.Location = new System.Drawing.Point(64, 104);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(88, 24);
this.label3.TabIndex = 2;
this.label3.Text = "新密码";
//
// label4
//
this.label4.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.label4.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.label4.Location = new System.Drawing.Point(56, 144);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(88, 24);
this.label4.TabIndex = 3;
this.label4.Text = "确认新密码";
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(16, 24);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(40, 40);
this.pictureBox1.TabIndex = 4;
this.pictureBox1.TabStop = false;
//
// textBox1
//
this.textBox1.Enabled = false;
this.textBox1.Location = new System.Drawing.Point(144, 24);
this.textBox1.Name = "textBox1";
this.textBox1.ReadOnly = true;
this.textBox1.Size = new System.Drawing.Size(120, 21);
this.textBox1.TabIndex = 5;
this.textBox1.Text = "";
//
// textBox2
//
this.textBox2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.textBox2.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.textBox2.Location = new System.Drawing.Point(144, 64);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(120, 23);
this.textBox2.TabIndex = 6;
this.textBox2.Text = "";
//
// textBox3
//
this.textBox3.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.textBox3.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.textBox3.Location = new System.Drawing.Point(144, 104);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(120, 23);
this.textBox3.TabIndex = 7;
this.textBox3.Text = "";
//
// textBox4
//
this.textBox4.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.textBox4.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.textBox4.Location = new System.Drawing.Point(144, 144);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(120, 23);
this.textBox4.TabIndex = 8;
this.textBox4.Text = "";
//
// button1
//
this.button1.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button1.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.button1.Location = new System.Drawing.Point(16, 184);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 32);
this.button1.TabIndex = 9;
this.button1.Text = "重置";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button2.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.button2.Location = new System.Drawing.Point(104, 184);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 32);
this.button2.TabIndex = 10;
this.button2.Text = "提交";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button3
//
this.button3.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button3.ForeColor = System.Drawing.SystemColors.ActiveCaption;
this.button3.Location = new System.Drawing.Point(192, 184);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(75, 32);
this.button3.TabIndex = 11;
this.button3.Text = "撤消";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// frmpasswordset
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(280, 222);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.textBox4);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.MaximumSize = new System.Drawing.Size(288, 256);
this.MinimumSize = new System.Drawing.Size(288, 256);
this.Name = "frmpasswordset";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "密码设置";
this.Load += new System.EventHandler(this.frmpasswordset_Load);
this.ResumeLayout(false);
}
#endregion
private void button1_Click(object sender, System.EventArgs e)
{
this.textBox2.Clear();
this.textBox3.Clear();
this.textBox4.Clear();
}
private void button3_Click(object sender, System.EventArgs e)
{
MessageBox.Show("尚未作出更改!","撤消");
if(true)
{
this.Close();
}
}
private void button2_Click(object sender, System.EventArgs e)
{
try
{
string Apassword="";
string Auid=this.textBox1.Text;
string path=Application.ExecutablePath;
objSqlConn=new SqlConnection ("SERVER=(local);database=atorregulate;uid=sa;password=");
objSqlConn.Open();
string str="select * from adminuser where Auid='"+Auid+"'";
objSqlCmd=new SqlCommand(str,objSqlConn);
objSqlDataReader=objSqlCmd.ExecuteReader();
bool flag=false;
objSqlDataReader.Read();
Apassword=this.objSqlDataReader.GetValue(3).ToString().Trim();
objSqlDataReader.Close();
objSqlConn.Close();
if(this.textBox2.Text.ToString().Trim().Equals(Apassword) && this.textBox3.Text==this.textBox4.Text)
{
flag=true;
objSqlConn= new SqlConnection("SERVER=(local);database=atorregulate;uid=sa;password=");
objSqlConn.Open();
string modCmd = "update adminuser set Apassword = '"+this.textBox3.Text.ToString().Trim()+"'";
this.objSqlCmd = new SqlCommand(modCmd,objSqlConn);
this.objSqlCmd.ExecuteNonQuery();
MessageBox.Show("密码修改成功!","服务器确认");
this.textBox2.Clear();
this.textBox3.Clear();
this.textBox4.Clear();
this.Hide();
}
if(!flag)
{
MessageBox.Show("你输入的原密码不正确!请重新输入!","服务器拒绝");
this.textBox2.Text="";
this.textBox3.Text="";
this.textBox4.Text="";
this.textBox2.Focus();
}
}
catch(SqlException ee)
{
MessageBox.Show(ee.Message);
}
finally
{
this.objSqlConn.Close();
}
}
private void frmpasswordset_Load(object sender, System.EventArgs e)
{
this.textBox1.Text=username;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?