提供:项目源码、项目文档、数据库脚本、软件工具等所有资料
从零开始手把手教学部署运行本系统
该项目附带的源码资料可作为毕设使用
提供技术答疑和远程协助指导,帮助调试并解决后期项目运行问题,
文章底部获取博主联系方式

基于Java的电影院在线购票系统设计与实现(附源码论文资料)-从零开始部署运行项目,学习环境搭建、项目导入及部署,含项目源码、文档、数据库、软件等资料-资料获取

文章目录

  • 1.绪论
    • 1.1.电影院在线购票系统的开发背景
    • 1.2.设计目的与意义
  • 2.系统需求分析
    • 2.1.可行性分析
      • 2.1.1 操作可行性
      • 2.1.2 经济可行性
      • 2.1.3 技术可行性
    • 2.2 方案的设计与比较
      • 2.2.1 C/S设计结构和B/S设计结构比较
      • 2.2.2 系统模式的设计
      • 2.2.3 系统设计的技术选择
      • 2.2.4系统的运行环境
    • 2.3 系统基本功能需求
      • 2.3.1 系统结构
      • 2.3.2 系统业务流程图
    • 2.4 数据库需求分析
    • 2.5 系统目标
  • 3.系统概要设计
    • 3.1总体设计
      • 3.1.1 处理流程
      • 3.1.2系统的数据流图
    • 3.2 系统结构图
    • 3.3数据库设计
    • 3.4逻辑结构设计
    • 3.5数据库表的设计
  • 4.系统的详细设计与实现
    • 4.1.前台系统设计实现
      • 4.1.1.首页界面实现
      • 4.1.2 用户注册功能实现
      • 4.1.3 用户登录功能实现
      • 4.1.4 影片信息查询实现
      • 4.1.5 影片详情实现
      • 4.1.6 用户评论评分实现
      • 4.1.7 用户订座位实现
      • 4.1.8 用户下单实现
      • 4.1.9 用户个人中心实现
    • 4.2 后台系统设计实现
      • 4.2.1 管理员登录实现
      • 4.2.2 后台主页面实现
      • 4.2.3 用户管理实现
      • 4.2.4 影片管理实现
      • 4.3.5 影院管理实现
      • 4.3.6 放映厅管理实现
      • 4.3.7 场次管理实现
      • 4.3.8 评论管理实现
      • 4.3.9 订单管理实现
  • 5.参考文献
  • 6.源码获取

1.绪论

1.1.电影院在线购票系统的开发背景

网络发展到今天,是必然的结果。网络使人们的生活发生了重大的变化,网络成为很多活动的重要场所。网上电影票售票系统现在虽然还处于发展阶段,但是随着互联网经济的迅速发展,越来越多的影院投入到电影票售票系统这个领域中来。网上售票最大程度的方便了顾客。顾客足不出户,在电影售票网站实现网上把售票员请到家服务,便可将购买到自己喜欢的电影票,无需东奔西跑。本次设计的电影售票网站是一种具有交互功能的商业网站,可以方便服务于每一个客户。

1.2.设计目的与意义

2002年,国内电影市场的全年票房只有9.2亿,如今,三周时间就可以有10 亿的票房收入。名导、明星、大制作都是电影票的吸金石。随着人们的生活水平的提高,人们更愿意走进电影院,去欣赏自己喜欢的电影。随着互联网的蓬勃发展,人们也开始拒绝柜台式购票。更多的人们热衷与网络购票。这样既能避免了排长队的苦恼,同时也能精准的找到和购买喜欢的电影票并且选到一个自己满意的观影位置。电影院售票系统旨在提供观众放映影片相关资讯,如场次时间表、影片预告及简介、电影院资讯等。电影业的蓬勃发展,必然引发的一个问题是群众对电影票需求的增大。如今的电影在线售票系统已经相当的成熟,可以提供最近热映的的影片讯息、快要上映的影片相关预告、每场电影的场次安排,以及每场次电影票的网上预订模式。对于观众而言可以增强他们对各部影片的了解,对最新的影片上映动态的掌握,让他们对影片更加期待,尤其能在网上订票模式下使观众享受到不需要等待排队买票与自由选择座位的权利。通过网络轻松订票,从而减少许多因现场购票失败的客户,促使我国电影事业更好更快的发展。

2.系统需求分析

2.1.可行性分析

2.1.1 操作可行性

本系统的开发是在三个月的时间内完成的。前期主要是以学习以及收集资料为主,接下来就是对系统的分析,设计数据库,界面,以及中间的连接。对于计算机专业作为毕业设计来说是可行的。

2.1.2 经济可行性

经济可行性主要是对项目的经济效益进行评价。目前,具备了运行网络平台的MIS的硬件基础,而且本系统是我组成员自行开发,免费帮助设计并实施的。因此开发、设计这套系统的支出费用是学校可以承担的,即经济上是可行的。

2.1.3 技术可行性

技术上的可行性要考虑将来采用的硬件和软件技术能否满足用户提出的要求。基于当前的计算机网络技术和数据技术已成熟,而且管理信息系统(MIS)的各种开发技术也已经相当成熟,并且在各个领域都不乏成熟的案例。所以开发一套网络平台的多用户共享信息的在线考试系统在技术上是可行的。

2.2 方案的设计与比较

2.2.1 C/S设计结构和B/S设计结构比较

目前网络应用软件运行的模式主要有两类:Client/Server模式,Browser/Server模式。前者的主要的缺点是维护、升级较为麻烦。且要同时开发服务器端和客户端;后者是近几年伴随Internet迅速发展起来的一种技术,B/S模式客户端是一个标准的浏览器,服务器端是web server,而Web server与数据库和应用服务器的紧密结合,使得这种模式的应用范围不断扩大,它已不仅仅用于网上查询,有很多企业部门的业务系统,企业的MIS系统纷纷采用这种模式,它的优点是便于扩展应用、升级维护简便、不需要开发专门的客户端、不需要对用户进行特殊的设置和软件安装,降低了维护成本,客户端只要有浏览器就可以了。

2.2.2 系统模式的设计

本系统的设计是两种用户,一种是普通用户,一种是管理员用户。权限都不一样;

2.2.3 系统设计的技术选择

处于安全性,功能可扩展性。我们采用java ee。
数据库使用开源的Mysql;
服务器采用Tomcat;

2.2.4系统的运行环境

(1).系统:Windows XP及其以上版本
(2).Web服务器:Tomcat8及其以上版本
(3).数据库服务器:MySql
(4).浏览器:IE7,8,9、火狐、Chrome

2.3 系统基本功能需求

系统中涉及系统普通用户和管理员两种权限;接下来针对这两种权限分别说明下功能结构;

2.3.1 系统结构

  • 主要功能有:
    普通用户:用户注册,用户登录,查询影片,影片打分,在线选座,在线订票,个人中心;
  • 系统管理员:管理员登录,后台用户管理,影片管理,场次管理,放映厅管理,评论管理,订单管理;

2.3.2 系统业务流程图

  • 普通用户:


  • 管理员:


2.4 数据库需求分析

根据上面业务流程图所涉及到的内容,数据库要设计的表有:用户表,影片表,影院表,放映厅表,订单表,订单明细表,评论表;

2.5 系统目标

本选题系统的设计主要将实现以下目标:

(1).人性化设计:系统界面友好,操作简单;
.前台实现用户注册,用户登录,查询影片,影片打分,在线选座,在线订票,个人中心;

(2).后台实现管理员登录;管理员登录,后台用户管理,影片管理,场次管理,放映厅管理,评论管理,订单管理;

3.系统概要设计

3.1总体设计

3.1.1 处理流程

