基于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

    <divid="loginAndRegisterForm">
    <formmethod="post"id="loginForm">

    <thstyle="text-align:left;">用户名: <thstyle="text-align:left;">密码: <thstyle="text-align:left;">用户类型:
    <inputtype="text"id="userName"style="width:150px;" name="username"class="easyui-textbox"/>
    <inputtype="password"id="userPwd"style="width:150px;" name="password"class="easyui-passwordbox"/>
    <selectname="usertype"class="easyui-textbox"id="option"> <optionvalue="1">前台操作员</option> <optionvalue="2">系统管理员</option> </select>
    </form>
  • LoginServlet.java

    privatevoid login(HttpServletRequestrequest, HttpServletResponse response) throws IOException{
    String username = request.getParameter("username");
    String password = request.getParameter("password");
    String usertype = request.getParameter("usertype");
    Json json = new Json();
    User u = UserDao.getUserByName(username, password);
    if(u!=null && u.getUsertype().equals(usertype)){
    request.getSession().setAttribute("currentUser",u);
    json.setMsg("登录成功");
    json.setSuccess(true);
    if(usertype.equals("1")){
    json.setUrl("/operator/index.jsp");
    }elseif(usertype.equals("2")){
    json.setUrl("/admin/index.jsp");
    }else{
    json.setUrl("/error.jsp");
    }
    }else{
    json.setMsg("用户名或密码错误,登录失败!");
    json.setSuccess(false);
    }
    String jsonStr = JSON.toJSONString(json);
    //将json字符串作为响应内容输出到客户端浏览器。
    response.getWriter().write(jsonStr);
    }

  • 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

      <tableid="dg"title="客户入住"class="easyui-datagrid"fitColumns="true"pagination="true"
      data-options="rownumbers:true,toolbar:'#tb'">

      <thfield="cb"checkbox="true"align="center"> <thfield="rno"width="50"align="center">房间号 <thfield="fno"width="50"align="center">楼层号 <thfield="standard"width="50"align="center">房间标准 <thfield="cost"width="50"align="center">房间费用 <thfield="position"width="50"align="center">地理位置 <divid="tb">
       房间标准:  <selectid="standard"class="easyui-combobox"data-options="panelHeight:'auto'"style="width:150px;"> <optionvalue="">全部</option> <optionvalue="大床房">大床房</option> <optionvalue="标间">标间</option> <optionvalue="豪华套房">豪华套房</option> </select>  入住开始时间:  <inputtype="text" class="easyui-datebox"id="btime"style="width:150px;">  入住结束时间:  <inputtype="text" class="easyui-datebox" id="etime"style="width:150px;"> <ahref="javascript:searchRoom()"class="easyui-linkbutton"iconCls="icon-search"plain="true">搜索 <ahref="javascript:openDialog()"class="easyui-linkbutton"iconCls="icon-edit"plain="true">入住 <ahref="javascript:reload()"class="easyui-linkbutton"iconCls="icon-reload"plain="true">刷新
    <divid="dlg"class="easyui-dialog"style="width:400px; padding:10px 20px" closed="true"buttons="#dlg-buttons"> <formid="fm"method="post"> <tablecellspacing="8px"> 房间号 <inputname="rno"class="textbox" readonly="true"> 楼层号 <inputname="fno"class="textbox"readonly="true"> 房间标准 <inputname="standard"class="textbox"readonly="true"> 房间费用 <inputname="cost"class="textbox"readonly="true"> 地理位置 <inputname="position"class="textbox"readonly="true"> 身份证号 <inputname="cid"class="easyui-validatebox"data-options="required:true"> 预付金 <inputname="prepay"class="easyui-numberbox"> </form>

    <divid="dlg-buttons">

    <ahref="javascript:saveStudent()"class="easyui-linkbutton"iconCls="icon-ok"plain="true">确认 <ahref="javascript:closeStudentDialog()"class="easyui-linkbutton"iconCls="icon-cancel"plain="true">关闭
  • BookServlet.java

    privatevoid book(HttpServletRequest request, HttpServletResponse response) throws IOException{
    String cid = request.getParameter("cid");
    String btime = request.getParameter("btime");
    String etime = request.getParameter("etime");
    String rno = request.getParameter("rno");
    doubleprepay = Double.parseDouble(request.getParameter("prepay"));
    Json json = new Json();
    User u = (User)request.getSession().getAttribute("currentUser");
    intuserid = u.getUserid();
    if(CustomerDao.getCustomer(cid) == null){
    json.setSuccess(false);
    json.setMsg("用户身份证号不存在,请先添加用户信息");
    }else{
    try {
    BookDao.addBook(rno, cid, btime, userid, etime, prepay);
    json.setSuccess(true);
    json.setMsg("");
    } catch (Exception e) {
    // TODO Auto-generated catch block
    json.setSuccess(false);
    json.setMsg(e.getMessage());
    e.printStackTrace();
    }
    }
    String jsonStr = JSON.toJSONString(json);
    //将json字符串作为响应内容输出到客户端浏览器。
    response.getWriter().write(jsonStr);

    }

  • 4.3退房管理模块实现

    4.3.1 界面设计

    此界面前台操作员处理客户退房管理。如:图4-4退房管理界面。

    图4.4退房管理界面

    4.3.2 退房管理功能实现

    该功能实现了前台操作员处理客户入住的功能。代码文件包括 dropList.jsp,BookServlet.java.

    描述:通过dropList.jsp中的form表单向BookServlet.java进行处理.

    1. dropList.jsp

      <scripttype="text/javascript">

      function deleteRoom() {
      var selectedRows = ("#dg").datagrid("getSelections"); if(selectedRows.length == 0) { .messager.alert("系统提示", "请选择要退房的房间");
      return;
      }
      if(selectedRows.length != 1) {
      .messager.alert("系统提示", "请选择一个要退房的客房"); return; } var row = selectedRows[0]; .messager.confirm("系统提示", "您确定退房么?", function(r) {
      if(r) {
      .post("{pageContext.request.contextPath}/BookServlet?action=search1",
      { rno:row.rno,
      cid:row.cid,
      btime:row.btime,
      etime:row.etime
      }, function(result){
      if(result.success) {
      .messager.alert("系统提示", result.msg); searchRoom(); } else { .messager.alert("系统提示", "退房失败!");
      }
      }, "json");
      }
      });
      }
      function searchRoom() {
      .post("{pageContext.request.contextPath}/BookServlet?action=drop", {
      rno:('#rno').val() }, function(data, states) { ("#dg").datagrid("loadData", data);
      },"json");
      }
      function reload() {
      searchRoom();
      }
      </script>

      </head> <bodystyle="margin: 1px; font-family: microsoft yahei"> <tableid="dg"title="退房管理"class="easyui-datagrid"fitColumns="true"pagination="true" data-options="rownumbers:true,toolbar:'#tb'"> <thfield="cb"checkbox="true"align="center"> <thfield="rno"width="50"align="center">房间号 <thfield="fno"width="50"align="center">楼层号 <thfield="standard"width="50"align="center">房间标准 <thfield="cost"width="50"align="center">房间费用 <thfield="position"width="50"align="center">地理位置 <thfield="cid"width="50"align="center">身份证号 <thfield="btime"width="50"align="center">入住时间 <thfield="etime"width="50"align="center">退房时间 <divid="tb">
       房间号:  <inputtype="text" class="easyui-textbox"id="rno"style="width:150px;"> <ahref="javascript:searchRoom()"class="easyui-linkbutton"iconCls="icon-search"plain="true">搜索 <ahref="javascript:deleteRoom()"class="easyui-linkbutton"iconCls="icon-edit"plain="true">退房 <ahref="javascript:reload()"class="easyui-linkbutton"iconCls="icon-reload"plain="true">刷新
    1. BookServlet.java privatevoid drop(HttpServletRequest request, HttpServletResponse response) throws IOException{ String rno = request.getParameter("rno"); List<Map<String, String>> list = new ArrayList<Map<String,String>>(); list = BookBpo.searchList(rno); Object jsonArray = JSON.toJSON(list); JSONObject result = new JSONObject(); result.put("rows", jsonArray); result.put("total", list.size()); response.getWriter().print(result); }

    privatevoid search1(HttpServletRequest request, HttpServletResponse response) throws IOException{
    String cid = request.getParameter("cid");
    String btime = request.getParameter("btime");
    String etime = request.getParameter("etime");
    String rno = request.getParameter("rno");
    Json json = new Json();
    User u = (User)request.getSession().getAttribute("currentUser");
    intuserid = u.getUserid();
    try {
    BookBpo.dropBook(rno, cid, userid, btime, etime);
    try{
    History h = HistoryDao.getHistory(rno, cid, btime);
    json.setSuccess(true);
    json.setMsg("房间号:"+rno+"
    入住时间:"+btime+"
    退房时间:"+etime+"
    总费用:"+h.getSumpay());
    }catch(Exception e){
    json.setSuccess(false);
    json.setMsg(e.getMessage());
    e.printStackTrace();
    }

    } catch (Exception e) {
    // TODO Auto-generated catch block
    json.setSuccess(false);
    json.setMsg(e.getMessage());
    e.printStackTrace();
    }
    String jsonStr = JSON.toJSONString(json);
    //将json字符串作为响应内容输出到客户端浏览器。
    response.getWriter().write(jsonStr);
    }

    4.4预订客房模块实现

    4.4.1 界面设计

    此界面前台操作员处理预定客户。如:图4-5预定客户界面。

    图4-5预定客户界面

    图4-6预定客户界面

    4.4.2 预订客房功能实现

    该功能实现了前台操作员处理预定客户的功能。代码文件包括该功能实现了前台操作员处理预定查询的功能。代码文件包括 advanceList.jsp,AdvanceServlet.java.

    描述:通过advanceList.jsp中的form表单向AdvanceServlet.java进行处理.

    1. advanceList

      <bodystyle="margin: 1px; font-family: microsoft yahei">
      <tableid="dg"title="预定客房"class="easyui-datagrid"fitColumns="true"pagination="true"
      data-options="rownumbers:true,toolbar:'#tb'">

      <thfield="cb"checkbox="true"align="center"> <thfield="rno"width="50"align="center">房间号 <thfield="fno"width="50"align="center">楼层号 <thfield="standard"width="50"align="center">房间标准 <thfield="cost"width="50"align="center">房间费用 <thfield="position"width="50"align="center">地理位置 <divid="tb">
       房间标准:  <selectid="standard"class="easyui-combobox"data-options="panelHeight:'auto'"style="width:150px;"> <optionvalue="">全部</option> <optionvalue="大床房">大床房</option> <optionvalue="标间">标间</option> <optionvalue="豪华套房">豪华套房</option> </select>  预订开始时间:  <inputtype="text" class="easyui-datebox"id="btime"style="width:150px;">  预订结束时间:  <inputtype="text" class="easyui-datebox" id="etime"style="width:150px;"> <ahref="javascript:searchRoom()"class="easyui-linkbutton"iconCls="icon-search"plain="true">搜索 <ahref="javascript:openDialog()"class="easyui-linkbutton"iconCls="icon-edit"plain="true">预定 <ahref="javascript:reload()"class="easyui-linkbutton"iconCls="icon-reload"plain="true">刷新
    <divid="dlg"class="easyui-dialog"style="width:400px; padding:10px 20px" closed="true"buttons="#dlg-buttons"> <formid="fm"method="post"> <tablecellspacing="8px"> 房间号 <inputname="rno"class="textbox" readonly="true"> 楼层号 <inputname="fno"class="textbox"readonly="true"> 房间标准 <inputname="standard"class="textbox"readonly="true"> 房间费用 <inputname="cost"class="textbox"readonly="true"> 地理位置 <inputname="position"class="textbox"readonly="true"> 预定人 <inputname="person"class="easyui-validatebox"data-options="required:true"> 预定人电话 <inputname="phone"class="easyui-validatebox"data-options="required:true"> </form>

    <divid="dlg-buttons">

    <ahref="javascript:saveStudent()"class="easyui-linkbutton"iconCls="icon-ok"plain="true">确认 <ahref="javascript:closeStudentDialog()"class="easyui-linkbutton"iconCls="icon-cancel"plain="true">关闭
  • AdvanceServlet.java

    privatevoid advance(HttpServletRequest request, HttpServletResponse response) throws IOException{
    String rno = request.getParameter("rno");
    String btime = request.getParameter("btime");
    String etime = request.getParameter("etime");
    String phone = request.getParameter("phone");
    String person = request.getParameter("person");
    Json json = new Json();
    User u = (User)request.getSession().getAttribute("currentUser");
    intuserid = u.getUserid();
    try {
    AdvanceDao.addAdvance(rno, phone, btime, userid, etime, person);
    json.setSuccess(true);
    json.setMsg("");
    } catch (Exception e) {
    // TODO Auto-generated catch block
    json.setSuccess(false);
    json.setMsg(e.getMessage());
    e.printStackTrace();
    }
    String jsonStr = JSON.toJSONString(json);
    //将json字符串作为响应内容输出到客户端浏览器。
    response.getWriter().write(jsonStr);

    }

  • 4.5.1 界面设计

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

    图4-7预定客户界面

    图4-8预定客户界面

    4.5.2 预定查询功能实现

    该功能实现了前台操作员处理预定查询的功能。代码文件包括 advanceList.jsp,AdvanceServlet.java.

    描述:通过advanceList.jsp中的form表单向AdvanceServlet.java进行处理.

    1. advanceList.jsp

      <bodystyle="margin: 1px; font-family: microsoft yahei">
      <tableid="dg"title="预定查询"class="easyui-datagrid"fitColumns="true"pagination="true"
      data-options="rownumbers:true,toolbar:'#tb'">

      <thfield="cb"checkbox="true"align="center"> <thfield="rno"width="50"align="center">房间号 <thfield="fno"width="50"align="center">楼层号 <thfield="standard"width="50"align="center">房间标准 <thfield="cost"width="50"align="center">房间费用 <thfield="position"width="50"align="center">地理位置 <thfield="person"width="50"align="center">客户名 <thfield="phone"width="50"align="center">联系电话 <thfield="btime"width="50"align="center">预订开始时间 <thfield="etime"width="50"align="center">预订结束时间 <divid="tb">
       客户名:  <inputtype="text" class="easyui-textbox"id="person"style="width:150px;">  客户电话:  <inputtype="text" class="easyui-textbox"id="phone"style="width:150px;"> <ahref="javascript:searchRoom()"class="easyui-linkbutton"iconCls="icon-search"plain="true">搜索 <ahref="javascript:openDialog()"class="easyui-linkbutton"iconCls="icon-edit"plain="true">入住 <ahref="javascript:reload()"class="easyui-linkbutton"iconCls="icon-reload"plain="true">刷新
    <divid="dlg"class="easyui-dialog"style="width:400px; padding:10px 20px" closed="true"buttons="#dlg-buttons"> <formid="fm"method="post"> <tablecellspacing="8px"> 房间号 <inputname="rno"class="textbox" readonly="true"> 入住时间 <inputname="btime" class="textbox" readonly="true"> 退房时间 <inputname="etime" class="textbox" readonly="true"> 客户名 <inputname="person"class="textbox" readonly="true"> 电话 <inputname="phone"class="textbox" readonly="true"> 身份证号 <inputname="cid"class="easyui-validatebox"data-options="required:true"> 预付金 <inputname="prepay"class="easyui-numberbox"> </form>

    <divid="dlg-buttons">

    <ahref="javascript:saveStudent()"class="easyui-linkbutton"iconCls="icon-ok"plain="true">确认 <ahref="javascript:closeStudentDialog()"class="easyui-linkbutton"iconCls="icon-cancel"plain="true">关闭
  • AdvanceServlet.java

    privatevoid search(HttpServletRequest request, HttpServletResponse response) throws IOException{
    String standard = request.getParameter("standard");
    String btime = request.getParameter("btime");
    String etime = request.getParameter("etime");
    List<Map<String, String>> list = new ArrayList<Map<String,String>>();
    list = AdvanceBpo.selectList(standard, btime, etime);
    Object jsonArray = JSON.toJSON(list);
    JSONObject result = new JSONObject();
    result.put("rows", jsonArray);
    result.put("total", list.size());
    response.getWriter().print(result);
    }
    publicstatic List<Room> roomAdanvce(String standard,String btime,String etime){
    EntityManager em = EntityManagerUtil.getEntityManager();
    String sql = null;
    if(standard.equals("") || standard == null){
    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+"')";
    }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+"'";}
    Query query=em.createNativeQuery(sql, Room.class);
    List<Room> Rooms = query.getResultList();
    em.close();
    returnRooms;
    }

    publicstatic List<Map<String,String>> selectList(String standard,String btime,String etime){
    List<Map<String,String>> tt = new ArrayList<Map<String,String>>();
    List<Room> Rooms = roomAdanvce(standard, btime, etime);
    Map<String,String> cc = null;
    for (Room user: Rooms) {
    cc = new HashMap<String,String>();
    cc.put("rno", user.getRno());
    cc.put("fno", user.getFno());
    cc.put("standard", user.getStandard());
    cc.put("cost", String.valueOf(user.getCost()));
    cc.put("position", user.getPosition());
    tt.add(cc);
    }
    returntt;
    }

  • 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

    上一篇:JVM 垃圾回收
    下一篇:Spring Boot一次接口请求涉及的完整执行链路
    相关推荐
    may_一一44 分钟前
    Docker中mysql镜像保存与导入
    mysql·docker·容器
    Pasregret1 小时前
    云原生 MySQL 架构:从容器化到 Serverless
    mysql·云原生·架构
    Pasregret2 小时前
    MySQL 安全架构:从渗透测试到合规审计
    数据库·mysql·安全架构
    为美好的生活献上中指3 小时前
    java每日精进 5.07【框架之数据权限】
    java·开发语言·mysql·spring·spring cloud·数据权限
    阿文弟3 小时前
    MYSQL之索引结构,为何要用B+树
    数据库·mysql
    博睿谷IT99_3 小时前
    MySQL OCP 认证限时免费活动 7 月 31 日 前截止!!!
    数据库·mysql·开闭原则
    博睿谷IT99_3 小时前
    MySQL OCP和Oracle OCP怎么选?
    数据库·mysql·oracle·开闭原则·ocp
    Catfood_Eason4 小时前
    初识MySQL
    数据库·mysql
    鬼才血脉5 小时前
    Ubuntu上安装MySQL 8并配置Navicat远程连接
    mysql·ubuntu·adb
    爱编程的王小美6 小时前
    本地MySQL连接hive
    数据库·hive·mysql
    热门推荐
    01从零安装 LLaMA-Factory 微调 Qwen 大模型成功及所有的坑02KGG转MP3工具|非KGM文件|解密音频03YOLOv8入门 | 重要性能衡量指标、训练结果评价及分析及影响mAP的因素【发论文关注的指标】04【SpeedAI科研小助手】2分钟极速解决知网维普重复率、AIGC率过高,一键全文降!文件格式不变,公式都保留的!05苍穹外卖面试总结06西电B测-计算机网络综合实验(含验收问题)07Coze扣子平台完整体验和实践(附国内和国际版对比)08yolov8,yolo11,yolo12 服务器训练到部署全流程 笔记09DeepSeek各版本说明与优缺点分析10YOLOv5改进 | 添加CA注意力机制 + 增加预测层 + 更换损失函数之GIoU