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

📄 passwordmodify.aspx.cs

📁 比较完整的仓库管理系统 大家都看看 希望对你们有帮助吧
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration ;
using System.Data .SqlClient ;


namespace WMS
{
	/// <summary>
	/// PasswordModify 的摘要说明。
	/// </summary>
	public class PasswordModify : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label lbl_uid;
		protected System.Web.UI.WebControls.TextBox tbx_upassword;
		protected System.Web.UI.WebControls.TextBox tbx_newpassword;
		protected System.Web.UI.WebControls.Button btn_submit;
		protected System.Web.UI.WebControls.Label lbl_message;
		protected System.Web.UI.WebControls.TextBox tbx_confirmpassword;
		protected System.Web.UI.WebControls.CompareValidator cpv_newpassword;
		protected System.Web.UI.WebControls.HyperLink hlk_default;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if(!IsPostBack)
			{
					lbl_uid.Text =Session["UID"].ToString ();
			}
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.btn_submit.Click += new System.EventHandler(this.btn_submit_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void btn_submit_Click(object sender, System.EventArgs e)
		{
			//从文件Web.config中读取连接字符串
			string strconn= ConfigurationSettings.AppSettings["dsn"];
			//连接本地计算机的WMS数据库
			SqlConnection cn= new SqlConnection (strconn);
			cn.Open ();
			//构造SQL语句,该语句在Users表中检查用户名和密码是否正确
			string mysql= "select * from Users where Uid='"+lbl_uid.Text +"'and UPassword='"+tbx_upassword.Text +"'";
			//创建Command对象
			SqlCommand cm=new SqlCommand  (mysql,cn);
			//执行ExecuteReader ()方法
			SqlDataReader dr=cm.ExecuteReader ();
			if(dr.Read ())
			{
				//修改密码
				SqlConnection cn1= new SqlConnection (strconn);
				cn1.Open ();
				SqlCommand cm1=new SqlCommand  ("userspasswdmodify",cn1);
				cm1.CommandType =CommandType .StoredProcedure ;
				cm1.Parameters .Add ("@UID",SqlDbType.VarChar  );
				cm1.Parameters .Add ("@UPassword",SqlDbType.VarChar  );
				cm1.Parameters ["@UID"].Value =lbl_uid.Text .ToString ();
				cm1.Parameters ["@UPassword"].Value =tbx_newpassword.Text .ToString ();
				cm1.ExecuteNonQuery ();
				cn1.Close ();
				lbl_message.Text="密码修改成功,请返回后验证新密码";

			}
			else
			{
				lbl_message.Text ="对不起,您输入的原密码不正确,请重新输入";
			}
			//关闭连接
			cn.Close();
		}
	}
}

⌨️ 快捷键说明

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