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

📄 usermod.aspx.cs

📁 ASP.NET的一些开发实例,有论坛管理系统等
💻 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 WorkGroupManager.user
{
	/// <summary>
	/// UserMod 的摘要说明。
	/// </summary>
	public class UserMod : WorkGroupManager.WebFormBase
	{
		protected System.Web.UI.WebControls.TextBox tbPassword;
		protected System.Web.UI.WebControls.TextBox tbpw;
		protected System.Web.UI.WebControls.DropDownList ddlStation;
		protected System.Web.UI.WebControls.LinkButton datacheck;
		protected User.user user=new User.user();
		protected System.Web.UI.WebControls.Label lbName;
		protected System.Web.UI.WebControls.CheckBox cbpsw;
		protected User.UserService us=new User.UserService();
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			this.VerifyPage();
			this.user=this.us.GetUser(this.GetCurrentPks(this,true));
			// 在此处放置用户代码以初始化页面
			if(!Page.IsPostBack)
			{
				ViewState["chpsw"]="0";
				this.lbName.Text=this.user.uName;
				this.tbPassword.Text=this.user.uPassword;
				this.tbpw.Text=this.user.uPassword;
				this.ddlStation.SelectedIndex=-1;
				this.ddlStation.Items.FindByValue(this.user.uStation).Selected=true;
			}
		}

		#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.cbpsw.CheckedChanged += new System.EventHandler(this.cbpsw_CheckedChanged);
			this.datacheck.Click += new System.EventHandler(this.datacheck_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void datacheck_Click(object sender, System.EventArgs e)
		{
			try
			{
				this.user.uName=this.lbName.Text;
				if(this.cbpsw.Checked==true)
					this.user.uPassword=this.tbPassword.Text;
				this.user.uStation=this.ddlStation.SelectedItem.Value;
				if(this.us.ModUser(this.user))
				{
					this.Return(this);	 
				}
				else	
				{
					//使用时将下面代码中的"MainModel_1.aspx"改到特定页面的打开页面的URL
					Response.Write("<script language=javascript>window.opener.location='../Error.aspx?errmsg=用户未能修改成功。';window.close();</script>");  
							
				}
			}
			catch(Exception ex)
			{
				this.BaseService.Write("用户修改。");
				this.BaseService.Write(ex.Message);
			}
		}

		private void cbpsw_CheckedChanged(object sender, System.EventArgs e)
		{
			if(this.cbpsw.Checked==true)
			{
				ViewState["chpsw"]="1";
				this.tbPassword.Enabled=true;
				this.tbpw.Enabled=true;
			}
			else
			{
				ViewState["chpsw"]="0";
				this.tbPassword.Enabled=false;
				this.tbpw.Enabled=false;
			}
		}
	}
}

⌨️ 快捷键说明

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