数据库SQL实训酒店客房管理系统.doc_第1页
数据库SQL实训酒店客房管理系统.doc_第2页
数据库SQL实训酒店客房管理系统.doc_第3页
数据库SQL实训酒店客房管理系统.doc_第4页
数据库SQL实训酒店客房管理系统.doc_第5页
已阅读5页,还剩26页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

目录目录1第一章 系统分析2一.可性行分析2第二章 需求分析2第三章 系统总体设计33.1总体设计33.2详细设计模块43.3 数据库设计53.4数据库需要分析53.4.1数据库分析53.4.2数据库概念结构设计73.4.3 数据库逻辑结构设计9第四章 系统代码设计及实现114.1 创建宾馆客房管理信息系统的主登录窗体114.2创建公用模块134.3 创建宾馆客房管理信息系统的主窗体144.4 创建主窗体的菜单154.5 客房标准设置204.6 客房查询224.7 住宿查询模块设计234.8 退房查询模块设计244.9 日结统计报表模块设计254.10 系统维护模块设计26该模块主要用于数据恢复及备份 用以保证数据安全打开系统维护-数据备份264.11 权限设置模块284.12 安全退出模块设计30第五章 系统的编译和发行30第六章 实训总结31第一章 系统分析一.可性行分析可行性分析是指在允许的成本、性能要求下,分析每项需求实施的可行性,提出需求实现的相关风险,包括与其它需求的冲突,对外界因素的依赖和技术障碍。可行性分析包括操作可行性、技术可行性、经济可行性和进度可行性。下面是对酒店管理系统的可行性分析。 1. 进度可行性:鉴于本系统的目标要求和特点,能够保证在预期的时间内完成该系统的研究和设计。2.经济可行性:本系统开发完成后可缩减工作时间,提高工作效率,而且简单易操作,不需对使用人员进行培训,不管是在资金上还是效率上都能达到预期的效果。 3. 技术可行性:从目前比较流行的数据库开发、管理软件来看;对于比较简单的中小型数据库,vb.net和sql server 2000的结合无疑是在实际应用中较为成功的一种解决方案。前者为用户提供了windows所一贯坚持的非常友好、操作简单的用户界面.;后者则可对数据库实施操作、维护和权限识别功能,也可通过与sql语句的结合对数据库进行更为复杂的操作。对本系统而言,上述的结合方式是可行的。第二章 需求分析(1)如果房客交的押金已经不能支付住宿费用,那么,房客需要去补交押金,这时可以添加房客的续住天数和应交押金等信息。(2)因宾馆需要人员进行各个方面的管理,如总经理、前台等。这里建立一个数据库来管理每个工作人员的信息,如用户添加、删除、修改密码等,这有助于清晰的管理每个工作人员的信息。因权限不同,各个用户进入的界面不同,他们只能进行权限之内的操作。所有的用户都可以在密码更改中更改密码。(3)房客来宾馆入住时,宾馆的工作人员应该可以添加房客的姓名和身份证等个人信息以客房的房号和押金等入住信息。(4)如果房客为了节省时间,需要预定房间,可以添加预定信息。房客来到宾馆之后,需要把预定信息,转为入住信息,如果房客由于其余事情,不能来宾馆入住,可以取消预定。(5)如果房客住宿时间期满,可以退房。(6)如果房客对入住的房间不满意,可以为房客换房。(7)按照宾馆人员的操作习惯,可以对客房和客房类型信息进行添加、修改、删除和查询操作。(8)系统运行在windows平台上,要求有一个较好的图形用户界面,操作要求简单。(9)系统应该有很好的可扩展性,以便宾馆根据实际情况添加新的功能。第三章 系统总体设计3.1总体设计宾馆客房管理系统登 陆住宿管理客房管理查询统一系统设置住宿登记追加押金退宿结帐客房设置客房查询住宿查询退宿查询操作员设置密码设置总体设计图3.2详细设计模块宾馆客房管理系统登 陆住宿管理客房管理查询统一系统设置宾馆客房管理系统功能图查询统一住宿查询退宿查询查询统一功能图住宿管理住宿登记追加押金退宿结帐系统设置操作员设置密码设置系统设置功能图 住宿管理功能图3.3 数据库设计设计数据库系统时首先应该充分了解用户各个方面的要求,包括现有的以及将来可能增加的要求。数据库设计一般包括如下几个步骤: 1. 数据库需要分析。2.数据库概念结构设计。 3.数据库逻辑结构设计。3.4数据库需要分析3.4.1数据库分析用户的需要具体体现在各种信息的提供,保存,更新和查询等方面,这就要求数据库结构能充分满足各种信息的输入和输出。收集基本数据,数据结构以及数据处理的流程,组成一份详尽的数据字典,为后面的具体设计打下基础。仔细分析调查有关宾馆客房管理信息要求的基础上,将得到如图31所示的本系统所处理的数据流程。客房标准设置结算信息管理顾客登记客房标准信息管理订房信息管理客房登记客户信息管理基本信息录入客房信息返回基本信息录入订房信息输入结算信息输入宾馆客房管理信息系统数据流程图 针对一般宾馆客房管理信息系统的需求,通过对宾馆客房管理工作过程的内容和数据流程分析,设计如下面所示的数据项和数据结构: 客房标准信息,包括的数据项有:标准编号,标准名称,房间面积,床位数量,住房单价,是否有空调,电视,电话,单独卫生间等。 客房信息,表格的数据项有:客房编号,客房种类,客房位置,客房单价,备注等。 订房信息,包括的数据项有:订房编号,客房编号,客房种类,客房位置,客房备注信息,顾客姓名,顾客身份证号码,入住时间,折扣,备注等。 结算信息,包括的数据项有:订房编号,客房编号,客房种类,客房位置,客房备注信息,顾客姓名,顾客身份证号码,入住时间,折扣,结算时间,备注等。有了上面的数据结构,数据项和数据流程,我们就能进行下面的数据库设计。3.4.2数据库概念结构设计得到上面的数据项和数据结构以后,就可以设计出能够满足用户需求的各种实体,以及它们之间的关系,为后面的逻辑结构设计打下基础。本实例根据上面的设计规划出的实体有:客房标准信息实体,客房信息实体,订房信息实体,结算信息实体。各个实体具体的描述e-r图如下。客房标准信息实体e-r图如图所示:客户标准信息实体标准编号标准名称床位数量客房单价 客房信息实体e-r图如图所示: 客户信息实体标准编号客房标准客户位置客房单价客户信息实体订房信息实体e-r图如图所示:订房信息实体客房信息顾客信息入住时间折扣 结算信息实体e-r图如图所示:结算信息实体客房信息顾客信息结算时间结算金额 实体之间关系的e-r图如图所示:客户标准信息实体结算信息管理客房信息实体订房信息实体客房登记订房客房结算实体 3.4.3 数据库逻辑结构设计现在需要将上面的数据库概念结构转化为数据库系统所支持的实体数据模型,也就是数据库的逻辑结构。宾馆客房管理信息系统数据库中各个表格的设计结果如下面表格所示。每个表格表示在数据库中的一个表。tb_djb 住房登记表:tb_kf房间标准详细表:tb_qxsz账户权限设置表: tb_tfdj退房登记表: tb_user:登录用户表:第四章 系统代码设计及实现至此有关数据库的设计和完善既所有后台工作初步完成 有了数据库和数据。现在将通过vb逐块来设计 宾馆客房管理信息系统中各个功能模块的功能:4.1 创建宾馆客房管理信息系统的主登录窗体用户登录窗体中放置了二个文本框(textbox),用来输入用户名和用户密码:二个按钮(commandbutton)用来确定或者取消登录:三个标签(label)用来标示窗体的信息。这些控件的属性设置见表。控件属性属性取值frmlogin(form)namefrmlogincaption登录startuppositioncenterscreenwindowstatenomaltxtusernamenametxtusernametxtpasswordnametxtpasswordpasswordchar*cmdoknamecmdokcaption确定cmdcanelnamecmdcanelcaption取消label1caption宾馆客房管理系统label2caption用户名label3caption用户密码双击确定输入以下代码完成登录判断:private sub image1_click()static itimes as integer main.statusbar1.panels(4).text = text1.text 赋值给main.statusbar1.panels(4).text 验证操作员及密码 adodc1.recordsource = select * from tb_user where 操作员= + text1.text + adodc1.refresh if adodc1.recordset.recordcount 0 then 如果记录数大于零 验证密码 if text2.text = adodc1.recordset.fields(密码) then load main main.show unload me else if text2.text adodc1.recordset.fields(密码) then msgbox 密码错误,请重新输入!, vbcritical, 系统提示 itimes = itimes + 1 text2.text = text2.setfocus end if end if else msgbox 操作员不存在,请重新输入!, vbcritical, 系统提示 itimes = itimes + 1 text1.text = text2.text = text1.setfocus end if if itimes = 3 then 错误3次,退出系统 mymsg = msgbox(输入错误,请向系统管理员查询!, vbcritical, 系统提示) if mymsg = vbok then end end ifend sub以下代码用于权限设置 当系统中不存在任何账户 第一次登录时会要求设置该账号权限private sub form_activate() 当记录为零时,进入系统具有所有权限 if adodc1.recordset.recordcount = 0 then msgbox 请先设置操作员密码和权限!, , 系统提示 load main main.show unload me else text1.setfocus end ifend sub当用户输入完用户名要输入密码时可以按回车系统自动定位到下一个文本框 实现代码如下:private sub text2_keydown(keycode as integer, shift as integer) if keycode = vbkeyreturn then image1_click 按回车键进入end subprivate sub text1_keydown(keycode as integer, shift as integer) if keycode = vbkeyreturn then text2.setfocus 按回车键,text2获得焦点end sub总体的登录窗口调试效果如下:用户运行系统首先将出现该登陆框,如果输入的用户名在用户表中没有找到,将提示重新输入用户名,文本框txt1将重新获得输入焦点。如果用户输入的密码不正确,文本框txt2将重新获得输入焦点。用户登录成功,全局变量ok将被赋值为true。一旦三次输入密码均不正确,全局变量ok将被赋值为false。系统强制退出。4.2创建公用模块在visual basic中可以用公用模块来存放整个工程项目公用的函数,过程和全局变量等。这样可以极大的提高代码的效率。在项目资源管理器中为项目添加一个module,保存为module 1.bas。下面就可以开始添加需要的代码了。public adocon as new adodb.connectionpublic adors as new adodb.recordsetpublic sub main() adocon.open provider=sqloledb.1;integrated security=sspi;persist security info=false;user id=sa;initial catalog=kfxt;data source=piglet 连接到本机的kfxt sql数据库end subpublic function esql(byval sql as string) as adodb.recordset 定义函数 定义连接 dim cnn as adodb.connection dim rs as adodb.recordset 创建连接 set cnn = new adodb.connection 打开连接 cnn.open strcnn set rs = new adodb.recordset rs.open trim(sql), cnn, adopenkeyset, adlockoptimistic set esql = rsend functionpublic function strcnn() 返回一个数据库连接 strcnn = provider=sqloledb.1;integrated security=sspi;persist security info=false;user id=sa;initial catalog=kfxt;data source=pigletend function4.3 创建宾馆客房管理信息系统的主窗体添加一个窗体 然后在该窗体上添加好所用的控件,添加后如图示;窗体和控件的主要属性设置见下表。控件属性属性取值frmmain(form)namefrmmaincaption宾馆客房管理信息系统startuppositioncenterscreenwindowstatemaximizedsbstatusbar(statusbar)namestylesbstatusbarpanels(1)stylesbrtextpanels(2)stylesbrdatepanels(3)stylesbrtime在主窗体中加入状态栏控件,可以实时反映系统中的各个状态的变化。状态栏控件需要在通常的属性窗口中设置一般属性,还需要在特有的弹出式菜单中进行设置。选择状态栏控件,单击鼠标右键,选中property菜单,然后设置属性。面板1用来显示当前日期,面板2用来显示当前时间,面板3用来显示系统信息。面板4显示 操作员信息。如图:4.4 创建主窗体的菜单1.在如图所示的主窗体中,单击鼠标右键,选择弹出式菜单中的“menu editor”命令,创建如图所示菜单结构:2:添加用户窗体的创建进入系统后,选择菜单“系统|添加用户”,就可以添加用户,出现添加用户的窗体:在这个窗体中放置了二个文本框,用来输入密码和确认密码,二个按钮用来确定是否修改密码,二个标签用来标示文本框的内容,这些控件属性的设置见下表:控件属性属性取值frmadduser (form)namefrmaddusercaption添加用户startuppositioncenterscreenwindowstatenomaltxtusernamenametxtusernametxtpassword1nametxtpassword1passwordchar*txtpassword2nametxtpassword2passwordchar*cmdoknamecommand1caption确定cmdcanelnamecommand2caption取消label1caption操作元label2caption密码label3caption确认二次输入密码后,单击command1按钮,将触发click事件判断是否修改密码,代码如下:private sub command1_click() 修改操作员密码adodc1.recordsource = select * from tb_qxsz where 操作员= + text1.text + adodc1.refresh if adodc1.recordset.recordcount 0 then ma.text = adodc1.recordset.fields(密码) else ma.text = msgbox 不存在该操作员!, , 系统提示 exit sub end if if text1.text and text2.text and text2.text = adodc1.recordset.fields(密码) then if text3.text then adocon.open provider=sqloledb.1;integrated security=sspi;persist security info=false;user id=sa;initial catalog=kfxt;data source=piglet set adors = adocon.execute(update tb_qxsz set 密码= + text3.text + where 操作员= + text1.text + ) adocon.close dim rs1 as new adodb.recordset rs1.open select * from tb_user where 操作员= + text1.text + , strcnn, adopenkeyset, adlockpessimistic if rs1.recordcount 0 then rs1.fields(密码) = text3.text rs1.update rs1.close end if msgbox 密码修改成功,退出操作员密码修改!, , 系统提示 main.enabled = true unload me else msgbox 请输入新密码!, , 系统提示 end if else if text1.text = then msgbox 请输入操作员!, , 系统提示 text1.setfocus else if text1.text adodc1.recordset.fields(操作员) then text1.setfocus text1.text = msgbox 无此操作员,请重新输入!, , 系统提示 end if end if if text2.text = then msgbox 请输入操作员原密码!, , 系统提示 text2.setfocus else if text2.text ma.text then msgbox 原密码错误,请重新输入原密码!, , 系统提示 text2.text = text2.setfocus end if end if end ifend sub3.操作员密码修改窗体创建用户可以修改自己的密码,选择菜单“系统|密码设置”出现如图所示的窗体:在这个窗体中放置了二个文本框,用来输入密码和确认密码,二个按钮按钮用来确定是否修改密码,二个标签用来标示文本框的内容,这些控件属性的设置见下表控件属性属性取值frmmodifyuserinfo (form)namefrmmodifyuserinfocaption密码设置startuppositioncenterscreenwindowstatenomaltxtpassword1nametxtpassword1passwordchar*txtpassword2nametxtpassword2passwordchar*cmdoknamecommand1caption确定cmdcanelnamecommand2caption取消label1caption操作员label2caption原密码label3caption新密码二次输入密码后,单击command1按钮,将触发click事件判断是否修改密码。private sub command1_click() 修改操作员密码adodc1.recordsource = select * from tb_qxsz where 操作员= + text1.text + adodc1.refresh if adodc1.recordset.recordcount 0 then ma.text = adodc1.recordset.fields(密码) else ma.text = msgbox 不存在该操作员!, , 系统提示 exit sub end if if text1.text and text2.text and text2.text = adodc1.recordset.fields(密码) then if text3.text then adocon.open provider=sqloledb.1;integrated security=sspi;persist security info=false;user id=sa;initial catalog=kfxt;data source=piglet set adors = adocon.execute(update tb_qxsz set 密码= + text3.text + where 操作员= + text1.text + ) adocon.close dim rs1 as new adodb.recordset rs1.open select * from tb_user where 操作员= + text1.text + , strcnn, adopenkeyset, adlockpessimistic if rs1.recordcount 0 then rs1.fields(密码) = text3.text rs1.update rs1.close end if msgbox 密码修改成功,退出操作员密码修改!, , 系统提示 main.enabled = true unload me else msgbox 请输入新密码!, , 系统提示 end if else if text1.text = then msgbox 请输入操作员!, , 系统提示 text1.setfocus else if text1.text adodc1.recordset.fields(操作员) then text1.setfocus text1.text = msgbox 无此操作员,请重新输入!, , 系统提示 end if end if if text2.text = then msgbox 请输入操作员原密码!, , 系统提示 text2.setfocus else if text2.text ma.text then msgbox 原密码错误,请重新输入原密码!, , 系统提示 text2.text = text2.setfocus end if end if end ifend sub4.5 客房标准设置宾馆在运行中需要设置不同的客房标准来适应不同消费水平顾客的需要。对于每个客房标准,有不同的硬件设施和服务。打开客房管理|客房设置 可以添加新房间并设置客房标准 如图: 客房标准管理模块主要实现如下:控件属性属性取值frmroomtype1(form)namefrmsinfocaption客房标准mdichildtruetxtitem(0) txtitem(4)nametxtitem(0) txtitem(4)combo1(0) combo1(3)namecombo1(0) combo1(3)cmdsavenamecmdokcaption保存cmdexitnamecmdcancelcaption取消添加label1caption房间号label2caption房间类型label4caption房态label5caption价格label6caption营业时间label7caption使用设备label8caption配置label9caption备注双击登记sub comdj按钮 添加如下代码:private sub comdj_click() 登记 texfjh.enabled = true combo1.enabled = true combo2.enabled = true texjg.enabled = true dtp1.enabled = true texsz.enabled = true texpz.enabled = true texbz.enabled = true texfjh.text = : texjg.text = : texsz.text = texpz.text = : texbz.text = comsave.enabled = true: comcancel.enabled = true: comdj.enabled = false texfjh.setfocusend sub 双击comsave 按钮添加下列代码:private sub comsave_click() 查找客房信息 adodc1.recordsource = select * from tb_kf where 房间号= & trim(texfjh.text) & adodc1.refresh if adodc1.recordset.recordcount 0 then 如果记录数大于零 if adodc1.recordset.fields(房态) = 入住 then msgbox 该房间正在使用,请客人退房后再修改信息 exit sub end if if msgbox(该客房已存在,确认修改客房信息, 4) = vbyes then if texfjh.text then adodc1.recordset.fields(房间号) = texfjh.text if combo2.text then adodc1.recordset.fields(房态) = combo2.text if combo1.text then adodc1.recordset.fields(房间类型) = combo1.text if texjg.text then adodc1.recordset.fields(价格) = texjg.text adodc1.recordset.fields(使用设置) = texsz.text adodc1.recordset.fields(配置) = texpz.text adodc1.recordset.fields(备注) = texbz.text adodc1.recordset.fields(标志) = 0 adodc1.recordset.update end if else if msgbox(添加新房间?, 4) = vbyes then adocon.open provider=sqloledb.1;integrated security=sspi;persist security info=false;user id=sa;initial catalog=kfxt;data source=piglet adors.open select * from tb_kf, adocon, adopenkeyset, adlockoptimistic adors.addnew adors.fields(房间号) = texfjh.text adors.fields(房间类型) = combo1.text adors.fields(房态) = combo2.text adors.fields(价格) = texjg.text adors.fields(营业日期) = dtp1.value adors.fields(使用设置) = texsz.text adors.fields(配置) = texpz.text adors.fields(备注) = texbz.text adors.fields(标志) = 0 adors.update 更新记录 adocon.close end if end if adodc1.connectionstring = provider=sqloledb.1;integrated security=sspi;persist security info=false;user id=sa;initial catalog=kfxt;data source=piglet adodc1.recordsource = select * from tb_kf adodc1.refresh set datagrid1.datasource = adodc1 unload me main_kfgl.show 设置控件有效或无效 comsave.enabled = false: comcancel.enabled = false comend.enabled = true: comdj.enabled = trueend subprivate sub comcancel_click() 取消操作 texfjh.text = : texjg.text = : texsz.text = texpz.text = : texbz.text = comsave.enabled = false: comcancel.enabled = false: comdj.enabled = trueend subprivate sub comend_click() main.enabled = true unload meend sub4.6 客房查询 客房信息管理模块主要实现如下功能: 添加设置客房信息、查询客房信息。执行 菜单客房管理-客房查询打开如下对话框代码实现如下:private sub command2_click() 查询 adodc1.recordsource = select * from tb_kf where 房间号 like % + text1.text + % adodc1.refreshend subprivate sub form_load() adodc1.connectionstring = provider=sqloledb.1;integrated security=sspi;persist security info=false;user id=sa;initial catalog=kfxt;data source=piglet adodc1.recordsource = select * from tb_kf adodc1.refresh set datagrid1.datasource = adodc1 datagrid1.columns(4).width = 0end subprivate sub form_unload(cancel as integer) main.enabled = trueend subprivate sub command3_click() main.enabled = true unload meend subprivate sub text1_keydown(keycode as integer, shift as integer) if keycode = 13 then command2.setfocus 按回车键command2获得焦点end sub4.7 住宿查询模块设计 点击查询统计下的住宿查询 即可打开如下对话框 添加了一个datagrid1控件实现数据显示双击查询按钮输入代码如下private sub command1_click() 查询住宿信息 adodc1.recordsource = select * from tb_djb where 姓名 like % + text1.text + % adodc1.refresh mshflexgrid1.colwidth(8) = 0 mshflexgrid1.colwidth(20) = 0 mshflexgrid1.colwidth(24) = 0 mshflexgrid1.colwidth(25) = 0 mshflexgrid1.colwidth(27) = 0end sub:4.8 退房查询模块设计点击菜单 查询统计-退宿查询即可打开该对话框 核心代码如下:private sub command1_click() 查询信息adodc1.recordsource = select * from tb_tfd where tb_tfd.姓名 = & text1.text & adodc1.refreshend subprivate sub command2_click() 删除退宿记录 if adodc1.recordset.recordcount 0 then 如果记录大于零 a = msgbox(确定删除该记录

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论