kfinfo.cs
上传用户:toshiba_01
上传日期:2007-06-08
资源大小:306k
文件大小:23k
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- using System.Data ;
using System.Data .SqlClient ;
- namespace RoomManage
- {
- /// <summary>
- /// kfinfo 的摘要说明。
- /// </summary>
- public class kfinfo : System.Windows.Forms.Form
- {
- private System.Windows.Forms.Label label3;
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.Container components = null;
-
- DataConn dc=new DataConn ();
- int num;//记录总数
- int operchoice=0;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.ComboBox fjh;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.Label label5;
- private System.Windows.Forms.Label label6;
- private System.Windows.Forms.Label label7;
- private System.Windows.Forms.TextBox textBox1;
- private System.Windows.Forms.TextBox textBox2;
- private System.Windows.Forms.TextBox textBox3;
- private System.Windows.Forms.TextBox textBox4;
- private System.Windows.Forms.TextBox textBox5;
- private System.Windows.Forms.GroupBox groupBox2;
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.Button buttexit;
- private System.Windows.Forms.Button buttsave;
- private System.Windows.Forms.Button buttmodify;
- private System.Windows.Forms.Button buttdelete;
- private System.Windows.Forms.Button buttfirst;
- private System.Windows.Forms.Button buttforward;
- private System.Windows.Forms.Button buttlast;
- private System.Windows.Forms.Button buttnext;
- private System.Windows.Forms.TextBox textBox6;
- private System.Windows.Forms.Button buttback;
- private System.Windows.Forms.ComboBox cblx;
- private System.Windows.Forms.ComboBox cbft;
- private System.Windows.Forms.Button buttappend;
-
- public kfinfo()
- {
- //
- // Windows 窗体设计器支持所必需的
- //
- InitializeComponent();
- //
- // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
- //
- }
- /// <summary>
- /// 清理所有正在使用的资源。
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if(components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #region Windows 窗体设计器生成的代码
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.label3 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.fjh = new System.Windows.Forms.ComboBox();
- this.label4 = new System.Windows.Forms.Label();
- this.label5 = new System.Windows.Forms.Label();
- this.label6 = new System.Windows.Forms.Label();
- this.label7 = new System.Windows.Forms.Label();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.textBox2 = new System.Windows.Forms.TextBox();
- this.textBox3 = new System.Windows.Forms.TextBox();
- this.textBox4 = new System.Windows.Forms.TextBox();
- this.textBox5 = new System.Windows.Forms.TextBox();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.buttexit = new System.Windows.Forms.Button();
- this.buttfirst = new System.Windows.Forms.Button();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.buttforward = new System.Windows.Forms.Button();
- this.buttnext = new System.Windows.Forms.Button();
- this.buttlast = new System.Windows.Forms.Button();
- this.buttback = new System.Windows.Forms.Button();
- this.buttsave = new System.Windows.Forms.Button();
- this.buttmodify = new System.Windows.Forms.Button();
- this.buttdelete = new System.Windows.Forms.Button();
- this.buttappend = new System.Windows.Forms.Button();
- this.textBox6 = new System.Windows.Forms.TextBox();
- this.cblx = new System.Windows.Forms.ComboBox();
- this.cbft = new System.Windows.Forms.ComboBox();
- this.groupBox2.SuspendLayout();
- this.SuspendLayout();
- //
- // label3
- //
- this.label3.Location = new System.Drawing.Point(8, 8);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(72, 23);
- this.label3.TabIndex = 31;
- this.label3.Text = "房 间 号:";
- this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // label2
- //
- this.label2.Location = new System.Drawing.Point(200, 8);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(72, 23);
- this.label2.TabIndex = 36;
- this.label2.Text = "客房类型:";
- this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // fjh
- //
- this.fjh.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.fjh.Location = new System.Drawing.Point(80, 8);
- this.fjh.Name = "fjh";
- this.fjh.Size = new System.Drawing.Size(100, 20);
- this.fjh.TabIndex = 37;
- this.fjh.SelectedIndexChanged += new System.EventHandler(this.fjh_SelectedIndexChanged);
- //
- // label4
- //
- this.label4.Location = new System.Drawing.Point(8, 32);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(72, 23);
- this.label4.TabIndex = 36;
- this.label4.Text = "价 格:";
- this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // label5
- //
- this.label5.Location = new System.Drawing.Point(200, 32);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(72, 23);
- this.label5.TabIndex = 36;
- this.label5.Text = "房 态:";
- this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // label6
- //
- this.label6.Location = new System.Drawing.Point(8, 56);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(72, 23);
- this.label6.TabIndex = 36;
- this.label6.Text = "配 置:";
- this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // label7
- //
- this.label7.Location = new System.Drawing.Point(8, 80);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(72, 23);
- this.label7.TabIndex = 36;
- this.label7.Text = "备 注:";
- this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
- //
- // textBox1
- //
- this.textBox1.Location = new System.Drawing.Point(272, 8);
- this.textBox1.Name = "textBox1";
- this.textBox1.ReadOnly = true;
- this.textBox1.TabIndex = 38;
- this.textBox1.Text = "";
- this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
- //
- // textBox2
- //
- this.textBox2.Location = new System.Drawing.Point(80, 33);
- this.textBox2.Name = "textBox2";
- this.textBox2.ReadOnly = true;
- this.textBox2.TabIndex = 38;
- this.textBox2.Text = "";
- //
- // textBox3
- //
- this.textBox3.Location = new System.Drawing.Point(272, 33);
- this.textBox3.Name = "textBox3";
- this.textBox3.ReadOnly = true;
- this.textBox3.TabIndex = 38;
- this.textBox3.Text = "";
- this.textBox3.TextChanged += new System.EventHandler(this.textBox3_TextChanged);
- //
- // textBox4
- //
- this.textBox4.Location = new System.Drawing.Point(80, 57);
- this.textBox4.Name = "textBox4";
- this.textBox4.ReadOnly = true;
- this.textBox4.Size = new System.Drawing.Size(291, 21);
- this.textBox4.TabIndex = 38;
- this.textBox4.Text = "";
- //
- // textBox5
- //
- this.textBox5.Location = new System.Drawing.Point(80, 81);
- this.textBox5.Name = "textBox5";
- this.textBox5.ReadOnly = true;
- this.textBox5.Size = new System.Drawing.Size(291, 21);
- this.textBox5.TabIndex = 38;
- this.textBox5.Text = "";
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.buttexit);
- this.groupBox2.Controls.Add(this.buttfirst);
- this.groupBox2.Controls.Add(this.groupBox1);
- this.groupBox2.Controls.Add(this.buttforward);
- this.groupBox2.Controls.Add(this.buttnext);
- this.groupBox2.Controls.Add(this.buttlast);
- this.groupBox2.Controls.Add(this.buttback);
- this.groupBox2.Controls.Add(this.buttsave);
- this.groupBox2.Controls.Add(this.buttmodify);
- this.groupBox2.Controls.Add(this.buttdelete);
- this.groupBox2.Controls.Add(this.buttappend);
- this.groupBox2.Location = new System.Drawing.Point(10, 104);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(360, 72);
- this.groupBox2.TabIndex = 40;
- this.groupBox2.TabStop = false;
- //
- // buttexit
- //
- this.buttexit.Location = new System.Drawing.Point(296, 44);
- this.buttexit.Name = "buttexit";
- this.buttexit.Size = new System.Drawing.Size(48, 23);
- this.buttexit.TabIndex = 2;
- this.buttexit.Text = "退出";
- this.buttexit.Click += new System.EventHandler(this.buttexit_Click);
- //
- // buttfirst
- //
- this.buttfirst.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
- this.buttfirst.Location = new System.Drawing.Point(112, 12);
- this.buttfirst.Name = "buttfirst";
- this.buttfirst.Size = new System.Drawing.Size(32, 23);
- this.buttfirst.TabIndex = 1;
- this.buttfirst.Text = "|<";
- this.buttfirst.Click += new System.EventHandler(this.buttfirst_Click);
- //
- // groupBox1
- //
- this.groupBox1.Location = new System.Drawing.Point(0, 38);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(360, 3);
- this.groupBox1.TabIndex = 0;
- this.groupBox1.TabStop = false;
- //
- // buttforward
- //
- this.buttforward.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
- this.buttforward.Location = new System.Drawing.Point(144, 12);
- this.buttforward.Name = "buttforward";
- this.buttforward.Size = new System.Drawing.Size(32, 23);
- this.buttforward.TabIndex = 1;
- this.buttforward.Text = "<";
- this.buttforward.Click += new System.EventHandler(this.buttforward_Click);
- //
- // buttnext
- //
- this.buttnext.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
- this.buttnext.Location = new System.Drawing.Point(176, 12);
- this.buttnext.Name = "buttnext";
- this.buttnext.Size = new System.Drawing.Size(32, 23);
- this.buttnext.TabIndex = 1;
- this.buttnext.Text = ">";
- this.buttnext.Click += new System.EventHandler(this.buttnext_Click);
- //
- // buttlast
- //
- this.buttlast.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
- this.buttlast.Location = new System.Drawing.Point(208, 12);
- this.buttlast.Name = "buttlast";
- this.buttlast.Size = new System.Drawing.Size(32, 23);
- this.buttlast.TabIndex = 1;
- this.buttlast.Text = ">|";
- this.buttlast.Click += new System.EventHandler(this.button4_Click);
- //
- // buttback
- //
- this.buttback.Location = new System.Drawing.Point(248, 44);
- this.buttback.Name = "buttback";
- this.buttback.Size = new System.Drawing.Size(48, 23);
- this.buttback.TabIndex = 2;
- this.buttback.Text = "返回";
- this.buttback.Click += new System.EventHandler(this.kfinfo_Load);
- //
- // buttsave
- //
- this.buttsave.Location = new System.Drawing.Point(200, 44);
- this.buttsave.Name = "buttsave";
- this.buttsave.Size = new System.Drawing.Size(48, 23);
- this.buttsave.TabIndex = 2;
- this.buttsave.Text = "保存";
- this.buttsave.Click += new System.EventHandler(this.buttsave_Click);
- //
- // buttmodify
- //
- this.buttmodify.Location = new System.Drawing.Point(104, 44);
- this.buttmodify.Name = "buttmodify";
- this.buttmodify.Size = new System.Drawing.Size(48, 23);
- this.buttmodify.TabIndex = 2;
- this.buttmodify.Text = "修改";
- this.buttmodify.Click += new System.EventHandler(this.buttmodify_Click);
- //
- // buttdelete
- //
- this.buttdelete.Location = new System.Drawing.Point(56, 44);
- this.buttdelete.Name = "buttdelete";
- this.buttdelete.Size = new System.Drawing.Size(48, 23);
- this.buttdelete.TabIndex = 2;
- this.buttdelete.Text = "删除";
- this.buttdelete.Click += new System.EventHandler(this.button9_Click);
- //
- // buttappend
- //
- this.buttappend.Location = new System.Drawing.Point(8, 44);
- this.buttappend.Name = "buttappend";
- this.buttappend.Size = new System.Drawing.Size(48, 23);
- this.buttappend.TabIndex = 2;
- this.buttappend.Text = "添加";
- this.buttappend.Click += new System.EventHandler(this.button10_Click);
- //
- // textBox6
- //
- this.textBox6.Location = new System.Drawing.Point(80, 8);
- this.textBox6.Name = "textBox6";
- this.textBox6.TabIndex = 41;
- this.textBox6.Text = "";
- //
- // cblx
- //
- this.cblx.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.cblx.Items.AddRange(new object[] {
- "普房",
- "标房",
- "套房",
- "双人间",
- "总统套房"});
- this.cblx.Location = new System.Drawing.Point(272, 8);
- this.cblx.Name = "cblx";
- this.cblx.Size = new System.Drawing.Size(100, 20);
- this.cblx.TabIndex = 42;
- //
- // cbft
- //
- this.cbft.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.cbft.Items.AddRange(new object[] {
- "空闲",
- "入住",
- "维修"});
- this.cbft.Location = new System.Drawing.Point(272, 33);
- this.cbft.Name = "cbft";
- this.cbft.Size = new System.Drawing.Size(100, 20);
- this.cbft.TabIndex = 42;
- //
- // kfinfo
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.ClientSize = new System.Drawing.Size(376, 181);
- this.Controls.Add(this.textBox6);
- this.Controls.Add(this.textBox1);
- this.Controls.Add(this.textBox2);
- this.Controls.Add(this.textBox4);
- this.Controls.Add(this.textBox5);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.fjh);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.label4);
- this.Controls.Add(this.label5);
- this.Controls.Add(this.label6);
- this.Controls.Add(this.label7);
- this.Controls.Add(this.cblx);
- this.Controls.Add(this.textBox3);
- this.Controls.Add(this.cbft);
- this.MaximizeBox = false;
- this.MaximumSize = new System.Drawing.Size(384, 208);
- this.MinimizeBox = false;
- this.MinimumSize = new System.Drawing.Size(384, 208);
- this.Name = "kfinfo";
- this.ShowInTaskbar = false;
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
- this.Text = "客房信息维护";
- this.Load += new System.EventHandler(this.kfinfo_Load);
- this.groupBox2.ResumeLayout(false);
- this.ResumeLayout(false);
- }
- #endregion
- private void kfinfo_Load(object sender, System.EventArgs e)
- {
- textBox6.Text ="";
- textBox2.Text ="";
- textBox4.Text ="";
- textBox5.Text ="";
-
- buttforward.Enabled =false;
- buttfirst.Enabled =false;
- buttback.Enabled =false;
- buttsave.Enabled =false;
- buttappend.Enabled =true;
- buttdelete.Enabled =true;
- buttmodify.Enabled =true;
- textBox6.Visible =false;
- textBox1.Visible =true;
- textBox3.Visible =true;
- textBox1.ReadOnly =true;
- textBox2.ReadOnly =true;
- textBox3.ReadOnly =true;
- textBox4.ReadOnly =true;
- textBox5.ReadOnly =true;
- string str=dc.connstr ;
- SqlConnection conn=new SqlConnection (str);
- string sql="select 房间号 from tabkfinfo";
- SqlDataAdapter adapter=new SqlDataAdapter (sql,conn);
- DataSet dataset=new DataSet ();
- adapter.Fill (dataset,"tab");
- this.fjh .DisplayMember ="房间号";
- this.fjh .DataSource =dataset.Tables ["tab"];
- dataset.Dispose ();
- adapter.Dispose ();
- conn.Dispose ();
- }
- private void fjh_SelectedIndexChanged(object sender, System.EventArgs e)
- {
-
- string str=dc.connstr ;
- SqlConnection conn=new SqlConnection (str);
- string sql="select * from tabkfinfo where 房间号='"+this.fjh .Text +"'";
- string sql1="select * from tabkfinfo";
- SqlDataAdapter adapter=new SqlDataAdapter (sql,conn);
- SqlDataAdapter adapter1=new SqlDataAdapter (sql1,conn);
- DataSet dataset=new DataSet ();
- adapter.Fill (dataset,"tab");
- adapter1.Fill (dataset,"cou");
- num=dataset.Tables ["cou"].Rows.Count ;
- this.textBox1 .DataBindings.Add (new Binding ("Text",dataset,"tab.客房类型"));
- this.textBox2 .DataBindings.Add (new Binding ("Text",dataset,"tab.价格"));
- this.textBox3 .DataBindings.Add (new Binding ("Text",dataset,"tab.房态"));
- this.textBox4 .DataBindings.Add (new Binding ("Text",dataset,"tab.配置"));
- this.textBox5 .DataBindings.Add (new Binding ("Text",dataset,"tab.备注"));
-
- //释放所有绑定
- this.textBox1 .DataBindings .Clear ();
- this.textBox2 .DataBindings .Clear ();
- this.textBox3 .DataBindings .Clear ();
- this.textBox4 .DataBindings .Clear ();
- this.textBox5 .DataBindings .Clear ();
-
- buttnext.Enabled =true;
- buttlast.Enabled =true;
- buttforward.Enabled =true;
- buttfirst.Enabled =true;
- if(fjh.SelectedIndex==0)
- {
- buttforward.Enabled =false;
- buttfirst.Enabled =false;
-
- }
-
- if(fjh.SelectedIndex ==(num-1))
- {
- buttnext.Enabled =false;
- buttlast.Enabled =false;
- }
- dataset.Dispose ();
- adapter.Dispose ();
- conn.Dispose ();
- }
-
- private void button10_Click(object sender, System.EventArgs e)
- {
- textBox1.Visible =false;
- textBox3.Visible =false;
- cblx.Visible =true;
- cbft.Visible =true;
- this.operchoice =1;
- textBox6.Visible =true;
- fjh.Text ="";
- textBox1.Text ="";
- textBox2.Text ="";
- textBox3.Text ="";
- textBox4.Text ="";
- textBox5.Text ="";
- textBox1.ReadOnly =false;
- textBox2.ReadOnly =false;
- textBox3.ReadOnly =false;
- textBox4.ReadOnly =false;
- textBox5.ReadOnly =false;
-
- buttforward.Enabled =false;
- buttfirst.Enabled =false;
- buttnext.Enabled =false;
- buttlast.Enabled =false;
- buttdelete.Enabled =false;
- buttmodify.Enabled =false;
-
- buttsave.Enabled =true;
- buttback.Enabled =true;
- }
- private void button9_Click(object sender, System.EventArgs e)
- {
- operchoice =2;
- buttforward.Enabled =false;
- buttfirst.Enabled =false;
- buttnext.Enabled =false;
- buttlast.Enabled =false;
- buttappend.Enabled =false;
- buttmodify.Enabled =false;
-
- buttsave.Enabled =true;
- buttback.Enabled =true;
- }
- private void button4_Click(object sender, System.EventArgs e)
- {
- fjh.SelectedIndex =num-1;
- }
- private void buttexit_Click(object sender, System.EventArgs e)
- {
- if(MessageBox.Show("真的要退出吗?","注意",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)
- this.Close ();
- }
- private void buttfirst_Click(object sender, System.EventArgs e)
- {
- fjh.SelectedIndex =0;
- }
- private void buttforward_Click(object sender, System.EventArgs e)
- {
- fjh.SelectedIndex =fjh.SelectedIndex -1;
- }
- private void buttnext_Click(object sender, System.EventArgs e)
- {
- fjh.SelectedIndex =fjh.SelectedIndex +1;
- }
- private void buttmodify_Click(object sender, System.EventArgs e)
- {
- cblx.Text =textBox1.Text ;
- cbft.Text =textBox3.Text ;
- operchoice =3;
- buttforward.Enabled =false;
- buttfirst.Enabled =false;
- buttnext.Enabled =false;
- buttlast.Enabled =false;
- buttappend.Enabled =false;
- buttdelete.Enabled =false;
-
- buttsave.Enabled =true;
- buttback.Enabled =true;
- textBox1.ReadOnly =false;
- textBox2.ReadOnly =false;
- textBox3.ReadOnly =false;
- textBox4.ReadOnly =false;
- textBox5.ReadOnly =false;
- textBox1.Visible =false;
- textBox3.Visible =false;
-
- cblx.Visible =true;
- cbft.Visible =true;
- }
- private void buttsave_Click(object sender, System.EventArgs e)
- {
- string str=dc.connstr ;
- SqlConnection conn=new SqlConnection (str);
- if(operchoice==1)
- {
- string sql="insert into tabkfinfo values(";
- sql=sql+"'"+textBox6.Text +"',";
- sql=sql+"'"+cblx.Text +"',";
- sql=sql+"'"+textBox2.Text +"',";
- sql=sql+"'"+cbft.Text +"',";
- sql=sql+"'"+textBox4.Text +"',";
- sql=sql+"'"+textBox5.Text +"')";
- SqlCommand cmd=new SqlCommand (sql,conn);
- if(textBox6.Text .Length >0&cblx.Text .Length >0&cbft.Text .Length >0&textBox2.Text .Length >0&textBox4.Text .Length >0)
- {
- try
- {
- conn.Open ();
- cmd.ExecuteNonQuery ();
- MessageBox.Show ("操作成功!","恭喜",MessageBoxButtons.OK ,MessageBoxIcon.Information);
- }
- catch
- {
- MessageBox.Show ("您的输入有误,请仔细检查,重新输入!","注意",MessageBoxButtons.OK ,MessageBoxIcon.Error );
- }
- }
- else
- {
- MessageBox.Show ("您未输入完整,请仔细检查,重新输入!","注意",MessageBoxButtons.OK ,MessageBoxIcon.Error );
- }
-
- cmd.Dispose ();
- conn.Close ();
- }
- //删除
- if(operchoice==2)
- {
- string sql="delete tabkfinfo where 房间号='"+fjh.Text +"'";
- SqlCommand cmd=new SqlCommand (sql,conn);
- if(MessageBox.Show("真的要删除吗?","注意",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)
- {
- try
- {
- conn.Open ();
- cmd.ExecuteNonQuery ();
- MessageBox.Show ("操作成功!","恭喜",MessageBoxButtons.OK ,MessageBoxIcon.Information);
- }
- catch
- {
- MessageBox.Show ("操作失败!");
- }
-
- string sql1="select 房间号 from tabkfinfo";
- SqlDataAdapter adapter=new SqlDataAdapter (sql1,conn);
- DataSet dataset=new DataSet ();
- adapter.Fill (dataset,"tab");
- this.fjh .DisplayMember ="房间号";
- this.fjh .DataSource =dataset.Tables ["tab"];
- dataset.Dispose ();
- adapter.Dispose ();
- }
- cmd.Dispose ();
- conn.Close ();
- }
- //修改
- if(operchoice==3)
- {
- string sql="update tabkfinfo set 房间号='"+fjh.Text +"',客房类型='"+cblx.Text +"',价格='"+textBox2.Text +"',房态='"+cbft.Text +"',配置='"+textBox4.Text +"',备注='"+textBox5.Text +"' where 房间号='"+fjh.Text +"'";
- SqlCommand cmd=new SqlCommand (sql,conn);
- if(MessageBox.Show("真的所做的修改吗?","注意",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)
- {
- try
- {
- conn.Open ();
- cmd.ExecuteNonQuery ();
- MessageBox.Show ("操作成功!","恭喜",MessageBoxButtons.OK ,MessageBoxIcon.Information);
- }
- catch
- {
- MessageBox.Show ("操作失败!");
- }
- }
- cmd.Dispose ();
- conn.Close ();
- }
- }
- private void textBox1_TextChanged(object sender, System.EventArgs e)
- {
- cblx.Text =textBox1.Text ;
- }
- private void textBox3_TextChanged(object sender, System.EventArgs e)
- {
- cbft.Text =textBox3.Text ;
- }
-
- }
- }