📄 default.aspx.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.Configuration;
namespace Manage
{
/// <summary>
/// Main 的摘要说明。
/// </summary>
public class Main : System.Web.UI.Page
{
protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
protected System.Data.SqlClient.SqlConnection sqlConnection1;
protected System.Web.UI.WebControls.Panel Panel1;
protected Manage.DataSet1 dataSet11;
protected System.Data.SqlClient.SqlCommand cmd;
protected string myConn;
protected System.Web.UI.WebControls.DataList DataList1;
protected System.Web.UI.WebControls.DataList DataList2;
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 string cmdText;
private void Data_Bind(string cmdtext,System.Web.UI.WebControls.DataList dl)
{
myConn=ConfigurationSettings.AppSettings["mySql"];
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,"Info");
dl.DataSource=this.dataSet11;
dl.DataBind();
this.sqlConnection1.Close();
}
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
StudentMenu sm=(StudentMenu)LoadControl("StudentMenu.ascx");
ManagerMenu sk=(ManagerMenu)LoadControl("managerMenu.ascx");
if(this.Session["kind"].ToString()=="学生")
this.Panel1.Controls.Add(sm);
else if(this.Session["kind"].ToString()=="管理员")
this.Panel1.Controls.Add(sk);
Data_Bind("select * from Info where Info_Kind='学生'",this.DataList2);
Data_Bind("select * from Info where Info_Kind='管理员'",this.DataList1);
}
#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();
//
// 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", "Info", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("Info_ID", "Info_ID"),
new System.Data.Common.DataColumnMapping("Info_Writer", "Info_Writer"),
new System.Data.Common.DataColumnMapping("Info_Main", "Info_Main"),
new System.Data.Common.DataColumnMapping("Info_Kind", "Info_Kind"),
new System.Data.Common.DataColumnMapping("Info_Text", "Info_Text"),
new System.Data.Common.DataColumnMapping("Info_Date", "Info_Date")})});
this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
//
// sqlDeleteCommand1
//
this.sqlDeleteCommand1.CommandText = "DELETE FROM Info WHERE (Info_ID = @Original_Info_ID) AND (Info_Date = @Original_I" +
"nfo_Date) AND (Info_Kind = @Original_Info_Kind) AND (Info_Main = @Original_Info_" +
"Main) AND (Info_Text = @Original_Info_Text) AND (Info_Writer = @Original_Info_Wr" +
"iter)";
this.sqlDeleteCommand1.Connection = this.sqlConnection1;
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Info_ID", System.Data.SqlDbType.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Info_ID", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Info_Date", System.Data.SqlDbType.NVarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Info_Date", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Info_Kind", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Info_Kind", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Info_Main", System.Data.SqlDbType.VarChar, 40, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Info_Main", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Info_Text", System.Data.SqlDbType.VarChar, 1000, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Info_Text", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Info_Writer", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Info_Writer", 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 Info(Info_ID, Info_Writer, Info_Main, Info_Kind, Info_Text, Info_Date) VALUES (@Info_ID, @Info_Writer, @Info_Main, @Info_Kind, @Info_Text, @Info_Date); SELECT Info_ID, Info_Writer, Info_Main, Info_Kind, Info_Text, Info_Date FROM Info WHERE (Info_ID = @Info_ID)";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Info_ID", System.Data.SqlDbType.BigInt, 8, "Info_ID"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Info_Writer", System.Data.SqlDbType.VarChar, 20, "Info_Writer"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Info_Main", System.Data.SqlDbType.VarChar, 40, "Info_Main"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Info_Kind", System.Data.SqlDbType.VarChar, 10, "Info_Kind"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Info_Text", System.Data.SqlDbType.VarChar, 1000, "Info_Text"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Info_Date", System.Data.SqlDbType.NVarChar, 10, "Info_Date"));
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT Info_ID, Info_Writer, Info_Main, Info_Kind, Info_Text, Info_Date FROM Info" +
"";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = @"UPDATE Info SET Info_ID = @Info_ID, Info_Writer = @Info_Writer, Info_Main = @Info_Main, Info_Kind = @Info_Kind, Info_Text = @Info_Text, Info_Date = @Info_Date WHERE (Info_ID = @Original_Info_ID) AND (Info_Date = @Original_Info_Date) AND (Info_Kind = @Original_Info_Kind) AND (Info_Main = @Original_Info_Main) AND (Info_Text = @Original_Info_Text) AND (Info_Writer = @Original_Info_Writer); SELECT Info_ID, Info_Writer, Info_Main, Info_Kind, Info_Text, Info_Date FROM Info WHERE (Info_ID = @Info_ID)";
this.sqlUpdateCommand1.Connection = this.sqlConnection1;
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Info_ID", System.Data.SqlDbType.BigInt, 8, "Info_ID"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Info_Writer", System.Data.SqlDbType.VarChar, 20, "Info_Writer"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Info_Main", System.Data.SqlDbType.VarChar, 40, "Info_Main"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Info_Kind", System.Data.SqlDbType.VarChar, 10, "Info_Kind"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Info_Text", System.Data.SqlDbType.VarChar, 1000, "Info_Text"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Info_Date", System.Data.SqlDbType.NVarChar, 10, "Info_Date"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Info_ID", System.Data.SqlDbType.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Info_ID", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Info_Date", System.Data.SqlDbType.NVarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Info_Date", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Info_Kind", System.Data.SqlDbType.VarChar, 10, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Info_Kind", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Info_Main", System.Data.SqlDbType.VarChar, 40, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Info_Main", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Info_Text", System.Data.SqlDbType.VarChar, 1000, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Info_Text", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Info_Writer", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Info_Writer", System.Data.DataRowVersion.Original, null));
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -