Response.Write(\入住成功!\\\);
5.4.2 大堂入住
大堂入住界面如下图所示:
关键代码
protected void Button1_Click(object sender, EventArgs e)//办理入住手续,将数据更新到数据库 {
if (txtzjh.Text==\) {
Response.Write(\证件号不能为空!\\\); }
else if (txtname.Text==\) {
Response.Write(\顾客姓名不能为空!\\\); }
else if (txtlivename.Text==\) {
Response.Write(\入住人不能为空!\\\); }
else if (Convert.ToInt32(lableft.Text)<=0) {
Response.Write(\所选房间已满请选择其他房间!\\\); } else {
string constr = ConfigurationManager.ConnectionStrings[\].ConnectionString; using (SqlConnection sqlcon = new SqlConnection(constr)) {
29
图 5-7 大堂入住界面
string comstr = \ + \(@rid,@zjh,@cname,@etime);\ +
\ + \
roomcategory
set
lamount=lamount-1
where
categoryid='\
+
into
liverecoder(roomid,cid,customername,entertime)
values
DropDownList1.SelectedValue + \ ;
using (SqlCommand sqlcom = new SqlCommand(comstr, sqlcon)) {
sqlcom.Parameters.AddWithValue(\, txtzjh.Text); sqlcom.Parameters.AddWithValue(\, zjlist.SelectedValue); sqlcom.Parameters.AddWithValue(\, txtname.Text); sqlcom.Parameters.AddWithValue(\, sexlist.SelectedValue); sqlcom.Parameters.AddWithValue(\, DropDownList2.SelectedValue); sqlcom.Parameters.AddWithValue(\, txtlivename.Text); sqlcom.Parameters.AddWithValue(\, DateTime.Now); sqlcon.Open();
using (SqlDataReader reader = sqlcom.ExecuteReader()) {
if (reader.HasRows) {
while (reader.Read()) {
labprice.Text = reader.GetValue(0).ToString() + \元/每天\; } } } } }
Response.Write(\入住成功!\\\); }
}
30
5.6 退房管理
顾客离开酒店时办理退房手续。退房管理界面如下图所示
图 5-8 退房管理界面
关键代码
protected void Button1_Click(object sender, EventArgs e)//查询客户住宿信息 {
Label2.Visible = false;
string constr = ConfigurationManager.ConnectionStrings[\].ConnectionString; using (SqlConnection sqlcon=new SqlConnection(constr)) { string price \
+\
+\liverecoder.roomid=@rid and liverecoder.roomid=roominfo.rid and rcategory=categoryid and liverecoder.cid=customerinfo.cid and liverecoder.livestatus='1'\;
using (SqlCommand sqlcom=new SqlCommand (comstr,sqlcon)) {
sqlcom.Parameters.AddWithValue(\, txtrid.Text); sqlcon.Open();
using (SqlDataReader reader=sqlcom.ExecuteReader()) {
if (reader.HasRows) {
31
comstr
=
\
recodeid,idcategory,liverecoder.cid,cname,csex,rid,categoryname,liverecoder.entertime,liverecoder.customername,
Panel1.Visible = true; while (reader.Read()) {
labid.Text = reader.GetValue(0).ToString(); labzj.Text = reader.GetValue(1).ToString(); labzjh.Text = reader.GetValue(2).ToString(); labname.Text = reader.GetValue(3).ToString(); labsex.Text = reader.GetValue(4).ToString(); labrid.Text = reader.GetValue(5).ToString(); labcate.Text = reader.GetValue(6).ToString(); labetime.Text = reader.GetValue(7).ToString(); lablivename.Text = reader.GetValue(8).ToString();
labprice.Text = reader.GetValue(9).ToString()+\元/每天\; TimeSpan ts = DateTime.Now - Convert.ToDateTime(reader.GetValue(7));//计算入住时间
int a = Convert.ToInt32(ts.Days);
if (a==0)//判断,入住天数为0时,按一天计算 {
labdays.Text = \;//中间变量,存储住宿天数 } else
labdays.Text = ts.Days.ToString();//获取入住时间的天数部分 int
money
=
Convert.ToInt32(labdays.Text)
*
Convert.ToInt32( reader.GetValue(9));//计算金额
labmoney.Text = money.ToString(); } } else {
Panel1.Visible = false; Label2.Visible = true; } } } } }
protected void Button2_Click(object sender, EventArgs e)//办理退宿手续,并将记录写入数据库 {
string constr = ConfigurationManager.ConnectionStrings[\].ConnectionString; using (SqlConnection sqlcon = new SqlConnection(constr)) {
string comstr = \recodeid='\ + labid.Text + \ +
\+labrid.Text+\
32
相关推荐: