IT评测·应用市场-qidao123.com技术社区

标题: 基于javaEE+jqueryEasyUi+eclipseLink+MySQL的课程设计客房管理信息系统 [打印本页]

作者: 莱莱    时间: 2025-4-17 12:05
标题: 基于javaEE+jqueryEasyUi+eclipseLink+MySQL的课程设计客房管理信息系统
1. 系统概述

1.1 系统功能概述

1)客户管理。可以大概增加一个客户,包括:身份证号、客户名称、出生年月、性别、联系电话、邮箱、会员类别等信息,默认会员类别为空;可以大概修改和删除客户信息;可以大概根据客户名称、联系电话查询客户根本信息。
2)客户入住。可以大概根据客房标准和日期查询状态为“空闲”的客房信息,表现楼层号、房间号、费用;可以大概根据客户名和联系方式查询房间预订信息,表现:楼层号、房间号、预订开始时间,预订结束时间;可以大概为指定的客户办理指定客房的入住手续,修改客户状态为“入住”,并记录入住时间、前台操纵员。
3)退房管理。可以大概根据房间号查询客房信息;可以大概完成指定客户对指定房间的退房操纵(利用存储过程实现),即起首增加一条客户实际入住记录,包括:客户身份证编号、客户名、房间号、入住时间、退房时间、房费、前台操纵员,然后修改客房状态为“空闲”;末了根据会员类别和入住天数盘算房费。
4)预订客房。可以大概根据标准和日期查询客房空闲情况;可以大概为指定客户预订指定的客房,并记录预订开始时间、预订结束时间、联系人、联系电话、前台操纵员、操纵时间等信息。
5)预订查询。可以大概根据客户名或联系电话查询其预订的客房信息,其中,一个客户可以预订多个客房;可以大概根据楼层号、房间号查询客房的预订详细信息。


图1-1 功能框图
1.2 系统体系结构



图1-2 体系结构图
Browser/Server结构是伴随着因特网的鼓起,对Client/Server结构的一种改进。从本质上说,Browser/Server结构也是一种Client/Server结构,它可看作是一种由传统的二层模式Client/Server结构发展而来的三层模式Client/Server结构在Web上应用的特例。
Browser/Server结构重要是利用了不停成熟的Web浏览器技术:联合浏览器的多种脚本语言和ActiveX技术,用通用浏览器实现原来需要复杂专用软件才华实现的强大功能,同时节约了开发成本。
B/S最大的长处就是可以在任何地方举行操纵而不消安装任何专门的软件,只要有一台能上网的电脑就能利用,客户端零安装、零维护。系统的扩展非常容易。
B/S结构的利用越来越多,特别是由需求推动了AJAX技术的发展,它的程序也能在客户端电脑上举行部分处置惩罚,从而大大的减轻了服务器的负担;并增加了交互性,能举行局部实时刷新。
1.3开发环境

此次设计重要接纳MyEclipse加Tomcat背景服务器举行,设计过程中页面重要利用JSP技术完成,下面对MyEclipse、Tomcat和SQL2008数据库举行简要先容。
MyEclipse,是一个非常良好的用于开发Java, J2EE的Eclipse插件聚集,MyEclipse的功能非常强大,支持也非常广泛,尤其是对各种开元产品的支持非常不错。MyEclipse企业级工作平台(MyEclipse Enterprise Workbench ,简称MyEclipse)是对Eclipse IDE的扩展,利用它我们可以在数据库和JavaEE的开发、发布,以及应用程序服务器的整合方面极大的提高工作效率。它是功能丰富的JavaEE集成开发环境,包括了完备的编码、调试、测试和发布功能,完备支持HTML,JSP,CSS,Javascript,SQL.
Tomcat是一个小型的轻量级应用服务器,在中小型系统和并发访问用户不是很多的场合下被普遍利用,是开发和调试JSP 程序的首选。可以如许认为,当在一台机器上配置好Apahce服务器,可利用它相应对HTML页面的访问请求。实际上Tomcat 部分是Apache 服务器的扩展,但它是独立运行的,所以当运行tomcat 时,它实际上作为一个与Apache 独立的历程单独运行的
MySQL是一个小型关系型数据库管理系统,开发者为瑞典MySQL AB公司。目前MySQL被广泛地应用在Internet上的中小型网站中。由于其体积小、速度快、总体拥有成本低,尤其是开放源码这一特点,许多中小型网站为了降低网站总体拥有成本而选择了MySQL作为网站数据库。
JSP技术利用Java编程语言编写类XML的tags和scriptlets,来封装产生动态网页的处置惩罚逻辑。网页还能通过tags和scriptlets访问存在于服务端的资源的应用逻辑。JSP将网页逻辑与网页设计和表现分离,支持可重用的基于组件的设计,使基于Web的应用程序的开发变得迅速和容易。Web服务器在碰到访问JSP网页的请求时,起首执行其中的程序段,然后将执行结果连同JSP文件中的HTML代码一起返回给客户。插入的Java程序段可以操纵数据库、重新定向网页等,以实现建立动态网页所需要的功能。JSP与Servlet一样,是在服务器端执行的,通常返回给客户端就是一个HTML文本,因此客户端只要有浏览器能浏览。JSP页面由HTML代码和嵌入其中的Java代码所组成。服务器在页面被客户端请求以后对这些Java代码举行处置惩罚,然后将天生的HTML页面返回给客户端的浏览器。Servlet是JSP的技术基础,而且大型的Web应用程序的开发需要Java Servlet和JSP共同才华完成。JSP具备了Java技术的简单易用,完全的面向对象,具有平台无关性且安全可靠,重要面向因特网的全部特点.
JavaScript是一种基于对象和事件驱动并具有相对安全性的客户端脚本语言。同时也是一种广泛用于客户端Web开发的脚本语言,常用来给HTML网页添加动态功能,比如相应用户的各种操纵。JavaScript的一个紧张功能就是面向对象的功能,通过基于对象的程序设计,可以用更直观、模块化和可重复利用的方式举行程序开发。在HTML基础上,利用JavaScript可以开发交互式Web网页。JavaScript的出现使得网页和用户之间实现了一种实时性的、动态的、交互性的关系,使网页包含更多活泼的元素和更加出色的内容。
2 数据库设计

表2.1关系模型表
关系名
属性及码
其他束缚条件
客户
身份证号,客户名称,出生年月,性别,联系电话,邮箱,会员类别
1、身份证号是唯一标识;
2、客户名称不允许为空;
3、联系电话不允许为空;
客房
房间号,楼层号,标准,费用,地理位置
房间号是唯一标识;
入住
身份证号,房间号,客户名,入住时间,退房时间,前台操纵员,预付金
1、 身份证号引用客户关系中的身份证号;
2、 房间号引用客房关系中的房间号;
用户
用户名,用户类型,默认密码,真实姓名,年事,性别
用户名是唯一标识;
预订客房
房间号,预定开始时间,预定结束时间,联系人,联系电话,前台操纵员,操纵时间
1、客房号引用客房关系中的房间号;
2、联系电话不允许为空;

会员
会员号,会员类型,会员折扣
会员类型不能为空
房间增加消耗信息
消耗编号,房间号,消耗类型,消耗金额,消耗时间,备注
客房号引用客房关系中的房间号;

表2.2 book 订单表
字段名
主键
外键
类型
字节数
长度
小数位
字段说明
cid


char
18
18
0
身份证号
rno


varchar
10
10
0
房间号
username


varchar
20
20
0
前台操纵人员
btime


datatime
0
0
0
入住开始时间
etime


datetime
0
0
0
入住结束时间
prePay


decimal
9
18
1
预支金额
表2.3 advance 预定表
字段名
主键
外键
类型
字节数
长度
小数位
字段说明
rno


varchar
10
10
0
房间号
username


varchar
20
20
0
前台操纵员
person


varchar
20
20
0
联系人
phone


char
11
11
0
联系电话
btime


datetime
20
20
0
身份证号
etime


datetime
9
18
1
总消耗额
otime


datetime
4
10
0
等级编号
3 系统概要设计

系统有两类用户:前台操纵员和系统管理员。其中,前台管理员负责客房预订、入住登记、房客查询、收费管理等功能,系统管理员负责客房信息输入、客房信息查询、前台操纵员管理、统计报表等功能。系统重要包括6大功能模块:根本信息管理、入住管理、会员管理、客房预订管理、收费管理、统计报表管理。
1)客户管理。可以大概增加一个客户,包括:身份证号、客户名称、出生年月、性别、联系电话、邮箱、会员类别等信息,默认会员类别为空;可以大概修改和删除客户信息;可以大概根据客户名称、联系电话查询客户根本信息。
2)客户入住。可以大概根据客房标准和日期查询状态为“空闲”的客房信息,表现楼层号、房间号、费用;可以大概根据客户名和联系方式查询房间预订信息,表现:楼层号、房间号、预订开始时间,预订结束时间;可以大概为指定的客户办理指定客房的入住手续,修改客户状态为“入住”,并记录入住时间、前台操纵员。
3)退房管理。可以大概根据房间号查询客房信息;可以大概完成指定客户对指定房间的退房操纵(利用存储过程实现),即起首增加一条客户实际入住记录,包括:客户身份证编号、客户名、房间号、入住时间、退房时间、房费、前台操纵员,然后修改客房状态为“空闲”;末了根据会员类别和入住天数盘算房费。


图3-1用例图


图3-2预定客房次序图


图3-3会员状态图


图3-4类图


图3-5前台操纵员活动图


图3-6系统管理员活动图
4系统详细设计与实现

(1) 登录功能。实现用户了登录功能。判断用户的类型,按用户类型表现差别的页面。
(2) 客户入住。可以大概根据客房标准和日期查询状态为“空闲”的客房信息,表现楼层号、房间号、费用;可以大概根据客户名和联系方式查询房间预订信息,表现:楼层号、房间号、预订开始时间,预订结束时间;可以大概为指定的客户办理指定客房的入住手续,修改客户状态为“入住”,并记录入住时间、前台操纵员。
(3) 退房管理。可以大概根据房间号查询客房信息;可以大概完成指定客户对指定房间的退房操纵(利用存储过程实现),即起首增加一条客户实际入住记录,包括:客户身份证编号、客户名、房间号、入住时间、退房时间、房费、前台操纵员,然后修改客房状态为“空闲”;末了根据会员类别和入住天数盘算房费。
(4) 预订客房。可以大概根据标准和日期查询客房空闲情况;可以大概为指定客户预订指定的客房,并记录预订开始时间、预订结束时间、联系人、联系电话、前台操纵员、操纵时间等信息。
(5) 预订查询。可以大概根据客户名或联系电话查询其预订的客房信息,其中,一个客户可以预订多个客房;可以大概根据楼层号、房间号查询客房的预订详细信息。
4.1 登录模块实现

4.1.1 界面设计

此界面实现了用户的登录功能。如图4-1登录界面所示。


图4-1登录界面
4.1.2登录功能实现

此界面重要实现了用户的登录功能。此部分代码文件:login.jsp,LoginServlet,UserDao.java,User.java
功能实现:通过login.jsp 的form表单提交到LoginServlet举行处置惩罚,再调用UserDao.java中方法实现登录验证.
1. login.js
  1. <divid="loginAndRegisterForm">
  2. <formmethod="post"id="loginForm">
  3. <table>
  4. <tr>
  5. <thstyle="text-align:left;">用户名:</th>
  6. <!-- class="easyui-textbox"表示使用EasyUI的textbox组件-->
  7. <td><inputtype="text"id="userName"style="width:150px;" name="username"class="easyui-textbox"/></td>                  </tr>
  8. <tr>
  9. <thstyle="text-align:left;">密码:</th>
  10. <td><inputtype="password"id="userPwd"style="width:150px;" name="password"class="easyui-passwordbox"/></td>
  11. </tr>
  12. <tr>
  13. <thstyle="text-align:left;">用户类型:</th>
  14. <td>
  15. <selectname="usertype"class="easyui-textbox"id="option">
  16. <optionvalue="1">前台操作员</option>
  17. <optionvalue="2">系统管理员</option>
  18. </select>
  19. </td>
  20. </tr>
  21. </table>
  22. </form>
  23. </div>
复制代码
2. LoginServlet.java
  1. privatevoid login(HttpServletRequestrequest, HttpServletResponse response) throws IOException{
  2.     String username = request.getParameter("username");
  3. String password = request.getParameter("password");
  4. String usertype = request.getParameter("usertype");
  5. Json json = new Json();
  6. User u = UserDao.getUserByName(username, password);
  7. if(u!=null && u.getUsertype().equals(usertype)){
  8.        request.getSession().setAttribute("currentUser",u);
  9.        json.setMsg("登录成功");
  10.             json.setSuccess(true);
  11.             if(usertype.equals("1")){
  12.               json.setUrl("/operator/index.jsp");
  13.             }elseif(usertype.equals("2")){
  14.               json.setUrl("/admin/index.jsp");
  15.             }else{
  16.               json.setUrl("/error.jsp");
  17.             }
  18. }else{
  19.      json.setMsg("用户名或密码错误,登录失败!");
  20.           json.setSuccess(false);
  21. }
  22. String jsonStr = JSON.toJSONString(json);
  23.         //将json字符串作为响应内容输出到客户端浏览器。
  24.      response.getWriter().write(jsonStr);
  25. }
复制代码
4.2客户入住模块实现

4.2.1 界面设计

此界眼前台操纵员处置惩罚客户入住。如:图4-2客户入住界面。


图4-2客户入住界面


图4-3客户入住界面
4.2.2 客户入住功能实现

该功能实现了前台操纵员处置惩罚客户入住的功能。代码文件包括 bookList.jsp,BookServlet.java.
描述:通过bookList.jsp中的form表单向BookServlet.java举行处置惩罚.
1. booklist.jsp
  1. <tableid="dg"title="客户入住"class="easyui-datagrid"fitColumns="true"pagination="true"
  2. data-options="rownumbers:true,toolbar:'#tb'">
  3. <thead>
  4. <tr>
  5. <thfield="cb"checkbox="true"align="center"></th>
  6. <thfield="rno"width="50"align="center">房间号</th>
  7. <thfield="fno"width="50"align="center">楼层号</th>
  8. <thfield="standard"width="50"align="center">房间标准</th>
  9. <thfield="cost"width="50"align="center">房间费用</th>
  10. <thfield="position"width="50"align="center">地理位置</th>
  11. </tr>
  12. </thead>
  13. </table>
  14. <divid="tb">
  15. <div>
  16.    <span>&nbsp;房间标准:&nbsp;</span>
  17.    <selectid="standard"class="easyui-combobox"data-options="panelHeight:'auto'"style="width:150px;">
  18. <optionvalue="">全部</option>
  19.     <optionvalue="大床房">大床房</option>
  20. <optionvalue="标间">标间</option>
  21. <optionvalue="豪华套房">豪华套房</option>
  22.    </select>
  23.     <span>&nbsp;入住开始时间:&nbsp;</span>
  24. <inputtype="text"  class="easyui-datebox"id="btime"style="width:150px;">
  25. <span>&nbsp;入住结束时间:&nbsp;</span>
  26. <inputtype="text"  class="easyui-datebox"  id="etime"style="width:150px;">
  27. <ahref="javascript:searchRoom()"class="easyui-linkbutton"iconCls="icon-search"plain="true">搜索</a>
  28. <ahref="javascript:openDialog()"class="easyui-linkbutton"iconCls="icon-edit"plain="true">入住</a>
  29. <ahref="javascript:reload()"class="easyui-linkbutton"iconCls="icon-reload"plain="true">刷新</a>     
  30. </div>
  31. </div>
  32. <divid="dlg"class="easyui-dialog"style="width:400px;  padding:10px 20px"
  33. closed="true"buttons="#dlg-buttons">
  34. <formid="fm"method="post">
  35. <tablecellspacing="8px">
  36.     <tr>
  37. <td>房间号</td>
  38. <td>
  39. <inputname="rno"class="textbox"  readonly="true">
  40. </td>
  41. </tr>
  42. <tr>
  43. <td>楼层号</td>
  44. <td>
  45.               <inputname="fno"class="textbox"readonly="true">
  46. </td>
  47. </tr>
  48. <tr>
  49. <td>房间标准</td>
  50. <td>
  51. <inputname="standard"class="textbox"readonly="true">
  52. </td>
  53. </tr>
  54. <tr>
  55. <td>房间费用</td>
  56. <td>
  57. <inputname="cost"class="textbox"readonly="true">
  58. </td>
  59. </tr>
  60. <tr>
  61. <td>地理位置</td>
  62. <td>
  63. <inputname="position"class="textbox"readonly="true">
  64. </td>
  65. </tr>
  66.    <tr>
  67. <td>身份证号</td>
  68. <td>
  69. <inputname="cid"class="easyui-validatebox"data-options="required:true">
  70. </td>
  71. </tr>
  72. <tr>
  73. <td>预付金</td>
  74. <td>
  75. <inputname="prepay"class="easyui-numberbox">
  76. </td>
  77. </tr>
  78. </table>
  79. </form>
  80. </div>
  81. <divid="dlg-buttons">
  82. <div>
  83. <ahref="javascript:saveStudent()"class="easyui-linkbutton"iconCls="icon-ok"plain="true">确认</a>
  84. <ahref="javascript:closeStudentDialog()"class="easyui-linkbutton"iconCls="icon-cancel"plain="true">关闭</a>
  85. </div>
  86. </div>
复制代码
3. BookServlet.java
  1. privatevoid book(HttpServletRequest request, HttpServletResponse response) throws IOException{
  2. String  cid = request.getParameter("cid");
  3. String btime = request.getParameter("btime");
  4. String etime = request.getParameter("etime");
  5. String rno = request.getParameter("rno");
  6. doubleprepay = Double.parseDouble(request.getParameter("prepay"));
  7. Json json = new Json();
  8. User u = (User)request.getSession().getAttribute("currentUser");
  9. intuserid = u.getUserid();
  10. if(CustomerDao.getCustomer(cid) == null){
  11. json.setSuccess(false);
  12. json.setMsg("用户身份证号不存在,请先添加用户信息");
  13. }else{
  14. try {
  15. BookDao.addBook(rno, cid, btime, userid, etime, prepay);
  16. json.setSuccess(true);
  17. json.setMsg("");
  18. } catch (Exception e) {
  19. // TODO Auto-generated catch block
  20. json.setSuccess(false);
  21. json.setMsg(e.getMessage());
  22. e.printStackTrace();
  23. }
  24. }
  25.   String jsonStr = JSON.toJSONString(json);
  26.         //将json字符串作为响应内容输出到客户端浏览器。
  27.       response.getWriter().write(jsonStr);
  28. }
复制代码
4.3退房管理模块实现

4.3.1 界面设计

此界眼前台操纵员处置惩罚客户退房管理。如:图4-4退房管理界面。


图4.4退房管理界面
4.3.2 退房管理功能实现

该功能实现了前台操纵员处置惩罚客户入住的功能。代码文件包括 dropList.jsp,BookServlet.java.
描述:通过dropList.jsp中的form表单向BookServlet.java举行处置惩罚.
  1. <scripttype="text/javascript">
  2. function deleteRoom() {
  3. var selectedRows = $("#dg").datagrid("getSelections");
  4. if(selectedRows.length == 0) {
  5. $.messager.alert("系统提示", "请选择要退房的房间");
  6. return;
  7. }
  8. if(selectedRows.length != 1) {
  9. $.messager.alert("系统提示", "请选择一个要退房的客房");
  10. return;
  11. }
  12. var row = selectedRows[0];
  13. $.messager.confirm("系统提示", "您确定退房么?", function(r) {
  14. if(r) {
  15.    $.post("${pageContext.request.contextPath}/BookServlet?action=search1",
  16. {  rno:row.rno,
  17.        cid:row.cid,
  18.        btime:row.btime,
  19.        etime:row.etime
  20.     }, function(result){
  21. if(result.success) {
  22. $.messager.alert("系统提示", result.msg);
  23. searchRoom();
  24. } else {
  25. $.messager.alert("系统提示", "退房失败!");
  26. }
  27. }, "json");
  28. }
  29. });
  30. }
  31. function searchRoom() {
  32. $.post("${pageContext.request.contextPath}/BookServlet?action=drop", {
  33.   rno:$('#rno').val()
  34. }, function(data, states) {
  35. $("#dg").datagrid("loadData", data);
  36. },"json");
  37. }
  38. function reload() {
  39. searchRoom();
  40. }
  41. </script>
  42. </head>
  43. <bodystyle="margin: 1px; font-family: microsoft yahei">
  44. <tableid="dg"title="退房管理"class="easyui-datagrid"fitColumns="true"pagination="true"
  45. data-options="rownumbers:true,toolbar:'#tb'">
  46. <thead>
  47. <tr>
  48. <thfield="cb"checkbox="true"align="center"></th>
  49. <thfield="rno"width="50"align="center">房间号</th>
  50. <thfield="fno"width="50"align="center">楼层号</th>
  51. <thfield="standard"width="50"align="center">房间标准</th>
  52. <thfield="cost"width="50"align="center">房间费用</th>
  53. <thfield="position"width="50"align="center">地理位置</th>
  54. <thfield="cid"width="50"align="center">身份证号</th>
  55. <thfield="btime"width="50"align="center">入住时间</th>
  56. <thfield="etime"width="50"align="center">退房时间</th>
  57. </tr>
  58. </thead>
  59. </table>
  60. <divid="tb">
  61. <div>
  62.     <span>&nbsp;房间号:&nbsp;</span>
  63.     <inputtype="text"  class="easyui-textbox"id="rno"style="width:150px;">
  64. <ahref="javascript:searchRoom()"class="easyui-linkbutton"iconCls="icon-search"plain="true">搜索</a>
  65. <ahref="javascript:deleteRoom()"class="easyui-linkbutton"iconCls="icon-edit"plain="true">退房</a>
  66. <ahref="javascript:reload()"class="easyui-linkbutton"iconCls="icon-reload"plain="true">刷新</a>     
  67. </div>
  68. </div>
  69. 1. BookServlet.java
  70. privatevoid drop(HttpServletRequest request, HttpServletResponse response) throws IOException{
  71. String rno = request.getParameter("rno");
  72. List<Map<String, String>> list = new ArrayList<Map<String,String>>();
  73.     list = BookBpo.searchList(rno);
  74. Object jsonArray = JSON.toJSON(list);
  75. JSONObject result = new JSONObject();
  76. result.put("rows", jsonArray);
  77. result.put("total", list.size());
  78. response.getWriter().print(result);
  79. }
  80. privatevoid search1(HttpServletRequest request, HttpServletResponse response) throws IOException{
  81. String  cid = request.getParameter("cid");
  82. String btime = request.getParameter("btime");
  83. String etime = request.getParameter("etime");
  84. String rno = request.getParameter("rno");
  85. Json json = new Json();
  86. User u = (User)request.getSession().getAttribute("currentUser");
  87. intuserid = u.getUserid();
  88. try {
  89. BookBpo.dropBook(rno, cid, userid, btime, etime);
  90. try{
  91. History h = HistoryDao.getHistory(rno, cid, btime);
  92. json.setSuccess(true);
  93. json.setMsg("房间号:"+rno+"<br/>入住时间:"+btime+"<br/>退房时间:"+etime+"<br/>总费用:"+h.getSumpay());
  94. }catch(Exception e){
  95. json.setSuccess(false);
  96. json.setMsg(e.getMessage());
  97. e.printStackTrace();
  98. }
  99. } catch (Exception e) {
  100. // TODO Auto-generated catch block
  101. json.setSuccess(false);
  102. json.setMsg(e.getMessage());
  103. e.printStackTrace();
  104. }
  105. String jsonStr = JSON.toJSONString(json);
  106.         //将json字符串作为响应内容输出到客户端浏览器。
  107.      response.getWriter().write(jsonStr);
  108. }
复制代码
4.4预订客房模块实现

4.4.1 界面设计

此界眼前台操纵员处置惩罚预定客户。如:图4-5预定客户界面。


图4-5预定客户界面


图4-6预定客户界面
4.4.2 预订客房功能实现

该功能实现了前台操纵员处置惩罚预定客户的功能。代码文件包括该功能实现了前台操纵员处置惩罚预定查询的功能。代码文件包括 advanceList.jsp,AdvanceServlet.java.
描述:通过advanceList.jsp中的form表单向AdvanceServlet.java举行处置惩罚.
  1. <bodystyle="margin: 1px; font-family: microsoft yahei">
  2. <tableid="dg"title="预定客房"class="easyui-datagrid"fitColumns="true"pagination="true"
  3. data-options="rownumbers:true,toolbar:'#tb'">
  4. <thead>
  5. <tr>
  6. <thfield="cb"checkbox="true"align="center"></th>
  7. <thfield="rno"width="50"align="center">房间号</th>
  8. <thfield="fno"width="50"align="center">楼层号</th>
  9. <thfield="standard"width="50"align="center">房间标准</th>
  10. <thfield="cost"width="50"align="center">房间费用</th>
  11. <thfield="position"width="50"align="center">地理位置</th>
  12. </tr>
  13. </thead>
  14. </table>
  15. <divid="tb">
  16. <div>
  17.    <span>&nbsp;房间标准:&nbsp;</span>
  18.    <selectid="standard"class="easyui-combobox"data-options="panelHeight:'auto'"style="width:150px;">
  19. <optionvalue="">全部</option>
  20. <optionvalue="大床房">大床房</option>
  21. <optionvalue="标间">标间</option>
  22. <optionvalue="豪华套房">豪华套房</option>
  23.    </select>
  24.     <span>&nbsp;预订开始时间:&nbsp;</span>
  25. <inputtype="text"  class="easyui-datebox"id="btime"style="width:150px;">
  26. <span>&nbsp;预订结束时间:&nbsp;</span>
  27. <inputtype="text"  class="easyui-datebox"  id="etime"style="width:150px;">
  28. <ahref="javascript:searchRoom()"class="easyui-linkbutton"iconCls="icon-search"plain="true">搜索</a>
  29. <ahref="javascript:openDialog()"class="easyui-linkbutton"iconCls="icon-edit"plain="true">预定</a>
  30. <ahref="javascript:reload()"class="easyui-linkbutton"iconCls="icon-reload"plain="true">刷新</a>     
  31. </div>
  32. </div>
  33. <divid="dlg"class="easyui-dialog"style="width:400px;  padding:10px 20px"
  34. closed="true"buttons="#dlg-buttons">
  35. <formid="fm"method="post">
  36. <tablecellspacing="8px">
  37.     <tr>
  38. <td>房间号</td>
  39. <td>
  40. <inputname="rno"class="textbox"  readonly="true">
  41. </td>
  42. </tr>
  43. <tr>
  44. <td>楼层号</td>
  45. <td>
  46. <inputname="fno"class="textbox"readonly="true">
  47. </td>
  48. </tr>
  49. <tr>
  50. <td>房间标准</td>
  51. <td>
  52. <inputname="standard"class="textbox"readonly="true">
  53. </td>
  54. </tr>
  55. <tr>
  56. <td>房间费用</td>
  57. <td>
  58. <inputname="cost"class="textbox"readonly="true">
  59. </td>
  60. </tr>
  61. <tr>
  62. <td>地理位置</td>
  63. <td>
  64. <inputname="position"class="textbox"readonly="true">
  65. </td>
  66. </tr>
  67. <tr>
  68. <td>预定人</td>
  69. <td>
  70. <inputname="person"class="easyui-validatebox"data-options="required:true">
  71. </td>
  72. </tr>
  73. <tr>
  74. <td>预定人电话</td>
  75. <td>
  76. <inputname="phone"class="easyui-validatebox"data-options="required:true">
  77. </td>
  78. </tr>
  79. </table>
  80. </form>
  81. </div>
  82. <divid="dlg-buttons">
  83. <div>
  84. <ahref="javascript:saveStudent()"class="easyui-linkbutton"iconCls="icon-ok"plain="true">确认</a>
  85. <ahref="javascript:closeStudentDialog()"class="easyui-linkbutton"iconCls="icon-cancel"plain="true">关闭</a>
  86. </div>
  87. </div>
复制代码
  1. privatevoid advance(HttpServletRequest request, HttpServletResponse response) throws IOException{
  2. String rno = request.getParameter("rno");
  3. String btime = request.getParameter("btime");
  4. String etime = request.getParameter("etime");
  5. String phone = request.getParameter("phone");
  6. String person = request.getParameter("person");
  7. Json json = new Json();
  8. User u = (User)request.getSession().getAttribute("currentUser");
  9. intuserid = u.getUserid();
  10. try {
  11. AdvanceDao.addAdvance(rno, phone, btime, userid, etime, person);
  12. json.setSuccess(true);
  13. json.setMsg("");
  14. } catch (Exception e) {
  15. // TODO Auto-generated catch block
  16. json.setSuccess(false);
  17. json.setMsg(e.getMessage());
  18. e.printStackTrace();
  19. }
  20.   String jsonStr = JSON.toJSONString(json);
  21.         //将json字符串作为响应内容输出到客户端浏览器。
  22.       response.getWriter().write(jsonStr);
  23. }
复制代码
4.5.1 界面设计

此界眼前台操纵员根据时间查询客房预定的客房。如:图4-7预定查询界面。


图4-7预定客户界面


图4-8预定客户界面
4.5.2 预定查询功能实现

该功能实现了前台操纵员处置惩罚预定查询的功能。代码文件包括 advanceList.jsp,AdvanceServlet.java.
描述:通过advanceList.jsp中的form表单向AdvanceServlet.java举行处置惩罚.
1. advanceList.jsp
  1. <bodystyle="margin: 1px; font-family: microsoft yahei">
  2. <tableid="dg"title="预定查询"class="easyui-datagrid"fitColumns="true"pagination="true"
  3. data-options="rownumbers:true,toolbar:'#tb'">
  4. <thead>
  5. <tr>
  6. <thfield="cb"checkbox="true"align="center"></th>
  7. <thfield="rno"width="50"align="center">房间号</th>
  8. <thfield="fno"width="50"align="center">楼层号</th>
  9. <thfield="standard"width="50"align="center">房间标准</th>
  10. <thfield="cost"width="50"align="center">房间费用</th>
  11. <thfield="position"width="50"align="center">地理位置</th>
  12. <thfield="person"width="50"align="center">客户名</th>
  13. <thfield="phone"width="50"align="center">联系电话</th>
  14. <thfield="btime"width="50"align="center">预订开始时间</th>
  15. <thfield="etime"width="50"align="center">预订结束时间</th>
  16. </tr>
  17. </thead>
  18. </table>
  19. <divid="tb">
  20. <div>
  21.     <span>&nbsp;客户名:&nbsp;</span>
  22.     <inputtype="text"  class="easyui-textbox"id="person"style="width:150px;">
  23.     <span>&nbsp;客户电话:&nbsp;</span>
  24.     <inputtype="text"  class="easyui-textbox"id="phone"style="width:150px;">
  25. <ahref="javascript:searchRoom()"class="easyui-linkbutton"iconCls="icon-search"plain="true">搜索</a>
  26. <ahref="javascript:openDialog()"class="easyui-linkbutton"iconCls="icon-edit"plain="true">入住</a>
  27. <ahref="javascript:reload()"class="easyui-linkbutton"iconCls="icon-reload"plain="true">刷新</a>     
  28. </div>
  29. </div>
  30. <divid="dlg"class="easyui-dialog"style="width:400px;  padding:10px 20px"
  31. closed="true"buttons="#dlg-buttons">
  32. <formid="fm"method="post">
  33. <tablecellspacing="8px">
  34.     <tr>
  35. <td>房间号</td>
  36. <td>
  37. <inputname="rno"class="textbox" readonly="true">
  38. </td>
  39. </tr>
  40. <tr>
  41. <td>入住时间</td>
  42. <td>
  43. <inputname="btime"  class="textbox"  readonly="true">
  44. </td>
  45. </tr>
  46. <tr>
  47. <td>退房时间</td>
  48. <td>
  49. <inputname="etime"   class="textbox"  readonly="true">
  50. </td>
  51. </tr>
  52. <tr>
  53. <td>客户名</td>
  54. <td>
  55. <inputname="person"class="textbox"  readonly="true">
  56. </td>
  57. </tr>
  58. <tr>
  59. <td>电话</td>
  60. <td>
  61. <inputname="phone"class="textbox"  readonly="true">
  62. </td>
  63. </tr>
  64. <tr>
  65. <td>身份证号</td>
  66. <td>
  67. <inputname="cid"class="easyui-validatebox"data-options="required:true">
  68. </td>
  69. </tr>
  70. <tr>
  71. <td>预付金</td>
  72. <td>
  73. <inputname="prepay"class="easyui-numberbox">
  74. </td>
  75. </tr>
  76. </table>
  77. </form>
  78. </div>
  79. <divid="dlg-buttons">
  80. <div>
  81. <ahref="javascript:saveStudent()"class="easyui-linkbutton"iconCls="icon-ok"plain="true">确认</a>
  82. <ahref="javascript:closeStudentDialog()"class="easyui-linkbutton"iconCls="icon-cancel"plain="true">关闭</a>
  83. </div>
  84. </div>
复制代码
2. AdvanceServlet.java
  1. privatevoid search(HttpServletRequest request, HttpServletResponse response) throws IOException{
  2. String standard = request.getParameter("standard");
  3. String btime = request.getParameter("btime");
  4. String etime = request.getParameter("etime");
  5. List<Map<String, String>> list = new ArrayList<Map<String,String>>();
  6.     list = AdvanceBpo.selectList(standard, btime, etime);
  7. Object jsonArray = JSON.toJSON(list);
  8. JSONObject result = new JSONObject();
  9. result.put("rows", jsonArray);
  10. result.put("total", list.size());
  11. response.getWriter().print(result);
  12. }  
  13. publicstatic List<Room> roomAdanvce(String standard,String btime,String etime){
  14. EntityManager em = EntityManagerUtil.getEntityManager();
  15. String sql = null;
  16. if(standard.equals("") || standard == null){
  17.    sql = "SELECT * FROM room r WHERE r.rno not in (SELECT rno from advance a WHERE a.btime between '"+btime+"' and  '"+etime+"' UNION SELECT rno from book b WHERE b.btime between '"+btime+"' and  '"+etime+"')";
  18. }else{ sql = "SELECT * FROM room r WHERE r.rno not in (SELECT rno from advance a WHERE a.btime between '"+btime+"' and  '"+etime+"' UNION SELECT rno from book b WHERE b.btime between '"+btime+"' and  '"+etime+"') and r.standard='"+standard+"'";}
  19. Query query=em.createNativeQuery(sql, Room.class);
  20. List<Room> Rooms = query.getResultList();
  21. em.close();
  22. returnRooms;
  23. }
  24. publicstatic List<Map<String,String>> selectList(String standard,String btime,String etime){
  25. List<Map<String,String>> tt = new ArrayList<Map<String,String>>();
  26. List<Room> Rooms = roomAdanvce(standard, btime, etime);
  27. Map<String,String> cc = null;
  28. for (Room user: Rooms) {
  29. cc = new HashMap<String,String>();
  30. cc.put("rno", user.getRno());
  31. cc.put("fno", user.getFno());
  32. cc.put("standard", user.getStandard());
  33. cc.put("cost", String.valueOf(user.getCost()));
  34. cc.put("position", user.getPosition());
  35. tt.add(cc);
  36. }
  37. returntt;
  38. }
复制代码
5 总结

通过本次课程设计使我进一步熟练掌握了JavaWeb开发的流程,增加了团队之间的相助。在运行程序过程中404错误,经过查抄后不是路径问题的错误,在重新安装Tomcat后并不起作用,经过讨教老师发现,是在web.xml中配置有问题,多写了一个斜杠,通过本次的经验教训使我明白细心的紧张性。
参考文献

[1] 萨师煊, 王珊. 数据库系统概论[M].北京:高等教诲出版社,2006.
[2] 计磊.醒目J2EE整合应用案例[M].北京:人民邮电出版社,2006
[3] 王红.Java Web应用开发技术应用.北京:电子工业出版社,2009
[4] 孙卫琴.Java Web 开发技术详解[M].北京:电子工业出版社,2009
[5] 唐有国.Jsp网站开发详解[M].北京:清华大学出版社,2010
[6]刘卫宏.Eclipse利用教程[M].科学出版社,2007
[7]王珊,陈红.数据库原理教程[M].清华大学出版社,2009
[8]施伯乐,Tomcat和Java web详解[M].科学出版社,2008
[9]封超,Java Web 应用开发[M].人民邮电出版社,2009
[10]吴忠福,数据库设计结构探讨[M].科学出版社,2007

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 IT评测·应用市场-qidao123.com技术社区 (https://dis.qidao123.com/) Powered by Discuz! X3.4