📄 kfyd.cs
字号:
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(80, 21);
this.textBox1.Name = "textBox1";
this.textBox1.TabIndex = 0;
this.textBox1.Text = "";
//
// comboBox1
//
this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox1.Items.AddRange(new object[] {
"身份证",
"学生证",
"其 它"});
this.comboBox1.Location = new System.Drawing.Point(264, 21);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(96, 20);
this.comboBox1.TabIndex = 1;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(80, 55);
this.textBox2.Name = "textBox2";
this.textBox2.TabIndex = 2;
this.textBox2.Text = "";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(264, 55);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(96, 21);
this.textBox3.TabIndex = 3;
this.textBox3.Text = "";
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(80, 91);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(280, 21);
this.textBox5.TabIndex = 4;
this.textBox5.Text = "";
//
// comboBox2
//
this.comboBox2.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox2.Items.AddRange(new object[] {
"普房",
"标房",
"套房",
"双人间",
"总统套房"});
this.comboBox2.Location = new System.Drawing.Point(80, 126);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(104, 20);
this.comboBox2.TabIndex = 5;
this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
//
// textBox6
//
this.textBox6.Location = new System.Drawing.Point(264, 126);
this.textBox6.Name = "textBox6";
this.textBox6.ReadOnly = true;
this.textBox6.Size = new System.Drawing.Size(96, 21);
this.textBox6.TabIndex = 6;
this.textBox6.Text = "";
//
// textBox7
//
this.textBox7.Location = new System.Drawing.Point(80, 161);
this.textBox7.Name = "textBox7";
this.textBox7.TabIndex = 7;
this.textBox7.Text = "";
this.textBox7.TextChanged += new System.EventHandler(this.textBox7_TextChanged);
//
// textBox8
//
this.textBox8.Location = new System.Drawing.Point(264, 161);
this.textBox8.Name = "textBox8";
this.textBox8.Size = new System.Drawing.Size(96, 21);
this.textBox8.TabIndex = 8;
this.textBox8.Text = "";
this.textBox8.TextChanged += new System.EventHandler(this.textBox8_TextChanged);
//
// textBox9
//
this.textBox9.Location = new System.Drawing.Point(80, 196);
this.textBox9.Name = "textBox9";
this.textBox9.Size = new System.Drawing.Size(280, 21);
this.textBox9.TabIndex = 9;
this.textBox9.Text = "";
//
// textBox10
//
this.textBox10.Location = new System.Drawing.Point(80, 244);
this.textBox10.Name = "textBox10";
this.textBox10.ReadOnly = true;
this.textBox10.TabIndex = 24;
this.textBox10.Text = "";
//
// button6
//
this.button6.Location = new System.Drawing.Point(8, 56);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(48, 23);
this.button6.TabIndex = 12;
this.button6.Text = "重填";
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// label12
//
this.label12.Location = new System.Drawing.Point(200, 248);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(144, 24);
this.label12.TabIndex = 11;
//
// groupBox4
//
this.groupBox4.Location = new System.Drawing.Point(0, 232);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(384, 3);
this.groupBox4.TabIndex = 25;
this.groupBox4.TabStop = false;
//
// kfyd
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(480, 283);
this.Name = "kfyd";
this.Text = "客房预定";
this.Load += new System.EventHandler(this.kfyd_Load);
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
} #endregion
DataConn dc=new DataConn ();
private void kfyd_Load(object sender, System.EventArgs e)
{
this.label12 .Text ="操作员:"+this.opername ;
this.AcceptButton =this.button5 ;
this.textBox10.Text =System.DateTime .Today.Date.ToShortDateString();
this.comboBox2 .Text="";
this.textBox6 .Text ="";
}
//检查输入是否有误
private bool checkinput()
{
bool passed=true;
if(this.textBox1.Text .Length==0|this.textBox2 .Text .Length ==0|this.textBox3 .Text .Length ==0|this.textBox5 .Text .Length ==0|this.textBox6 .Text .Length ==0|this.textBox7 .Text .Length ==0|this.textBox8 .Text .Length ==0)
passed=false;
return passed;
}
//清空
private void chushi()
{
textBox1.Text ="";
comboBox1.SelectedIndex =-1;
comboBox2.SelectedIndex =-1;
textBox2.Text ="";
textBox3.Text ="";
textBox5.Text ="";
textBox6.Text ="";
textBox7.Text ="";
textBox8.Text ="";
textBox9.Text ="";
}
private void button5_Click(object sender, System.EventArgs e)
{
string str=dc.connstr ;
SqlConnection conn=new SqlConnection (str);
string sql="insert into tabkfyd values(";
sql=sql+"'"+this.textBox1 .Text +"',";
sql=sql+"'"+this.comboBox1.Text +"',";
sql=sql+"'"+this.textBox2 .Text +"',";
sql=sql+"'"+this.textBox3 .Text +"',";
sql=sql+"'"+this.textBox5 .Text +"',";
sql=sql+"'"+this.comboBox2.Text +"',";
sql=sql+""+this.textBox6 .Text +",";
sql=sql+"'"+this.textBox10 .Text +"',";
sql=sql+""+this.textBox7 .Text +",";
sql=sql+""+this.textBox8 .Text +",";
sql=sql+"'"+this.opername +"',";
sql=sql+"'"+this.textBox9 .Text +"')";
SqlCommand cmd=new SqlCommand (sql,conn);
conn.Open ();
try
{
if(this.checkinput ()==true)
{
cmd.ExecuteNonQuery ();
MessageBox.Show ("您已预定成功!","恭喜",MessageBoxButtons.OK ,MessageBoxIcon.Information);
chushi ();//清空
}
else
MessageBox.Show ("对不起,您的输入有误,请仔细检查,重新输入!","注意",MessageBoxButtons.OK ,MessageBoxIcon.Error );
}
catch
{
MessageBox.Show ("对不起,您的输入有误,请仔细检查,重新输入!","注意",MessageBoxButtons.OK ,MessageBoxIcon.Error );
}
finally
{
conn.Close ();
cmd.Dispose ();
}
}
private void button6_Click(object sender, System.EventArgs e)
{
this.textBox1 .Text ="";
this.textBox2 .Text ="";
this.textBox3 .Text ="";
this.textBox5 .Text ="";
this.textBox6 .Text ="";
this.textBox7 .Text ="";
this.textBox8 .Text ="";
this.textBox9 .Text ="";
this.comboBox1 .Text ="";
this.comboBox2 .Text ="";
}
private void comboBox2_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.textBox6 .DataBindings .Clear ();
string str=dc.connstr ;
SqlConnection conn=new SqlConnection (str);
string sql="select * from tabkflx where 客房类型='"+this.comboBox2.Text+"'";
SqlDataAdapter adapter=new SqlDataAdapter (sql,conn);
DataSet dataset=new DataSet ();
adapter.Fill (dataset,"tabkflx");
this.textBox6 .DataBindings.Add (new Binding ("Text",dataset,"tabkflx.价格"));;
conn.Close ();
adapter.Dispose ();
dataset.Dispose ();
}
private void textBox7_TextChanged(object sender, System.EventArgs e)
{
string str=this.textBox7.Text ;
int f=1;
for(int i=0;i<str.Length ;i++)
{
if(str[i]<'0'|str[i]>'9')
f=0;
break;
}
if(f==0)
{
// MessageBox.Show ("对不起,您的输入有误!","注意",MessageBoxButtons.OK ,MessageBoxIcon.Error );
this.textBox7 .Text ="";
}
}
private void textBox8_TextChanged(object sender, System.EventArgs e)
{
string str=this.textBox8.Text ;
int f=1;
for(int i=0;i<str.Length ;i++)
{
if(str[i]<'0'|str[i]>'9')
f=0;
break;
}
if(f==0)
{
// MessageBox.Show ("对不起,您的输入有误!","注意",MessageBoxButtons.OK ,MessageBoxIcon.Error );
this.textBox8 .Text ="";
}
} }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -