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

📄 uppasswordform.cs

📁 c#编写的人事管理系统源码 写得不错 值得收藏
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;
namespace PM
{
	/// <summary>
	/// uppasswordForm 的摘要说明。
	/// </summary>
	public class uppasswordForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox user_txt;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox oldpwd_txt;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.TextBox newpwd_txt;
		private System.Windows.Forms.Label label4;
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.Button ok_bt;
		private System.Windows.Forms.Button cancel_bt;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public uppasswordForm()
		{
			//
			// 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(uppasswordForm));
			this.label1 = new System.Windows.Forms.Label();
			this.user_txt = new System.Windows.Forms.TextBox();
			this.label2 = new System.Windows.Forms.Label();
			this.oldpwd_txt = new System.Windows.Forms.TextBox();
			this.label3 = new System.Windows.Forms.Label();
			this.newpwd_txt = new System.Windows.Forms.TextBox();
			this.label4 = new System.Windows.Forms.Label();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.ok_bt = new System.Windows.Forms.Button();
			this.cancel_bt = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(48, 32);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(56, 16);
			this.label1.TabIndex = 0;
			this.label1.Text = "当前用户";
			// 
			// user_txt
			// 
			this.user_txt.Location = new System.Drawing.Point(120, 24);
			this.user_txt.Name = "user_txt";
			this.user_txt.ReadOnly = true;
			this.user_txt.TabIndex = 1;
			this.user_txt.Text = "";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(48, 80);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(48, 16);
			this.label2.TabIndex = 2;
			this.label2.Text = "旧密码";
			// 
			// oldpwd_txt
			// 
			this.oldpwd_txt.Location = new System.Drawing.Point(120, 72);
			this.oldpwd_txt.Name = "oldpwd_txt";
			this.oldpwd_txt.PasswordChar = '*';
			this.oldpwd_txt.TabIndex = 3;
			this.oldpwd_txt.Text = "";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(48, 128);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(48, 16);
			this.label3.TabIndex = 4;
			this.label3.Text = "新密码";
			// 
			// newpwd_txt
			// 
			this.newpwd_txt.Location = new System.Drawing.Point(120, 120);
			this.newpwd_txt.Name = "newpwd_txt";
			this.newpwd_txt.PasswordChar = '*';
			this.newpwd_txt.TabIndex = 5;
			this.newpwd_txt.Text = "";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(32, 184);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(72, 16);
			this.label4.TabIndex = 6;
			this.label4.Text = "确认新密码";
			// 
			// textBox1
			// 
			this.textBox1.Location = new System.Drawing.Point(120, 176);
			this.textBox1.Name = "textBox1";
			this.textBox1.PasswordChar = '*';
			this.textBox1.TabIndex = 7;
			this.textBox1.Text = "";
			// 
			// ok_bt
			// 
			this.ok_bt.Location = new System.Drawing.Point(24, 232);
			this.ok_bt.Name = "ok_bt";
			this.ok_bt.TabIndex = 8;
			this.ok_bt.Text = "确定";
			this.ok_bt.Click += new System.EventHandler(this.ok_bt_Click);
			// 
			// cancel_bt
			// 
			this.cancel_bt.Location = new System.Drawing.Point(152, 232);
			this.cancel_bt.Name = "cancel_bt";
			this.cancel_bt.TabIndex = 9;
			this.cancel_bt.Text = "取消";
			this.cancel_bt.Click += new System.EventHandler(this.cancel_bt_Click);
			// 
			// uppasswordForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(280, 285);
			this.Controls.Add(this.cancel_bt);
			this.Controls.Add(this.ok_bt);
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.newpwd_txt);
			this.Controls.Add(this.oldpwd_txt);
			this.Controls.Add(this.user_txt);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.Name = "uppasswordForm";
			this.Text = "更改密码";
			this.Load += new System.EventHandler(this.uppasswordForm_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void cancel_bt_Click(object sender, System.EventArgs e)
		{
		    this.Close();
		}

		private void uppasswordForm_Load(object sender, System.EventArgs e)
		{
			this.user_txt.Text = Form1.f1.Cmb;
		}

		private void ok_bt_Click(object sender, System.EventArgs e)
		{
			if(this.oldpwd_txt.Text != "")
			{
				if(this.newpwd_txt.Text != "")
				{
					if(this.textBox1.Text != "")
					{
						string str = "select * from UserInfo where uName='" + this.user_txt.Text + "' and uPassword='" + this.oldpwd_txt.Text + "'";
						Base bb = new Base();
						if(bb.IsRead(str) == false)
						{
							MessageBox.Show("旧密码错误!");
						}
						else
						{
							if(this.newpwd_txt.Text == this.textBox1.Text)
							{
								Base b = new Base();
								string s = "update UserInfo set uPassword='" + this.newpwd_txt.Text.Trim() + "' where uName='" + this.user_txt.Text + "'";
								b.ExeSQL(s);
								MessageBox.Show("修改密码成功!");
							}
							else
							{
								MessageBox.Show("密码不一致,请重新输入!");
							}
						}
					}
					else
					{
						MessageBox.Show("确认密码不能为空!");
					}
				}
				else
				{
					MessageBox.Show("新密码不能为空!"); 
				}
			}
			else
			{
			    MessageBox.Show("旧密码不能为空!");
			}
		}
	}
}

⌨️ 快捷键说明

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