一,普通用户
(1).打开系统,进入系统前台首页界面,用户可以浏用户注册,用户登录,查询影片;
(2).用户登录,影片打分,在线选座,在线订票,个人中心;
(3).退出系统。

二,管理员
(1).打开系统,进入系统登录界面,
(2).通过验证后,进入系统管理主界面
(3).用户操作,执行相应的功能,
(4).退出系统。

3.1.2系统的数据流图

3.2 系统结构图


针对本系统的需求,设计出如下面所示的数据项和数据结构:

  • 用户表:编号,用户名,密码,邮箱,角色,用户头像;
  • 影片表:编号,影片名称,国外名称,演职人员,导演,电影详情,电影时长,电影类型,电影评分,票房,电影参评人数,上映时间,制片地区,电影海报地址,电影状态;
  • 影院表:编号,影院名称,影院地址;
  • 放映厅表:编号,放映厅名称,放映厅容量,所属影院编号;
  • 订单表:编号,所属用户编号,所属场次编号,电影票座位信息,订单状态,订单价格,订单支付时间,所属用户对象;
  • 订单详情表:编号,所属放映厅,放映的电影编号,电影放映时间,售价,剩余座位数,场次状态,所属放映厅对象,放映的电影;
  • 评论表:编号,所属用户编号,评论内容,所属电影编号,评论时间,所属用户,评分;

3.3数据库设计

(1).用户信息E-R图

(2). 电影信息E-R图

(3). 影院信息E-R图

(4). 放映厅表信息E-R图


(5). 订单信息E-R图

(6). 订单详情信息E-R图

(7). 评论信息E-R图

3.4逻辑结构设计

1,放映厅实体和影院实体的关系是多对一;
2,评论实体和用户实体的关系是多对一;
3,评论实体和影片实体的关系是多对多;
4,订单实体和用户实体的关系是多对一;
5,订单实体和订单详情实体的关系是多对一;
6,订单详情实体和放映厅实体的关系是多对一;
7,订单详情实体和影片实体的关系是多对一;

3.5数据库表的设计

(1).用户表

(2).影片表


(3).影院表

(4).放映厅表


(5).订单表

(6).订单详情表

(7).评论表

4.系统的详细设计与实现

4.1.前台系统设计实现

4.1.1.首页界面实现

浏览器访问:http://localhost:8080/jsp/mainPage.jsp
进入首页:

说明:
顶部是菜单,可以访问“首页”,“电影”,右侧是用户菜单,可以登录,注册,进入个人中心;
菜单下方是一个滚动大图,主要放置一些热门影片;
再下方左侧是影片列表,右侧是评分排行;
底部是版权说明;
关键代码实现:
前端核心代码:

 <!-- ------------------------------------------------------------------- --><!-- 导航栏 --><jsp:include page="header.jsp"/><!-- 占位符 --><!-- <div style="margin-top: 100px;"></div> --><!-- 主体 --><div class="main" style="height:1200px"><div class="main-inner main-page"><div class="layui-carousel" id="test3" lay-filter="test4"><div carousel-item=""> <div><img src="../static/images/lhy.jpg" onclick="window.location.href='/jsp/buyTickets.jsp" />></div><div><img src="../static/images/hhxd.jpg" onclick="window.location.href='/jsp/buyTickets.jsp?movie_id=21'"></div> <div><img src="../static/images/tt3.jpg" onclick="window.location.href='/jsp/buyTickets.jsp?movie_id=8'"></div></div></div> <div class="aside"><!-- 3 --><div class="most-expect-wrapper"><div class="panel"><div class="panel-header"><span class="panel-more"><a href="/jsp/movieList.jsp" class="textcolor_orange" data-act="all-mostExpect-click"><span>查看完整榜单</span></a><span class="panel-arrow panel-arrow-orange"></span></span><span class="panel-title"><span class="textcolor_orange">评分排名</span></span></div><div class="panel-content"><ul class="ranking-wrapper ranking-mostExpect" id="sortMovie"></ul></div></div></div></div><div class="movie-grid"><div class="panel-header"><span class="panel-more"><a href="/jsp/movieList.jsp" class="textcolor_red" data-act="all-playingMovie-click"><span>全部</span></a><span class="panel-arrow panel-arrow-red"></span></span><span class="panel-title hot-title"></span></div><div class="panel-content"><ul class="movie-list movie-hot"></ul></div></div></div></div><!----><jsp:include page="footer.jsp"/>

后端关键代码:
查询所有影片:

List<Movie> list = movieService.findAllMovies(1);List<Movie> offList = movieService.sortMovieByScore();String type[] = {"喜剧","动作","爱情","动画","科幻","惊悚","冒险","犯罪","悬疑"};ArrayList<Object> typeArr = new ArrayList<Object>();for(int i = 0;i < type.length;i++) {List<Movie> movieList = this.movieService.findMoviesLikeType("",type[i],"","","");float boxOffice = 0;for(int j = 0; j < movieList.size();j++) {boxOffice += movieList.get(j).getMovie_boxOffice();}JSONObject typeJson = new JSONObject();typeJson.put(type[i], boxOffice);typeArr.add(typeJson);}

分页查询影片dao实现:

public List<Movie> findAllMoviesPage(int movie_state,int startPage,int endPage){List<Movie> list = new ArrayList<Movie>();String sql = "select * from moviewhere movie_state = ? limit ?,?";Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setInt(1, movie_state);ps.setInt(2, startPage);ps.setInt(3, endPage);rs = ps.executeQuery();while(rs.next()) {Movie movie = new Movie();movie.setMovie_id(rs.getLong("movie_id"));movie.setMovie_cn_name(rs.getString("movie_cn_name"));movie.setMovie_fg_name(rs.getString("movie_fg_name"));movie.setMovie_actor(rs.getString("movie_actor"));movie.setMovie_director(rs.getString("movie_director"));movie.setMovie_detail(rs.getString("movie_detail"));movie.setMovie_duration(rs.getString("movie_duration"));movie.setMovie_type(rs.getString("movie_type"));movie.setMovie_score(rs.getFloat("movie_score"));movie.setMovie_boxOffice(rs.getFloat("movie_boxOffice"));movie.setMovie_commentCount(rs.getLong("movie_commentCount"));movie.setReleaseDate(rs.getDate("movie_releaseDate"));movie.setMovie_picture(rs.getString("movie_picture"));movie.setMovie_country(rs.getString("movie_country"));movie.setMovie_state(rs.getInt("movie_state"));list.add(movie);}return list;} catch (SQLException e) {e.printStackTrace();}finally {JdbcUtil.close(conn, ps, rs);}return list;}

4.1.2 用户注册功能实现

点击导航右侧登录:

进入登录注册页面:

页面代码实现:

<div class="childpage" style="display: none"><div><label class="register_title">用户注册</label><br/></div><div class="register_page"><div><label>帐号</label><br/><input id="UserName" type="text"/></div><div><label>密码</label><br/><input id="PassWord" type="password"/></div><div><label>邮箱</label><br/><input id="Email" type="text"/></div><div><label>验证码</label><br/><input id="Test" type="text"/><input id="TestNum" type="button"/></div></div><div class="re_error"><label class="register_error"></label></div><div><input type="button" value="注册" class="btn btn-warning register_btn" onclick="registerbtn()"/></div>

Ajax发送注册请求后端:

