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

📄 changepassword.cs

📁 进销存
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.sqltxtUser.UpdateCommand = this.sqlUpdateCommand1;
			// 
			// sqlDeleteCommand1
			// 
			this.sqlDeleteCommand1.CommandText = "DELETE FROM 用户清单 WHERE (用户编号 = @Original_用户编号) AND (姓名 = @Original_姓名) AND (密码 = " +
				"@Original_密码 OR @Original_密码 IS NULL AND 密码 IS NULL) AND (性别 = @Original_性别) AND" +
				" (部门 = @Original_部门)";
			this.sqlDeleteCommand1.Connection = this.conn;
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_用户编号", System.Data.SqlDbType.VarChar, 6, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "用户编号", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_姓名", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "姓名", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_密码", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "密码", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_性别", System.Data.SqlDbType.VarChar, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "性别", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_部门", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "部门", System.Data.DataRowVersion.Original, null));
			// 
			// conn
			// 
			this.conn.ConnectionString = "workstation id=ZHANGWENXU;packet size=4096;integrated security=SSPI;data source=\"" +
				".\";persist security info=False;initial catalog=DBApp";
			// 
			// sqlInsertCommand1
			// 
			this.sqlInsertCommand1.CommandText = "INSERT INTO 用户清单(用户编号, 部门, 姓名, 性别, 密码) VALUES (@用户编号, @部门, @姓名, @性别, @密码); SELECT" +
				" 用户编号, 部门, 姓名, 性别, 密码 FROM 用户清单 WHERE (用户编号 = @用户编号)";
			this.sqlInsertCommand1.Connection = this.conn;
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@用户编号", System.Data.SqlDbType.VarChar, 6, "用户编号"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@部门", System.Data.SqlDbType.VarChar, 20, "部门"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@姓名", System.Data.SqlDbType.VarChar, 50, "姓名"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@性别", System.Data.SqlDbType.VarChar, 2, "性别"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@密码", System.Data.SqlDbType.VarChar, 50, "密码"));
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.CommandText = "SELECT 用户编号, 部门, 姓名, 性别, 密码 FROM 用户清单";
			this.sqlSelectCommand1.Connection = this.conn;
			// 
			// sqlUpdateCommand1
			// 
			this.sqlUpdateCommand1.CommandText = @"UPDATE 用户清单 SET 用户编号 = @用户编号, 部门 = @部门, 姓名 = @姓名, 性别 = @性别, 密码 = @密码 WHERE (用户编号 = @Original_用户编号) AND (姓名 = @Original_姓名) AND (密码 = @Original_密码 OR @Original_密码 IS NULL AND 密码 IS NULL) AND (性别 = @Original_性别) AND (部门 = @Original_部门); SELECT 用户编号, 部门, 姓名, 性别, 密码 FROM 用户清单 WHERE (用户编号 = @用户编号)";
			this.sqlUpdateCommand1.Connection = this.conn;
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@用户编号", System.Data.SqlDbType.VarChar, 6, "用户编号"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@部门", System.Data.SqlDbType.VarChar, 20, "部门"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@姓名", System.Data.SqlDbType.VarChar, 50, "姓名"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@性别", System.Data.SqlDbType.VarChar, 2, "性别"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@密码", System.Data.SqlDbType.VarChar, 50, "密码"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_用户编号", System.Data.SqlDbType.VarChar, 6, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "用户编号", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_姓名", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "姓名", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_密码", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "密码", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_性别", System.Data.SqlDbType.VarChar, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "性别", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_部门", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "部门", System.Data.DataRowVersion.Original, null));
			// 
			// imageList1
			// 
			this.imageList1.ImageSize = new System.Drawing.Size(32, 32);
			this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
			this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
			// 
			// pictureBox2
			// 
			this.pictureBox2.BackColor = System.Drawing.Color.Transparent;
			this.pictureBox2.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox2.BackgroundImage")));
			this.pictureBox2.Location = new System.Drawing.Point(24, 64);
			this.pictureBox2.Name = "pictureBox2";
			this.pictureBox2.Size = new System.Drawing.Size(32, 32);
			this.pictureBox2.TabIndex = 21;
			this.pictureBox2.TabStop = false;
			// 
			// pictureBox1
			// 
			this.pictureBox1.BackColor = System.Drawing.Color.Transparent;
			this.pictureBox1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox1.BackgroundImage")));
			this.pictureBox1.Location = new System.Drawing.Point(32, 16);
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.Size = new System.Drawing.Size(16, 32);
			this.pictureBox1.TabIndex = 20;
			this.pictureBox1.TabStop = false;
			// 
			// changePassword
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(312, 213);
			this.Controls.Add(this.pictureBox2);
			this.Controls.Add(this.pictureBox1);
			this.Controls.Add(this.btnExit);
			this.Controls.Add(this.btnSubmit);
			this.Controls.Add(this.newPassword2);
			this.Controls.Add(this.newPassword);
			this.Controls.Add(this.oldPassword);
			this.Controls.Add(this.txtName);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Name = "changePassword";
			this.Text = "口令更改";
			this.Load += new System.EventHandler(this.changePassword_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void btnSubmit_Click(object sender, System.EventArgs e)
		{
			string name=this.txtName .Text ;
			string op=this.oldPassword .Text ;
			string np=this.newPassword .Text ;
			string np2=this.newPassword2 .Text;
			int i;
			if(name!=""&& op!=""&& np!=""&& np2!="")
			{
				SqlCommand cmd=new SqlCommand ("select count(*) from 用户清单 where 姓名='"+name+"' AND 密码='"+op+"'",conn);
				this.conn .Open ();
				i=Convert.ToInt32(cmd.ExecuteScalar());
				this.conn .Close ();
				if(i>0)
				{
					if(np==np2)
					{SqlCommand cmd1=new SqlCommand ("update 用户清单 set 密码='"+np+"' where 用户编号=2",conn);
						this.conn .Open ();
						cmd1.ExecuteNonQuery ();
						this.conn .Close();
						MessageBox.Show ("密码更改成功!!!!");
						this.Close ();
					}
					else
						MessageBox.Show ("两次输入密码不一致,请重新输入!!");
				
				}
				else
					MessageBox.Show ("该用户不存在!!!!");



			}
//			string Name1,Name2;
//			string Password1,chNewPassword;
//			Name1 = txtName.Text;
////			Name2 =frmLogin.para @userName;
//            
//			conn.Open();
//			cmd.CommandText = "select Password from 用户清单 where Name =@userName";
//			Password1=Convert.ToString(cmd.ExecuteScalar());
//		
//			conn.Close();
//			
//             
//			chNewPassword = newPassword.Text.ToString();
//			if(Password1==oldPassword.Text)
//			{
//				//				newPassword.ReadOnly = false;
//				//				newPassword2.ReadOnly = false;
//
//				//				MessageBox.Show(Convert.ToString(Password1==oldPassword.Text));
//				if(newPassword2.Text==chNewPassword)
//				{
//					conn.Open();
//					cmd.CommandText = "Update 用户清单 set 密码='"+chNewPassword+"' where Name =@userName";
//					
//					cmd.ExecuteNonQuery();
//					cmd.ExecuteScalar();
//				
//					conn.Close();
//				}
//				else
//				{
//
//					MessageBox.Show("你输入的新密码有错误!!!");
//					return;
//				}
//			}
		}

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

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

⌨️ 快捷键说明

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