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

📄 admin2.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.Data.SqlClient;

namespace tang
{
	/// <summary>
	/// admin2 的摘要说明。
	/// </summary>
	public class admin2 : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.Label Label3;
		protected System.Web.UI.WebControls.Label Label4;
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.TextBox TextBox1;
		protected System.Web.UI.WebControls.TextBox TextBox2;
		protected System.Web.UI.WebControls.TextBox TextBox3;
		protected System.Web.UI.WebControls.Label Label5;
		protected System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
		protected System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
		protected System.Data.SqlClient.SqlCommand sqlDeleteCommand2;
		protected System.Web.UI.WebControls.DataGrid DataGrid1;
		protected System.Web.UI.WebControls.Label Label6;
		protected System.Web.UI.WebControls.HyperLink HyperLink1;
		protected System.Web.UI.WebControls.HyperLink HyperLink2;
		protected System.Web.UI.WebControls.HyperLink HyperLink3;
		protected System.Web.UI.WebControls.HyperLink HyperLink4;
		protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
		protected System.Data.SqlClient.SqlCommand sqlSelectCommand1;
		protected System.Data.SqlClient.SqlCommand sqlInsertCommand1;
		protected System.Data.SqlClient.SqlCommand sqlUpdateCommand2;
		protected System.Data.SqlClient.SqlCommand sqlDeleteCommand3;
		protected System.Data.SqlClient.SqlConnection sqlConnection1;
		protected tang.DataSet1 dataSet11;
		protected System.Web.UI.WebControls.Button Button2;

	
		private void Page_Load(object sender, System.EventArgs e)
		{
			if (!IsPostBack)//页面第一次加载时; 
			{ 
				if (Session["username"] ==null) 
				{ 

					this.Response.Redirect("error.aspx");//重定向到登录也就是身份验证的那个页面 
				} 
			} 

			// 在此处放置用户代码以初始化页面
				sqlDataAdapter1.Fill(dataSet11,"授课教师信息");
				if(!Page.IsPostBack)
					DataGrid1.DataBind();
		}

		#region Web 窗体设计器生成的代码
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    
			this.sqlDeleteCommand2 = new System.Data.SqlClient.SqlCommand();
			this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
			this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
			this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
			this.sqlDeleteCommand3 = 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.sqlUpdateCommand2 = new System.Data.SqlClient.SqlCommand();
			this.dataSet11 = new tang.DataSet1();
			((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
			this.Button1.Click += new System.EventHandler(this.Button1_Click);
			this.Button2.Click += new System.EventHandler(this.Button2_Click);
			// 
			// sqlDataAdapter1
			// 
			this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand3;
			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", "授课教师信息", new System.Data.Common.DataColumnMapping[] {
																																																				new System.Data.Common.DataColumnMapping("授课教师编号", "授课教师编号"),
																																																				new System.Data.Common.DataColumnMapping("授课教师密码", "授课教师密码"),
																																																				new System.Data.Common.DataColumnMapping("授课教师姓名", "授课教师姓名")})});
			this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand2;
			// 
			// sqlDeleteCommand3
			// 
			this.sqlDeleteCommand3.CommandText = "DELETE FROM 授课教师信息 WHERE (授课教师编号 = @Original_授课教师编号) AND (授课教师姓名 = @Original_授课教师" +
				"姓名 OR @Original_授课教师姓名 IS NULL AND 授课教师姓名 IS NULL) AND (授课教师密码 = @Original_授课教师密" +
				"码 OR @Original_授课教师密码 IS NULL AND 授课教师密码 IS NULL)";
			this.sqlDeleteCommand3.Connection = this.sqlConnection1;
			this.sqlDeleteCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_授课教师编号", System.Data.SqlDbType.VarChar, 6, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "授课教师编号", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_授课教师姓名", System.Data.SqlDbType.VarChar, 18, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "授课教师姓名", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand3.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_授课教师密码", System.Data.SqlDbType.VarChar, 6, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "授课教师密码", System.Data.DataRowVersion.Original, null));
			// 
			// sqlConnection1
			// 
			this.sqlConnection1.ConnectionString = "workstation id=\"SUNLIGHT-17F324\";packet size=4096;integrated security=SSPI;data s" +
				"ource=\"SUNLIGHT-17F324\";persist security info=False;initial catalog=大型数据库";
			// 
			// sqlInsertCommand1
			// 
			this.sqlInsertCommand1.CommandText = "INSERT INTO 授课教师信息(授课教师编号, 授课教师密码, 授课教师姓名) VALUES (@授课教师编号, @授课教师密码, @授课教师姓名); SE" +
				"LECT 授课教师编号, 授课教师密码, 授课教师姓名 FROM 授课教师信息 WHERE (授课教师编号 = @授课教师编号)";
			this.sqlInsertCommand1.Connection = this.sqlConnection1;
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@授课教师编号", System.Data.SqlDbType.VarChar, 6, "授课教师编号"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@授课教师密码", System.Data.SqlDbType.VarChar, 6, "授课教师密码"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@授课教师姓名", System.Data.SqlDbType.VarChar, 18, "授课教师姓名"));
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.CommandText = "SELECT 授课教师编号, 授课教师密码, 授课教师姓名 FROM 授课教师信息";
			this.sqlSelectCommand1.Connection = this.sqlConnection1;
			// 
			// sqlUpdateCommand2
			// 
			this.sqlUpdateCommand2.CommandText = @"UPDATE 授课教师信息 SET 授课教师编号 = @授课教师编号, 授课教师密码 = @授课教师密码, 授课教师姓名 = @授课教师姓名 WHERE (授课教师编号 = @Original_授课教师编号) AND (授课教师姓名 = @Original_授课教师姓名 OR @Original_授课教师姓名 IS NULL AND 授课教师姓名 IS NULL) AND (授课教师密码 = @Original_授课教师密码 OR @Original_授课教师密码 IS NULL AND 授课教师密码 IS NULL); SELECT 授课教师编号, 授课教师密码, 授课教师姓名 FROM 授课教师信息 WHERE (授课教师编号 = @授课教师编号)";
			this.sqlUpdateCommand2.Connection = this.sqlConnection1;
			this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@授课教师编号", System.Data.SqlDbType.VarChar, 6, "授课教师编号"));
			this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@授课教师密码", System.Data.SqlDbType.VarChar, 6, "授课教师密码"));
			this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@授课教师姓名", System.Data.SqlDbType.VarChar, 18, "授课教师姓名"));
			this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_授课教师编号", System.Data.SqlDbType.VarChar, 6, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "授课教师编号", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_授课教师姓名", System.Data.SqlDbType.VarChar, 18, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "授课教师姓名", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand2.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_授课教师密码", System.Data.SqlDbType.VarChar, 6, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "授课教师密码", System.Data.DataRowVersion.Original, null));
			// 
			// dataSet11
			// 
			this.dataSet11.DataSetName = "DataSet1";
			this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
			this.Load += new System.EventHandler(this.Page_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();

		}
		#endregion	

		

		
			
		

		private void Button1_Click(object sender, System.EventArgs e)
		{
			
				DataRow row=dataSet11.Tables["授课教师信息"].NewRow();
				row["授课教师编号"]=TextBox1.Text;
				row["授课教师密码"]=TextBox3.Text;
				row["授课教师姓名"]=TextBox2.Text;
				dataSet11.Tables["授课教师信息"].Rows.Add(row);
				sqlDataAdapter1.Update(dataSet11,"授课教师信息");
				DataGrid1.DataBind();
			
		}
		
		public void DataGrid_Delete(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
		{
				dataSet11.Tables["授课教师信息"].Rows[e.Item.DataSetIndex].Delete();
				sqlDataAdapter1.Update(dataSet11,"授课教师信息");
				DataGrid1.DataBind();
		}

		private void Button2_Click(object sender, System.EventArgs e)
		{
			TextBox1.Text="";
			TextBox2.Text="";
			TextBox3.Text="";
		
		}

	}
}

⌨️ 快捷键说明

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