📄 roommanageform.cs
字号:
this.label3.TabIndex = 9;
this.label3.Text = "额定人数";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// 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(208, 12);
this.comboRoomType.Name = "comboRoomType";
this.comboRoomType.Size = new System.Drawing.Size(88, 20);
this.comboRoomType.Sorted = true;
this.comboRoomType.TabIndex = 7;
this.comboRoomType.Text = "选择";
//
// label6
//
this.label6.BackColor = System.Drawing.Color.White;
this.label6.Location = new System.Drawing.Point(300, 12);
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(140, 8);
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(8, 8);
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(68, 12);
this.textRoomID.Multiline = true;
this.textRoomID.Name = "textRoomID";
this.textRoomID.Size = new System.Drawing.Size(68, 20);
this.textRoomID.TabIndex = 0;
this.textRoomID.Text = "";
//
// btnSave
//
this.btnSave.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnSave.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnSave.Location = new System.Drawing.Point(468, 40);
this.btnSave.Name = "btnSave";
this.btnSave.Size = new System.Drawing.Size(76, 24);
this.btnSave.TabIndex = 17;
this.btnSave.Text = "保存";
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
//
// btnNew
//
this.btnNew.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnNew.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnNew.Location = new System.Drawing.Point(468, 8);
this.btnNew.Name = "btnNew";
this.btnNew.Size = new System.Drawing.Size(76, 23);
this.btnNew.TabIndex = 18;
this.btnNew.Text = "新建";
this.btnNew.Click += new System.EventHandler(this.btnNew_Click);
//
// btnExit
//
this.btnExit.BackColor = System.Drawing.SystemColors.Window;
this.btnExit.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.btnExit.ForeColor = System.Drawing.SystemColors.Desktop;
this.btnExit.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
this.btnExit.Location = new System.Drawing.Point(468, 76);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new System.Drawing.Size(76, 23);
this.btnExit.TabIndex = 15;
this.btnExit.Text = "退出";
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// dataGrid1
//
this.dataGrid1.BackgroundColor = System.Drawing.SystemColors.ActiveCaptionText;
this.dataGrid1.CaptionVisible = false;
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(8, 160);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.Size = new System.Drawing.Size(584, 256);
this.dataGrid1.TabIndex = 4;
//
// RoomManageForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.AliceBlue;
this.ClientSize = new System.Drawing.Size(600, 429);
this.Controls.Add(this.dataGrid1);
this.Controls.Add(this.panel1);
this.Name = "RoomManageForm";
this.Text = "客房信息管理";
this.Load += new System.EventHandler(this.Room_Load);
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new RoomManageForm());
}
private void btnExit_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void Room_Load(object sender, System.EventArgs e)
{
this.FillDataGrid();
}
private void btnNew_Click(object sender, System.EventArgs e)
{
this.add=true;
this.textRoomID.Enabled=true;
this.textRoomID.Clear();
this.comboRoomPosition.Text="请选择";
this.comboBedNum.Text="请选择";
this.comboPeopleNum.Text="请选择";
this.comboRoomType.Text="请选择";
this.textRemark.Clear();
}
private void btnSave_Click(object sender, System.EventArgs e)
{
this.textRoomID.Enabled=false;
string roomid=this.textRoomID.Text;
string roomtype=this.comboRoomType.Text;
string roomposition=this.comboRoomPosition.Text;
int bednum=Convert.ToInt16(this.comboBedNum.Text);
int HoldPeopleNum=Convert.ToInt16(this.comboPeopleNum.Text);
string roomremark=this.textRemark.Text;
if(this.add)
{
//this.selectStr="insert into Room values("+"'"+this.textRoomID.Text+"',"+"'"+this.comboRoomType.Text+"',"+"'"+this.comboRoomPosition.Text+"',"+"'"+this.comboBedNum.Text+"',"+"'"+this.comboPeopleNum.Text+"',"+"'"+this.textRemark.Text+"'"+")";
if(this.roomManage.Room_Add(roomid,roomtype,roomposition,bednum,HoldPeopleNum,roomremark)==true)
{
this.FillDataGrid();
}
else
{
MessageBox.Show("添加新记录有误");
}
}
else
{
// this.selectStr="update Room set RoomType="+"'"+this.comboRoomType.Text+"',"+"RoomPosition="+"'"+this.comboRoomPosition.Text+"',"+"BedNum="+"'"+this.comboBedNum.Text+"',"+"HoldPeopleNum="+"'"+this.comboPeopleNum.Text+"',"+"Remark="+"'"+this.textRemark.Text+"'"+" where RoomID="+this.textRoomID.Text;
if(this.roomManage.Room_Modify(roomid,roomtype,roomposition,bednum,HoldPeopleNum,roomremark)==true)
{
this.FillDataGrid();
}
else
{
MessageBox.Show("保存记录有误");
}
}
this.add=false;
}
private void FillDataGrid()
{
this.selectStr="select RoomID 房间号,RoomTypeName 房间类型,RoomPosition 房间楼层,HoldPeopleNum 额定人数,FactPeopleNum 实际人数,Remark 备注 from Room ";
if(this.sqlConnection1.State==ConnectionState.Closed)this.sqlConnection1.Open();
Console.WriteLine(selectStr);
SqlDataAdapter adapter = new SqlDataAdapter(selectStr,sqlConnection1);
ds = new DataSet("t_user");
adapter.Fill(ds,"t_user");
this.dataGrid1.SetDataBinding(ds,"t_user");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -