📄 roomsearch.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.RoomManage
{
/// <summary>
/// RoomSearch 的摘要说明。
/// </summary>
public class RoomSearch : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.DropDownList DropDownList1;
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.Button Search;
protected System.Web.UI.WebControls.Label Label1;
protected string cmdText;
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 Label2;
protected Manage.DataSet1 dataSet11;
private void Data_Bind()
{
myConn=ConfigurationSettings.AppSettings["mySql"];
cmdText="select * from Room";
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,"Room");
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 Room 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,"Room");
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.Search.Click += new System.EventHandler(this.Search_Click);
this.DataGrid1.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.DataGrid1_PageIndexChanged);
//
// 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", "Room", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("Room_ID", "Room_ID"),
new System.Data.Common.DataColumnMapping("Floor_ID", "Floor_ID"),
new System.Data.Common.DataColumnMapping("Room_NO", "Room_NO"),
new System.Data.Common.DataColumnMapping("Room_Sta", "Room_Sta"),
new System.Data.Common.DataColumnMapping("Room_Phone", "Room_Phone"),
new System.Data.Common.DataColumnMapping("Room_Desk", "Room_Desk"),
new System.Data.Common.DataColumnMapping("Room_Light", "Room_Light"),
new System.Data.Common.DataColumnMapping("Room_Bed", "Room_Bed"),
new System.Data.Common.DataColumnMapping("Room_Seat", "Room_Seat"),
new System.Data.Common.DataColumnMapping("Room_Closet", "Room_Closet"),
new System.Data.Common.DataColumnMapping("Room_WaterBill", "Room_WaterBill"),
new System.Data.Common.DataColumnMapping("Room_ElectricalBill", "Room_ElectricalBill")})});
this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
//
// sqlDeleteCommand1
//
this.sqlDeleteCommand1.CommandText = @"DELETE FROM Room WHERE (Room_ID = @Original_Room_ID) AND (Floor_ID = @Original_Floor_ID) AND (Room_Bed = @Original_Room_Bed) AND (Room_Closet = @Original_Room_Closet) AND (Room_Desk = @Original_Room_Desk) AND (Room_ElectricalBill = @Original_Room_ElectricalBill OR @Original_Room_ElectricalBill IS NULL AND Room_ElectricalBill IS NULL) AND (Room_Light = @Original_Room_Light) AND (Room_NO = @Original_Room_NO) AND (Room_Phone = @Original_Room_Phone OR @Original_Room_Phone IS NULL AND Room_Phone IS NULL) AND (Room_Seat = @Original_Room_Seat) AND (Room_Sta = @Original_Room_Sta) AND (Room_WaterBill = @Original_Room_WaterBill OR @Original_Room_WaterBill IS NULL AND Room_WaterBill IS NULL)";
this.sqlDeleteCommand1.Connection = this.sqlConnection1;
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_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_Room_Bed", System.Data.SqlDbType.SmallInt, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "Room_Bed", System.Data.DataRowVersion.Original, null));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -