📄 roomsearch.cs
字号:
//
// comboFactPeopleNum
//
this.comboFactPeopleNum.Items.AddRange(new object[] {
"0",
"1",
"2",
"3",
"4"});
this.comboFactPeopleNum.Location = new System.Drawing.Point(200, 56);
this.comboFactPeopleNum.Name = "comboFactPeopleNum";
this.comboFactPeopleNum.Size = new System.Drawing.Size(88, 20);
this.comboFactPeopleNum.TabIndex = 23;
//
// comboPeopleNum
//
this.comboPeopleNum.Items.AddRange(new object[] {
"1",
"2",
"3",
"4"});
this.comboPeopleNum.Location = new System.Drawing.Point(72, 56);
this.comboPeopleNum.Name = "comboPeopleNum";
this.comboPeopleNum.Size = new System.Drawing.Size(72, 20);
this.comboPeopleNum.TabIndex = 22;
//
// comboRoomPosition
//
this.comboRoomPosition.Items.AddRange(new object[] {
"一层",
"二层",
"三层",
"四层",
"五层"});
this.comboRoomPosition.Location = new System.Drawing.Point(352, 24);
this.comboRoomPosition.Name = "comboRoomPosition";
this.comboRoomPosition.Size = new System.Drawing.Size(72, 20);
this.comboRoomPosition.TabIndex = 21;
//
// comboRoomType
//
this.comboRoomType.Items.AddRange(new object[] {
"标准间",
"双人间",
"四人间",
"豪华间"});
this.comboRoomType.Location = new System.Drawing.Point(200, 24);
this.comboRoomType.Name = "comboRoomType";
this.comboRoomType.Size = new System.Drawing.Size(88, 20);
this.comboRoomType.TabIndex = 20;
//
// textRemark
//
this.textRemark.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.textRemark.Location = new System.Drawing.Point(72, 88);
this.textRemark.Multiline = true;
this.textRemark.Name = "textRemark";
this.textRemark.Size = new System.Drawing.Size(352, 20);
this.textRemark.TabIndex = 18;
this.textRemark.TextChanged += new System.EventHandler(this.textRemark_TextChanged);
//
// listView1
//
this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.listView1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2,
this.columnHeader3,
this.columnHeader4,
this.columnHeader5,
this.columnHeader6});
this.listView1.ForeColor = System.Drawing.SystemColors.Desktop;
this.listView1.FullRowSelect = true;
this.listView1.GridLines = true;
this.listView1.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
this.listView1.Location = new System.Drawing.Point(24, 160);
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(400, 224);
this.listView1.TabIndex = 21;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "房间号";
//
// columnHeader2
//
this.columnHeader2.Text = "房间类型";
//
// columnHeader3
//
this.columnHeader3.Text = "房间楼层";
//
// columnHeader4
//
this.columnHeader4.Text = "额定人数";
//
// columnHeader5
//
this.columnHeader5.Text = "实际人数";
//
// columnHeader6
//
this.columnHeader6.Text = "备注";
this.columnHeader6.Width = 100;
//
// RoomSearch
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(448, 454);
this.Controls.Add(this.listView1);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.btnExit);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "RoomSearch";
this.Text = "客房查询";
this.Load += new System.EventHandler(this.RoomSearch_Load);
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
}
#endregion
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="";
}
private void btnSearch_Click(object sender, System.EventArgs e)
{
bool first=true;
this.selectStr="select * from Room where";
if(this.textRoomID.Text!="")
{
this.selectStr=this.selectStr+" RoomID="+"'"+this.textRoomID.Text+"'";
}
else
{
if(this.comboRoomType.Text!="")
{
this.selectStr=this.selectStr+" RoomType="+"'"+this.comboRoomType.Text+"'";
first=false;
}
if(this.comboRoomPosition.Text!="")
{
if(first)
this.selectStr=this.selectStr+" RoomPosition="+"'"+this.comboRoomPosition.Text+"'";
else
this.selectStr=this.selectStr+" and RoomPosition="+"'"+this.comboRoomPosition.Text+"'";
first=false;
}
if(this.comboPeopleNum.Text!="")
{
if(first)
this.selectStr=this.selectStr+" PeopleNum="+Convert.ToInt32(this.comboPeopleNum.Text);
else
this.selectStr=this.selectStr+" and PeopleNum="+Convert.ToInt32(this.comboPeopleNum.Text);
first=false;
}
if(this.comboFactPeopleNum.Text!="")
{
if(first)
this.selectStr=this.selectStr+" FactPeopleNum="+Convert.ToInt32(this.comboFactPeopleNum.Text);
else
this.selectStr=this.selectStr+" and FactPeopleNum="+Convert.ToInt32(this.comboFactPeopleNum.Text);
first=false;
}
if(this.textRemark.Text!="")
{
if(first)
this.selectStr=this.selectStr+" Remark="+"'"+this.textRemark.Text+"'";
else
this.selectStr=this.selectStr+" and Remark="+"'"+this.textRemark.Text+"'";
first=false;
}
}
this.UpdateListView(this.selectStr);
this.TextClear();
this.btnBookIn.Enabled=true;
}
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["RoomTypeName"].ToString ( ) ) ;
li.SubItems.Add ( sqlDataReader1["RoomPosition"].ToString ( ) ) ;
li.SubItems.Add (sqlDataReader1["PeopleNum"].ToString ( ) );
li.SubItems.Add (sqlDataReader1["FactPeopleNum"].ToString ( ) ) ;
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();
}
}
private void btnBookIn_Click(object sender, System.EventArgs e)
{
int i;
for(i=0;i<this.listView1.Items.Count;i++)
{
if(this.listView1.Items[i].Selected==true)
break;
}
ClientBookIn bookinForm=new ClientBookIn(this.listView1.Items[i].SubItems[0].Text);
try
{
bookinForm.ShowDialog();
}
catch(Exception E)
{
MessageBox.Show(E.ToString());
}
if(this.listView1.Items.Count==0)
{
MessageBox.Show("没有记录存在","没有记录",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
this.listView1.Items.Clear();
this.TextClear();
}
private void RoomSearch_Load(object sender, System.EventArgs e)
{
this.btnBookIn.Enabled=false;
}
private void btnEmptyRoom_Click(object sender, System.EventArgs e)
{
this.selectStr="select * from Room where FactPeopleNum=0";
this.UpdateListView(this.selectStr);
this.TextClear();
this.btnBookIn.Enabled=true;
}
private void btnNotFull_Click(object sender, System.EventArgs e)
{
this.selectStr="select * from Room where PeopleNum>FactPeopleNum";
this.UpdateListView(this.selectStr);
this.TextClear();
this.btnBookIn.Enabled=true;
}
private void textRemark_TextChanged(object sender, EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -