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

📄 studentedit.aspx.cs

📁 学生公寓管理系统使用说明: 1.服务器运行环境 SQL 2000 .NET FRAMEWORK 1.1 .NET FRAMEWORK 1.1 CHINESE (SIMPL
💻 CS
📖 第 1 页 / 共 2 页
字号:
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 Manage
{
	/// <summary>
	/// StudentEdit 的摘要说明。
	/// </summary>
	public class StudentEdit : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.DataGrid DataGrid1;
		protected System.Web.UI.WebControls.DropDownList DropDownList1;
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Data.SqlClient.SqlConnection conn;
		protected System.Data.SqlClient.SqlCommand cmd;
		protected System.Data.SqlClient.SqlDataReader reader;
		protected string myConn;
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
		protected System.Data.SqlClient.SqlCommand sqlSelectCommand1;
		protected System.Data.SqlClient.SqlCommand sqlInsertCommand1;
		protected System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
		protected System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
		protected System.Data.SqlClient.SqlConnection sqlConnection1;
		protected string cmdText;
		protected System.Web.UI.WebControls.TextBox TextBox4;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
		protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
		protected Manage.DataSet1 dataSet11;
		
		private void Data_Bind()
		{
			myConn=ConfigurationSettings.AppSettings["mySql"];
			cmdText="select * from Student";
			this.sqlConnection1=new System.Data.SqlClient.SqlConnection(myConn);
			this.sqlConnection1.Open();
			this.sqlDataAdapter1=new System.Data.SqlClient.SqlDataAdapter(cmdText,this.sqlConnection1);
			
			this.dataSet11=new DataSet1();
			this.sqlDataAdapter1.Fill(this.dataSet11,"Student");
			this.DataGrid1.DataSource=this.dataSet11;
			this.DataGrid1.DataBind();
			this.sqlConnection1.Close();
		}
		private void Grid_Bind()
		{
			myConn=ConfigurationSettings.AppSettings["mySql"];
			string s;
			s=this.DropDownList1.SelectedValue.ToString()+"="+"'"+this.TextBox4.Text+"'";
			cmdText="select * from Student where ";
			cmdText=cmdText+s;
			this.sqlConnection1=new System.Data.SqlClient.SqlConnection(myConn);
			this.sqlConnection1.Open();
			this.sqlDataAdapter1=new System.Data.SqlClient.SqlDataAdapter(cmdText,this.sqlConnection1);
			
			this.dataSet11=new DataSet1();
			this.sqlDataAdapter1.Fill(this.dataSet11,"Student");
			this.DataGrid1.DataSource=this.dataSet11;
			this.DataGrid1.DataBind();
			this.sqlConnection1.Close();
		}
		private void Page_Load(object sender, System.EventArgs e)
		{
	
			if (!IsPostBack)
			
				Data_Bind();
			
			
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
			this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
			this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
			this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
			this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
			this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
			this.Button1.Click += new System.EventHandler(this.Button1_Click);
			this.DataGrid1.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.DataGrid1_PageIndexChanged);
			this.DataGrid1.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_CancelCommand);
			this.DataGrid1.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_EditCommand);
			this.DataGrid1.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_UpdateCommand);
			this.DataGrid1.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid1_ItemDataBound);
			// 
			// sqlDataAdapter1
			// 
			this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
			this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
			this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
			this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
																									  new System.Data.Common.DataTableMapping("Table", "Student", new System.Data.Common.DataColumnMapping[] {
																																																				 new System.Data.Common.DataColumnMapping("Student_ID", "Student_ID"),
																																																				 new System.Data.Common.DataColumnMapping("Student_Name", "Student_Name"),
																																																				 new System.Data.Common.DataColumnMapping("Student_Password", "Student_Password"),
																																																				 new System.Data.Common.DataColumnMapping("Student_Birth", "Student_Birth"),
																																																				 new System.Data.Common.DataColumnMapping("Student_Sex", "Student_Sex"),
																																																				 new System.Data.Common.DataColumnMapping("Student_Photo", "Student_Photo"),
																																																				 new System.Data.Common.DataColumnMapping("Student_Depart", "Student_Depart"),
																																																				 new System.Data.Common.DataColumnMapping("Student_Course", "Student_Course"),
																																																				 new System.Data.Common.DataColumnMapping("Student_Postion", "Student_Postion"),
																																																				 new System.Data.Common.DataColumnMapping("Room_ID", "Room_ID"),
																																																				 new System.Data.Common.DataColumnMapping("Student_Email", "Student_Email"),
																																																				 new System.Data.Common.DataColumnMapping("Student_LiveCost", "Student_LiveCost"),
																																																				 new System.Data.Common.DataColumnMapping("Student_StudyCost", "Student_StudyCost"),
																																																				 new System.Data.Common.DataColumnMapping("Student_Address", "Student_Address"),
																																																				 new System.Data.Common.DataColumnMapping("Student_Phone", "Student_Phone")})});
			this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
			// 
			// sqlDeleteCommand1
			// 
			this.sqlDeleteCommand1.CommandText = @"DELETE FROM Student WHERE (Student_ID = @Original_Student_ID) AND (Room_ID = @Original_Room_ID OR @Original_Room_ID IS NULL AND Room_ID IS NULL) AND (Student_Address = @Original_Student_Address OR @Original_Student_Address IS NULL AND Student_Address IS NULL) AND (Student_Birth = @Original_Student_Birth OR @Original_Student_Birth IS NULL AND Student_Birth IS NULL) AND (Student_Course = @Original_Student_Course) AND (Student_Depart = @Original_Student_Depart) AND (Student_Email = @Original_Student_Email OR @Original_Student_Email IS NULL AND Student_Email IS NULL) AND (Student_LiveCost = @Original_Student_LiveCost OR @Original_Student_LiveCost IS NULL AND Student_LiveCost IS NULL) AND (Student_Name = @Original_Student_Name) AND (Student_Password = @Original_Student_Password OR @Original_Student_Password IS NULL AND Student_Password IS NULL) AND (Student_Phone = @Original_Student_Phone OR @Original_Student_Phone IS NULL AND Student_Phone IS NULL) AND (Student_Photo = @Original_Student_Photo OR @Original_Student_Photo IS NULL AND Student_Photo IS NULL) AND (Student_Postion = @Original_Student_Postion OR @Original_Student_Postion IS NULL AND Student_Postion IS NULL) AND (Student_Sex = @Original_Student_Sex) AND (Student_StudyCost = @Original_Student_StudyCost OR @Original_Student_StudyCost IS NULL AND Student_StudyCost IS NULL)";
			this.sqlDeleteCommand1.Connection = this.sqlConnection1;
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_ID", System.Data.SqlDbType.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_ID", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Room_ID", System.Data.SqlDbType.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Room_ID", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Address", System.Data.SqlDbType.VarChar, 50, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Address", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Birth", System.Data.SqlDbType.NVarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Birth", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Course", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Course", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Depart", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Depart", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Email", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Email", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_LiveCost", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_LiveCost", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Name", System.Data.SqlDbType.VarChar, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Name", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Password", System.Data.SqlDbType.VarChar, 16, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Password", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Phone", System.Data.SqlDbType.VarChar, 12, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Phone", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Photo", System.Data.SqlDbType.VarChar, 30, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Photo", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Postion", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Postion", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_Sex", System.Data.SqlDbType.VarChar, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_Sex", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Student_StudyCost", System.Data.SqlDbType.Money, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Student_StudyCost", System.Data.DataRowVersion.Original, null));
			// 
			// sqlConnection1
			// 
			this.sqlConnection1.ConnectionString = "workstation id=\"BBS-HZ0752-NET\";packet size=4096;integrated security=SSPI;data so" +
				"urce=\"BBS-HZ0752-NET\";persist security info=False;initial catalog=student";
			// 
			// sqlInsertCommand1
			// 
			this.sqlInsertCommand1.CommandText = @"INSERT INTO Student(Student_ID, Student_Name, Student_Password, Student_Birth, Student_Sex, Student_Photo, Student_Depart, Student_Course, Student_Postion, Room_ID, Student_Email, Student_LiveCost, Student_StudyCost, Student_Address, Student_Phone) VALUES (@Student_ID, @Student_Name, @Student_Password, @Student_Birth, @Student_Sex, @Student_Photo, @Student_Depart, @Student_Course, @Student_Postion, @Room_ID, @Student_Email, @Student_LiveCost, @Student_StudyCost, @Student_Address, @Student_Phone); SELECT Student_ID, Student_Name, Student_Password, Student_Birth, Student_Sex, Student_Photo, Student_Depart, Student_Course, Student_Postion, Room_ID, Student_Email, Student_LiveCost, Student_StudyCost, Student_Address, Student_Phone FROM Student WHERE (Student_ID = @Student_ID)";
			this.sqlInsertCommand1.Connection = this.sqlConnection1;
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_ID", System.Data.SqlDbType.BigInt, 8, "Student_ID"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Name", System.Data.SqlDbType.VarChar, 8, "Student_Name"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Password", System.Data.SqlDbType.VarChar, 16, "Student_Password"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Birth", System.Data.SqlDbType.NVarChar, 10, "Student_Birth"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Sex", System.Data.SqlDbType.VarChar, 2, "Student_Sex"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Photo", System.Data.SqlDbType.VarChar, 30, "Student_Photo"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Depart", System.Data.SqlDbType.VarChar, 20, "Student_Depart"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Course", System.Data.SqlDbType.VarChar, 20, "Student_Course"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Postion", System.Data.SqlDbType.VarChar, 20, "Student_Postion"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Room_ID", System.Data.SqlDbType.BigInt, 8, "Room_ID"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Email", System.Data.SqlDbType.VarChar, 30, "Student_Email"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_LiveCost", System.Data.SqlDbType.Money, 8, "Student_LiveCost"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_StudyCost", System.Data.SqlDbType.Money, 8, "Student_StudyCost"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Address", System.Data.SqlDbType.VarChar, 50, "Student_Address"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Student_Phone", System.Data.SqlDbType.VarChar, 12, "Student_Phone"));
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.CommandText = "SELECT Student_ID, Student_Name, Student_Password, Student_Birth, Student_Sex, St" +
				"udent_Photo, Student_Depart, Student_Course, Student_Postion, Room_ID, Student_E" +

⌨️ 快捷键说明

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