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

📄 admin1.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 tang
{
	/// <summary>
	/// admin1 的摘要说明。
	/// </summary>
	public class admin1 : System.Web.UI.Page
	{
		protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
		protected tang.DataSet1 dataSet11;
		protected System.Web.UI.WebControls.DataGrid DataGrid1;
		protected System.Web.UI.WebControls.Label Label2;
		protected System.Web.UI.WebControls.Label Label3;
		protected System.Web.UI.WebControls.Label Label4;
		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 sqlConnection2;
		protected System.Web.UI.WebControls.RadioButtonList RadioButtonList1;
		protected System.Web.UI.WebControls.Button Button1;
		protected System.Web.UI.WebControls.Label Label6;
		protected System.Data.SqlClient.SqlConnection sqlConnection1;
		protected System.Web.UI.WebControls.Label Label1;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
				if (!IsPostBack)//页面第一次加载时; 
		 { 
			 if (Session["username"] ==null) 
			 { 

				 this.Response.Redirect("error.aspx");//重定向到登录也就是身份验证的那个页面 
			 } 
		 } 
			// 在此处放置用户代码以初始化页面
			string id=Session["username"].ToString();
			sqlDataAdapter1.SelectCommand.Parameters["@id"].Value=id;
			sqlDataAdapter1.Fill(dataSet11,"学生信息");
			DataGrid1.DataBind();
			Label3.Text=Session["username"].ToString();
		}

		#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.sqlConnection2 = 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.dataSet11 = new tang.DataSet1();
			this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
			((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
			this.Button1.Click += new System.EventHandler(this.Button1_Click);
			// 
			// 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", "学生信息", new System.Data.Common.DataColumnMapping[] {
																																																			  new System.Data.Common.DataColumnMapping("学生编号", "学生编号"),
																																																			  new System.Data.Common.DataColumnMapping("学生姓名", "学生姓名"),
																																																			  new System.Data.Common.DataColumnMapping("性别", "性别"),
																																																			  new System.Data.Common.DataColumnMapping("学生密码", "学生密码"),
																																																			  new System.Data.Common.DataColumnMapping("其他学生信息", "其他学生信息"),
																																																			  new System.Data.Common.DataColumnMapping("班级编号", "班级编号")})});
			this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
			// 
			// sqlDeleteCommand1
			// 
			this.sqlDeleteCommand1.CommandText = @"DELETE FROM 学生信息 WHERE (学生编号 = @Original_学生编号) AND (其他学生信息 = @Original_其他学生信息 OR @Original_其他学生信息 IS NULL AND 其他学生信息 IS NULL) AND (学生姓名 = @Original_学生姓名 OR @Original_学生姓名 IS NULL AND 学生姓名 IS NULL) AND (学生密码 = @Original_学生密码 OR @Original_学生密码 IS NULL AND 学生密码 IS NULL) AND (性别 = @Original_性别 OR @Original_性别 IS NULL AND 性别 IS NULL) AND (班级编号 = @Original_班级编号 OR @Original_班级编号 IS NULL AND 班级编号 IS NULL)";
			this.sqlDeleteCommand1.Connection = this.sqlConnection2;
			this.sqlDeleteCommand1.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.sqlDeleteCommand1.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.sqlDeleteCommand1.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.sqlDeleteCommand1.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.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_性别", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "性别", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.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));
			// 
			// sqlConnection2
			// 
			this.sqlConnection2.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 (@学生编号, @学生姓名, @性别, @" +
				"学生密码, @其他学生信息, @班级编号); SELECT 学生编号, 学生姓名, 性别, 学生密码, 其他学生信息, 班级编号 FROM 学生信息 WHERE" +
				" (学生编号 = @学生编号)";
			this.sqlInsertCommand1.Connection = this.sqlConnection2;
			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, "学生姓名"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@性别", System.Data.SqlDbType.VarChar, 20, "性别"));
			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, "其他学生信息"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@班级编号", System.Data.SqlDbType.VarChar, 6, "班级编号"));
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.CommandText = "SELECT 学生编号, 学生姓名, 性别, 学生密码, 其他学生信息, 班级编号 FROM 学生信息 WHERE (学生编号 = @id)";
			this.sqlSelectCommand1.Connection = this.sqlConnection2;
			this.sqlSelectCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@id", System.Data.SqlDbType.VarChar, 6, "学生编号"));
			// 
			// sqlUpdateCommand1
			// 
			this.sqlUpdateCommand1.CommandText = @"UPDATE 学生信息 SET 学生编号 = @学生编号, 学生姓名 = @学生姓名, 性别 = @性别, 学生密码 = @学生密码, 其他学生信息 = @其他学生信息, 班级编号 = @班级编号 WHERE (学生编号 = @Original_学生编号) AND (其他学生信息 = @Original_其他学生信息 OR @Original_其他学生信息 IS NULL AND 其他学生信息 IS NULL) AND (学生姓名 = @Original_学生姓名 OR @Original_学生姓名 IS NULL AND 学生姓名 IS NULL) AND (学生密码 = @Original_学生密码 OR @Original_学生密码 IS NULL AND 学生密码 IS NULL) AND (性别 = @Original_性别 OR @Original_性别 IS NULL AND 性别 IS NULL) AND (班级编号 = @Original_班级编号 OR @Original_班级编号 IS NULL AND 班级编号 IS NULL); SELECT 学生编号, 学生姓名, 性别, 学生密码, 其他学生信息, 班级编号 FROM 学生信息 WHERE (学生编号 = @学生编号)";
			this.sqlUpdateCommand1.Connection = this.sqlConnection2;
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@学生编号", System.Data.SqlDbType.VarChar, 6, "学生编号"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@学生姓名", System.Data.SqlDbType.VarChar, 18, "学生姓名"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@性别", System.Data.SqlDbType.VarChar, 20, "性别"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@学生密码", System.Data.SqlDbType.VarChar, 6, "学生密码"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@其他学生信息", System.Data.SqlDbType.VarChar, 18, "其他学生信息"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@班级编号", System.Data.SqlDbType.VarChar, 6, "班级编号"));
			this.sqlUpdateCommand1.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.sqlUpdateCommand1.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.sqlUpdateCommand1.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.sqlUpdateCommand1.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.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_性别", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "性别", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.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 DataGrid1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		
		}

		private void Button1_Click(object sender, System.EventArgs e)
		{
		    Session["id"]=Session["username"].ToString();
			if(RadioButtonList1.SelectedIndex==0)
			{
				Response.Redirect("xs.aspx");
			}
			else
			if(RadioButtonList1.SelectedIndex==1)
			    Response.Redirect("kq_xs.aspx");
			else
				Response.Redirect("xs.aspx");

		}
		
	}
}

⌨️ 快捷键说明

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