function registerbtn(){var textNum = document.getElementById('TestNum'); var user_name = $(".register_page").find("#UserName").val();var user_pwd = $(".register_page").find("#PassWord").val();var user_email = $(".register_page").find("#Email").val();var register_error = $(".register_error");var test = $("#Test").val();var testbtn = $("#TestNum").val();var patrn=/^([a-zA-Z0-9]){0,7}$/;if (!patrn.exec(user_name)){register_error.text("账号只能输入1-8个字符串");textNum.value = TestNum();return;}var patrnPwd=/^([a-zA-Z0-9]){2,9}$/;if (!patrnPwd.exec(user_pwd)){register_error.text("密码只能输入3-10字符串");textNum.value = TestNum();return;}if((user_name == "") || (user_pwd == "") || (user_email == "")){register_error.text("账号和密码和邮箱不能为空");textNum.value = TestNum();}else if((test == "") || test!=testbtn){register_error.text("验证码错误");textNum.value = TestNum();}else{register_error.text("");$.ajax({type: "post",url: url + "/user",data: {method:'register',user_name: user_name,user_pwd: user_pwd,user_email: user_email},dataType: "json",success: function(data){console.log(data);if(data.state == "success"){window.alert("注册成功!");window.location.href="/jsp/login.jsp";}else{register_error.text('该账号已被注册!');}}});}}

后端dao插入数据逻辑:

public Integer addUser(User user){String sql = "insert into user(user_name,user_pwd,user_email,user_role) values(" />;Connection conn = null;PreparedStatement ps = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setString(1, user.getUser_name());ps.setString(2, user.getUser_pwd());ps.setString(3, user.getUser_email());ps.setInt(4,user.getUser_role());ps.execute();return 1;} catch (SQLException e) {e.printStackTrace();} finally {JdbcUtil.close(conn, ps, null);}return 0;}

4.1.3 用户登录功能实现

用户登录和注册页面类似:

登录逻辑代码:

