1、 南昌航空大学酒店客房管理系统 课程设计报告学 院 软件学院 专 业 软件工程班 级 112062 学 号 20 学生姓名 李昂 指导教师 王璐课程成绩 完成日期 2013年7月2号目录1 酒店客房管理管理系统需求分析21.1开发背景31.2 系统主要业务分析31。3 系统功能需求分析41.4 系统数据模型92 酒店客房管理系统逻辑结构设计122。1 系统模块划分122。2 数据库逻辑结构设计132。3 在数据库中创建表的语句153 酒店客房管理系统功能设计(存储过程与触发器)163.1 前台操作功能设计163。1.1 开房登记操作163.1。2 退房结账173。1。3 房信息查看183。2
2、预订管理功能设计193。2。1 预定房间193。2.2 预定入住203.2.3 解除预订213。3 信息查询功能设计213。3 报表统计功能设计234 课程设计总结231 酒店客房管理管理系统需求分析1.1开发背景当前,随着信息的不断飞速发展,信息技术已逐渐成为各种技术的基础,信息也成为企业具有竞争力的核心要素。企业的生存和发展依靠正确的决策,而决策的基础就是信息,所以企业竞争力的高低完全取决于企业对信息的获取和处理能力.企业要准确、快速的获取和处理信息,企业信息化是必然的选择。企业必须加快内部信息交流,改进企业业务流程和管理模式,提高运行效率,降低成本,提高竞争力,信息化建设是企业适应社会发
3、展的要求。企业管理信息系统即企业MIS是企业信息化的重要内容。 随着我国改革开放的不断推进,人民生活水平日益提高,旅游经济蓬勃发展,这一切都带动了酒店行业的发展.再加上入境旅游的人也越来越多,入境从事商务活动的外宾也越来越多。传统的手工已不适应现代化酒店管理的需要.及时、准确、全方位的网络化信息管理成为必需. 酒店是一个服务至上的行业,从客人的预定开始,到入住登记直至最后退房结账,每一步骤都要保持一致性的服务水准,错失一步, 会令其辛苦经营的形象功亏一篑。要成为一间成功的酒店,就必须作到宾至如归,面对酒店业内激烈的竞争形势,各酒店均在努力拓展其服务领域的广度和深度。虽然计算机并不是酒店走向成功
4、的关键元素,但它可以帮助那些真正影响成败的要素发挥更大的效用.因此,采用全新的计算机网络和管理系统,将成为提高酒店的管理效率,改善服务水准的重要手段之一.1。2 系统主要业务分析1。2。1前台操作:1开房登记:客人把自身信息和要入住的房号告诉酒店操作员,酒店操作员可以帮用户登记入住信息;退房登记:客人要是想查询房间的状态-是否已入住、是否已预订、是否是空闲-时,由酒店操作员帮忙查询;3房状态查看:客人要退房的时候付清住宿费,酒店操作员便帮客人把在住记录改成历史记录.1。2.2预定管理:预定房间:客人把自身信息和想预订的房间号给酒店操作员,酒店操作员便帮客人预订这间房间,之后其他人在此房间被取消
5、预定前无法入住或预定;2预定入住:客人把自身信息和预定的房间号告诉酒店操作员,酒店操作员调出预定记录核对后在客户出示身份证件后便允许他登记入住此房间;3解除预定:客人把自身信息和预定了的房号告诉酒店操作员,酒店操作员便帮客户取消预订.1。2。3信息查询: 1在住客人列表查询:显示现在在住的客人信息 2预订客人列表查询:显示预定了房间的客人信息 3历史客人列表查询:显示所有曾经在该酒店定房或入住的1。2。4报表统计: 1开房记录统计:显示现在有多少已经开房入住的客人 2退房结账统计:显示现在有多少客人已经退房结账 预订房间统计:显示现在有多少客人预定了房间1。3 系统功能需求分析 图1-1 0层
6、数据流图 图12 1层数据流图 图13 2层数据流图-房间操作处理 图1-4 2层数据流图-预定操作处理 图15 2层数据流图信息查询处理 图1-6 2层数据流图报表统计处理1。4 系统数据模型根据上面所述的业务流程,可以得到系统的数据流图.根据业务流程以及对应的数据流图,可以得到客户、账户、信用卡、表单、凭证等的数据字典。根据得到的数据字典,我们可以得到各个实体的属性图。以下就是主要实体的数据字典和实体图.客人信息的数据项有:姓名、性别、证件类型号、证件号码、联系电话.由客人信息的数据项可以得到其相应的实体属性图,如图17 所示:客人信息姓名性别证件类型号联系电话证件号码图1-7 客人信息实
7、体图证件类型的数据项有:证件类型号、证件类型名.由证件类型的数据项可以得到其相应的实体属性图,如图18 所示:证件类型证件类型号证件类型名图18 证件类型实体图房间信息的数据项有:房号、房类型号、价格、押金、房状态。由房间信息的数据项可以得到其相应的实体属性图,如图1-9 所示:房间信息房状态押金价格房类型号房号图1-9 房间信息实体图房类型的数据项有:房类型号、房类型名、房间平米。由房类型的数据项可以得到其相应的实体属性图,如图110 所示:房类型房类型号房类型名房间平米图1-10 房类型实体图订单的数据项有:订单编号、客人证件号、预计入住日期、预计离开日期、入住日期、结账离开日期、应付金额
8、.由订单的数据项可以得到其相应的实体属性图,如图1-11 所示:订单客人证件号预计入住日期预计离开日期订单编号入住日期结账离开日期应付金额图1-11 订单实体图由上述各实体及其属性可以得到实体间的关系图即ER图,如下图112 所示:预订开房包含包含证件类型客人信息订单房间信息房类型nm1n1nm1图1-12 ER图2 酒店客房管理系统逻辑结构设计2。1 系统模块划分主要功能报表统计前台操作预订管理信息查询退房结账统计预订房间统计开房记录统计预订客人列表查询历史客人列表查询在住客人列表查询解除预订预订入住预订房间退房结账开房登记房状态查看图21 系统模块划分2。2 数据库逻辑结构设计数据库的关系
9、模型根据数据模型来确定,即将关系模型转化为SQLServer数据库系统所支持的实际数据模型,得到数据库的逻辑结构。在数据库的关系模型及系统处理过程中的数据的结构的基础上,获得系统数据库表以及表之间的关系.在本系统中,以下是系统中几个主要的数据依赖和数据库表结构,如表21 到2-7 所示:数据依赖 表21 数据依赖关系关系名主 要 函 数 依 赖客人信息BCNF证件号码-(姓名,性别,证件类型号,联系电话)证件类型BCNF 证件类型号(证件类型名)房间信息BCNF房号(房类型号,价格,押金,房状态)房类型BCNF房类型号(房类型名,房间平米)订单BCNF订单编号(客人证件号,预计入住日期,预计离
10、开日期,入住日期,结账离开日期,应付金额)开房BCNF(订单编号,房号)-() 表2-2 订单表(order_log)编号字段名字段类型备注说明字段约束1order_idchar(10)订单编号主键2cust_idchar(20)客人证件号外键3plan_enter_datedatetime预计入住日期4plan_leave_datedatetime预计离开日期5enter_datedatetime入住日期6leave_datedatetime结账离开日期7order_moneyint应付金额表23 客人信息表(customer)编号字段名字段类型备注说明字段约束1cust_idchar(20
11、)证件号码主键2ptype_idchar(10)证件类型号外键3cust_namechar(10)姓名4sexchar(1)性别5phonechar(10)联系电话 表24 房间信息表(room)编号字段名字段类型备注说明字段约束1room_idchar(10)房号主键2rtype_idchar(10)房类型号外键3rpriceint价格4rdepositint押金5rstatechar(10)房状态 表25 证件类型表(paper_type)编号字段名字段类型备注说明字段约束1ptype_idchar(10)证件类型号主键2ptype_namechar(10)证件类型名 表26 房类型表(r
12、oom_type)编号字段名字段类型备注说明字段约束1rtype_idchar(10)房类型号主键2rtype_namechar(10)房类型名3rareanumeric(5,2)房间平米 表2-7 开房表(book_room)编号字段名字段类型备注说明字段约束1order_idchar(10)订单编号主键2room_idchar(10)房号2。3 在数据库中创建表的语句创建房类型表:createtable room_type(rtype_id char(10)primarykey,rtype_name char(10),rarea numeric(5,2);创建房间信息表:createtab
13、le room(room_id char(10)primarykey,rtype_id char(10),rprice int,rdeposit int,rstate char(10),foreignkey(rtype_id)references room_type(rtype_id));创建证件类型表:createtable paper_type(ptype_id char(10)primarykey,ptype_name char(10);创建客人信息表:createtable customer(cust_id char(20)primarykey,ptype_id char(10),cu
14、st_name char(10),sex char(1),phone char(10),foreignkey(ptype_id)references paper_type(ptype_id);创建订单表:createtable order_log(order_id char(10)primarykey,cust_id char(20),plan_enter_date datetime,plan_leave_date datetime,enter_date datetime,leave_date datetime,order_money int,foreignkey(cust_id)refere
15、nces customer(cust_id);创建订房表:createtablebook_room(order_id char(10),room_id char(10),foreignkey(order_id)references order_log(order_id),foreignkey(room_id)references room(room_id));3 酒店客房管理系统功能设计(存储过程与触发器)3.1 前台操作功能设计3。1.1 开房登记操作-输入房号查询房状态createprocedurepro_rstateroom_idchar(10)asselectroom_id房号,rst
16、ate房状态fromroomwhereroom_id=room_id-运行execpro_rstate101-输入房状态查询房号createprocedurepro_rstate1rstatechar(10)asselectroom_id房号,rtype_name房类型名,rarea房间平米,rprice价格,rdeposit押金fromroom,room_typewhereroom。rtype_id=room_type。rtype_idandrstate=rstate;运行execpro_rstate1空闲输入房号把房间状态改成入住createprocedurepro_change_rsta
17、te_into_liveroom_idchar(10)asupdateroomsetrstate=入住whereroom_id=room_idselectroom_id房号,rstate房状态fromroomwhereroom_id=room_id-运行execpro_change_rstate_into_live101-输入顾客信息(证件号码,证件类型号,姓名,性别,联系电话)createprocedurepro_insert_custcust_idchar(20),ptype_idchar(10),cust_namechar(10),sexchar(1),phonechar(10)asin
18、sertintocustomervalues(cust_id,ptype_id,cust_name,sex,phone);selectcust_id证件号码,ptype_id证件号类型,cust_name姓名,sex性别,phone联系电话fromcustomer-运行execpro_insert_cust360203199307274018,01,李昂,m,18296115815-输入订单信息(订单编号,客人证件号,入住日期,预计离开日期)createprocedurepro_insert_orderorder_idchar(10),cust_idchar(20),enter_datedat
19、etime,plan_leave_datedatetimeasinsertintoorder_log(order_id,cust_id,enter_date,plan_leave_date)values(order_id,cust_id,enter_date,plan_leave_date);selectorder_id订单编号,cust_id客人证件号,plan_enter_date预计入住日期,enter_date入住日期,plan_leave_date预计离开日期,leave_date结账离开日期,order_money应付金额fromorder_log-运行execpro_insert
20、_order000001,360203199307274018,2013-7-1,2013-710输入开房信息(订单号,房号)createprocedurepro_insert_book_roomorder_idchar(10),room_idchar(10)asinsertintobook_roomvalues(order_id,room_id);selectorder_id订单编号,room_id房号frombook_roomwhereorder_id=order_id-运行execpro_insert_book_room000001,1013。1.2 退房结账-输入房号把房间状态改成空闲
21、createprocedurepro_change_rstate_into_freeroom_idchar(10)asupdateroomsetrstate=空闲whereroom_id=room_id;selectroom_id房号,rstate房状态fromroomwhereroom_id=room_id-运行execpro_change_rstate_into_free101-退房结账时输入订单号,输出应结账金额并自动把订单中的“结账离开日期”改为当前日期createprocedurepro_quit_getmoneyorder_idchar(10)asbegindeclareenter
22、_datedatetime,order_moneyint,sumintdeclaregetCurcursorforselectenter_date,order_moneyfromorder_logwhereorder_id=order_id;opengetCurfetchgetCurintoenter_date,order_moneybeginupdateorder_logsetleave_date=getdate()whereorder_id=order_id;selectsum=(day(getdate()day(enter_date))order_money;endclosegetCur
23、deallocategetCurend-运行execpro_quit_getmoney0000013.1。3 房信息查看输入房号查询房信息createprocedurepro_room_inforoom_idchar(10)asselectroom_id房号,rtype_id房类型号,rprice价格,rdeposit押金,rstate房状态fromroomwhereroom_id=room_id-运行execpro_room_info1013。2 预订管理功能设计3。2。1 预定房间输入房号查询房状态createprocedurepro_rstateroom_idchar(10)assele
24、ctroom_id房号,rstate房状态fromroomwhereroom_id=room_id-运行execpro_rstate101输入房号把房间状态改成预订createprocedurepro_change_rstate_into_subscriberoom_idchar(10)asupdateroomsetrstate=预订whereroom_id=room_id;selectroom_id房号,rstate房状态fromroomwhereroom_id=room_id运行execpro_change_rstate_into_subscribe101-输入顾客信息(证件号码,证件类型
25、号,姓名,性别,联系电话)createprocedurepro_insert_custcust_idchar(20),ptype_idchar(10),cust_namechar(10),sexchar(1),phonechar(10)asinsertintocustomervalues(cust_id,ptype_id,cust_name,sex,phone);selectcust_id证件号码,ptype_id证件号类型,cust_name姓名,sex性别,phone联系电话fromcustomer运行execpro_insert_cust360203201307274018,01,王小贱
26、,m,12345678900-输入订单信息(订单编号,客人证件号,预计入住日期)进行预订createprocedurepro_subscribeorder_idchar(10),cust_idchar(20),plan_enter_datedatetimeasinsertintoorder_log(order_id,cust_id,plan_enter_date)values(order_id,cust_id,plan_enter_date);selectorder_id订单编号,cust_id客人证件号,plan_enter_date预计入住日期,enter_date入住日期,plan_le
27、ave_date预计离开日期,leave_date结账离开日期,order_money应付金额fromorder_logwhereorder_id=order_id;运行execpro_subscribe000002,360203201307274018,2013629-输入订房信息(订单号,房号)createprocedurepro_insert_book_roomorder_idchar(10),room_idchar(10)asinsertintobook_roomvalues(order_id,room_id);selectorder_id订单编号,room_id房号frombook_
28、roomwhereorder_id=order_id运行execpro_insert_book_room000002,2013。2.2 预定入住-输入订单编号,查询此订单的信息(看是否为已预订)createprocedurepro_subscribe_to_enterorder_idchar(10)asifexists(selectfromorder_logwhereorder_id=order_id)print已预订elseprint未预定运行execpro_subscribe_to_enter101输入房号把房间状态改成入住createprocedurepro_change_rstate_
29、into_liveroom_idchar(10)asupdateroomsetrstate=入住whereroom_id=room_idselectroom_id房号,rstate房状态fromroomwhereroom_id=room_id运行execpro_change_rstate_into_live101-输入订单信息(订单编号,预计离开日期,入住日期,应付金额)createprocedurepro_subscribe_to_liveorder_idchar(10),plan_leave_datedatetime,enter_datedatetime,order_moneyintasu
30、pdateorder_logsetplan_leave_date=plan_leave_date,enter_date=enter_date,order_money=order_moneywhereorder_id=order_idselectorder_id订单编号,cust_id客人证件号,plan_enter_date预计入住日期,enter_date入住日期,plan_leave_date预计离开日期,leave_date结账离开日期,order_money应付金额fromorder_logwhereorder_id=order_id运行execpro_subscribe_to_liv
31、e000002,20137-12,201371,3003。2。3 解除预订-删除订房信息(订单号,房号) 【触发器实现】createtriggertrig_dele_book_roomonorder_logfordeleteasdeletebook_roomfrombook_room,deletedwherebook_room.order_id=deleted。order_id输入订单编号,删除客人信息、订单对应的房号、订单信息并把对应的房间状态改成空闲(取消预订)createprocedurepro_cancel_subscribeorder_idchar(10)asdeclarecust_
32、idchar(20)declaregetCurcursorforselectcust_idfromorder_logwhereorder_id=order_idopengetCurfetchgetCurintocust_idupdateroomsetrstate=空闲whereroom_idin(selectroom_idfrombook_roomwhereorder_id=order_id)deletefromorder_logwhereorder_id=order_iddeletefrombook_roomwhereorder_id=order_iddeletefromcustomerwh
33、erecust_id=cust_idclosegetCurdeallocategetCur运行execpro_cancel_subscribe0000023.3信息查询功能设计查询在住客人列表create procedure pro_select_cust asdeclare cust_id char(20)declare getCur cursor forselect cust_id from order_logwhere enter_date is not null and leave_date is nullopen getCurfetch getCur into cust_idsele
34、ct cust_id 证件号码,ptype_id 证件号类型,cust_name 姓名,sex 性别,phone 联系电话from customerwhere cust_id=cust_idclose getCurdeallocate getCur运行exec pro_select_cust -查询预订客人信息create procedure pro_select_subscribe asdeclare cust_id char(20)declare getCur cursor forselect cust_id from order_logwhere plan_enter_date is n
35、ot null and enter_date is nullopen getCurfetch getCur into cust_idselect cust_id 证件号码,ptype_id 证件号类型,cust_name 姓名,sex 性别,phone 联系电话from customerwhere cust_id=cust_idclose getCurdeallocate getCur运行exec pro_select_subscribe -查询历史客人信息create procedure pro_select_past asdeclare cust_id char(20)declare ge
36、tCur cursor forselect cust_id from order_logwhere leave_date is not nullopen getCur fetch getCur into cust_idselect cust_id 证件号码,ptype_id 证件号类型,cust_name 姓名,sex 性别,phone 联系电话from customerwhere cust_id=cust_idclose getCurdeallocate getCur-运行exec pro_select_past3。3报表统计功能设计-开房记录统计create procedure pro_s
37、um_live asdeclare count intselect count=COUNT(*) from order_logwhere enter_date is not null and leave_date is nullprint开房记录共+convert(char(10),count)+条-运行exec pro_sum_live-退房结账记录统计create procedure pro_sum_leave asdeclare count intselect count=COUNT() from order_logwhere leave_date is not nullprint退房结
38、账记录共+convert(char(10),count)+条-运行exec pro_sum_leave预订房间记录统计create procedure pro_sum_subscribe asdeclare count intselect count=COUNT() from order_logwhere plan_enter_date is not null and enter_date is nullprint预定房间记录共+convert(char(10),count)+条-运行exec pro_sum_subscribe4 课程设计总结本次课程设计并不是我一第一次接触数据库设计,所以做
39、起来的时候觉得还是比较顺手。直到后面开始用触发器和存储过程来实现功能的时候比较吃力,想了挺多,也问了老师挺多的,后来总算交出了一份比较满意的答卷。我终于明白,再困难的问题总会有个解决的答案.在检查课设的时候,指导老师一丝不苟的态度让我很感动,因为听说隔壁班的老师检查三两下就放过了,我心想这样不是应付我们学生吗,这可是我们一点一滴辛苦做出来的数据库设计啊!但是我们的指导老师很负责,虽然经常因为检查得认真仔细花费的时间多而受到同学们的抱怨,但是老师还是坚持地不放过任何一个敷衍了事者,验收辛苦劳动者们收获的成功果实. 通过本次实验,我受益颇多,在此感谢为我解答问题的段喜龙老师和检查我们课设的王璐老师,谢谢!15