updateperinfor.aspx.cs

来自「图书馆的书目查询」· CS 代码 · 共 95 行

CS
95
字号
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.Data.SqlClient;

namespace Library_BS
{
	/// <summary>
	/// Register 的摘要说明。
	/// </summary>
	public class UpdatePerInfor : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.DropDownList DropDownListSex;
		protected System.Web.UI.WebControls.TextBox TextBoxQuestion;
		protected System.Web.UI.WebControls.TextBox TextBoxAnswer;
		protected System.Web.UI.WebControls.TextBox TextBoxAddress;
		protected System.Web.UI.WebControls.TextBox TextBoxPostNum;
		protected System.Web.UI.WebControls.TextBox TextBoxEMail;
		protected System.Web.UI.WebControls.TextBox TextBoxTel;
		protected System.Web.UI.WebControls.TextBox TextBoxDepartment;
		protected System.Web.UI.WebControls.DropDownList DropDownListType;
		protected System.Web.UI.WebControls.Button ButtonOK;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator4;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator5;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator6;
		protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
		protected System.Web.UI.WebControls.Label LabelID;
		//protected System.Web.UI.WebControls.CustomValidator CustomValidator1;
		protected UserDB user = new UserDB();
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if (!this.IsPostBack)
			{
				this.LabelID.Text = Request["UserID"];
				string connStr = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];
				SqlConnection myConnection = new SqlConnection(connStr);
 
				myConnection.Open();
				DataTable table = user.QueryReaderInfoByID(this.LabelID.Text).Tables[0];

				this.DropDownListType.DataSource = table.DefaultView;
				this.DropDownListType.DataTextField = "类型";
				//this.DropDownListType.DataValueField = "编号";
				DropDownListType.DataBind();

				this.TextBoxDepartment.Text = table.Rows[0]["单位名称"].ToString();
				//this.TextBoxName.Text = table.Rows[0]["姓名"].ToString();
				myConnection.Close();
			}
		}

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

		}
		#endregion

		private void ButtonOK_Click(object sender, System.EventArgs e)
		{	
			if (this.Page.IsValid)
			{
				this.user.UpdateUserInfor(LabelID.Text,this.TextBoxQuestion.Text, this.TextBoxAnswer.Text, TextBoxTel.Text, TextBoxAddress.Text, TextBoxPostNum.Text,TextBoxEMail.Text);

				//this.Session["name"] = this.TextBoxName.Text;
				//this.Response.Redirect("Register_OK.aspx");
				
			}
		}
	}
}

⌨️ 快捷键说明

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