⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 password.cs

📁 物业管理系统
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;

namespace WindowsApplication1
{
	/// <summary>
	/// password 的摘要说明。
	/// </summary>
	public class password : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox textBox2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.TextBox textBox3;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.TextBox textBox4;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public password()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// 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(password));
			this.label2 = new System.Windows.Forms.Label();
			this.textBox2 = new System.Windows.Forms.TextBox();
			this.label3 = new System.Windows.Forms.Label();
			this.textBox3 = new System.Windows.Forms.TextBox();
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.textBox4 = new System.Windows.Forms.TextBox();
			this.label4 = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// label2
			// 
			this.label2.BackColor = System.Drawing.Color.Transparent;
			this.label2.ForeColor = System.Drawing.Color.Red;
			this.label2.Location = new System.Drawing.Point(56, 128);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(152, 16);
			this.label2.TabIndex = 2;
			this.label2.Text = "新密码(3-20个字符):";
			// 
			// textBox2
			// 
			this.textBox2.Location = new System.Drawing.Point(56, 152);
			this.textBox2.Name = "textBox2";
			this.textBox2.Size = new System.Drawing.Size(152, 21);
			this.textBox2.TabIndex = 3;
			this.textBox2.Text = "";
			// 
			// label3
			// 
			this.label3.BackColor = System.Drawing.Color.Transparent;
			this.label3.ForeColor = System.Drawing.Color.Red;
			this.label3.Location = new System.Drawing.Point(56, 192);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(160, 16);
			this.label3.TabIndex = 4;
			this.label3.Text = "确认密码(3-20个字符):";
			// 
			// textBox3
			// 
			this.textBox3.Location = new System.Drawing.Point(56, 216);
			this.textBox3.Name = "textBox3";
			this.textBox3.Size = new System.Drawing.Size(152, 21);
			this.textBox3.TabIndex = 5;
			this.textBox3.Text = "";
			// 
			// button1
			// 
			this.button1.BackColor = System.Drawing.Color.Transparent;
			this.button1.ForeColor = System.Drawing.Color.Red;
			this.button1.Location = new System.Drawing.Point(48, 256);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(64, 32);
			this.button1.TabIndex = 6;
			this.button1.Text = "确认";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.BackColor = System.Drawing.Color.Transparent;
			this.button2.ForeColor = System.Drawing.Color.Red;
			this.button2.Location = new System.Drawing.Point(152, 256);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(64, 32);
			this.button2.TabIndex = 7;
			this.button2.Text = "取消";
			// 
			// label1
			// 
			this.label1.BackColor = System.Drawing.Color.Transparent;
			this.label1.ForeColor = System.Drawing.Color.Red;
			this.label1.Location = new System.Drawing.Point(56, 72);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(56, 16);
			this.label1.TabIndex = 0;
			this.label1.Text = "原密码:";
			// 
			// textBox1
			// 
			this.textBox1.Location = new System.Drawing.Point(56, 88);
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(152, 21);
			this.textBox1.TabIndex = 1;
			this.textBox1.Text = "";
			this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
			// 
			// textBox4
			// 
			this.textBox4.Location = new System.Drawing.Point(56, 40);
			this.textBox4.Name = "textBox4";
			this.textBox4.Size = new System.Drawing.Size(152, 21);
			this.textBox4.TabIndex = 9;
			this.textBox4.Text = "";
			// 
			// label4
			// 
			this.label4.BackColor = System.Drawing.Color.Transparent;
			this.label4.ForeColor = System.Drawing.Color.Red;
			this.label4.Location = new System.Drawing.Point(56, 16);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(56, 16);
			this.label4.TabIndex = 8;
			this.label4.Text = "用户名:";
			// 
			// password
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			this.ClientSize = new System.Drawing.Size(272, 304);
			this.Controls.Add(this.textBox4);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.textBox3);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.textBox2);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.label1);
			this.ForeColor = System.Drawing.Color.Red;
			this.Name = "password";
			this.Text = "修改密码";
			this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox1_TextChanged);
			this.Load += new System.EventHandler(this.password_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void password_Load(object sender, System.EventArgs e)
		{
			this.textBox2.Enabled=false;
			this.textBox3.Enabled=false;


		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			/*OleDbConnection conn2=new OleDbConnection(@"provider=Microsoft.jet.oledb.4.0;data source="+Application.StartupPath+ "\\xqwy.mdb");
			conn2.Open();
			OleDbDataAdapter da=new OleDbDataAdapter("select * from user1",conn2);
			DataSet ds=new DataSet();
			da.Fill(ds);
			DataTable dt=new DataTable();
			dt=ds.Tables[0];
			DataRow dr=dt.NewRow();
			
			if(this.textBox1.Text==dr[1].ToString())
			
				if(this.textBox4.Text==dr[0].ToString())
				{

					dr.Delete();
					MessageBox.Show("删除成功");
				}*/
			try
			{
					OleDbConnection conn2=new OleDbConnection(@"provider=Microsoft.jet.oledb.4.0;data source="+Application.StartupPath+ "\\xqwy.mdb");
					conn2.Open();

					string strsql="select * from user1 where name='"+this.textBox4.Text.Trim()+"' and passwd='"+this.textBox1.Text.Trim()+"'";

					OleDbDataAdapter da=new OleDbDataAdapter(strsql,conn2);

					DataSet ds=new DataSet();
					da.Fill(ds);

					DataTable mytable=new DataTable();
					mytable=ds.Tables[0];

				if(this.button1.Text=="确认")
				{

					if(mytable.Rows.Count==1)
					{
						this.textBox2.Enabled=true;
						this.textBox3.Enabled=true;
						this.button1.Text="修改";
					


					}
					else

					{
						this.textBox2.Enabled=false;
						this.textBox3.Enabled=false;
						this.button1.Text="确认";

					}
				}


				else
				{
					DataRow row1;
					row1=mytable.Rows[0];
					row1[1]=this.textBox3.Text.Trim();

					OleDbCommandBuilder cmdbld=new OleDbCommandBuilder(da);

					da.Update(mytable);
					MessageBox.Show("密码修改成功!");



					//string strsql2="update user1 set passwd='"+this.textBox3.Text.Trim()+"'";
				}

				conn2.Close();
			}
			catch(Exception err)
			{
				MessageBox.Show(err.Message);
			}




		}

		private void textBox1_TextChanged(object sender, System.EventArgs e)
		{




		
		}

		private void textBox1_TextChanged(object sender, System.Windows.Forms.KeyEventArgs e)
		{
		
		}


	


	

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -