📄 zsdj.cs
字号:
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(80, 16);
this.textBox4.Name = "textBox4";
this.textBox4.ReadOnly = true;
this.textBox4.Size = new System.Drawing.Size(105, 21);
this.textBox4.TabIndex = 0;
this.textBox4.Text = "";
//
// label14
//
this.label14.Location = new System.Drawing.Point(8, 118);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(72, 23);
this.label14.TabIndex = 52;
this.label14.Text = "房 间 号:";
//
// textBox11
//
this.textBox11.Location = new System.Drawing.Point(80, 90);
this.textBox11.Name = "textBox11";
this.textBox11.TabIndex = 5;
this.textBox11.Text = "";
//
// label15
//
this.label15.Location = new System.Drawing.Point(8, 143);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(72, 23);
this.label15.TabIndex = 54;
this.label15.Text = "住宿日期:";
//
// textBox12
//
this.textBox12.Location = new System.Drawing.Point(264, 140);
this.textBox12.Name = "textBox12";
this.textBox12.ReadOnly = true;
this.textBox12.TabIndex = 9;
this.textBox12.Text = "";
this.textBox12.TextChanged += new System.EventHandler(this.textBox12_TextChanged);
//
// label17
//
this.label17.Location = new System.Drawing.Point(192, 143);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(72, 23);
this.label17.TabIndex = 58;
this.label17.Text = "预住天数:";
//
// textBox14
//
this.textBox14.Location = new System.Drawing.Point(264, 165);
this.textBox14.Name = "textBox14";
this.textBox14.ReadOnly = true;
this.textBox14.TabIndex = 11;
this.textBox14.Text = "";
//
// label19
//
this.label19.Location = new System.Drawing.Point(192, 196);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(72, 23);
this.label19.TabIndex = 62;
this.label19.Text = "提醒日期:";
//
// textBox10
//
this.textBox10.Location = new System.Drawing.Point(264, 192);
this.textBox10.Name = "textBox10";
this.textBox10.ReadOnly = true;
this.textBox10.TabIndex = 10;
this.textBox10.Text = "";
//
// label9
//
this.label9.Location = new System.Drawing.Point(8, 170);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(72, 23);
this.label9.TabIndex = 64;
this.label9.Text = "应交宿费:";
//
// textBox8
//
this.textBox8.Location = new System.Drawing.Point(80, 165);
this.textBox8.Name = "textBox8";
this.textBox8.ReadOnly = true;
this.textBox8.TabIndex = 12;
this.textBox8.Text = "";
//
// label16
//
this.label16.Location = new System.Drawing.Point(8, 196);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(72, 23);
this.label16.TabIndex = 66;
this.label16.Text = "预付金额:";
//
// textBox13
//
this.textBox13.Location = new System.Drawing.Point(80, 192);
this.textBox13.Name = "textBox13";
this.textBox13.ReadOnly = true;
this.textBox13.TabIndex = 13;
this.textBox13.Text = "";
this.textBox13.TextChanged += new System.EventHandler(this.textBox13_TextChanged);
//
// comboBox5
//
this.comboBox5.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox5.Location = new System.Drawing.Point(80, 115);
this.comboBox5.Name = "comboBox5";
this.comboBox5.Size = new System.Drawing.Size(100, 20);
this.comboBox5.TabIndex = 69;
this.comboBox5.SelectedIndexChanged += new System.EventHandler(this.comboBox5_SelectedIndexChanged);
//
// groupBox4
//
this.groupBox4.Location = new System.Drawing.Point(0, 245);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(384, 3);
this.groupBox4.TabIndex = 70;
this.groupBox4.TabStop = false;
//
// zsdj
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(480, 283);
this.Name = "zsdj";
this.Text = "住宿登记";
this.Load += new System.EventHandler(this.zsdj_Load);
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
} #endregion
DataConn dc=new DataConn ();
string opername;//传递操作员姓名
private void zsdj_Load(object sender, System.EventArgs e)
{
this.AcceptButton =this.button2 ;
this.textBox7.Text =System.DateTime .Today.Date.ToShortDateString();
this.label12 .Text ="操作员:"+this.opername ;
this.textBox6 .Text ="";
this.comboBox5 .Text ="";
this.scbh ();//自动生成编号。
}
//自动生成凭证编号。
private void scbh()
{
string str=dc.connstr ;
SqlConnection conn=new SqlConnection (str);
string sql="select 凭证号码 from tabdjb where 住宿日期='"+this.textBox7 .Text+"'";
SqlDataAdapter adapter=new SqlDataAdapter (sql,conn);
DataSet dataset=new DataSet ();
adapter.Fill (dataset,"tabdjb");
int num=0;
num=dataset.Tables ["tabdjb"].Rows.Count;
num++;
this.textBox4 .Text =this.textBox7.Text+"ZSD"+num.ToString ("d4");
conn.Close ();
dataset.Dispose ();
adapter.Dispose ();
}
private void chushi()
{
this.textBox1 .Text ="";
this.textBox2 .Text ="";
this.textBox5 .Text ="";
this.comboBox1.SelectedIndex =-1;
this.textBox11 .Text ="";
this.textBox9 .Text ="";
this.textBox13 .Text ="";
this.comboBox2.SelectedIndex =-1;
this.comboBox5.SelectedIndex =-1;
this.textBox6 .Text ="";
this.textBox8 .Text ="";
this.textBox14 .Text ="";
this.textBox10 .Text ="";
this.textBox12 .Text ="";
}
private void button3_Click(object sender, System.EventArgs e)
{
scbh ();
chushi();
}
//检查输入是否有误
private bool checkinput()
{
bool passed=true;
if(this.textBox1.Text .Length==0|this.comboBox1 .Items .Contains(this.comboBox1 .Text)==false|this.comboBox2 .Items .Contains(this.comboBox2 .Text)==false|this.textBox2.Text .Length ==0|this.textBox5 .Text .Length ==0|this.textBox6 .Text .Length ==0)
passed=false;
return passed;
}
private void button2_Click(object sender, System.EventArgs e)
{
string str=dc.connstr ;
SqlConnection conn=new SqlConnection (str);
string sql="insert into tabdjb values(";
sql=sql+"'"+this.textBox4 .Text +"',";
sql=sql+"'"+this.textBox1 .Text +"',";
sql=sql+"'"+this.comboBox1.Text +"',";
sql=sql+"'"+this.textBox2 .Text +"',";
sql=sql+"'"+this.textBox5 .Text +"',";
sql=sql+"'"+this.comboBox5.Text +"',";
sql=sql+"'"+this.comboBox2.Text +"',";
sql=sql+"'"+this.textBox11 .Text +"',";
sql=sql+""+this.textBox6 .Text +",";
sql=sql+"'"+this.textBox7 .Text +"',";
sql=sql+"'"+this.textBox10 .Text +"',";
sql=sql+"'"+this.textBox14 .Text +"',";
sql=sql+""+this.textBox12 .Text +",";
sql=sql+""+this.textBox8 .Text +",";
sql=sql+""+this.textBox13 .Text +",";
sql=sql+"'0',";
sql=sql+"'"+this.opername+"',";
sql=sql+"'"+this.textBox9 .Text +"')";
SqlCommand cmd=new SqlCommand (sql,conn);
string sql1="update tabkfinfo set 房态='入住' where 房间号='"+this.comboBox5 .Text +"'";
SqlCommand cmd1=new SqlCommand (sql1,conn);
conn.Open ();
try
{
if(this.checkinput() ==true)
{
cmd.ExecuteNonQuery ();
MessageBox.Show ("您已登记成功!","恭喜",MessageBoxButtons.OK ,MessageBoxIcon.Information);
cmd1.ExecuteNonQuery ();//修改房态
scbh ();
chushi();
}
else
MessageBox.Show ("对不起,您的输入有误,请仔细检查,重新输入!","注意",MessageBoxButtons.OK ,MessageBoxIcon.Error );
}
catch
{
MessageBox.Show ("对不起,您的输入有误,请仔细检查,重新输入!","注意",MessageBoxButtons.OK ,MessageBoxIcon.Error );
}
finally
{
conn.Close();
cmd1.Dispose ();
cmd.Dispose ();
}
}
private void textBox12_TextChanged(object sender, System.EventArgs e)
{
string str1=this.textBox12.Text ;
int f=1;
for(int i=0;i<str1.Length ;i++)
{
if(str1[i]<'0'|str1[i]>'9')
f=0;
break;
}
if(this.textBox12.Text .Length >0&textBox12.Text .Length <4&f==1)
{
string str=Convert.ToString(Math.Abs(Convert.ToInt32(this.textBox12 .Text )));
this.textBox14 .Text =(Convert.ToDateTime (this.textBox7 .Text ).AddDays(Convert.ToUInt32(str))).ToShortDateString();
this.textBox8 .Text =Convert.ToString(((Convert.ToDecimal (str)*Convert.ToDecimal (this.textBox6 .Text))));
this.textBox13.ReadOnly =false;
}
else
{
this.textBox13.ReadOnly =true;
this.textBox8 .Text ="";
this.textBox14 .Text ="";
this.textBox10 .Text ="";
this.textBox12 .Text ="";
this.textBox13.Text ="";
}
}
private void comboBox5_SelectedIndexChanged(object sender, System.EventArgs e)
{
this.textBox6 .DataBindings .Clear ();
string str=dc.connstr ;
SqlConnection conn=new SqlConnection (str);
string sql="select * from tabkfinfo where 房间号='"+this.comboBox5.Text+"'";
SqlDataAdapter adapter=new SqlDataAdapter (sql,conn);
DataSet dataset=new DataSet ();
adapter.Fill (dataset,"tabkfinfo");
this.textBox6 .DataBindings.Add (new Binding ("Text",dataset,"tabkfinfo.价格"));;
adapter.Dispose ();
conn.Close ();
dataset.Dispose ();
}
private void comboBox2_SelectedIndexChanged(object sender, System.EventArgs e)
{
string str=dc.connstr ;
SqlConnection conn=new SqlConnection (str);
string sql="select 房间号 from tabkfinfo where 房态='空闲'and 客房类型='"+this.comboBox2 .Text +"'";
SqlDataAdapter adapter=new SqlDataAdapter (sql,conn);
DataSet dataset=new DataSet ();
adapter.Fill (dataset,"tabkfinfo");
this.comboBox5 .DisplayMember="房间号";
this.comboBox5 .DataSource =dataset.Tables ["tabkfinfo"];
if(this.comboBox5 .Items .Count ==0&this.comboBox2.Text .Length >0)
{
MessageBox.Show ("对不起,此类客房暂无空房!","注意",MessageBoxButtons.OK ,MessageBoxIcon.Error );
this.textBox6 .ReadOnly =true;
this.textBox6 .Text ="";
this.textBox12.ReadOnly =true;
}
else
this.textBox12.ReadOnly =false;
conn.Close ();
dataset.Dispose ();
adapter.Dispose ();
}
private void textBox13_TextChanged(object sender, System.EventArgs e)
{
string str=this.textBox13.Text ;
int f=1;
for(int i=0;i<str.Length ;i++)
{
if(str[i]<'0'|str[i]>'9')
f=0;
break;
}
if(this.textBox13.Text .Length >0&textBox13.Text .Length <8&f==1)
{
int usedays=Convert.ToInt32(this.textBox13.Text)/Convert.ToInt32(this.textBox6.Text );
this.textBox10 .Text =(Convert.ToDateTime (this.textBox7 .Text ).AddDays(Convert.ToUInt32(usedays))).ToShortDateString();
}
else
{
this.textBox10.Text ="";
this.textBox13.Text ="";
}
}
}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -