kfyd.cs
上传用户:toshiba_01
上传日期:2007-06-08
资源大小:306k
文件大小:18k
- using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using System.Data ;
using System.Data .SqlClient ;
namespace RoomManage
{
public class kfyd : RoomManage.pub
{
- private System.Windows.Forms.Button button2;
- private System.Windows.Forms.Button button3;
- private System.Windows.Forms.Button button4;
- private System.Windows.Forms.PictureBox pictureBox2;
- private System.Windows.Forms.Button button5;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.Label label6;
- private System.Windows.Forms.Label label7;
- private System.Windows.Forms.Label label8;
- private System.Windows.Forms.Label label9;
- private System.Windows.Forms.Label label10;
- private System.Windows.Forms.Label label11;
- private System.Windows.Forms.Label label13;
- private System.Windows.Forms.TextBox textBox1;
- private System.Windows.Forms.ComboBox comboBox1;
- private System.Windows.Forms.TextBox textBox2;
- private System.Windows.Forms.TextBox textBox3;
- private System.Windows.Forms.TextBox textBox5;
- private System.Windows.Forms.ComboBox comboBox2;
- private System.Windows.Forms.TextBox textBox6;
- private System.Windows.Forms.TextBox textBox7;
- private System.Windows.Forms.TextBox textBox8;
- private System.Windows.Forms.TextBox textBox9;
- private System.Windows.Forms.TextBox textBox10;
- private System.Windows.Forms.Button button6;
private System.ComponentModel.IContainer components = null;
- private System.Windows.Forms.Label label12;
- private System.Windows.Forms.GroupBox groupBox4;
string opername;
public kfyd(string s)
{
// 该调用是 Windows 窗体设计器所必需的。
InitializeComponent();
this.opername =s;
// TODO: 在 InitializeComponent 调用后添加任何初始化
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region 设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(kfyd));
- this.button2 = new System.Windows.Forms.Button();
- this.button3 = new System.Windows.Forms.Button();
- this.button4 = new System.Windows.Forms.Button();
- this.pictureBox2 = new System.Windows.Forms.PictureBox();
- this.button5 = new System.Windows.Forms.Button();
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.label4 = new System.Windows.Forms.Label();
- this.label6 = new System.Windows.Forms.Label();
- this.label7 = new System.Windows.Forms.Label();
- this.label8 = new System.Windows.Forms.Label();
- this.label9 = new System.Windows.Forms.Label();
- this.label10 = new System.Windows.Forms.Label();
- this.label11 = new System.Windows.Forms.Label();
- this.label13 = new System.Windows.Forms.Label();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.comboBox1 = new System.Windows.Forms.ComboBox();
- this.textBox2 = new System.Windows.Forms.TextBox();
- this.textBox3 = new System.Windows.Forms.TextBox();
- this.textBox5 = new System.Windows.Forms.TextBox();
- this.comboBox2 = new System.Windows.Forms.ComboBox();
- this.textBox6 = new System.Windows.Forms.TextBox();
- this.textBox7 = new System.Windows.Forms.TextBox();
- this.textBox8 = new System.Windows.Forms.TextBox();
- this.textBox9 = new System.Windows.Forms.TextBox();
- this.textBox10 = new System.Windows.Forms.TextBox();
- this.button6 = new System.Windows.Forms.Button();
- this.label12 = new System.Windows.Forms.Label();
- this.groupBox4 = new System.Windows.Forms.GroupBox();
- this.groupBox2.SuspendLayout();
- this.groupBox3.SuspendLayout();
- //
- // button1
- //
- this.button1.Name = "button1";
- this.button1.TabIndex = 13;
- //
- // groupBox1
- //
- this.groupBox1.Name = "groupBox1";
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.button6);
- this.groupBox2.Controls.Add(this.button5);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Controls.SetChildIndex(this.button1, 0);
- this.groupBox2.Controls.SetChildIndex(this.button5, 0);
- this.groupBox2.Controls.SetChildIndex(this.button6, 0);
- //
- // pictureBox1
- //
- this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
- this.pictureBox1.Name = "pictureBox1";
- //
- // groupBox3
- //
- this.groupBox3.Controls.Add(this.groupBox4);
- this.groupBox3.Controls.Add(this.textBox10);
- this.groupBox3.Controls.Add(this.textBox9);
- this.groupBox3.Controls.Add(this.textBox8);
- this.groupBox3.Controls.Add(this.textBox7);
- this.groupBox3.Controls.Add(this.textBox6);
- this.groupBox3.Controls.Add(this.textBox5);
- this.groupBox3.Controls.Add(this.textBox3);
- this.groupBox3.Controls.Add(this.textBox2);
- this.groupBox3.Controls.Add(this.textBox1);
- this.groupBox3.Controls.Add(this.comboBox2);
- this.groupBox3.Controls.Add(this.comboBox1);
- this.groupBox3.Controls.Add(this.label13);
- this.groupBox3.Controls.Add(this.label12);
- this.groupBox3.Controls.Add(this.label11);
- this.groupBox3.Controls.Add(this.label10);
- this.groupBox3.Controls.Add(this.label9);
- this.groupBox3.Controls.Add(this.label8);
- this.groupBox3.Controls.Add(this.label7);
- this.groupBox3.Controls.Add(this.label6);
- this.groupBox3.Controls.Add(this.label4);
- this.groupBox3.Controls.Add(this.label3);
- this.groupBox3.Controls.Add(this.label2);
- this.groupBox3.Controls.Add(this.label1);
- this.groupBox3.Name = "groupBox3";
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(32, 136);
- this.button2.Name = "button2";
- this.button2.TabIndex = 1;
- this.button2.Text = "button2";
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(0, 192);
- this.button3.Name = "button3";
- this.button3.TabIndex = 2;
- this.button3.Text = "button3";
- //
- // button4
- //
- this.button4.Location = new System.Drawing.Point(16, 136);
- this.button4.Name = "button4";
- this.button4.TabIndex = 3;
- this.button4.Text = "button4";
- //
- // pictureBox2
- //
- this.pictureBox2.Location = new System.Drawing.Point(16, 72);
- this.pictureBox2.Name = "pictureBox2";
- this.pictureBox2.TabIndex = 4;
- this.pictureBox2.TabStop = false;
- //
- // button5
- //
- this.button5.Location = new System.Drawing.Point(8, 16);
- this.button5.Name = "button5";
- this.button5.Size = new System.Drawing.Size(48, 23);
- this.button5.TabIndex = 11;
- this.button5.Text = "登记";
- this.button5.Click += new System.EventHandler(this.button5_Click);
- //
- // label1
- //
- this.label1.Location = new System.Drawing.Point(16, 24);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(72, 23);
- this.label1.TabIndex = 0;
- this.label1.Text = "姓 名:";
- //
- // label2
- //
- this.label2.Location = new System.Drawing.Point(200, 24);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(72, 23);
- this.label2.TabIndex = 1;
- this.label2.Text = "证件名称:";
- //
- // label3
- //
- this.label3.Location = new System.Drawing.Point(16, 59);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(72, 23);
- this.label3.TabIndex = 2;
- this.label3.Text = "证件号码:";
- //
- // label4
- //
- this.label4.Location = new System.Drawing.Point(200, 59);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(72, 23);
- this.label4.TabIndex = 3;
- this.label4.Text = "联系电话:";
- //
- // label6
- //
- this.label6.Location = new System.Drawing.Point(16, 94);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(72, 23);
- this.label6.TabIndex = 5;
- this.label6.Text = "详细地址:";
- //
- // label7
- //
- this.label7.Location = new System.Drawing.Point(16, 129);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(72, 23);
- this.label7.TabIndex = 6;
- this.label7.Text = "客房类型:";
- //
- // label8
- //
- this.label8.Location = new System.Drawing.Point(200, 129);
- this.label8.Name = "label8";
- this.label8.Size = new System.Drawing.Size(72, 23);
- this.label8.TabIndex = 7;
- this.label8.Text = "房间价格:";
- //
- // label9
- //
- this.label9.Location = new System.Drawing.Point(200, 164);
- this.label9.Name = "label9";
- this.label9.Size = new System.Drawing.Size(72, 23);
- this.label9.TabIndex = 8;
- this.label9.Text = "预付金额:";
- //
- // label10
- //
- this.label10.Location = new System.Drawing.Point(16, 248);
- this.label10.Name = "label10";
- this.label10.Size = new System.Drawing.Size(144, 24);
- this.label10.TabIndex = 9;
- this.label10.Text = "预住日期:";
- //
- // label11
- //
- this.label11.Location = new System.Drawing.Point(16, 164);
- this.label11.Name = "label11";
- this.label11.Size = new System.Drawing.Size(72, 23);
- this.label11.TabIndex = 10;
- this.label11.Text = "预住天数:";
- //
- // label13
- //
- this.label13.Location = new System.Drawing.Point(16, 199);
- this.label13.Name = "label13";
- this.label13.Size = new System.Drawing.Size(72, 23);
- this.label13.TabIndex = 12;
- this.label13.Text = "备 注:";
- //
- // 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 ="";
- }
- }
}
}