酒店消费管理系统算法-基于b/s的酒店管理系统设计与实现
微信号
KTV115116
本文目录一览:
基于b/s的酒店管理系统设计与实现
基于 B /S 模式的酒店管理系统的设计与实现
XXXXX学院 电大工作部, XX省 XX 457000)
摘要:酒店客房管理系统可以实现酒店内各个客房信息以最快、最准确、 最全面的形式传输、 共享, 是酒店前后台联网的一个
网络系统。本系统采用基于 B /S 结构和关系数据库相结合的开发平台,在 Jbuider10 这种开发环境下,选用了 SQL /Server2000
数据库和 Tomcat 服务器,并在此基础上将理论知识与开发技术 JSP + JavaBean + Servlet 相结合运用到系统的实现过程当中, 完
成了系统平台的构建。该系统分为前台员工登录系统和后台管理员管理系统两部分。
关键词:酒店客房管理系统;浏览器 /服务器设计模式;关系数据库
中图分类号:TP311 文献标识码:A 文章编号:1672 - 9161(2010)04 - 0138 - 02
1 引言
随着中国 GDP 的不断增长和旅游业的飞速发
展,人们因商务或休闲娱乐出行的频率上升,酒店的
市场需求增高。同时酒店行业的高利润高回报使得
更多的资金涌进,国内市场开放后国外大型连锁酒
店进入内地,使得行业竞争日趋激烈。酒店管理系统
的引入使酒店内部能集中管理,集中控制, 快速反应
各个部门的经营状况,大大降低工作人员的劳动强
度,提高工作效率, 给客户带来极大的便利, 同时也
带来良好的经济效益和社会效益。此外, 酒店管理中
各种信息的提供能使管理者实时动态地掌握酒店的
经营状况,还为管理者提供了有力的决策支持。它的
目标是实现客房管理的系统化、规范化和自动化,使
酒店管理真正由经验管理转入到科学管理。
一个好的酒店管理体制将带来很可观的经济效
益。无论是一个小型旅店还是一个星级酒店,都有很
多的数据需要管理。手工管理这些纷繁复杂数据的
方式已经不适应时代的潮流,而衡量企业管理水平
的基本尺度是资金和时间。因此, 开发酒店客房管理
系统可以及时通过网络将相关信息传送给管理者,
可以及时地发现问题,解决问题。
2 相关理论基础
2. 1 JSP 简介
JSP 是基于 Java 的技术,用于创建可支持跨平
台及跨 Web 服务器的动态网页。当用户浏览器从
Web 服务器上请求 JSP 文件时,Web 服务器响应该
HTTP 的请求,JSP 引擎解释 JSP 标识和小脚本,生
成所请求的内容,并将结果以 HTML 或 XML 页面的
形式发回给浏览器。JSP 引擎通常构架在 Servlet 引
擎上,以 Servlet 形式存在,把 JSP 文件转成 Servlet
源代码,经 Java 编译器编译成为 Servlet。
2. 2 Java Bean 的概念
Java Bean 是一种专门为当前软件开发者设计
的全新组件技术,它为软件开发者提供了一种极佳
的解决方案。JSP 网页吸引人的地方之一就是能够
结合 Java Bean 技术来扩充网页中程序的功能。Java
Bean 是一种 Java 类(class), 通过封装属性和方法使
其成为具有某种功能或者处理某个业务的对象。
2. 3 Servlet 的概念
Servlet 是使用 Java Servlet 应用程序设计接口
(API) 及相关类和方法,并且由 Java 语言编写的服
务器端程序模块。除了 Java Servlet API,Servlet 还可
以使用用以扩展和添加到 API 的 Java 类软件包。
Servlet 在支持 Java 的 Web 服务器上或应用服务器
上运行并扩展了该服务器的能力。Servlet 对于 Web
服务器,就好像 Javaapplet 对于 Web 浏览器。Servlet
装入 Web 服务器并在 Web 服务器内执行,而 applet
装入 Web 浏览器并在 Web 浏览器内执行。
—139—
3 酒店客房管理系统分析
酒店管理系统应该具备以下功能: 快速办理客
人入住、退房;实时、快速、 准确地提供客房动态;方
便查询客人的消费情况。前台系统是酒店管理系统
中的核心部分,它是一个 24 小时连续运行的实时管
理系统,只有完善了前台系统才能说是实现了酒店
电脑管理。前台系统应包括:有效的预订处理,充分
发挥销售潜力;简便迅捷的前台登记服务;有效的客
房管理;客人历史资料处理、 VIP 客人、协议客人、 黑
名单管理; 完善、全面的综合查询;系统运行稳定可
靠、各项维护功能齐全、易于维护;简单、友好的操作
界面。
软件体系结构是开发软件的基础,其基本思想
是将系统设计成由相对独立、单一功能的模块组成
的结构,完成系统的总体结构设计、数据设计、 过程
设计和界面设计,为实现由需求转化为源代码提供
依据和框架,同时也为测试做准备。
针对酒店客房管理系统,根据系统分析和需求
分析,可以将系统大致分为七个模块,这七个模块之
间是没有太大的联系的,可以分别属于一个领域,单
独完成自己的功能,完成属于相应用户的操作。对于
其中一个模块的操作不影响其他模块的操作和功
能。这个酒店客房管理系统,有员工管理、 参数设置、
客房管理、宾客管理、 结算管理、 账目报表、 登录系统
几个模块,再具体的还有客房类型维护,客房信息添
加,客房信息修改, 客房信息查询, 客户类型添加, 客
户信息添加,订房、 退房、 结算等。
该系统包含如下七个模块:
系统模块图
3. 1 系统开发及运行环境
3. 1. 1 系统开发平台: 基于 B /S 结构和关系数据
库结合的开发平台。
3. 1. 2 系统的开发环境: 数据库选用SQLServ-
er2000。选用 JSP 服务器:Tomcat。浏览器:IE5. 0, 推
荐使用 IE6. 0。开发工具包:JDKVersion1. 4. 2。开发
环境:Jbuider10。
3. 2 数据库设计
为了提高数据存取效率,降低数据冗余度,对系
统所需的数据先建一个数据库,数据库包含 7 个数
据表,即宾房类型信息表 (afficede)、宾房信息表
(info)、 员工基本信息表(bumf)、 宾客类型信息表、 宾
客信息表(eminfo)、账目信息表(deparment)等。
4 系统实现
根据以上项目的特点,本系统采用 B /S 模式的
Web 设计方案,整体基于 J2EE 的 Web 应用体系结
构。将 MVC 模式与 J2EE 应用结合,采用基于 JSP +
JavaBean + Servlet 相结合的框架来改进J2EE 体系
的 Web 系统。
登录模块主要实现管理员、经理、员工的登录,
是整个系统的入口,是系统的首页。 利用登录来管理
用户操作权限。登录系统时, 需输入用户名和登录密
码,其它详细信息如用户姓名、用户权限、 用户单位、
备注等将从后台数据库中自动检索出来。程序首先
判断输入的用户名和密码是否合法,即判断用户的
合法身份,如果用户输入错误,程序将给出提示。
通过身份验证后,系统将在后台执行另一个检
测过程,从员工密码信息表中调取权限数据,判断该
用户的权限级别。
4. 1 前台系统功能实现
前台系统主要涉及普通职员和经理对系统的操
作,其中普通职员只具备“客房管理、 “ 宾客管理和
“结账管理” 等功能, 经理具有全部查询功能。
4. 2 后台系统功能实现
后台系统主要是管理员进行管理,有参数设置、
公告管理、员工在线信息管理和权限的管理等功
能。
5 结束语
结合XX柏维快捷酒店,开发设计客房管理系
统,采用了经典 JSP 开发模式“ JSP + JavaBean +
Servlet” 相结合的方式来完成对系统的整体开发, 取
得的效果很好,能完成所有预期设计的功能。
参考文献:
[1]盛宇华, 朱晓峰 . 单位办公自动化管理系统[M]. 北京:
科学出版社, 2004. 15 - 23.
[2]姜 浩 . 办公自动化系统及其应用[M]. 北京:清华大学
出版社, 2004. 10 - 13.
[3]耿祥义, 张跃平 . Java2 实用教程[M]. 北京:清华大学出
版社, 2004. 3 - 4.
酒店管理系统应该怎么操作呢
酒店管理系统一般包含预定接待、帐务处理、客房中心、报表中心等功能模块。 酒店管理系统
优秀的酒店管理软件能显著地提高酒店的服务水平和工作效率,规范酒店的业务流程,帮助酒店管理者及时、全面地了解经营信息,做出更加准确的决策,从而有效地提高酒店的经营效益。
酒店管理系统-组成介绍
(1)前台系统: 营销、客档、房价方案、预订、接待、前台客帐、客房中心、夜审、报表中心、总 酒店管理系统
经理查询、留言中心、后台AR帐、功能分配、角色授权。
(2)可选系统: 电话管理系统: 功能:电话实时接收入帐、话单分类统计、电话反控、电话自动开/关。 餐厅管理系统: 功能:预订、开桌、点菜收银、报表中心、迎宾、系统设置、库存进销存、销售排行、成本核算。 娱乐管理系统: 功能: 预订、开台、点单收银、营业统计、酒水管理、场所设置。 洗浴管理系统: 功能: 开牌、点单、收银、统计查询、会员管理、技师提成、销售排行、项目设置。 酒吧管理系统: 功能:迎宾接待、点单、收银、IC卡管理、酒水进销存、系统设置。 工程管理系统: 功能:设备台帐、设备保养、工程报修、工程接单、在线维护、实时销单、工作量统计。 会员管理系统: 功能:会员账号、会员账款、会员消费等管理以及会员一系列的报表。 库存管理系统: 功能:入库、出库、记明细帐、总帐、盘存、分仓管理、查询统计、报表。 人事工资管理: 功能:员工信息、奖惩、培训教育、工资发放、查询统计、报表。
你以什么样的身份登录呢,一般要进入后台需要用户名和密码的。
酒店管理系统的功能
酒店管理系统功能涵盖预定管理、接待管理、收银管理、会员管理、房间解锁、房态管理、客户管理、财务管理、系统设置、日志管理、管理员管理等。
酒店管理系统的功能介绍如下:
1、预定管理。系统提供在线预订平台,通过预订平台,用户可以清楚地了解当前房源信息,此外,还可以处理用户有关酒店更新、退房等问题。
2、接待管理。可实时查看远期房态表,历史客人可以快速入住,节省前台办理时间,可查询员工操作痕迹,恢复退房功能,自定义房价,预离房提示。
3、收银管理。收银时,可以选择多种结算方式,支持账单汇总或明细打印等多种结账方式。
4、会员管理。可查看会员注册信息,也可以查询、修改、删除会员信息。根据不同会员等级设置不能优惠价格。
5、房间解锁。可对已锁定的操作系统进行自动解锁,如果不是正常操作退出,可强制性进行解锁。
6、房态管理。可实时查看房态现状,及房态出售数量和类型,提供预订房间的统计和数据汇总。
7、客户管理。可查询、修改客人入住资料,以及客人住店历史查询。
8、消费管理。添加多种消费项目进行设置和管理,可查看客房的消费明细。
9、财务管理。支持各种报表查询,比如会员积分表,预订单表,收银表,经营表等等。
10、日志管理。通过系统可查询到所有操作人员的操作记录。防止操作人员不按照规则办事。
11、管理员管理。可设置所有操作人员的操作权限。
12、客服服务中心。为住宿用户提供服务,使用户可以致电相关的酒店住宿服务内容,并提高用户在酒店住宿的体验。
C语言编写酒店管理系统
int CheckRoom(struct room *pr)
{char phonenu[4][12]={"110","119","120","122"};/*非法私人电话号码*/
char type[3][2]={"2","t","T"};
int flag=1,i;
static int pass=1;
if(NULL==pr) {printf("Error:Null point! Can't check the datas:\n");return 0;}
printf("Start to part Maintain:about room\n");
while( strlen(pr-roomnu)5 )/*检查数据长度酒店消费管理系统算法,防止保存二进制数据错误*/
{pr-roomnu[5]=0;
printf("ERROR:the roomnu: %s is longer than 5 bytes.\n",pr-roomnu);
printf("Please select another shorter roomnu:\n");
scanf("%s",pr-roomnu);
}
while( strlen(pr-cleaner)19 )/*检查数据长度,防止保存二进制数据错误*/
{pr-cleaner[19]=0;
printf("ERROR:the cleaner:%s is longer than 19 bytes.\n",pr-cleaner);
printf("Please select another shorter name:\n");
scanf("%s",pr-cleaner);
}
while(flag||strlen(pr-phonenu)11)/*检查数据内容(由flag控制)和长度,防止保存二进制数据错误*/
{
while( strlen(pr-phonenu)11 )/*检查长度*/
{pr-phonenu[11]=0;
printf("ERROR:the phonenu:%s is longer than 11 bytes.\n",pr-phonenu);
printf("Please select another shorter phonenu:\n");
scanf("%s",pr-phonenu);
}
while(flag)/*检查内容*//*这个算法也有问题,如果内容非法,但长度通过怎么办呢?*/
{for(i=0;flagi4;i++)
if( 0==strcmp(pr-phonenu,phonenu[i]) )/*内容非法*/
{printf("ERROR:illegal phonenu:%s!\n",pr-phonenu);
flag=0;/*检测到内容非法*/
}
if(flag) flag=0;/*内容检查通过*/
else {flag=1;
printf("Please input a legal phonenu:\n");
scanf("%s",pr-phonenu);/*内容检查未通过,重新收入*/
}
}
}
flag=1;
while(flag||strlen(pr-type)1)/*检查数据内容(由flag控制)和长度,此例和上例不同*/
{
while( strlen(pr-type)1 )/*检查长度*/
{pr-type[1]=0;
printf("ERROR:the type:%s is longer than 1 byte.\n",pr-type);
printf("Please select another shorter type:\n");
scanf("%s",pr-type);
}
while(flag)/*检查内容*/
{if(strcmp(pr-type,type[0])strcmp(pr-type,type[1])strcmp(pr-type,type[2]) )/*内容非法*/
{printf("ERROR:illegal type:%s!\n",pr-type);
flag=0;/*检测到内容非法*/
}
if(flag) flag=0;/*内容检查通过*/
else {flag=1;
printf("Please input a legal type:\n");
scanf("%s",pr-type);/*内容检查未通过,重新收入*/
}
}
}
while( pr-maximumpr-currentclient )/*检查数据间的联系*/
{printf("ERROR:the room's capacity does not fit for the number of current clients.\n");
printf("Please alter the maximum:\n");
scanf("%d",(pr-maximum));
}/*检查房间最大容量和当前已住顾客人数是否相容,如果前者小于后者则写入错误报告文件 */
printf("Congratulations: ROOM Check pass %d!\n",pass++);
return 1;
}
int CheckClient(struct client *pc)
{ int flag=1,i;
char sex[4][2]={"m","M","f","F"};
static int pass=1;
if(NULL==pc) {printf("Error:Null point! Can't check the datas:\n");return 0;}
printf("Start to part Maintain:about client\n");
while( strlen(pc-roomnu)5 )/*检查房间长度*/
{pc-roomnu[5]=0;
printf("ERROR:the roomnu: %s is longer than 5 bytes.\n",pc-roomnu);
printf("Please select another shorter roomnu:\n");
scanf("%s",pc-roomnu);
}
while( strlen(pc-identity_card)!=18 )/*检查身份证号长度*/
{pc-identity_card[18]=0;
printf("ERROR:the identity_card:%s is not 18 bytes.\n",pc-identity_card);
printf("Please check the length and input it again:\n");
scanf("%s",pc-identity_card);
}
while(strlen(pc-name)19)/*检查姓名长度*/
{pc-name[19]=0;
printf("ERROR:the name:%s is longer than 19 bytes.\n",pc-name);
printf("Please select another shorter phonenu:\n");
scanf("%s",pc-name);
}
while(flag||strlen(pc-sex)1)/*检查性别内容(由flag控制)和长度*/
{
while( strlen(pc-sex)1 )/*检查长度*/
{pc-sex[1]=0;
printf("ERROR:the sex:%s is longer than 1 byte.\n",pc-sex);
printf("Please select another shorter sex:\n");
scanf("%s",pc-sex);
}
while(flag)/*检查内容*/
{if(strcmp(pc-sex,sex[0])strcmp(pc-sex,sex[1])strcmp(pc-sex,sex[2])strcmp(pc-sex,sex[3]) )/*内容非法*/
{printf("ERROR:illegal sex:%s!\n",pc-sex);
flag=0;/*检测到内容非法*/
}
if(flag) flag=0;/*内容检查通过*/
else {flag=1;
printf("Please input a legal sex:\n");
scanf("%s",pc-sex);/*内容检查未通过,重新收入*/
}
}
}
while( strlen(pc-date)!=8 )/*检查日期长度*/
{pc-date[8]=0;
printf("ERROR:the date:%s is not 8 bytes.\n",pc-date);
printf("Please check the length and input it again:\n");
scanf("%s",pc-date);
}
while( strlen(pc-collect)5 )/*检查收款人长度*/
{pc-collect[5]=0;
printf("ERROR:the collect:%s is not 5 bytes.\n",pc-collect);
printf("Please check the length and input it again:\n");
scanf("%s",pc-collect);
}
while(pc-time0)/*检查入住天数*/
{printf("ERROR:illegal input of time: %f!\n",pc-time);
printf("Please check and input it again:\n");
scanf("%f",pc-time);
}
while(pc-cost0)/*检查应缴费用*/
{printf("ERROR:illegal input of cost: %f!\n",pc-cost);
printf("Please check and input it again:\n");
scanf("%f",pc-cost);
}
while(pc-fee0)/*检查实缴费用*/
{printf("ERROR:illegal input of cost: %f!\n",pc-fee);
printf("Please check and input it again:\n");
scanf("%f",pc-fee);
}
if( pc-feepc-cost )/*检查数据间的联系,实缴费用应小于应缴用*/
{printf("It may be a error:fee=%f cost=%f\n",pc-fee,pc-cost);
printf("Do you like to alter them?(1:YES;0:NO)\n");
scanf("%d",flag);
while(flag)
{printf("Please input the values:cost and fee\n");
scanf("%f%f",pc-cost,pc-fee);
if(pc-feepc-cost)
{printf("Error again!!\n");flag=1;}
else flag=0;
}
}
printf("Congratulations: CLIENT Check pass %d!\n",pass++);
return 1;
}
int CheckAll(struct room *head_room)
{struct client *pc;
struct room *pr;
if(NULL==head_room) {printf("head_room=0\n");return 0;}
printf("Start to part Maintain:about room and client\n");
pr=head_room;
while(pr)
{CheckRoom(pr);
pc=pr-head;
while(pc)
{CheckClient(pc);
pc=pc-next;
}
pr=pr-next;
}
return 1;
}
/**该函数为内部数据维护,不提供输入数据服务。实体完整性,参照完整性,用户自定义完整性
出现错误则将错误输出到doc文档。
错误范围暂时定义如下酒店消费管理系统算法:
1.同一房间的客户房间号不同(同房搜索!)
2.实缴费用大于应缴费用。(同房搜索!)
3.同一个客户在同一天两次住进宾馆(全表搜索!身份证号和入住日期相同)
4.同一身份证号,姓名和性别不同(全表搜索!)
另外,应该完成的任务有:
5.计算客户的应缴费用-对cost操作,需要用到:time,unit_price
6.计算客房的总住户人数(包括当前住户)-对totalclient操作,需要用到:没有
7.重新修订当前住户数-对currentclient进行操作,需要用到:time
8.计算客房的总计收入-对income进行操作,需要用到:fee
9.当前住户的实缴费用清零-对fee进行操作,需要用到:time
完成这些操作的先后顺序为:7-6-5-9-8-2-1-3-4*/
int Consistency(struct room *head_room)
{struct room *pr,*tpr;
struct client *pc,*tpc;
char file[12]="error.doc";
int i=0;/*i用于错误计数*/
static int count=0;
FILE *fp;
if(NULL==head_room) {printf("head_room=0\n");return 0;}
printf("Start to part Maintain:Consistency!\n");
pr=head_room;
while(pr)
{pr-currentclient=0;
/*pr-totalclient=0;*/
pr-income=0;
pc=pr-head;
while(pc)
{if(!pc-time) pr-currentclient++;/*完成........7.....*/
/*pr-totalclient++;*/ /*完成........6.....*/
pc-cost=(pc-time)*(pr-unit_price); /*完成........5.....*/
if(!pc-time) pc-fee=0; /*完成........9.....*/
pr-income=pr-income+pc-fee; /*完成........8.....*/
pc=pc-next;
}
pr=pr-next;
}
if(NULL==( fp=fopen(file,"wt") ) )
{printf("Cannot open file:%s!\n",file);
return 0;
}
pr=head_room;
while(pr)
{pc=pr-head;
while(pc)
{if(pc-feepc-cost)
{fprintf(fp,"Error %d:fee=%f cost=%f\n",++i,pc-fee,pc-cost);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",pc-roomnu,pc-identity_card,pc-name,pc-sex,pc-date,pc-collect,pc-time,pc-cost,pc-fee);
/*完成........2.....*/
}
if( strcmp(pr-roomnu,pc-roomnu) )
{fprintf(fp,"Error %d:the client's roomnu:%s != the room's roomnu:%s",++i,pc-roomnu,pr-roomnu);
fprintf(fp,"roomnu cleaner phonenu type max area price clientNO\n");
fprintf(fp,"%-6s %-16s %-12s %-4s %-3d %-6.1f %-6.1f %-2d\n",pr-roomnu,pr-cleaner,pr-phonenu,pr-type,pr-maximum,pr-area,pr-unit_price,pr-currentclient);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",pc-roomnu,pc-identity_card,pc-name,pc-sex,pc-date,pc-collect,pc-time,pc-cost,pc-fee);
/*完成........1.....*/
}
pc=pc-next;
}
pr=pr-next;
}
/*这个要全表搜索,搜索一次全表过掉一个客户*/
pr=head_room;
while(pr)
{pc=pr-head;
while(pc)
{
if(pc-next)
{tpc=pc-next;
while(tpc)
{if(0==strcmp(pc-identity_card,tpc-identity_card) 0==strcmp(pc-date,tpc-date) )
{fprintf(fp,"Error %d:the same client:%s lived in our hotel in the same day:%s\n",++i,pc-identity_card,pc-date);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n",pc-roomnu,pc-identity_card,pc-name,pc-sex,pc-date,pc-collect,pc-time,pc-cost,pc-fee);
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",tpc-roomnu,tpc-identity_card,tpc-name,tpc-sex,tpc-date,tpc-collect,tpc-time,tpc-cost,tpc-fee);
}/*完成........3.....*/
if(0==strcmp(pc-identity_card,tpc-identity_card) (strcmp(pc-name,tpc-name)||strcmp(pc-sex,tpc-sex)) )
{fprintf(fp,"Error %d:the same client:%s have the different name or sex in our hotel.\n",++i,pc-identity_card);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n",pc-roomnu,pc-identity_card,pc-name,pc-sex,pc-date,pc-collect,pc-time,pc-cost,pc-fee);
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",tpc-roomnu,tpc-identity_card,tpc-name,tpc-sex,tpc-date,tpc-collect,tpc-time,tpc-cost,tpc-fee);
}/*完成........4.....*/
tpc=tpc-next;
}/*while(tpc) exit */
/*当前房间比较结束,进入下一个房间*/
tpr=pr-next;
while(tpr)
{tpc=tpr-head;
while(tpc)
{if(0==strcmp(pc-identity_card,tpc-identity_card) 0==strcmp(pc-date,tpc-date) )
{fprintf(fp,"Error %d:the same client:%s lived in our hotel in the same day:%s\n",++i,pc-identity_card,pc-date);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n",pc-roomnu,pc-identity_card,pc-name,pc-sex,pc-date,pc-collect,pc-time,pc-cost,pc-fee);
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",tpc-roomnu,tpc-identity_card,tpc-name,tpc-sex,tpc-date,tpc-collect,tpc-time,tpc-cost,tpc-fee);
}/*完成........3.....*/
if(0==strcmp(pc-identity_card,tpc-identity_card) (strcmp(pc-name,tpc-name)||strcmp(pc-sex,tpc-sex)) )
{fprintf(fp,"Error %d:the same client:%s have the different name or sex in our hotel.\n",++i,pc-identity_card);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n",pc-roomnu,pc-identity_card,pc-name,pc-sex,pc-date,pc-collect,pc-time,pc-cost,pc-fee);
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",tpc-roomnu,tpc-identity_card,tpc-name,tpc-sex,tpc-date,tpc-collect,tpc-time,tpc-cost,tpc-fee);
}/*完成........4.....*/
tpc=tpc-next;
}/*while(tpc) exit */
tpr=tpr-next;
}/*while(tpr) exit */
}
else/*当前客户下一节点为空的情况搜索*/
{tpr=pr-next;
while(tpr)
{tpc=tpr-head;
while(tpc)
{if(0==strcmp(pc-identity_card,tpc-identity_card) 0==strcmp(pc-date,tpc-date) )
{fprintf(fp,"Error %d:the same client:%s lived in our hotel in the same day:%s\n",++i,pc-identity_card,pc-date);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n",pc-roomnu,pc-identity_card,pc-name,pc-sex,pc-date,pc-collect,pc-time,pc-cost,pc-fee);
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",tpc-roomnu,tpc-identity_card,tpc-name,tpc-sex,tpc-date,tpc-collect,tpc-time,tpc-cost,tpc-fee);
}/*完成........3.....*/
if(0==strcmp(pc-identity_card,tpc-identity_card) (strcmp(pc-name,tpc-name)||strcmp(pc-sex,tpc-sex)) )
{fprintf(fp,"Error %d:the same client:%s have the different name or sex in our hotel.\n",++i,pc-identity_card);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n",pc-roomnu,pc-identity_card,pc-name,pc-sex,pc-date,pc-collect,pc-time,pc-cost,pc-fee);
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",tpc-roomnu,tpc-identity_card,tpc-name,tpc-sex,tpc-date,tpc-collect,tpc-time,tpc-cost,tpc-fee);
}/*完成........4.....*/
tpc=tpc-next;
}/*while(tpc) exit */
tpr=tpr-next;
}/*while(tpr) exit */
}
pc=pc-next;/*搜索一次全表过掉一个客户*/
}/*while(pc) exit */
pr=pr-next;
}/*while(pr) exit */
printf("Maintain NO. %d\n",++count);
fclose(fp);
return 1;
}
int ToDate(char *date,int year,int month,int day)/*将年月日转换为字符串*/
{int i,j;
char temp[9];
for(i=3;i-1;i--)
{j=year%10;
temp[i]=j+'0';
year=year/10;
}
for(i=1;i-1;i--)
{j=month%10;
temp[4+i]=j+'0';
month=month/10;
}
for(i=1;i-1;i--)
{j=day%10;
temp[6+i]=j+'0';
day=day/10;
}
temp[8]=0;
strcpy(date,temp);
return 1;
}
int Account(struct room *head_room)
{struct room *pr;
struct client *pc;
char temp[20],date[9],name[6];
float cost,fee;
int time,year,month,day;
int flag=1;
clr();
if(NULL==head_room) {printf("head_room=0\n");getch();clr();return 0;}
printf("Please input CLIENT ID(18bytes)!\n");/*mode=1表示根据身份证号查找特定客户*/
scanf("%s",temp);
while(strlen(temp)!=18)
{printf("Error:the client(ID=%s) is not 18 bytes!",temp);
printf("Please check and input CLIENT ID(18bytes),again!\n");/*mode=1表示根据身份证号查找特定客户*/
scanf("%s",temp);
}
/*查找客户*/
pr=head_room;
flag=1;
while(flagpr)
{pc=pr-head;
while(flagpc)
{if( !strcmp(pc-identity_card,temp)!pc-time)
{printf("roomnu identity_card name sex date clt time cost fee\n");
PrintClient(pc);
flag=0;
}
if(flag) pc=pc-next;
}
pr=pr-next;
}
if(NULL==pc) {printf("Error:the client(ID=%s) does not exist in out hotel!\n",temp);getch();clr();return 0;}
/*获取日期*/
year =GetTime(0,1);
month=GetTime(0,2);
day =GetTime(0,3);
ToDate(date,year,month,day);
time=CountDays(pc-date,date);
cost=time*pr-unit_price;
printf("The client ID=%s who have lived %d days should pay %6.1f $!\n",temp,time,cost);
printf("Please input how much you get from him and your name!\n");
printf("The money is:");
scanf("%f",fee);
printf("Your name(collect) is:");
scanf("%s",name);
while(strlen(name)5)
{printf("Error:the name=%s is longer than 5 bytes!",name);
printf("Please check and input ,again!\n");/*mode=1表示根据身份证号查找特定客户*/
scanf("%s",name);
}
pc-fee=fee;
pc-cost=cost;
pc-time=time;
strcpy(pc-collect,name);
printf("Account end! Thank you!\n");
return 1;
}
C语言程序设计 酒店管理 急急急急 求编程高手
int CheckRoom(struct room *pr)
{char phonenu[4][12]={"110","119","120","122"};/*非法私人电话号码*/
char type[3][2]={"2","t","T"};
int flag=1,i;
static int pass=1;
if(NULL==pr) {printf("Error:Null point! Can't check the datas:\n");return 0;}
printf("Start to part Maintain:about room\n");
while( strlen(pr-roomnu)5 )/*检查数据长度,防止保存二进制数据错误*/
{pr-roomnu[5]=0;
printf("ERROR:the roomnu: %s is longer than 5 bytes.\n",pr-roomnu);
printf("Please select another shorter roomnu:\n");
scanf("%s",pr-roomnu);
}
while( strlen(pr-cleaner)19 )/*检查数据长度,防止保存二进制数据错误*/
{pr-cleaner[19]=0;
printf("ERROR:the cleaner:%s is longer than 19 bytes.\n",pr-cleaner);
printf("Please select another shorter name:\n");
scanf("%s",pr-cleaner);
}
while(flag||strlen(pr-phonenu)11)/*检查数据内容(由flag控制)和长度,防止保存二进制数据错误*/
{
while( strlen(pr-phonenu)11 )/*检查长度*/
{pr-phonenu[11]=0;
printf("ERROR:the phonenu:%s is longer than 11 bytes.\n",pr-phonenu);
printf("Please select another shorter phonenu:\n");
scanf("%s",pr-phonenu);
}
while(flag)/*检查内容*//*这个算法也有问题,如果内容非法,但长度通过怎么办呢?*/
{for(i=0;flagi4;i++)
if( 0==strcmp(pr-phonenu,phonenu[i]) )/*内容非法*/
{printf("ERROR:illegal phonenu:%s!\n",pr-phonenu);
flag=0;/*检测到内容非法*/
}
if(flag) flag=0;/*内容检查通过*/
else {flag=1;
printf("Please input a legal phonenu:\n");
scanf("%s",pr-phonenu);/*内容检查未通过,重新收入*/
}
}
}
flag=1;
while(flag||strlen(pr-type)1)/*检查数据内容(由flag控制)和长度,此例和上例不同*/
{
while( strlen(pr-type)1 )/*检查长度*/
{pr-type[1]=0;
printf("ERROR:the type:%s is longer than 1 byte.\n",pr-type);
printf("Please select another shorter type:\n");
scanf("%s",pr-type);
}
while(flag)/*检查内容*/
{if(strcmp(pr-type,type[0])strcmp(pr-type,type[1])strcmp(pr-type,type[2]) )/*内容非法*/
{printf("ERROR:illegal type:%s!\n",pr-type);
flag=0;/*检测到内容非法*/
}
if(flag) flag=0;/*内容检查通过*/
else {flag=1;
printf("Please input a legal type:\n");
scanf("%s",pr-type);/*内容检查未通过,重新收入*/
}
}
}
while( pr-maximumpr-currentclient )/*检查数据间的联系*/
{printf("ERROR:the room's capacity does not fit for the number of current clients.\n");
printf("Please alter the maximum:\n");
scanf("%d",(pr-maximum));
}/*检查房间最大容量和当前已住顾客人数是否相容,如果前者小于后者则写入错误报告文件 */
printf("Congratulations: ROOM Check pass %d!\n",pass++);
return 1;
}
int CheckClient(struct client *pc)
{ int flag=1,i;
char sex[4][2]={"m","M","f","F"};
static int pass=1;
if(NULL==pc) {printf("Error:Null point! Can't check the datas:\n");return 0;}
printf("Start to part Maintain:about client\n");
while( strlen(pc-roomnu)5 )/*检查房间长度*/
{pc-roomnu[5]=0;
printf("ERROR:the roomnu: %s is longer than 5 bytes.\n",pc-roomnu);
printf("Please select another shorter roomnu:\n");
scanf("%s",pc-roomnu);
}
while( strlen(pc-identity_card)!=18 )/*检查身份证号长度*/
{pc-identity_card[18]=0;
printf("ERROR:the identity_card:%s is not 18 bytes.\n",pc-identity_card);
printf("Please check the length and input it again:\n");
scanf("%s",pc-identity_card);
}
while(strlen(pc-name)19)/*检查姓名长度*/
{pc-name[19]=0;
printf("ERROR:the name:%s is longer than 19 bytes.\n",pc-name);
printf("Please select another shorter phonenu:\n");
scanf("%s",pc-name);
}
while(flag||strlen(pc-sex)1)/*检查性别内容(由flag控制)和长度*/
{
while( strlen(pc-sex)1 )/*检查长度*/
{pc-sex[1]=0;
printf("ERROR:the sex:%s is longer than 1 byte.\n",pc-sex);
printf("Please select another shorter sex:\n");
scanf("%s",pc-sex);
}
while(flag)/*检查内容*/
{if(strcmp(pc-sex,sex[0])strcmp(pc-sex,sex[1])strcmp(pc-sex,sex[2])strcmp(pc-sex,sex[3]) )/*内容非法*/
{printf("ERROR:illegal sex:%s!\n",pc-sex);
flag=0;/*检测到内容非法*/
}
if(flag) flag=0;/*内容检查通过*/
else {flag=1;
printf("Please input a legal sex:\n");
scanf("%s",pc-sex);/*内容检查未通过,重新收入*/
}
}
}
while( strlen(pc-date)!=8 )/*检查日期长度*/
{pc-date[8]=0;
printf("ERROR:the date:%s is not 8 bytes.\n",pc-date);
printf("Please check the length and input it again:\n");
scanf("%s",pc-date);
}
while( strlen(pc-collect)5 )/*检查收款人长度*/
{pc-collect[5]=0;
printf("ERROR:the collect:%s is not 5 bytes.\n",pc-collect);
printf("Please check the length and input it again:\n");
scanf("%s",pc-collect);
}
while(pc-time0)/*检查入住天数*/
{printf("ERROR:illegal input of time: %f!\n",pc-time);
printf("Please check and input it again:\n");
scanf("%f",pc-time);
}
while(pc-cost0)/*检查应缴费用*/
{printf("ERROR:illegal input of cost: %f!\n",pc-cost);
printf("Please check and input it again:\n");
scanf("%f",pc-cost);
}
while(pc-fee0)/*检查实缴费用*/
{printf("ERROR:illegal input of cost: %f!\n",pc-fee);
printf("Please check and input it again:\n");
scanf("%f",pc-fee);
}
if( pc-feepc-cost )/*检查数据间的联系,实缴费用应小于应缴用*/
{printf("It may be a error:fee=%f cost=%f\n",pc-fee,pc-cost);
printf("Do you like to alter them?(1:YES;0:NO)\n");
scanf("%d",flag);
while(flag)
{printf("Please input the values:cost and fee\n");
scanf("%f%f",pc-cost,pc-fee);
if(pc-feepc-cost)
{printf("Error again!!\n");flag=1;}
else flag=0;
}
}
printf("Congratulations: CLIENT Check pass %d!\n",pass++);
return 1;
}
int CheckAll(struct room *head_room)
{struct client *pc;
struct room *pr;
if(NULL==head_room) {printf("head_room=0\n");return 0;}
printf("Start to part Maintain:about room and client\n");
pr=head_room;
while(pr)
{CheckRoom(pr);
pc=pr-head;
while(pc)
{CheckClient(pc);
pc=pc-next;
}
pr=pr-next;
}
return 1;
}
/**该函数为内部数据维护,不提供输入数据服务。实体完整性,参照完整性,用户自定义完整性
出现错误则将错误输出到doc文档。
错误范围暂时定义如下:
1.同一房间的客户房间号不同(同房搜索!)
2.实缴费用大于应缴费用。(同房搜索!)
3.同一个客户在同一天两次住进宾馆(全表搜索!身份证号和入住日期相同)
4.同一身份证号,姓名和性别不同(全表搜索!)
另外,应该完成的任务有:
5.计算客户的应缴费用-对cost操作,需要用到:time,unit_price
6.计算客房的总住户人数(包括当前住户)-对totalclient操作,需要用到:没有
7.重新修订当前住户数-对currentclient进行操作,需要用到:time
8.计算客房的总计收入-对income进行操作,需要用到:fee
9.当前住户的实缴费用清零-对fee进行操作,需要用到:time
完成这些操作的先后顺序为:7-6-5-9-8-2-1-3-4*/
int Consistency(struct room *head_room)
{struct room *pr,*tpr;
struct client *pc,*tpc;
char file[12]="error.doc";
int i=0;/*i用于错误计数*/
static int count=0;
FILE *fp;
if(NULL==head_room) {printf("head_room=0\n");return 0;}
printf("Start to part Maintain:Consistency!\n");
pr=head_room;
while(pr)
{pr-currentclient=0;
/*pr-totalclient=0;*/
pr-income=0;
pc=pr-head;
while(pc)
{if(!pc-time) pr-currentclient++;/*完成........7.....*/
/*pr-totalclient++;*/ /*完成........6.....*/
pc-cost=(pc-time)*(pr-unit_price); /*完成........5.....*/
if(!pc-time) pc-fee=0; /*完成........9.....*/
pr-income=pr-income+pc-fee; /*完成........8.....*/
pc=pc-next;
}
pr=pr-next;
}
if(NULL==( fp=fopen(file,"wt") ) )
{printf("Cannot open file:%s!\n",file);
return 0;
}
pr=head_room;
while(pr)
{pc=pr-head;
while(pc)
{if(pc-feepc-cost)
{fprintf(fp,"Error %d:fee=%f cost=%f\n",++i,pc-fee,pc-cost);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",pc-roomnu,pc-identity_card,pc-name,pc-sex,pc-date,pc-collect,pc-time,pc-cost,pc-fee);
/*完成........2.....*/
}
if( strcmp(pr-roomnu,pc-roomnu) )
{fprintf(fp,"Error %d:the client's roomnu:%s != the room's roomnu:%s",++i,pc-roomnu,pr-roomnu);
fprintf(fp,"roomnu cleaner phonenu type max area price clientNO\n");
fprintf(fp,"%-6s %-16s %-12s %-4s %-3d %-6.1f %-6.1f %-2d\n",pr-roomnu,pr-cleaner,pr-phonenu,pr-type,pr-maximum,pr-area,pr-unit_price,pr-currentclient);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",pc-roomnu,pc-identity_card,pc-name,pc-sex,pc-date,pc-collect,pc-time,pc-cost,pc-fee);
/*完成........1.....*/
}
pc=pc-next;
}
pr=pr-next;
}
/*这个要全表搜索,搜索一次全表过掉一个客户*/
pr=head_room;
while(pr)
{pc=pr-head;
while(pc)
{
if(pc-next)
{tpc=pc-next;
while(tpc)
{if(0==strcmp(pc-identity_card,tpc-identity_card) 0==strcmp(pc-date,tpc-date) )
{fprintf(fp,"Error %d:the same client:%s lived in our hotel in the same day:%s\n",++i,pc-identity_card,pc-date);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n",pc-roomnu,pc-identity_card,pc-name,pc-sex,pc-date,pc-collect,pc-time,pc-cost,pc-fee);
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",tpc-roomnu,tpc-identity_card,tpc-name,tpc-sex,tpc-date,tpc-collect,tpc-time,tpc-cost,tpc-fee);
}/*完成........3.....*/
if(0==strcmp(pc-identity_card,tpc-identity_card) (strcmp(pc-name,tpc-name)||strcmp(pc-sex,tpc-sex)) )
{fprintf(fp,"Error %d:the same client:%s have the different name or sex in our hotel.\n",++i,pc-identity_card);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n",pc-roomnu,pc-identity_card,pc-name,pc-sex,pc-date,pc-collect,pc-time,pc-cost,pc-fee);
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",tpc-roomnu,tpc-identity_card,tpc-name,tpc-sex,tpc-date,tpc-collect,tpc-time,tpc-cost,tpc-fee);
}/*完成........4.....*/
tpc=tpc-next;
}/*while(tpc) exit */
/*当前房间比较结束,进入下一个房间*/
tpr=pr-next;
while(tpr)
{tpc=tpr-head;
while(tpc)
{if(0==strcmp(pc-identity_card,tpc-identity_card) 0==strcmp(pc-date,tpc-date) )
{fprintf(fp,"Error %d:the same client:%s lived in our hotel in the same day:%s\n",++i,pc-identity_card,pc-date);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n",pc-roomnu,pc-identity_card,pc-name,pc-sex,pc-date,pc-collect,pc-time,pc-cost,pc-fee);
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",tpc-roomnu,tpc-identity_card,tpc-name,tpc-sex,tpc-date,tpc-collect,tpc-time,tpc-cost,tpc-fee);
}/*完成........3.....*/
if(0==strcmp(pc-identity_card,tpc-identity_card) (strcmp(pc-name,tpc-name)||strcmp(pc-sex,tpc-sex)) )
{fprintf(fp,"Error %d:the same client:%s have the different name or sex in our hotel.\n",++i,pc-identity_card);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n",pc-roomnu,pc-identity_card,pc-name,pc-sex,pc-date,pc-collect,pc-time,pc-cost,pc-fee);
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",tpc-roomnu,tpc-identity_card,tpc-name,tpc-sex,tpc-date,tpc-collect,tpc-time,tpc-cost,tpc-fee);
}/*完成........4.....*/
tpc=tpc-next;
}/*while(tpc) exit */
tpr=tpr-next;
}/*while(tpr) exit */
}
else/*当前客户下一节点为空的情况搜索*/
{tpr=pr-next;
while(tpr)
{tpc=tpr-head;
while(tpc)
{if(0==strcmp(pc-identity_card,tpc-identity_card) 0==strcmp(pc-date,tpc-date) )
{fprintf(fp,"Error %d:the same client:%s lived in our hotel in the same day:%s\n",++i,pc-identity_card,pc-date);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n",pc-roomnu,pc-identity_card,pc-name,pc-sex,pc-date,pc-collect,pc-time,pc-cost,pc-fee);
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",tpc-roomnu,tpc-identity_card,tpc-name,tpc-sex,tpc-date,tpc-collect,tpc-time,tpc-cost,tpc-fee);
}/*完成........3.....*/
if(0==strcmp(pc-identity_card,tpc-identity_card) (strcmp(pc-name,tpc-name)||strcmp(pc-sex,tpc-sex)) )
{fprintf(fp,"Error %d:the same client:%s have the different name or sex in our hotel.\n",++i,pc-identity_card);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n",pc-roomnu,pc-identity_card,pc-name,pc-sex,pc-date,pc-collect,pc-time,pc-cost,pc-fee);
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",tpc-roomnu,tpc-identity_card,tpc-name,tpc-sex,tpc-date,tpc-collect,tpc-time,tpc-cost,tpc-fee);
}/*完成........4.....*/
tpc=tpc-next;
}/*while(tpc) exit */
tpr=tpr-next;
}/*while(tpr) exit */
}
pc=pc-next;/*搜索一次全表过掉一个客户*/
}/*while(pc) exit */
pr=pr-next;
}/*while(pr) exit */
printf("Maintain NO. %d\n",++count);
fclose(fp);
return 1;
}
int ToDate(char *date,int year,int month,int day)/*将年月日转换为字符串*/
{int i,j;
char temp[9];
for(i=3;i-1;i--)
{j=year%10;
temp[i]=j+'0';
year=year/10;
}
for(i=1;i-1;i--)
{j=month%10;
temp[4+i]=j+'0';
month=month/10;
}
for(i=1;i-1;i--)
{j=day%10;
temp[6+i]=j+'0';
day=day/10;
}
temp[8]=0;
strcpy(date,temp);
return 1;
}
int Account(struct room *head_room)
{struct room *pr;
struct client *pc;
char temp[20],date[9],name[6];
float cost,fee;
int time,year,month,day;
int flag=1;
clr();
if(NULL==head_room) {printf("head_room=0\n");getch();clr();return 0;}
printf("Please input CLIENT ID(18bytes)!\n");/*mode=1表示根据身份证号查找特定客户*/
scanf("%s",temp);
while(strlen(temp)!=18)
{printf("Error:the client(ID=%s) is not 18 bytes!",temp);
printf("Please check and input CLIENT ID(18bytes),again!\n");/*mode=1表示根据身份证号查找特定客户*/
scanf("%s",temp);
}
/*查找客户*/
pr=head_room;
flag=1;
while(flagpr)
{pc=pr-head;
while(flagpc)
{if( !strcmp(pc-identity_card,temp)!pc-time)
{printf("roomnu identity_card name sex date clt time cost fee\n");
PrintClient(pc);
flag=0;
}
if(flag) pc=pc-next;
}
pr=pr-next;
}
if(NULL==pc) {printf("Error:the client(ID=%s) does not exist in out hotel!\n",temp);getch();clr();return 0;}
/*获取日期*/
year =GetTime(0,1);
month=GetTime(0,2);
day =GetTime(0,3);
ToDate(date,year,month,day);
time=CountDays(pc-date,date);
cost=time*pr-unit_price;
printf("The client ID=%s who have lived %d days should pay %6.1f $!\n",temp,time,cost);
printf("Please input how much you get from him and your name!\n");
printf("The money is:");
scanf("%f",fee);
printf("Your name(collect) is:");
scanf("%s",name);
while(strlen(name)5)
{printf("Error:the name=%s is longer than 5 bytes!",name);
printf("Please check and input ,again!\n");/*mode=1表示根据身份证号查找特定客户*/
scanf("%s",name);
}
pc-fee=fee;
pc-cost=cost;
pc-time=time;
strcpy(pc-collect,name);
printf("Account end! Thank you!\n");
return 1;
}