function loginbtn(){var user_name = $(".login_page").find("#UserName").val();var user_pwd = $(".login_page").find("#PassWord").val();var login_error = $(".login_error");if((user_name == "") || (user_pwd == "")){login_error.text("账号和密码不能为空");}else{login_error.text("");$.ajax({type: "post",url: "/user",data: {method:'login',user_name: user_name,user_pwd: user_pwd},dataType: "json",success: function(obj){if(obj.msg == "fail"){ // sessionStorage.removeItem('userJson');login_error.text('账号或密码错误!');}else{localStorage.setItem("userJson",JSON.stringify(obj.data));// sessionStorage.setwindow.location.href="/jsp/mainPage.jsp";}},error:function(){alert("network error!");}});}}

查询判断逻辑:

public User findUserById(long user_id){String sql = "select * from user where user_id = ?";Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setLong(1, user_id);rs = ps.executeQuery();if(rs.next()) {User user = new User();user.setUser_id(rs.getLong("user_id"));user.setUser_name(rs.getString("user_name"));user.setUser_pwd(rs.getString("user_pwd"));user.setUser_role(rs.getInt("user_role"));user.setUser_email(rs.getString("user_email"));user.setUser_headImg(rs.getString("user_headImg"));return user;}} catch (SQLException e) {e.printStackTrace();}finally {JdbcUtil.close(conn, ps, rs);}return null;}

4.1.4 影片信息查询实现

首页可以展示影片信息,以及通过搜索框注入影片信息实现查询:

前端核心代码:

<jsp:include page="header.jsp"/><ul class="layui-nav fu-nav"><div id="yui"></div><li class="layui-nav-item layui-this"><a>正在热映</a></li></ul><div class="main"><div class="main-Tagsz main-inner movieList"><div class="movies-channel"><div class="tags-panel"><ul class="tags-lines"><li class="tags-line"><div class="tags-title">类型 :</div><ul class="tags tags-type"></ul></li><li class="tags-line tags-line-border"><div class="tags-title">区域 :</div><ul class="tags tags-area"></ul></li><li class="tags-line tags-line-border"><div class="tags-title">年代 :</div><ul class="tags tags-year"></ul></li></ul></div></div><div class="movies-panel"><div class="movies-sorter"><div class="cat-sorter"><ul><li><span class="sort-control-group" data-act="sort-click" ><span class="sort-control sort-radio sort-radio-checked"></span><span class="sort-control-label">按热门排序</span></span></li><li><span class="sort-control-group" data-act="sort-click" data-href="" />"><span class="sort-control sort-radio"></span><span class="sort-control-label">按时间排序</span></span></li><li><span class="sort-control-group" data-act="sort-click" data-href="?sortId=3"><span class="sort-control sort-radio"></span><span class="sort-control-label">按评价排序</span></span></li></ul></div></div><div class="movies-list" style="height:1000px"><ul class="movie-list"></ul></div><div id="demo0"></div></div></div></div>

后端根据名称查询实现:

public List<Movie> findMoviesLikeName(String name){List<Movie> list = new ArrayList<Movie>();String sql = "select * from movie where movie_cn_name like ? and movie_state = 1";Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setString(1, "%"+name+"%");rs = ps.executeQuery();while(rs.next()) {Movie movie = new Movie();movie.setMovie_id(rs.getLong("movie_id"));movie.setMovie_cn_name(rs.getString("movie_cn_name"));movie.setMovie_fg_name(rs.getString("movie_fg_name"));movie.setMovie_actor(rs.getString("movie_actor"));movie.setMovie_director(rs.getString("movie_director"));movie.setMovie_detail(rs.getString("movie_detail"));movie.setMovie_duration(rs.getString("movie_duration"));movie.setMovie_type(rs.getString("movie_type"));movie.setMovie_score(rs.getFloat("movie_score"));movie.setMovie_boxOffice(rs.getFloat("movie_boxOffice"));movie.setMovie_commentCount(rs.getLong("movie_commentCount"));movie.setReleaseDate(rs.getDate("movie_releaseDate"));movie.setMovie_picture(rs.getString("movie_picture"));movie.setMovie_country(rs.getString("movie_country"));movie.setMovie_state(rs.getInt("movie_state"));list.add(movie);}return list;} catch (SQLException e) {e.printStackTrace();}finally {JdbcUtil.close(conn, ps, rs);}return list;}

根据类别参数查询:

public List<Movie> findMoviesLikeType(String order,String type,String area,String year,String searchMovie){List<Movie> list = new ArrayList<Movie>();StringBuilder sql = new StringBuilder("select * from movie where movie_state = 1");Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;try {conn = JdbcUtil.getConnection();if(!"".equals(type)){sql.append(" and movie_type like ?");}if(!"".equals(area)){sql.append(" and movie_country like ?");}if(!"".equals(year)){sql.append(" and movie_releaseDate like ?");}if(searchMovie!=null && !"".equals(searchMovie)){sql.append(" and (movie_cn_name like ? or movie_fg_name like ? )");}switch (order) {case "热门":sql.append(" order by movie_commentCount DESC");break;case "时间":sql.append(" order by movie_releaseDate DESC");break;case "评价":sql.append(" order by movie_score DESC");break;}ps = conn.prepareStatement(sql.toString());int i=1;if(!"".equals(type)){ps.setString(i, "%"+type+"%");i++;}if(!"".equals(area)){ps.setString(i, "%"+area+"%");i++;}if(!"".equals(year)){ps.setString(i, "%"+year+"%");i++;}if(searchMovie!=null && !"".equals(searchMovie)){ps.setString(i, "%"+searchMovie+"%");i++;ps.setString(i, "%"+searchMovie+"%");}rs = ps.executeQuery();while(rs.next()) {Movie movie = new Movie();movie.setMovie_id(rs.getLong("movie_id"));movie.setMovie_cn_name(rs.getString("movie_cn_name"));movie.setMovie_fg_name(rs.getString("movie_fg_name"));movie.setMovie_actor(rs.getString("movie_actor"));movie.setMovie_director(rs.getString("movie_director"));movie.setMovie_detail(rs.getString("movie_detail"));movie.setMovie_duration(rs.getString("movie_duration"));movie.setMovie_type(rs.getString("movie_type"));movie.setMovie_score(rs.getFloat("movie_score"));movie.setMovie_boxOffice(rs.getFloat("movie_boxOffice"));movie.setMovie_commentCount(rs.getLong("movie_commentCount"));movie.setReleaseDate(rs.getDate("movie_releaseDate"));movie.setMovie_picture(rs.getString("movie_picture"));movie.setMovie_country(rs.getString("movie_country"));movie.setMovie_state(rs.getInt("movie_state"));list.add(movie);}return list;} catch (SQLException e) {e.printStackTrace();}finally {JdbcUtil.close(conn, ps, rs);}return list;}public List<Movie> findMoviesLikeTypePage(int startPage,int endPage,String order,String type,String area,String year,String searchMovie){List<Movie> list = new ArrayList<Movie>();StringBuilder sql = new StringBuilder("select * from movie where movie_state = 1");Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;try {conn = JdbcUtil.getConnection();if(!"".equals(type)){sql.append(" and movie_type like ?");}if(!"".equals(area)){sql.append(" and movie_country like ?");}if(!"".equals(year)){sql.append(" and movie_releaseDate like ?");}if(searchMovie!=null && !"".equals(searchMovie)){sql.append(" and (movie_cn_name like ? or movie_fg_name like ? )");}switch (order) {case "热门":sql.append(" order by movie_commentCount DESC");break;case "时间":sql.append(" order by movie_releaseDate DESC");break;case "评价":sql.append(" order by movie_score DESC");break;}sql.append(" limit ?,? ");ps = conn.prepareStatement(sql.toString());int i=1;if(!"".equals(type)){ps.setString(i, "%"+type+"%");i++;}if(!"".equals(area)){ps.setString(i, "%"+area+"%");i++;}if(!"".equals(year)){ps.setString(i, "%"+year+"%");i++;}if(searchMovie!=null && !"".equals(searchMovie)){ps.setString(i, "%"+searchMovie+"%");i++;ps.setString(i, "%"+searchMovie+"%");i++;}ps.setInt(i, startPage);i++;ps.setInt(i, endPage);rs = ps.executeQuery();while(rs.next()) {Movie movie = new Movie();movie.setMovie_id(rs.getLong("movie_id"));movie.setMovie_cn_name(rs.getString("movie_cn_name"));movie.setMovie_fg_name(rs.getString("movie_fg_name"));movie.setMovie_actor(rs.getString("movie_actor"));movie.setMovie_director(rs.getString("movie_director"));movie.setMovie_detail(rs.getString("movie_detail"));movie.setMovie_duration(rs.getString("movie_duration"));movie.setMovie_type(rs.getString("movie_type"));movie.setMovie_score(rs.getFloat("movie_score"));movie.setMovie_boxOffice(rs.getFloat("movie_boxOffice"));movie.setMovie_commentCount(rs.getLong("movie_commentCount"));movie.setReleaseDate(rs.getDate("movie_releaseDate"));movie.setMovie_picture(rs.getString("movie_picture"));movie.setMovie_country(rs.getString("movie_country"));movie.setMovie_state(rs.getInt("movie_state"));list.add(movie);}return list;} catch (SQLException e) {e.printStackTrace();}finally {JdbcUtil.close(conn, ps, rs);}return list;}

4.1.5 影片详情实现

点击影片图片,进入影片介绍页面:

进入详情页面:
页面核心代码实现:

<div class="main"><div class="main-inner main-detail"><div class="main-content"><div class="tab-container"><div class="tab-title-container clearfix"><div class="tab-title active" data-act="tab-desc-click">介绍</div></div><div class="tab-content-container"><div class="tab-desc tab-content active" data-val="{tabtype:'desc'}"><div class="module introduction"><div class="mod-title"><h3>剧情简介</h3></div></div><div class="module staringPeople" ><div class="mod-title"><h3>演职人员</h3></div><div class="mod-content"><div class="celebrity-container clearfix"></div></div></div><div class="module"><div class="mod-title"><h3>热门短评</h3></div><div class="mod-content"><div class="comment-list-container" data-hot="10"><ul></ul></div><a class="comment-entry" data-act="comment-no-content-click" onclick="writeComment()">写短评</a></div><div id="demo0"></div></div></div></div></div></div>

后端核心代码实现:

public Movie findMovieById(long movie_id){String sql = "select * from movie where movie_id = " />;Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setLong(1, movie_id);rs = ps.executeQuery();if(rs.next()) {Movie movie = new Movie();movie.setMovie_id(movie_id);movie.setMovie_cn_name(rs.getString("movie_cn_name"));movie.setMovie_fg_name(rs.getString("movie_fg_name"));movie.setMovie_actor(rs.getString("movie_actor"));movie.setMovie_director(rs.getString("movie_director"));movie.setMovie_detail(rs.getString("movie_detail"));movie.setMovie_duration(rs.getString("movie_duration"));movie.setMovie_type(rs.getString("movie_type"));movie.setMovie_score(rs.getFloat("movie_score"));movie.setMovie_boxOffice(rs.getFloat("movie_boxOffice"));movie.setMovie_commentCount(rs.getLong("movie_commentCount"));movie.setReleaseDate(rs.getDate("movie_releaseDate"));movie.setMovie_picture(rs.getString("movie_picture"));movie.setMovie_country(rs.getString("movie_country"));movie.setMovie_state(rs.getInt("movie_state"));return movie;}} catch (SQLException e) {e.printStackTrace();}finally {JdbcUtil.close(conn, ps, rs);}return null;}

4.1.6 用户评论评分实现

点击“评分”按钮:


下方会显示点评信息;

页面核心代码实现:

 <div class="module"><div class="mod-title"><h3>热门短评</h3></div><div class="mod-content"><div class="comment-list-container" data-hot="10"><ul></ul></div><a class="comment-entry" data-act="comment-no-content-click" onclick="writeComment()">写短评</a></div><div id="demo0"></div></div></div>

后端核心代码实现:

public Integer addComemnt(Comment comment){String sql = "insert into comment(comment_content,comment_time,movie_id,user_id,comment_score)values(" />;Connection conn = null;PreparedStatement ps = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setString(1, comment.getComment_content());ps.setTimestamp(2, new Timestamp(comment.getComment_time().getTime()));ps.setLong(3, comment.getMovie_id());ps.setLong(4, comment.getUser_id());ps.setInt(5, comment.getComment_score());ps.execute();return 1;} catch (SQLException e) {e.printStackTrace();} finally {JdbcUtil.close(conn, ps, null);}return 0;}

4.1.7 用户订座位实现

进入影片详情,选择好日期和影城,然后点击“选座购票”按钮

选好座位后,点击“确认选座”;

前端核心代码实现:

<div class="container"><div class="order-progress-bar"><div class="step first done"><span class="step-num">1</span><div class="bar"></div><span class="step-next">选择影片场次</span></div><div class="step done"><span class="step-num">2</span><div class="bar"></div><span class="step-next">选择座位</span></div><div class="step"><span class="step-num">3</span><div class="bar"></div><span class="step-next">付款</span></div><div class="step last"><span class="step-num">4</span><div class="bar"></div><span class="step-next">影院取票观影</span></div></div><div class="main"><div class="hall"><div class="seat-example"><div class="selectable-example example"><span>可选座位</span></div><div class="sold-example example"><span>已售座位</span></div><div class="selected-example example"><span>已选座位</span></div><div class="couple-example example"><span>情侣座位</span></div></div><div class="seats-block"><div class="row-id-container"></div><div class="seats-container"><div class="screen-container"><div class="screen">银幕中央</div><div class="c-screen-line"></div></div><div class="seats-wrapper"></div></div></div></div><div class="side"><div class="movie-info clearfix"></div><div class="show-info"></div><div class="ticket-info"><div class="no-ticket" style="display: block;"><p class="buy-limit">座位:一次最多选4个座位</p></div><div class="has-ticket" style="display: none;"><span class="text">座位:</span><div class="ticket-container"></div></div><div class="total-price"><span>总价:</span><span class="price"></span></div></div><div class="confirm-order"><div class="email"><span>邮箱号:</span></div><div class="confirm-btn disable" onclick="confirm()">确认选座</div></div></div></div></div>

4.1.8 用户下单实现

在之前“选座”后,进入支付页面;

点击“确认支付”,直接模拟支付;

支付完结,购票成功;个人中心可以查看;

前端核心代码实现:

<div class="container"><div class="order-progress-bar"><div class="step first done"><span class="step-num">1</span><div class="bar"></div><span class="step-next">选择影片场次</span></div><div class="step done"><span class="step-num">2</span><div class="bar"></div><span class="step-next">选择座位</span></div><div class="step done"><span class="step-num">3</span><div class="bar"></div><span class="step-next">付款</span></div><div class="step last"><span class="step-num">4</span><div class="bar"></div><span class="step-next">影院取票观影</span></div></div><div class="count-down-wrapper"><div class="count-down"><p class="time-left">请在<span class="minute"></span>分钟<span class="second"></span>秒内完成支付</p><p class="tip">超时订单会自动取消,如遇支付问题,请联系管理员</p></div></div><p class="warning">请仔细核对场次信息,出票后将<span class="attention">无法退票和改签</span></p><table class="order-table"><thead><tr><th>影片</th><th>时间</th><th>影院</th><th>座位</th></tr></thead><tbody> </tbody></table><div class="right"><div class="price-wrapper"><span>实际支付:</span><span class="price"></span></div><div><div class="pay-btn">确认支付</div></div></div></div>

后端核心代码实现:

public Integer addOrder(Order order){String sql = "insert into orderinfo(order_id,order_position,schedule_id,user_id,order_price,order_time,order_state) values(" />;Connection conn = null;PreparedStatement ps = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setString(1, order.getOrder_id());ps.setString(2, order.getOrder_position());ps.setLong(3, order.getSchedule_id());ps.setLong(4, order.getUser_id());ps.setInt(5, order.getOrder_price());ps.setTimestamp(6, new Timestamp(order.getOrder_time().getTime()));ps.setInt(7, order.getOrder_state());ps.execute();return 1;} catch (SQLException e) {e.printStackTrace();} finally {JdbcUtil.close(conn, ps, null);}return 0;}

4.1.9 用户个人中心实现

点击右上方导航,进入“个人中心”;

可以查看订单信息,以及修改个人基本信息;

和修改密码;

前端核心代码实现:

<div class="nav-body"><div class="one card" style="display: block;"><div><div class="title">我的订单</div><hr/></div></div><div class="two card" style="display: none;"><div><div class="title">基本信息</div><hr/></div><div class="avatar-container layui-upload"><div class="layui-upload-list"><img class="layui-upload-img" id="demo1"><p id="demoText"></p></div><a href="javascript:;" class="file">选择文件<input type="file" name="file" id="file"></a><div class="tips">支持JPG,JPEG,PNG格式,且文件需小于1000KB</div></div><div class="avatar-body"></div></div><div class="three card" style="display: none;"><div><div class="title">修改密码</div><hr/></div><div class="avatar-body"></div></div></div>

后端核心代码实现:
查询所有订单:

public List<Order> findAllOrders(){String sql = "select * from orderinfo order by order_time desc";Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;List<Order> list = new ArrayList<Order>();try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);rs = ps.executeQuery();while(rs.next()) {Order order = new Order();order.setOrder_id(rs.getString("order_id"));order.setOrder_position(rs.getString("order_position"));order.setOrder_state(rs.getInt("order_state"));order.setSchedule_id(rs.getLong("schedule_id"));order.setUser_id(rs.getLong("user_id"));order.setOrder_price(rs.getInt("order_price"));order.setOrder_time(rs.getDate("order_time"));list.add(order);}return list;} catch (SQLException e) {e.printStackTrace();}finally {JdbcUtil.close(conn, ps, rs);}return list;}

修改个人基本信息:

public Integer updateUser(User user){StringBuilder sql = new StringBuilder("update user set ");if(user.getUser_name() != null && !"".equals(user.getUser_name())){sql.append("user_name = '"+user.getUser_name()+"',");}if(user.getUser_pwd() != null && !"".equals(user.getUser_pwd())){sql.append("user_pwd = '"+user.getUser_pwd()+"',");}if(user.getUser_email() != null && !"".equals(user.getUser_email())){sql.append("user_email = '"+user.getUser_email()+"',");}if(user.getUser_headImg() != null && !"".equals(user.getUser_headImg())){sql.append("user_headImg = '"+user.getUser_headImg()+"',");}sql.deleteCharAt(sql.length() - 1);sql.append(" where user_id = " />);Connection conn = null;PreparedStatement ps = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql.toString());ps.setLong(1, user.getUser_id());ps.execute();return 1;} catch (SQLException e) {e.printStackTrace();} finally {JdbcUtil.close(conn, ps, null);}return 0;}

4.2 后台系统设计实现

4.2.1 管理员登录实现

管理员登录页面和普通用户登录页面是一个,只不过管理员根据角色,有自己的账号;

设计的时候,通过user_role来判断;

4.2.2 后台主页面实现

点击顶部菜单“管理”,进入管理页面;

有“用户管理”,“电影管理”,“放映厅管理”,“场次管理”,“评论管理”,“订单管理”
前端核心代码实现:

<div class="container"><div class="contents"><div class="nav-next"><div class="nav-title"><h3>后台管理</h3></div><a class="cardId" href="/jsp/manage/user.jsp">用户管理</a><a class="cardId" href="/jsp/manage/movie.jsp">电影管理</a><a class="cardId" href="/jsp/manage/cinema.jsp">影院管理</a><a class="cardId" href="/jsp/manage/hall.jsp">放映厅管理</a><a class="cardId" href="/jsp/manage/schedule.jsp">场次管理</a><a class="cardId" href="/jsp/manage/comment.jsp">评论管理</a><a class="cardId" href="/jsp/manage/order.jsp">订单管理</a></div><div class="nav-body"><div class="six card"><div><div class="title">影院管理</div><hr/></div><div class="cinemalist"><table class="layui-hide" id="cinema_table_id" lay-filter="CinemaTable" style="margin-right: 5%;"></table></div></div></div></div></div>

4.2.3 用户管理实现

点击“用户管理”,进入用户管理界面,可以查询用户,添加用户,删除用户;

点击“添加用户”;

输入账号,密码,邮箱,点击“确认添加”,验证无误,则添加成功;双击行的单元格,即可直接编辑用户信息,点击保存,即可完成修改;

前端核心代码实现:

<div class="container"><div class="contents"><div class="nav-next"><div class="nav-title"><h3>后台管理</h3></div><a class="cardId" href="/jsp/manage/user.jsp">用户管理</a><a class="cardId" href="/jsp/manage/movie.jsp">电影管理</a><a class="cardId" href="/jsp/manage/cinema.jsp">影院管理</a><a class="cardId" href="/jsp/manage/hall.jsp">放映厅管理</a><a class="cardId" href="/jsp/manage/schedule.jsp">场次管理</a><a class="cardId" href="/jsp/manage/comment.jsp">评论管理</a><a class="cardId" href="/jsp/manage/order.jsp">订单管理</a></div><div class="nav-body"><div class="one card" style="display: block;"><div><div class="title">用户管理</div><hr/></div><div class="userlist"><table class="layui-hide" id="user_table_id" lay-filter="UserTable" style="margin-right: 5%;"></table></div></div></div></div></div><jsp:include page="../footer.jsp"/><script type="text/html" id="userbar"><a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a><a class="layui-btn layui-btn-xs" lay-event="edit">保存</a></script><script type="text/html" id="usertoolbar"><div class="layui-btn-container adduserbtn"><button class="layui-btn layui-btn-warm layui-btn-sm" lay-event="useradd">添加用户</button> </div><div class="usercheck"><input id="userfindtext" type="text" name="title" lay-verify="title" autocomplete="off" placeholder="请输入用户账号" class="layui-input"><button class="layui-btn layui-btn-sm" lay-event="finduserbtn">搜索</button> </div>

后端核心代码实现:

public Integer addUser(User user){String sql = "insert into user(user_name,user_pwd,user_email,user_role) values(" /><User> findAllUser(){List<User> list = new ArrayList<User>();String sql = "select * from user";Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);rs = ps.executeQuery();while(rs.next()) {User user = new User();user.setUser_id(rs.getLong("user_id"));user.setUser_name(rs.getString("user_name"));user.setUser_pwd(rs.getString("user_pwd"));user.setUser_role(rs.getInt("user_role"));user.setUser_email(rs.getString("user_email"));user.setUser_headImg(rs.getString("user_headImg"));list.add(user);}return list;} catch (SQLException e) {e.printStackTrace();}finally {JdbcUtil.close(conn, ps, rs);}return list;}public List<User> findAllUserPage(int startPage,int endPage){List<User> list = new ArrayList<User>();String sql = "select * from user limit ?,?";Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setInt(1, startPage);ps.setInt(2, endPage);rs = ps.executeQuery();while(rs.next()) {User user = new User();user.setUser_id(rs.getLong("user_id"));user.setUser_name(rs.getString("user_name"));user.setUser_pwd(rs.getString("user_pwd"));user.setUser_role(rs.getInt("user_role"));user.setUser_email(rs.getString("user_email"));user.setUser_headImg(rs.getString("user_headImg"));list.add(user);}return list;} catch (SQLException e) {e.printStackTrace();}finally {JdbcUtil.close(conn, ps, rs);}return list;}

4.2.4 影片管理实现

点击“电影管理”菜单:

进入菜单管理界面,可以添加电影,修改和删除电影;

点击“添加电影”:

进入电影添加页面,输入电影信息,点击“添加”按钮,即可完成电影添加;

点击“修改”按钮,弹出修改页面;

完成修改后,点击“修改”按钮,即可完成修改;
点击删除,则删除电影信息;
前端核心代码实现:

<div class="nav-body"><div class="two card"><div><div class="title">电影管理</div><hr/></div><div class="main-inner"><div class="addMovie"><img alt="" src="${ctx }/static/images/addMovie.png" onclick="addConfirm(-1)"><span>添加电影</span></div><div class="movie-grid"><div class="panel-header"><span class="panel-title"></span></div><div id="demo0"></div><div class="panel-content"><ul class="movies-list"></ul></div></div></div></div></div>

后端核心代码实现:

public Movie findMovieByName(String movie_cn_name){String sql = "select * from moviewhere movie_cn_name = " />;Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setString(1, movie_cn_name);rs = ps.executeQuery();if(rs.next()) {Movie movie = new Movie();movie.setMovie_id(rs.getLong("movie_id"));movie.setMovie_cn_name(rs.getString("movie_cn_name"));movie.setMovie_fg_name(rs.getString("movie_fg_name"));movie.setMovie_actor(rs.getString("movie_actor"));movie.setMovie_director(rs.getString("movie_director"));movie.setMovie_detail(rs.getString("movie_detail"));movie.setMovie_duration(rs.getString("movie_duration"));movie.setMovie_type(rs.getString("movie_type"));movie.setMovie_score(rs.getFloat("movie_score"));movie.setMovie_boxOffice(rs.getFloat("movie_boxOffice"));movie.setMovie_commentCount(rs.getLong("movie_commentCount"));movie.setReleaseDate(rs.getDate("movie_releaseDate"));movie.setMovie_picture(rs.getString("movie_picture"));movie.setMovie_country(rs.getString("movie_country"));movie.setMovie_state(rs.getInt("movie_state"));return movie;}} catch (SQLException e) {e.printStackTrace();}finally {JdbcUtil.close(conn, ps, rs);}return null;}public Integer addMovie(Movie movie){String sql = "insert into movie(movie_cn_name,movie_fg_name,movie_actor,movie_director,movie_detail,movie_duration,movie_type,movie_score,movie_releaseDate,movie_country,movie_picture,movie_state) "+"values(?,?,?,?,?,?,?,?,?,?,?,?)";Connection conn = null;PreparedStatement ps = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setString(1, movie.getMovie_cn_name());ps.setString(2, movie.getMovie_fg_name());ps.setString(3, movie.getMovie_actor());ps.setString(4, movie.getMovie_director());ps.setString(5, movie.getMovie_detail());ps.setString(6, movie.getMovie_duration());ps.setString(7, movie.getMovie_type());ps.setFloat(8, movie.getMovie_score());ps.setDate(9, new java.sql.Date(movie.getReleaseDate().getTime()));ps.setString(10, movie.getMovie_country());ps.setString(11, movie.getMovie_picture());ps.setInt(12, movie.getMovie_state());ps.execute();return 1;} catch (SQLException e) {e.printStackTrace();} finally {JdbcUtil.close(conn, ps, null);}return 0;}public Integer deleteMovie(long movie_id){String sql = "delete from movie where movie_id = ?";Connection conn = null;PreparedStatement ps = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setLong(1, movie_id);ps.execute();return 1;} catch (SQLException e) {e.printStackTrace();} finally {JdbcUtil.close(conn, ps, null);}return 0;}public Integer updateMovie(Movie movie){String sql = "update movie set movie_cn_name = ?,"+"movie_fg_name = ?,"+"movie_actor = ?,"+"movie_director = ?,"+"movie_detail = ?,"+"movie_duration = ?,"+"movie_type = ?,"+"movie_country = ?,"+"movie_picture = ?,"+"movie_releaseDate = ?"+"where movie_id = ?";Connection conn = null;PreparedStatement ps = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setString(1, movie.getMovie_cn_name());ps.setString(2, movie.getMovie_fg_name());ps.setString(3, movie.getMovie_actor());ps.setString(4, movie.getMovie_director());ps.setString(5, movie.getMovie_detail());ps.setString(6, movie.getMovie_duration());ps.setString(7, movie.getMovie_type());ps.setString(8, movie.getMovie_country());ps.setString(9, movie.getMovie_picture());ps.setDate(10, new java.sql.Date(movie.getReleaseDate().getTime()));ps.setLong(11, movie.getMovie_id());ps.execute();return 1;} catch (SQLException e) {e.printStackTrace();} finally {JdbcUtil.close(conn, ps, null);}return 0;}

4.3.5 影院管理实现

点击“影院管理”,进入影院管理页面;

操作和前面类似,这里不赘述;

前端核心代码实现:

<div class="nav-body"><div class="six card"><div><div class="title">影院管理</div><hr/></div><div class="cinemalist"><table class="layui-hide" id="cinema_table_id" lay-filter="CinemaTable" style="margin-right: 5%;"></table></div></div></div>

后端核心代码实现:

public Cinema findCinemaById(long cinema_id){String sql = "select * from cinema where cinema_id = " />;Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setLong(1, cinema_id);rs = ps.executeQuery();if(rs.next()) {Cinema cinema = new Cinema();cinema.setCinema_id(rs.getLong("cinema_id"));cinema.setCinema_name(rs.getString("cinema_name"));cinema.setCinema_address(rs.getString("cinema_address"));return cinema;}} catch (SQLException e) {e.printStackTrace();}finally {JdbcUtil.close(conn, ps, rs);}return null;}public Integer addCinema(Cinema cinema){String sql = "insert into cinema(cinema_name,cinema_address) values(?,?)";Connection conn = null;PreparedStatement ps = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setString(1, cinema.getCinema_name());ps.setString(2, cinema.getCinema_address());ps.execute();return 1;} catch (SQLException e) {e.printStackTrace();} finally {JdbcUtil.close(conn, ps, null);}return 0;}public Integer updateCinema(Cinema cinema){String sql = "update cinema set cinema_name = ?,cinema_address = ? where cinema_id = ?";Connection conn = null;PreparedStatement ps = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setString(1, cinema.getCinema_name());ps.setString(2, cinema.getCinema_address());ps.setLong(3, cinema.getCinema_id());ps.execute();return 1;} catch (SQLException e) {e.printStackTrace();} finally {JdbcUtil.close(conn, ps, null);}return 0;}public Integer deleteCinema(long cinema_id){String sql = "delete from cinema where cinema_id = ?";Connection conn = null;PreparedStatement ps = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setLong(1, cinema_id);ps.execute();return 1;} catch (SQLException e) {e.printStackTrace();} finally {JdbcUtil.close(conn, ps, null);}return 0;}public List<Cinema> findAllCinemas(){List<Cinema> list = new ArrayList<Cinema>();String sql = "select * from cinema";Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);rs = ps.executeQuery();while(rs.next()) {Cinema cinema = new Cinema();cinema.setCinema_id(rs.getLong("cinema_id"));cinema.setCinema_name(rs.getString("cinema_name"));cinema.setCinema_address(rs.getString("cinema_address"));list.add(cinema);}return list;} catch (SQLException e) {e.printStackTrace();}finally {JdbcUtil.close(conn, ps, rs);}return list;}

4.3.6 放映厅管理实现

点击“放映厅管理”,进入影院管理页面;

操作和前面类似,这里不赘述;

前端核心代码实现:

<div class="nav-body"><div class="six card"><div><div class="title">放映厅管理</div><hr/></div><div class="cinemalist"><table class="layui-hide" id="hall_table_id" lay-filter="HallTable" style="margin-right: 5%;"></table></div></div></div>

后端核心代码实现:

public Hall findHallById(long hall_id){String sql = "select * from hall where hall_id = " />;Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setLong(1, hall_id);rs = ps.executeQuery();if(rs.next()) {Hall hall = new Hall();hall.setHall_id(rs.getLong("hall_id"));hall.setHall_name(rs.getString("hall_name"));hall.setHall_capacity(rs.getInt("hall_capacity"));hall.setCinema_id(rs.getLong("cinema_id"));return hall;}} catch (SQLException e) {e.printStackTrace();}finally {JdbcUtil.close(conn, ps, rs);}return null;}public Hall findHallByCinemaAndHallName(String cinema_name,String hall_name){String sql = "select hall.* from hall,cinema where hall.cinema_id = cinema.cinema_id and cinema_name = ? and hall_name= ?";Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setString(1, cinema_name);ps.setString(2, hall_name);rs = ps.executeQuery();if(rs.next()) {Hall hall = new Hall();hall.setHall_id(rs.getLong("hall_id"));hall.setHall_name(rs.getString("hall_name"));hall.setHall_capacity(rs.getInt("hall_capacity"));hall.setCinema_id(rs.getLong("cinema_id"));return hall;}} catch (SQLException e) {e.printStackTrace();}finally {JdbcUtil.close(conn, ps, rs);}return null;}public Integer addHall(Hall hall){String sql = "insert into hall(hall_name,cinema_id,hall_capacity)values(?,?,?)";Connection conn = null;PreparedStatement ps = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setString(1, hall.getHall_name());ps.setLong(2, hall.getCinema_id());ps.setInt(3,hall.getHall_capacity());ps.execute();return 1;} catch (SQLException e) {e.printStackTrace();} finally {JdbcUtil.close(conn, ps, null);}return 0;}public Integer updateHall(Hall hall){String sql = "update hall set hall_name = ?,hall_capacity = ? where hall_id = ?";Connection conn = null;PreparedStatement ps = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setString(1, hall.getHall_name());ps.setInt(2, hall.getHall_capacity());ps.setLong(3,hall.getHall_id());ps.execute();return 1;} catch (SQLException e) {e.printStackTrace();} finally {JdbcUtil.close(conn, ps, null);}return 0;}public Integer deleteHall(long hall_id){String sql = "delete from hall where hall_id = ?";Connection conn = null;PreparedStatement ps = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setLong(1, hall_id);ps.execute();return 1;} catch (SQLException e) {e.printStackTrace();} finally {JdbcUtil.close(conn, ps, null);}return 0;}

4.3.7 场次管理实现

点击“场次管理”,进入影院管理页面;

基本操作和前面一样,多了一个 “显示上映”和“显示下架”查询;

前端核心代码实现:

<div class="three card"><div><div class="title">场次管理</div><hr/></div><div class="schedulelist"><table class="layui-hide" id="schedule_table_id" lay-filter="ScheduleTable" style="margin-right: 5%;"></table></div></div>

后端核心代码实现:

public Schedule findScheduleById(long schedule_id){String sql = "select * from schedule where schedule_id = " />;Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setLong(1, schedule_id);rs = ps.executeQuery();if(rs.next()) {Schedule schedule = new Schedule();schedule.setSchedule_id(rs.getLong("schedule_id"));schedule.setHall_id(rs.getLong("hall_id"));schedule.setMovie_id(rs.getLong("movie_id"));schedule.setSchedule_price(rs.getInt("schedule_price"));schedule.setSchedule_startTime(rs.getString("schedule_startTime"));schedule.setSchedule_remain(rs.getInt("schedule_remain"));schedule.setSchedule_state(rs.getInt("schedule_state"));return schedule;}} catch (SQLException e) {e.printStackTrace();}finally {JdbcUtil.close(conn, ps, rs);}return null;}public Integer addSchedule(Schedule schedule){String sql = "insert into schedule(hall_id,movie_id,schedule_price,schedule_remain,schedule_startTime,schedule_state) values(?,?,?,?,?,?)";Connection conn = null;PreparedStatement ps = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setLong(1, schedule.getHall_id());ps.setLong(2, schedule.getMovie_id());ps.setInt(3, schedule.getSchedule_price());ps.setInt(4, schedule.getSchedule_remain());ps.setString(5, schedule.getSchedule_startTime());ps.setInt(6, schedule.getSchedule_state());ps.execute();return 1;} catch (SQLException e) {e.printStackTrace();} finally {JdbcUtil.close(conn, ps, null);}return 0;}public Integer updateSchedule(Schedule schedule){String sql = "update schedule set schedule_price = ?where schedule_id = ?";Connection conn = null;PreparedStatement ps = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setLong(1, schedule.getHall_id());ps.setLong(2, schedule.getMovie_id());ps.setInt(1, schedule.getSchedule_price());ps.setInt(4, schedule.getSchedule_remain());ps.setString(5, schedule.getSchedule_startTime());ps.execute();return 1;} catch (SQLException e) {e.printStackTrace();} finally {JdbcUtil.close(conn, ps, null);}return 0;}public Integer deleteSchedule(long schedule_id){String sql = "update schedule set schedule_state = 0 where schedule_id = ?";Connection conn = null;PreparedStatement ps = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setLong(1, schedule_id);ps.execute();return 1;} catch (SQLException e) {e.printStackTrace();} finally {JdbcUtil.close(conn, ps, null);}return 0;}

4.3.8 评论管理实现

点击“评论管理”,进入影院管理页面;

操作和前面类似,这里不赘述;

前端核心代码实现:

 <div class="nav-body"><div class="four card"><div><div class="title">评论管理</div><hr/></div><div class="commentlist"><table class="layui-hide" id="comment_table_id" lay-filter="CommentTable" style="margin-right: 5%;"></table></div></div></div>

后端核心代码实现:

public Comment findCommentById(long comment_id){String sql = "select * from comment where comment_id = " />;Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setLong(1, comment_id);rs = ps.executeQuery();if(rs.next()) {Comment comment = new Comment();comment.setComment_id(comment_id);comment.setUser_id(rs.getLong("user_id"));comment.setMovie_id(rs.getLong("movie_id"));comment.setComment_content(rs.getString("comment_content"));comment.setComment_time(rs.getTimestamp("comment_time"));comment.setComment_score(rs.getInt("comment_score"));return comment;}} catch (SQLException e) {e.printStackTrace();}finally {JdbcUtil.close(conn, ps, rs);}return null;}public Integer addComemnt(Comment comment){String sql = "insert into comment(comment_content,comment_time,movie_id,user_id,comment_score)values(?,?,?,?,?)";Connection conn = null;PreparedStatement ps = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setString(1, comment.getComment_content());ps.setTimestamp(2, new Timestamp(comment.getComment_time().getTime()));ps.setLong(3, comment.getMovie_id());ps.setLong(4, comment.getUser_id());ps.setInt(5, comment.getComment_score());ps.execute();return 1;} catch (SQLException e) {e.printStackTrace();} finally {JdbcUtil.close(conn, ps, null);}return 0;}public Integer updateComment(Comment comment){String sql = "update comment set comment_content = ?,movie_id = ?,user_id = ? where comment_id = ?";Connection conn = null;PreparedStatement ps = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setString(1, comment.getComment_content());ps.setLong(2, comment.getMovie_id());ps.setLong(3, comment.getUser_id());ps.setLong(4, comment.getComment_id());ps.execute();return 1;} catch (SQLException e) {e.printStackTrace();} finally {JdbcUtil.close(conn, ps, null);}return 0;}public Integer deleteComment(long comment_id){String sql = "delete from comment where comment_id = ?";Connection conn = null;PreparedStatement ps = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setLong(1, comment_id);ps.execute();return 1;} catch (SQLException e) {e.printStackTrace();} finally {JdbcUtil.close(conn, ps, null);}return 0;}public List<Comment> findAllComments(){List<Comment> list = new ArrayList<Comment>();String sql = "select * from comment";Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);rs = ps.executeQuery();while(rs.next()) {Comment comment = new Comment();comment.setComment_id(rs.getLong("comment_id"));comment.setUser_id(rs.getLong("user_id"));comment.setMovie_id(rs.getLong("movie_id"));comment.setComment_content(rs.getString("comment_content"));comment.setComment_time(rs.getTimestamp("comment_time"));comment.setComment_score(rs.getInt("comment_score"));list.add(comment);}return list;} catch (SQLException e) {e.printStackTrace();}finally {JdbcUtil.close(conn, ps, rs);}return list;}

4.3.9 订单管理实现

点击“订单管理”,进入影院管理页面;

操作和前面类似,这里不赘述;

前端核心代码实现:

<div class="nav-body"><div class="five card"><div><div class="title">订单管理</div><hr/></div><div class="ticketlist"><table class="layui-hide" id="ticket_table_id" lay-filter="TicketTable" style="margin-right: 5%;"></table></div></div>

后端核心代码实现:

public Order findOrderById(String order_id){String sql = "select * from orderinfo where order_id = " />;Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setString(1, order_id);rs = ps.executeQuery();if(rs.next()) {Order order = new Order();order.setOrder_id(order_id);order.setOrder_position(rs.getString("order_position"));order.setOrder_state(rs.getInt("order_state"));order.setSchedule_id(rs.getLong("schedule_id"));order.setUser_id(rs.getLong("user_id"));order.setOrder_price(rs.getInt("order_price"));order.setOrder_time(rs.getDate("order_time"));return order;}} catch (SQLException e) {e.printStackTrace();}finally {JdbcUtil.close(conn, ps, rs);}return null;}public Integer addOrder(Order order){String sql = "insert into orderinfo(order_id,order_position,schedule_id,user_id,order_price,order_time,order_state) values(?,?,?,?,?,?,?)";Connection conn = null;PreparedStatement ps = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setString(1, order.getOrder_id());ps.setString(2, order.getOrder_position());ps.setLong(3, order.getSchedule_id());ps.setLong(4, order.getUser_id());ps.setInt(5, order.getOrder_price());ps.setTimestamp(6, new Timestamp(order.getOrder_time().getTime()));ps.setInt(7, order.getOrder_state());ps.execute();return 1;} catch (SQLException e) {e.printStackTrace();} finally {JdbcUtil.close(conn, ps, null);}return 0;}//申请退票public Integer updateOrderStateToRefund(String order_id){String sql = "update orderinfo set order_state = 0 where order_id = ?";Connection conn = null;PreparedStatement ps = null;try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setString(1, order_id);ps.execute();return 1;} catch (SQLException e) {e.printStackTrace();} finally {JdbcUtil.close(conn, ps, null);}return 0;}public List<Order> findRefundOrderByUserName(String user_name){String sql = "select orderinfo.*from orderinfo,user where orderinfo.user_id = user.user_id and user.user_name = ? and orderinfo.order_state = 0 order by order_time desc";Connection conn = null;PreparedStatement ps = null;ResultSet rs = null;List<Order> list = new ArrayList<Order>();try {conn = JdbcUtil.getConnection();ps = conn.prepareStatement(sql);ps.setString(1, user_name);rs = ps.executeQuery();while(rs.next()) {Order order = new Order();order.setOrder_id(rs.getString("order_id"));order.setOrder_position(rs.getString("order_position"));order.setOrder_state(rs.getInt("order_state"));order.setSchedule_id(rs.getLong("schedule_id"));order.setUser_id(rs.getLong("user_id"));order.setOrder_price(rs.getInt("order_price"));order.setOrder_time(rs.getDate("order_time"));list.add(order);}} catch (SQLException e) {e.printStackTrace();}finally {JdbcUtil.close(conn, ps, rs);}return null;}

5.参考文献

[1]李刚.轻量级Java EE企业应用实战(第3版)【M】.电子工业出版社.2011.2.
[2]李钟尉.Java开发实战1200例【M】.清华大学出版社, 2011.6.
[3]刁成嘉,刁奕. UML系统建模与分析设计【M】.机械工业出版社, 2008.1.
[4]杨琳洁. 网上订票系统的研究与应用.铁路计算机应用, 2004.10.
[5]梁立新. 项目实践精解.【M】.电子工业出版社, 2006.
[6]赵韶平.PowerDesigner系统分析与建模(第2版).清华大学出版社,2010
[7]Ralph M. Stair, George W.Reymilds.Principles ofInformation Systems Thomson
Learing(sixthedition)【M】.北京:机械工业出版社,2003.
[8] Sum Mircosystems.JSP Developers Guide[EB/01].http://www.javasofl.com/Products/jsp.
[9] Barrett Daniel J,Silverman Ricbard E. SSH,The Secure Shell: the Definitive Guide【M】.中国电力出版社,2003
[10]John Beresniewicz,Adrian Billington,Martin Büchi,Melanie Caffrey,Ron Crisco . Oracle PL/SQL实战. 人民邮电出版社,2012

6.源码获取

精彩专栏推荐订阅:在下方专栏

Java精品项目源码大全
https://blog.csdn.net/bruceliu_code/category_9538286.html

欢迎大家点赞收藏关注评论啦 、查看下方二维码获取联系方式