📄 managerdel.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>
/// ManagerDel 的摘要说明。
/// </summary>
public class ManagerDel : System.Web.UI.Page
{
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 System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.DropDownList DropDownList1;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Button Search;
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected string cmdText;
protected System.Data.SqlClient.SqlConnection conn;
protected System.Data.SqlClient.SqlCommand cmd;
protected System.Data.SqlClient.SqlDataReader reader;
protected string myConn;
protected Manage.DataSet1 dataSet12;
protected Manage.DataSet1 dataSet11;
private void Data_Bind()
{
myConn=ConfigurationSettings.AppSettings["mySql"];
cmdText="select * from Manager";
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,"Manager");
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.TextBox1.Text+"'";
cmdText="select * from Manager 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,"Manager");
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.dataSet12 = new Manage.DataSet1();
((System.ComponentModel.ISupportInitialize)(this.dataSet12)).BeginInit();
this.Search.Click += new System.EventHandler(this.Search_Click);
this.DataGrid1.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.DataGrid1_PageIndexChanged);
this.DataGrid1.DeleteCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_DeleteCommand);
//
// 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", "Manager", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("Manager_UserName", "Manager_UserName"),
new System.Data.Common.DataColumnMapping("Manager_Name", "Manager_Name"),
new System.Data.Common.DataColumnMapping("Manager_Age", "Manager_Age"),
new System.Data.Common.DataColumnMapping("Manager_Sex", "Manager_Sex"),
new System.Data.Common.DataColumnMapping("Manager_Tel", "Manager_Tel"),
new System.Data.Common.DataColumnMapping("Floor_ID", "Floor_ID")})});
this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
//
// sqlDeleteCommand1
//
this.sqlDeleteCommand1.CommandText = @"DELETE FROM Manager WHERE (Manager_UserName = @Original_Manager_UserName) AND (Floor_ID = @Original_Floor_ID OR @Original_Floor_ID IS NULL AND Floor_ID IS NULL) AND (Manager_Age = @Original_Manager_Age OR @Original_Manager_Age IS NULL AND Manager_Age IS NULL) AND (Manager_Name = @Original_Manager_Name) AND (Manager_Sex = @Original_Manager_Sex) AND (Manager_Tel = @Original_Manager_Tel OR @Original_Manager_Tel IS NULL AND Manager_Tel IS NULL)";
this.sqlDeleteCommand1.Connection = this.sqlConnection1;
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Manager_UserName", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Manager_UserName", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Floor_ID", System.Data.SqlDbType.SmallInt, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Floor_ID", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Manager_Age", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Manager_Age", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Manager_Name", System.Data.SqlDbType.VarChar, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Manager_Name", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Manager_Sex", System.Data.SqlDbType.VarChar, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Manager_Sex", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_Manager_Tel", System.Data.SqlDbType.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Manager_Tel", System.Data.DataRowVersion.Original, null));
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -