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

📄 wf_change_password.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;

namespace WebApplication1 //HNtest1_main1
{
	/// <summary>
	/// WFapp 的摘要说明。
	/// </summary>
	public class WF_Change_password : System.Web.UI.Page
	{
		protected System.Data.DataView dataView1;
		protected System.Data.Odbc.OdbcConnection odbcConnection1;
		protected System.Data.Odbc.OdbcCommand odbcSelectCommand1;
		internal System.Data.Odbc.OdbcCommand odbcInsertCommand1;
		protected System.Data.Odbc.OdbcCommand odbcUpdateCommand1;
		protected System.Data.Odbc.OdbcCommand odbcDeleteCommand1;
		protected System.Data.Odbc.OdbcDataAdapter odbcDataAdapter1;
		protected System.Web.UI.WebControls.TextBox TextBox4;
		protected System.Web.UI.WebControls.TextBox TextBox3;
		protected System.Web.UI.WebControls.TextBox TextBox2;
		protected System.Data.DataSet dataSet1;
		protected System.Data.Odbc.OdbcCommand odbcCommand1;
		protected System.Web.UI.WebControls.DropDownList DropDownList3;
		protected System.Web.UI.WebControls.TextBox TextBox1;
		protected System.Web.UI.WebControls.Button Button2;

		protected System.Web.UI.WebControls.TextBox TextBox6;
		protected System.Web.UI.WebControls.Label Label3;
		protected System.Web.UI.WebControls.DropDownList DropDownList2;
		protected System.Web.UI.WebControls.TextBox TextBox7;

		private string strUser ;    
		private string strUserName; 
		private string strDept;
		private string strDeptName; 
		private string strRole;    
		protected System.Web.UI.WebControls.Label Label4;
		protected System.Web.UI.WebControls.Label Label6;
		protected System.Web.UI.WebControls.TextBox TextBox8;
		protected System.Web.UI.WebControls.Label lblMessage;
		protected System.Web.UI.WebControls.TextBox Textbox9;
		protected System.Web.UI.WebControls.Label Label5;     

		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			strUser =(string)Session["strUser"];          
			strUserName = (string)Session["strUserName"];  
			strDept = (string)Session["strDept"];          
			strDeptName = (string)Session["strDeptName"];
			strRole = (string)Session["strRole"];

			if (!IsPostBack)
			{

				if (!Global.CheckUserValidation(strRole, Global.MENU_CHANGEPSW))
				{
					Response.Redirect("err_session.htm", true);
				}
				selectdata();
			}

		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.dataView1 = new System.Data.DataView();
			this.odbcConnection1 = new System.Data.Odbc.OdbcConnection();
			this.odbcSelectCommand1 = new System.Data.Odbc.OdbcCommand();
			this.odbcInsertCommand1 = new System.Data.Odbc.OdbcCommand();
			this.odbcUpdateCommand1 = new System.Data.Odbc.OdbcCommand();
			this.odbcDeleteCommand1 = new System.Data.Odbc.OdbcCommand();
			this.odbcDataAdapter1 = new System.Data.Odbc.OdbcDataAdapter();
			this.dataSet1 = new System.Data.DataSet();
			this.odbcCommand1 = new System.Data.Odbc.OdbcCommand();
			((System.ComponentModel.ISupportInitialize)(this.dataView1)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.dataSet1)).BeginInit();
			this.Button2.Click += new System.EventHandler(this.Button2_Click);
			// 
			// odbcDataAdapter1
			// 
			this.odbcDataAdapter1.DeleteCommand = this.odbcDeleteCommand1;
			this.odbcDataAdapter1.InsertCommand = this.odbcInsertCommand1;
			this.odbcDataAdapter1.SelectCommand = this.odbcSelectCommand1;
			this.odbcDataAdapter1.UpdateCommand = this.odbcUpdateCommand1;
			// 
			// dataSet1
			// 
			this.dataSet1.DataSetName = "NewDataSet";
			this.dataSet1.Locale = new System.Globalization.CultureInfo("zh-CN");
			this.Load += new System.EventHandler(this.Page_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataView1)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.dataSet1)).EndInit();

		}
		#endregion
		private void connectionDB()
		{
			Global.OpenConnection(ref odbcConnection1);		
		}	
		private void closeDB()
		{
			odbcConnection1.Close();	
		}	

		private void selectdata()
		{
			TextBox1.Text = strUser;
			TextBox2.Text = strUserName;
			TextBox6.Text = strDept;
			TextBox7.Text = strDeptName;
			DropDownList2.SelectedValue = strRole;
			DropDownList3.SelectedValue = "1";
		}	

		private bool ErrInfo()
		{
			if((TextBox3.Text=="")||(TextBox4.Text==""))
			{
				Page.RegisterStartupScript("alert", @"<script language=""javascript"">window.alert(""错误:管理员密码不能为空!"")</script>");
				return false;
			}

			TextBox3.Text.Replace(@"""", "");
			TextBox3.Text.Replace("'", "");
			if(TextBox3.Text!=TextBox4.Text)
			{
				Page.RegisterStartupScript("alert", @"<script language=""javascript"">window.alert(""错误:输入两次密码不同或包含非法字符!"")</script>");
				return false;
			}

			return true;
		}

		private void Button2_Click(object sender, System.EventArgs e)
		{	
			System.Data.Odbc.OdbcDataReader dtr;
			string psswordstr="";
			string strUpdate;
			int iUpdateRowCount;		
			bool hasrow;		
			string strDBPsw = "";

			connectionDB();

			odbcCommand1.CommandText = "select passwd, `name`, `department_id`, `department`, `role_id` from t_manager where manager_id = '" + strUser + "' and effect = '1'";
			odbcCommand1.Connection =	odbcConnection1;
			dtr = odbcCommand1.ExecuteReader();
			hasrow = dtr.HasRows;
			if (dtr.HasRows)		
			{
				strDBPsw = dtr.GetString(0);
			}
			closeDB();

			if (strDBPsw != Textbox9.Text)
			{
				Page.RegisterStartupScript("alert", @"<script language=""javascript"">window.alert(""旧密码错,请重新输入!"")</script>");
				return;
			}
			else
			{
				if (!ErrInfo())
				{
					return ;
				}
				psswordstr =TextBox3.Text;

				lblMessage.Text = "";

				strUpdate = "UPDATE T_manager set " +
				"Passwd  = '" + psswordstr + "' " +
				"where Manager_id = '"+strUser+"'";

  			connectionDB();
				odbcCommand1.CommandText = strUpdate;
				odbcCommand1.Connection = odbcConnection1;
				iUpdateRowCount = odbcCommand1.ExecuteNonQuery ();
				if (iUpdateRowCount != 1)
				{
					Page.RegisterStartupScript("alert", @"<script language=""javascript"">window.alert(""错误:修改密码错误!"")</script>");
				}
				else
				{
		  		Global.WriteLog(ref odbcConnection1,strUser,Global.MENU_CHANGEPSW,Global.ACTION_UPDATE,"修改密码!");
				}
				closeDB();
			}
		}
	}
}

⌨️ 快捷键说明

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