zl程序教程

您现在的位置是:首页 >  数据库

当前栏目

基于javaEE+jqueryEasyUi+eclipseLink+MySQL的课程设计客房管理信息系统【100010148】

mysql 基于 课程设计 JavaEE
2023-09-11 14:17:50 时间

基于 javaEE+jqueryEasyUi+eclipseLink 的课程设计客房管理信息系统

1系统概述

1.1 系统功能概述

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

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数据库设计

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

3系统概要设计

系统有两类用户:前台操作员和系统管理员。其中,前台管理员负责客房预订、入住登记、房客查询、收费管理等功能,系统管理员负责客房信息输入、客房信息查询、前台操作员管理、统计报表等功能。系统主要包括6大功能模块:基本信息管理、入住管理、会员管理、客房预订管理、收费管理、统计报表管理。

  1. 客户管理。能够增加一个客户,包括:身份证号、客户名称、出生年月、性别、联系电话、邮箱、会员类别等信息,默认会员类别为空;能够修改和删除客户信息;能够根据客户名称、联系电话查询客户基本信息。
  2. 客户入住。能够根据客房标准和日期查询状态为“空闲”的客房信息,显示楼层号、房间号、费用;能够根据客户名和联系方式查询房间预订信息,显示:楼层号、房间号、预订开始时间,预订结束时间;能够为指定的客户办理指定客房的入住手续,修改客户状态为“入住”,并记录入住时间、前台操作员。
  3. 退房管理。能够根据房间号查询客房信息;能够完成指定客户对指定房间的退房操作(利用存储过程实现),即首先增加一条客户实际入住记录,包括:客户身份证编号、客户名、房间号、入住时间、退房时间、房费、前台操作员,然后修改客房状态为“空闲”;最后根据会员类别和入住天数计算房费。
    在这里插入图片描述
    用例图
    在这里插入图片描述
    预定客房顺序图
    在这里插入图片描述
    会员状态图
    在这里插入图片描述
    类图
    在这里插入图片描述
    前台操作员活动图
    在这里插入图片描述
    系统管理员活动图

4系统详细设计与实现

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

4.1 登录模块实现

4.1.1 界面设计
此界面实现了用户的登录功能。如图4-1登录界面所示。
在这里插入图片描述
4.1.2登录功能实现
此界面主要实现了用户的登录功能。此部分代码文件:login.jsp,LoginServlet,UserDao.java,User.java
功能实现:通过login.jsp 的form表单提交到LoginServlet进行处理,再调用UserDao.java中方法实现登录验证.

  1. login.js
<div id="loginAndRegisterForm">
          <form method="post" id="loginForm">
              <table>
                  <tr>
                      <th style="text-align:left;">用户名:</th>
                      <!-- class="easyui-textbox"表示使用EasyUI的textbox组件-->
                      <td><input type="text" id="userName" style="width:150px;" name="username" class="easyui-textbox"/></td>                  </tr>
                  <tr>
                      <th style="text-align:left;">密码:</th>
                      <td><input type="password" id="userPwd" style="width:150px;" name="password" class="easyui-passwordbox"/></td>
                  </tr>
                  <tr>
                      <th style="text-align:left;">用户类型:</th>
                    <td>
                          <select name="usertype" class="easyui-textbox" id="option">
                              <option value="1">前台操作员</option>
                              <option value="2">系统管理员</option>
                          </select>
                      </td>
                  </tr>
              </table>
          </form>
      </div>

  1. LoginServlet.java
private void login(HttpServletRequest request, 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");
	            }else if(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.2 客户入住界面
客户入住功能实现
该功能实现了前台操作员处理客户入住的功能。代码文件包括 bookList.jsp,BookServlet.java.
描述:通过bookList.jsp中的form表单向BookServlet.java进行处理.

  1. booklist.jsp
<table id="dg" title="客户入住" class="easyui-datagrid" fitColumns="true" pagination="true"
   data-options="rownumbers:true,toolbar:'#tb'">
	<thead>
		<tr>
			<th field="cb" checkbox="true" align="center"></th>
			<th field="rno" width="50" align="center">房间号</th>
			<th field="fno" width="50" align="center">楼层号</th> 
			<th field="standard" width="50" align="center">房间标准</th>
			<th field="cost" width="50" align="center">房间费用</th>
			<th field="position" width="50" align="center">地理位置</th>
		</tr>
	</thead>
</table>
<div id="tb"> 
	<div>
	   <span>&nbsp;房间标准:&nbsp;</span>
	   <select id="standard" class="easyui-combobox" data-options="panelHeight:'auto'" style="width:150px;">
               <option value="">全部</option>
               <option value="大床房">大床房</option>
               <option value="标间">标间</option>
               <option value="豪华套房">豪华套房</option>
	   </select>
	    <span>&nbsp;入住开始时间:&nbsp;</span>
		<input type="text"  class="easyui-datebox" id="btime" style="width:150px;">
		<span>&nbsp;入住结束时间:&nbsp;</span>
		<input type="text"  class="easyui-datebox"  id="etime" style="width:150px;">
		<a href="javascript:searchRoom()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>
		<a href="javascript:openDialog()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">入住</a>	
		<a href="javascript:reload()" class="easyui-linkbutton" iconCls="icon-reload" plain="true">刷新</a>		
	</div>
</div>
<div id="dlg" class="easyui-dialog" style="width:400px;  padding:10px 20px" 
	closed="true" buttons="#dlg-buttons">
	<form id="fm" method="post">
		<table cellspacing="8px">
		    <tr>
				<td>房间号</td>
				<td>
					 <input name="rno" class="textbox"  readonly="true">
				</td>
			</tr>
			<tr>
				<td>楼层号</td>
				<td>
					 <input name="fno" class="textbox" readonly="true">
				</td>
			</tr>
			<tr>
				<td>房间标准</td>
				<td>
					 <input name="standard" class="textbox" readonly="true">
				</td>
			</tr>
			<tr>
				<td>房间费用</td>
				<td>
					 <input name="cost" class="textbox" readonly="true">
				</td>
			</tr>
			<tr>
				<td>地理位置</td>
				<td>
					 <input name="position" class="textbox" readonly="true">
				</td>
			</tr>
		   <tr>
				<td>身份证号</td>
				<td>
					 <input name="cid" class="easyui-validatebox" data-options="required:true">
				</td>
			</tr>
			<tr>
				<td>预付金</td>
				<td>
					 <input name="prepay" class="easyui-numberbox">
				</td>
			</tr>
		</table>
	</form>
</div>

<div id="dlg-buttons">
	<div>
		<a href="javascript:saveStudent()" class="easyui-linkbutton" iconCls="icon-ok" plain="true">确认</a>
		<a href="javascript:closeStudentDialog()" class="easyui-linkbutton" iconCls="icon-cancel" plain="true">关闭</a>
	</div>
</div>

  1. BookServlet.java
private void 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");
		double prepay = Double.parseDouble(request.getParameter("prepay"));
		Json json = new Json();
		User u = (User)request.getSession().getAttribute("currentUser");
		int userid = 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.3.2 退房管理功能实现
该功能实现了前台操作员处理客户入住的功能。代码文件包括 dropList.jsp,BookServlet.java.
描述:通过dropList.jsp中的form表单向BookServlet.java进行处理.

  1. dropList.jsp
<script type="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>
<body style="margin: 1px; font-family: microsoft yahei">
<table id="dg" title="退房管理" class="easyui-datagrid" fitColumns="true" pagination="true"
   data-options="rownumbers:true,toolbar:'#tb'">
	<thead>
		<tr>
			<th field="cb" checkbox="true" align="center"></th>
			<th field="rno" width="50" align="center">房间号</th>
			<th field="fno" width="50" align="center">楼层号</th> 
			<th field="standard" width="50" align="center">房间标准</th>
			<th field="cost" width="50" align="center">房间费用</th>
			<th field="position" width="50" align="center">地理位置</th>
			<th field="cid" width="50" align="center">身份证号</th>
			<th field="btime" width="50" align="center">入住时间</th>
			<th field="etime" width="50" align="center">退房时间</th>
		</tr>
	</thead>
</table>
<div id="tb"> 
	<div>
	    <span>&nbsp;房间号:&nbsp;</span>
	    <input type="text"  class="easyui-textbox" id="rno" style="width:150px;">
		<a href="javascript:searchRoom()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>
		<a href="javascript:deleteRoom()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">退房</a>	
		<a href="javascript:reload()" class="easyui-linkbutton" iconCls="icon-reload" plain="true">刷新</a>		
	</div>
</div>

  1. BookServlet.java
private void 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);
	}
	
	private void 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");
		int userid = u.getUserid();
		try {
			BookBpo.dropBook(rno, cid, userid, btime, etime);
			try{
				History h = HistoryDao.getHistory(rno, cid, btime);
				json.setSuccess(true);
				json.setMsg("房间号:"+rno+"<br/>入住时间:"+btime+"<br/>退房时间:"+etime+"<br/>总费用:"+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.4.2 预订客房功能实现
该功能实现了前台操作员处理预定客户的功能。代码文件包括该功能实现了前台操作员处理预定查询的功能。代码文件包括 advanceList.jsp,AdvanceServlet.java.
描述:通过advanceList.jsp中的form表单向AdvanceServlet.java进行处理.

  1. advanceList
<body style="margin: 1px; font-family: microsoft yahei">
<table id="dg" title="预定客房" class="easyui-datagrid" fitColumns="true" pagination="true"
   data-options="rownumbers:true,toolbar:'#tb'">
	<thead>
		<tr>
			<th field="cb" checkbox="true" align="center"></th>
			<th field="rno" width="50" align="center">房间号</th>
			<th field="fno" width="50" align="center">楼层号</th> 
			<th field="standard" width="50" align="center">房间标准</th>
			<th field="cost" width="50" align="center">房间费用</th>
			<th field="position" width="50" align="center">地理位置</th>
		</tr>
	</thead>
</table>
<div id="tb"> 
	<div>
	   <span>&nbsp;房间标准:&nbsp;</span>
	   <select id="standard" class="easyui-combobox" data-options="panelHeight:'auto'" style="width:150px;">
               <option value="">全部</option>
               <option value="大床房">大床房</option>
               <option value="标间">标间</option>
               <option value="豪华套房">豪华套房</option>
	   </select>
	    <span>&nbsp;预订开始时间:&nbsp;</span>
		<input type="text"  class="easyui-datebox" id="btime" style="width:150px;">
		<span>&nbsp;预订结束时间:&nbsp;</span>
		<input type="text"  class="easyui-datebox"  id="etime" style="width:150px;">
		<a href="javascript:searchRoom()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>
		<a href="javascript:openDialog()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">预定</a>	
		<a href="javascript:reload()" class="easyui-linkbutton" iconCls="icon-reload" plain="true">刷新</a>		
	</div>
</div>
<div id="dlg" class="easyui-dialog" style="width:400px;  padding:10px 20px" 
	closed="true" buttons="#dlg-buttons">
	<form id="fm" method="post">
		<table cellspacing="8px">
		    <tr>
				<td>房间号</td>
				<td>
					 <input name="rno" class="textbox"  readonly="true">
				</td>
			</tr>
			<tr>
				<td>楼层号</td>
				<td>
					 <input name="fno" class="textbox" readonly="true">
				</td>
			</tr>
			<tr>
				<td>房间标准</td>
				<td>
					 <input name="standard" class="textbox" readonly="true">
				</td>
			</tr>
			<tr>
				<td>房间费用</td>
				<td>
					 <input name="cost" class="textbox" readonly="true">
				</td>
			</tr>
			<tr>
				<td>地理位置</td>
				<td>
					 <input name="position" class="textbox" readonly="true">
				</td>
			</tr>
			<tr>
				<td>预定人</td>
				<td>
					 <input name="person" class="easyui-validatebox" data-options="required:true">
				</td>
			</tr>
			<tr>
				<td>预定人电话</td>
				<td>
					 <input name="phone" class="easyui-validatebox" data-options="required:true">
				</td>
			</tr>
		</table>
	</form>
</div>

<div id="dlg-buttons">
	<div>
		<a href="javascript:saveStudent()" class="easyui-linkbutton" iconCls="icon-ok" plain="true">确认</a>
		<a href="javascript:closeStudentDialog()" class="easyui-linkbutton" iconCls="icon-cancel" plain="true">关闭</a>
	</div>
</div>

  1. AdvanceServlet.java
private void 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");
		int userid = 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.5.2 预定查询功能实现
该功能实现了前台操作员处理预定查询的功能。代码文件包括 advanceList.jsp,AdvanceServlet.java.
描述:通过advanceList.jsp中的form表单向AdvanceServlet.java进行处理.

  1. advanceList.jsp
<body style="margin: 1px; font-family: microsoft yahei">
<table id="dg" title="预定查询" class="easyui-datagrid" fitColumns="true" pagination="true"
   data-options="rownumbers:true,toolbar:'#tb'">
	<thead>
		<tr>
			<th field="cb" checkbox="true" align="center"></th>
			<th field="rno" width="50" align="center">房间号</th>
			<th field="fno" width="50" align="center">楼层号</th> 
			<th field="standard" width="50" align="center">房间标准</th>
			<th field="cost" width="50" align="center">房间费用</th>
			<th field="position" width="50" align="center">地理位置</th>
			<th field="person" width="50" align="center">客户名</th>
			<th field="phone" width="50" align="center">联系电话</th>
			<th field="btime" width="50" align="center">预订开始时间</th>
			<th field="etime" width="50" align="center">预订结束时间</th>
		</tr>
	</thead>
</table>
<div id="tb"> 
	<div>
	    <span>&nbsp;客户名:&nbsp;</span>
	    <input type="text"  class="easyui-textbox" id="person" style="width:150px;">
	    <span>&nbsp;客户电话:&nbsp;</span>
	    <input type="text"  class="easyui-textbox" id="phone" style="width:150px;">
		<a href="javascript:searchRoom()" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>
		<a href="javascript:openDialog()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">入住</a>	
		<a href="javascript:reload()" class="easyui-linkbutton" iconCls="icon-reload" plain="true">刷新</a>		
	</div>
</div>
<div id="dlg" class="easyui-dialog" style="width:400px;  padding:10px 20px" 
	closed="true" buttons="#dlg-buttons">
	<form id="fm" method="post">
		<table cellspacing="8px">
		    <tr>
				<td>房间号</td>
				<td>
					 <input name="rno" class="textbox"  readonly="true">
				</td>
			</tr>
			<tr>
				<td>入住时间</td>
				<td>
					 <input name="btime"  class="textbox"  readonly="true">
				</td>
			</tr>
			<tr>
				<td>退房时间</td>
				<td>
					 <input name="etime"   class="textbox"  readonly="true">
				</td>
			</tr>
			 <tr>
				<td>客户名</td>
				<td>
					 <input name="person" class="textbox"  readonly="true">
				</td>
			</tr>
			 <tr>
				<td>电话</td>
				<td>
					 <input name="phone" class="textbox"  readonly="true">
				</td>
			</tr>
			<tr>
				<td>身份证号</td>
				<td>
					 <input name="cid" class="easyui-validatebox" data-options="required:true">
				</td>
			</tr>
			<tr>
				<td>预付金</td>
				<td>
					 <input name="prepay" class="easyui-numberbox">
				</td>
			</tr>
		</table>
	</form>
</div>

<div id="dlg-buttons">
	<div>
		<a href="javascript:saveStudent()" class="easyui-linkbutton" iconCls="icon-ok" plain="true">确认</a>
		<a href="javascript:closeStudentDialog()" class="easyui-linkbutton" iconCls="icon-cancel" plain="true">关闭</a>
	</div>
</div>

  1. AdvanceServlet.java
private void 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);
	}	
public static 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();
		return Rooms;
	}
	
	public static 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);
		}
		return tt;
	}

♻️ 资源

在这里插入图片描述

大小: 3.64MB
➡️ 资源下载:https://download.csdn.net/download/s1t16/87300946