📄 searchroom.cs
字号:
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.textRoomID);
this.groupBox1.Controls.Add(this.comboFactPeopleNum);
this.groupBox1.ForeColor = System.Drawing.SystemColors.Desktop;
this.groupBox1.Location = new System.Drawing.Point(24, 8);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(456, 120);
this.groupBox1.TabIndex = 23;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "输入查询条件";
//
// checkIsFull
//
this.checkIsFull.Location = new System.Drawing.Point(360, 56);
this.checkIsFull.Name = "checkIsFull";
this.checkIsFull.Size = new System.Drawing.Size(80, 24);
this.checkIsFull.TabIndex = 19;
this.checkIsFull.Text = "是否人满";
//
// textRemark
//
this.textRemark.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textRemark.Enabled = false;
this.textRemark.Location = new System.Drawing.Point(80, 88);
this.textRemark.Multiline = true;
this.textRemark.Name = "textRemark";
this.textRemark.Size = new System.Drawing.Size(360, 20);
this.textRemark.TabIndex = 18;
this.textRemark.Text = "";
//
// comboRoomPosition
//
this.comboRoomPosition.AllowDrop = true;
this.comboRoomPosition.BackColor = System.Drawing.Color.White;
this.comboRoomPosition.ForeColor = System.Drawing.SystemColors.Desktop;
this.comboRoomPosition.IntegralHeight = false;
this.comboRoomPosition.Items.AddRange(new object[] {
"二层",
"三层",
"四层",
"五层",
"一层"});
this.comboRoomPosition.Location = new System.Drawing.Point(368, 24);
this.comboRoomPosition.Name = "comboRoomPosition";
this.comboRoomPosition.Size = new System.Drawing.Size(84, 20);
this.comboRoomPosition.Sorted = true;
this.comboRoomPosition.TabIndex = 15;
//
// label5
//
this.label5.BackColor = System.Drawing.Color.White;
this.label5.Location = new System.Drawing.Point(16, 88);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(56, 25);
this.label5.TabIndex = 11;
this.label5.Text = "其他条件";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label4
//
this.label4.BackColor = System.Drawing.Color.White;
this.label4.Location = new System.Drawing.Point(160, 56);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(56, 25);
this.label4.TabIndex = 10;
this.label4.Text = "实际人数";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label3
//
this.label3.BackColor = System.Drawing.Color.White;
this.label3.Location = new System.Drawing.Point(16, 56);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(60, 25);
this.label3.TabIndex = 9;
this.label3.Text = "额定人数";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// comboPeopleNum
//
this.comboPeopleNum.AllowDrop = true;
this.comboPeopleNum.BackColor = System.Drawing.Color.White;
this.comboPeopleNum.ForeColor = System.Drawing.SystemColors.Desktop;
this.comboPeopleNum.IntegralHeight = false;
this.comboPeopleNum.Items.AddRange(new object[] {
"1",
"2",
"3",
"4"});
this.comboPeopleNum.Location = new System.Drawing.Point(80, 56);
this.comboPeopleNum.Name = "comboPeopleNum";
this.comboPeopleNum.Size = new System.Drawing.Size(72, 20);
this.comboPeopleNum.Sorted = true;
this.comboPeopleNum.TabIndex = 17;
//
// comboRoomType
//
this.comboRoomType.AllowDrop = true;
this.comboRoomType.BackColor = System.Drawing.Color.White;
this.comboRoomType.ForeColor = System.Drawing.SystemColors.Desktop;
this.comboRoomType.IntegralHeight = false;
this.comboRoomType.Items.AddRange(new object[] {
"标准间",
"豪华间",
"双人间",
"四人间"});
this.comboRoomType.Location = new System.Drawing.Point(216, 24);
this.comboRoomType.Name = "comboRoomType";
this.comboRoomType.Size = new System.Drawing.Size(88, 20);
this.comboRoomType.Sorted = true;
this.comboRoomType.TabIndex = 7;
//
// label6
//
this.label6.BackColor = System.Drawing.Color.White;
this.label6.Location = new System.Drawing.Point(312, 24);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(60, 25);
this.label6.TabIndex = 6;
this.label6.Text = "房间楼层";
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label2
//
this.label2.BackColor = System.Drawing.Color.White;
this.label2.Location = new System.Drawing.Point(152, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(64, 25);
this.label2.TabIndex = 2;
this.label2.Text = "房间类型";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label1
//
this.label1.BackColor = System.Drawing.Color.White;
this.label1.Location = new System.Drawing.Point(16, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(60, 25);
this.label1.TabIndex = 1;
this.label1.Text = "房间号";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// textRoomID
//
this.textRoomID.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textRoomID.Enabled = false;
this.textRoomID.Location = new System.Drawing.Point(80, 24);
this.textRoomID.Multiline = true;
this.textRoomID.Name = "textRoomID";
this.textRoomID.Size = new System.Drawing.Size(68, 20);
this.textRoomID.TabIndex = 0;
this.textRoomID.Text = "";
//
// comboFactPeopleNum
//
this.comboFactPeopleNum.AllowDrop = true;
this.comboFactPeopleNum.BackColor = System.Drawing.Color.White;
this.comboFactPeopleNum.ForeColor = System.Drawing.SystemColors.Desktop;
this.comboFactPeopleNum.IntegralHeight = false;
this.comboFactPeopleNum.Items.AddRange(new object[] {
"1",
"2",
"3",
"4"});
this.comboFactPeopleNum.Location = new System.Drawing.Point(216, 56);
this.comboFactPeopleNum.Name = "comboFactPeopleNum";
this.comboFactPeopleNum.Size = new System.Drawing.Size(88, 20);
this.comboFactPeopleNum.Sorted = true;
this.comboFactPeopleNum.TabIndex = 16;
//
// SearchRoom
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.SystemColors.Window;
this.ClientSize = new System.Drawing.Size(600, 453);
this.Controls.Add(this.listView1);
this.Controls.Add(this.panel2);
this.Controls.Add(this.groupBox1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "SearchRoom";
this.Text = "客房查询";
this.panel2.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
static void Main()
{
Application.Run(new SearchRoom());
}
private void btnExit_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void btnCancel_Click(object sender, System.EventArgs e)
{
this.TextClear();
}
private void TextClear()
{
this.textRoomID.Clear();
this.textRemark.Clear();
this.comboRoomType.Text="";
this.comboRoomPosition.Text="";
this.comboPeopleNum.Text="";
this.comboFactPeopleNum.Text="";
this.checkIsFull.Checked=false;
}
private void btnSearch_Click(object sender, System.EventArgs e)
{
this.selectStr="select * from Room";
if(this.textRoomID.Text!="")
{
this.selectStr=this.selectStr+" where RoomID="+"'"+this.textRoomID.Text+"'";
this.UpdateListView(this.selectStr);
}
}
private void UpdateListView(string selectstr)
{
this.listView1.Items.Clear();
this.listView1.Refresh();
this.sqlCommand1.CommandText=selectstr;
try
{
if(this.sqlConnection1.State==ConnectionState.Closed)this.sqlConnection1.Open();
this.sqlDataReader1=this.sqlCommand1.ExecuteReader();
while(this.sqlDataReader1.Read())
{
ListViewItem li = new ListViewItem ( ) ;
li.SubItems.Clear ( ) ;
li.SubItems[0].Text = sqlDataReader1["RoomID"].ToString ( ) ;
li.SubItems.Add ( sqlDataReader1["RoomType"].ToString ( ) ) ;
li.SubItems.Add ( sqlDataReader1["RoomPosition"].ToString ( ) ) ;
li.SubItems.Add (sqlDataReader1["PeopleNum"].ToString ( ) );
li.SubItems.Add (sqlDataReader1["FactPeopleNum"].ToString ( ) ) ;
if(Convert.ToBoolean(sqlDataReader1["IsFull"]) ==true)
li.SubItems.Add ("是" ) ;
else
li.SubItems.Add("否");
li.SubItems.Add ( sqlDataReader1["Remark"].ToString ( ) ) ;
this.listView1.Items.Add ( li ) ;
}
}
catch(System.Exception E)
{
MessageBox.Show(E.ToString());
}
finally
{
this.sqlDataReader1.Close();
this.sqlConnection1.Close();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -