📄 tjsb.cs
字号:
//
this.label15.Location = new System.Drawing.Point(448, 26);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(56, 16);
this.label15.TabIndex = 18;
this.label15.Text = "房间类型";
//
// textBox10
//
this.textBox10.Location = new System.Drawing.Point(312, 24);
this.textBox10.Name = "textBox10";
this.textBox10.Size = new System.Drawing.Size(104, 21);
this.textBox10.TabIndex = 17;
this.textBox10.Text = "";
//
// label16
//
this.label16.Location = new System.Drawing.Point(248, 26);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(56, 16);
this.label16.TabIndex = 16;
this.label16.Text = "房间楼层";
//
// textBox9
//
this.textBox9.Location = new System.Drawing.Point(96, 24);
this.textBox9.Name = "textBox9";
this.textBox9.Size = new System.Drawing.Size(104, 21);
this.textBox9.TabIndex = 15;
this.textBox9.Text = "";
//
// label17
//
this.label17.Location = new System.Drawing.Point(32, 26);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(48, 16);
this.label17.TabIndex = 14;
this.label17.Text = "房间号";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.comboBox2);
this.groupBox2.Controls.Add(this.label2);
this.groupBox2.Controls.Add(this.listView5);
this.groupBox2.Location = new System.Drawing.Point(8, 8);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(752, 224);
this.groupBox2.TabIndex = 2;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "房间";
//
// comboBox2
//
this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox2.Location = new System.Drawing.Point(168, 22);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(152, 20);
this.comboBox2.TabIndex = 19;
this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
//
// label2
//
this.label2.Location = new System.Drawing.Point(32, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(128, 16);
this.label2.TabIndex = 18;
this.label2.Text = "您要显示的房间类型:";
//
// listView5
//
this.listView5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.listView5.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader25,
this.columnHeader26,
this.columnHeader12,
this.columnHeader27,
this.columnHeader28,
this.columnHeader29,
this.columnHeader31});
this.listView5.FullRowSelect = true;
this.listView5.GridLines = true;
this.listView5.Location = new System.Drawing.Point(8, 56);
this.listView5.Name = "listView5";
this.listView5.Size = new System.Drawing.Size(728, 160);
this.listView5.TabIndex = 3;
this.listView5.View = System.Windows.Forms.View.Details;
this.listView5.Click += new System.EventHandler(this.listView5_Click_1);
//
// columnHeader25
//
this.columnHeader25.Text = "房间号";
this.columnHeader25.Width = 80;
//
// columnHeader26
//
this.columnHeader26.Text = "客房楼层";
this.columnHeader26.Width = 100;
//
// columnHeader12
//
this.columnHeader12.Text = "房间状态";
this.columnHeader12.Width = 80;
//
// columnHeader27
//
this.columnHeader27.Text = "客房类型";
this.columnHeader27.Width = 100;
//
// columnHeader28
//
this.columnHeader28.Text = "居住人数";
this.columnHeader28.Width = 1;
//
// columnHeader29
//
this.columnHeader29.Text = "客房电话";
this.columnHeader29.Width = 100;
//
// columnHeader31
//
this.columnHeader31.Text = "注释";
this.columnHeader31.Width = 260;
//
// tjsb
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(792, 453);
this.Controls.Add(this.tabControl1);
this.MaximizeBox = false;
this.Name = "tjsb";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "添加设备";
this.Load += new System.EventHandler(this.tjsb_Load);
this.Closed += new System.EventHandler(this.tjsb_Closed);
this.groupBox1.ResumeLayout(false);
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.groupBox6.ResumeLayout(false);
this.groupBox5.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.groupBox8.ResumeLayout(false);
this.groupBox7.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.tabPage3.ResumeLayout(false);
this.groupBox10.ResumeLayout(false);
this.groupBox9.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void tjsb_Load(object sender, System.EventArgs e)
{
getsb();//调用设备表
getkf();//调用房间表
setcom();//给com1入值
setfl();//给com2入值
getfjlx();// 调用房间类型表
setfl1();
}
private void getsb(){
sbobjset=sbsql.selectexe();
this.listView1.Items.Clear();
foreach(DataRow dr in sbobjset.Tables[0].Rows)
{
ListViewItem lst=new ListViewItem();
lst.SubItems.Clear();
lst.SubItems[0].Text=dr[0].ToString();
lst.SubItems.Add(dr[1].ToString());
lst.SubItems.Add(dr[2].ToString());
lst.SubItems.Add(dr[3].ToString());
lst.SubItems.Add(dr[4].ToString());
lst.SubItems.Add(dr[5].ToString());
lst.SubItems.Add(dr[6].ToString());
this.listView1.Items.Add(lst);
}
}
private void getkf()
{
kfobjset=ksql.selectexeshu();
this.listView5.Items.Clear();
foreach(DataRow dr in kfobjset.Tables[0].Rows)
{
ListViewItem lst=new ListViewItem();
lst.SubItems.Clear();
lst.SubItems[0].Text=dr["kid"].ToString();
lst.SubItems.Add(dr["klc"].ToString());
lst.SubItems.Add(dr["kzt"].ToString());
lst.SubItems.Add(dr["klx"].ToString());
lst.SubItems.Add(dr["krs"].ToString());
lst.SubItems.Add(dr["kdh"].ToString());
lst.SubItems.Add(dr["kzs"].ToString());
this.listView5.Items.Add(lst);
}
}
private void setcom(){
sbobjset=sbsql.selectexeshu();
foreach(DataRow dr in sbobjset.Tables[0].Rows)
{
this.comboBox1.Items.Add(dr["slx"].ToString());
}
this.comboBox1.SelectedIndex=0;
}
private void setfl(){
fjobjset=flsql.selectexe();
this.comboBox2.Items.Clear();
foreach(DataRow dr in fjobjset.Tables[0].Rows)
{
this.comboBox2.Items.Add(dr["xname"].ToString());
}
this.comboBox2.SelectedIndex=0;
}
private void setfl1()
{
fjobjset=flsql.selectexe();
this.comboBox3.Items.Clear();
foreach(DataRow dr in fjobjset.Tables[0].Rows)
{
this.comboBox3.Items.Add(dr["xname"].ToString().Trim());
}
this.comboBox3.SelectedIndex=0;
}
private void getfjlx(){
fjobjset=flsql.selectexe();;
this.listView2.Items.Clear();
foreach(DataRow dr in fjobjset.Tables[0].Rows)
{
ListViewItem lst=new ListViewItem();
lst.SubItems.Clear();
lst.SubItems[0].Text=dr[0].ToString();
lst.SubItems.Add(dr[1].ToString());
lst.SubItems.Add(dr[2].ToString());
lst.SubItems.Add(dr[3].ToString());
lst.SubItems.Add(dr[4].ToString());
this.listView2.Items.Add(lst);
}
}
private void button1_Click(object sender, System.EventArgs e)
{
cs.sbbsql sbsql=new bggl.cs.sbbsql();
if(this.textBox1.Text.Trim()!=null && this.textBox2.Text.Trim()!=null && this.textBox4.Text.Trim()!=null && this.textBox5.Text.Trim()!=null)
{
bool pd=sbsql.insertexe(this.textBox1.Text,this.textBox2.Text,this.dateTimePicker1.Text,this.textBox4.Text,this.textBox5.Text,this.textBox6.Text);
if(pd==true)
{
MessageBox.Show("添加成功!");
qksb();
getsb();
setcom();
}
}
else
{
MessageBox.Show("资料不完整,请填写完整!");
}
}
private void button2_Click(object sender, System.EventArgs e)
{
if(idzhi!="")
{
bggl.cs.fjsbsql fjsbsq=new bggl.cs.fjsbsql();
if(fjsbsq.sfyz(this.textBox2.Text))//判断设备是否在房间
{
if(this.textBox1.Text.Trim()!=null && this.textBox2.Text.Trim()!=null && this.textBox4.Text.Trim()!=null && this.textBox5.Text.Trim()!=null)
{
this.button1.Enabled=true;
this.button2.Enabled=false;
this.button3.Enabled=false;
bool pd=sbsql.updateexe(idzhi,this.textBox1.Text,this.textBox2.Text,this.dateTimePicker1.Text,this.textBox4.Text,this.textBox5.Text,this.textBox6.Text);
if(pd==true)
{
MessageBox.Show("修改成功!");
getsb();
setcom();
qksb();
}
}
else
{
MessageBox.Show("资料不完整,请填写完整!");
}
idzhi="";
idzhi1="";
}
else{
MessageBox.Show("设备在房间类型中引用,请先把设备从房间类型里面移除");
}
}
else{
MessageBox.Show("未选择要修改的值");
}
}
private void listView1_Click(object sender, System.EventArgs e)
{
idzhi=this.listView1.SelectedItems[0].SubItems[0].Text;//把选定的记录值放入变量
idzhi1=this.listView1.SelectedItems[0].SubItems[3].Text;
this.button1.Enabled=false;
this.button2.Enabled=true;
this.button3.Enabled=true;
cs.sbbsql sbsql=new bggl.cs.sbbsql();
DataSet objset1=sbsql.selectexe();
foreach(DataRow dr in objset1.Tables[0].Rows)
{
if(idzhi.ToString()==dr["sid"].ToString())
{
this.textBox1.Text=dr["slx"].ToString().Trim();
this.textBox2.Text=dr["sname"].ToString().Trim();
this.dateTimePicker1.Text=dr["srq"].ToString().Trim();
this.textBox4.Text=dr["sgmr"].ToString().Trim();
this.textBox5.Text=dr["sjg"].ToString().Trim();
this.textBox6.Text=dr["sbz"].ToString().Trim();
}
}
}
private void button3_Click(object sender, System.EventArgs e)//删除记录
{
if(idzhi.Trim()!="")
{
bggl.cs.fjsbsql fjsbsq=new bggl.cs.fjsbsql();
if(fjsbsq.sfyz(this.textBox2.Text))//判断设备是否在房间
{
this.button1.Enabled=true;
this.button2.Enabled=false;
this.button3.Enabled=false;
DialogResult panduan=new DialogResult();
panduan=MessageBox.Show("您确定删除当前记录吗?","确认",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if(panduan==DialogResult.Yes)
{
bool pd=sbsql.delexe(idzhi.Trim());
if(pd==true)
{
MessageBox.Show("删除成功!");
this.listView1.Items.Clear();
this.comboBox1.Items.Clear();
getsb();
setcom();
qksb();
idzhi="";
idzhi1="";
}
}
}
else{
MessageBox.Show("设备还在房间中,请先把设备从房间里面移除");
}
}
else
{
MessageBox.Show("没有数据可以删除!");
}
}
private void button6_Click(object sender, System.EventArgs e)
{
if(this.textBox7.Text.Trim()!=""&&this.textBox8.Text.Trim()!=""&&this.textBox14.Text.Trim()!=""&&this.textBox13.Text.Trim()!="")
{
cs.fjlx kfsq=new bggl.cs.fjlx();
bool pd=kfsq.insertexe(this.textBox7.Text,this.textBox8.Text,this.textBox13.Text,this.textBox14.Text,this.textBox3.Text);
if(pd==true)
{
MessageBox.Show("添加成功!");
setfl();//给com2入值
getfjlx();// 调用房间类型表
qkfjlx();
setfl1();
}
else{
MessageBox.Show("添加失败,请重新操作");
}
}
else{
MessageBox.Show("资料填写不完整,请填写完整!");
}
}
private void button5_Click(object sender, System.EventArgs e)
{
this.button6.Enabled=true;
this.button5.Enabled=false;
this.button4.Enabled=false;
this.textBox7.Enabled=true;
cs.fjlx fjlxsql=new bggl.cs.fjlx();
if(fjlxid.Trim()!="")
{
if(this.textBox7.Text.Trim()!=""&&this.textBox8.Text.Trim()!=""&&this.textBox14.Text.Trim()!=""&&this.textBox13.Text.Trim()!="")
{
cs.kfsql kfsq=new bggl.cs.kfsql();
bool pd=fjlxsql.upexe(fjlxid.Trim(),this.textBox7.Text,this.textBox8.Text,this.textBox13.Text,this.textBox14.Text,this.textBox3.Text);
if(pd==true)
{
MessageBox.Show("修改成功!");
fjlxid="";
setfl();//给com2入值
getfjlx();// 调用房间类型表
qkfjlx();
setfl1();
}
}
else
{
MessageBox.Show("资料不全,请填写完整");
}
}
else{
MessageBox.Show("请选择你要修改的记录!");
}
}
private void listView2_Click(object sender, System.EventArgs e)
{
fjlxid=this.listView2.SelectedItems[0].SubItems[0].Text;//把房间类型id值放入fjlxid
if(fjlxid.Trim()!="")
{
this.button6.Enabled=false;
this.button5.Enabled=true;
this.button4.Enabled=true;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -