当前位置:文档之家› 面向对象程序的设计实训说明书_电影院网上订票系统设计

面向对象程序的设计实训说明书_电影院网上订票系统设计

中北大学面向对象程序设计实训说明书学院、系:软件学院专业:软件工程学生班级:13140A01学生姓名:景贝贝学号:1314011438 设计题目:电影院网上订票系统设计起迄日期: 2015年6月29日- 2015年7月10日指导教师:秋翔2015 年 7月 8 日实训任务书实训任务书一、需求分析需求分析包括可行性分析、系统流程图和数据流图,数据字典。

可行性分析包括技术可行性、经济可行性和操作可行性。

1.1 可行性分析1.1.1 技术可行性根据电影院提出的系统功能、性能及实现系统的各种约束条件,根据新系统目标来衡量所需的技术是否具备,本系统是一个数据库管理和查询的系统,现有的技术已较为成熟,硬件、软件的性能要求、环境条件等各项条件良好,估计利用现有技术条件应完全可以达到该系统的功能目标。

同时,考虑给予的开发期限也较为充裕,预计系统是可以在规定期限完成开发的。

由以上分析可知,影院售票系统的开发在技术上是可行的。

1.1.2 经济可行性电影院具有信息化的处理设施,并且拥有支持本系统的应用平台。

因此无需再投入资金购买其他设施。

系统的开发基于本人对程序开发的实践学习而来,电影院无需资金投入,并且软件开发过程投入的成本不高,因此开发经费完全可以接受。

由以上分析可知,影院售票系统在经济上是可行的。

1.1.3 操作可行性根据系统页面用户可以自动查询影片信息。

还可浏览完影片信息以后操作订票、退票等功能。

管理员也可以在后台添加、修改并删除影片信息,还可以管理注册用户信息和用户订票信息。

由以上分析可知本系统在操作上也是可行的。

1.2 系统流程图首先未注册的用户要先注册,注册完了以后输入用户名和密码进入页面。

根据上的影片信息用户可以选择自己喜欢的电影来订票。

然后订票信息会自动存储到后台订票信息数据当中。

本系统的具体流程为如图所示。

系统流程图1.3 数据流图本系统的基本模型数据流图为如图所示。

系统基本模型数据流图系统功能数据流图1.4数据需求(1)影片信息:电影名称、导演、演员、电影简介、语言、片场(分钟)、放映日期、时间、价格、票数、(2)订票信息:电影名称、放映时间、放映大厅、座位号、票价(单价)(3)用户信息:用户名、用户密码、手机号(4)放映厅信息:放映大厅名字、座位数1.5数据字典Film(电影表)seatname 放映大厅varchar10)10列名含义类型长度取值围UID 用户序号Int 2 1-1010 50username 用户名varchar(10)10 0-9password 用户密码varchar(10)列名含义类型长度取值围10 50Adminname 用户名varchar(10)10 0-9password 用户密码varchar(10)Seat(座位类别)列名含义类型长度取值围Seatid 主键Int 1-103 1-100seatname 座位编号Nvarchar(10)二、概要设计从数据需求分析中得出系统的实体属性图,遵循三式原则,对实体之间的依关系进行了整合,得出本系统E-R图,如图所示。

系统E-R图其中影片信息实体属性图又为如下图所示。

影片信息实体属性图订单详情实体属性图为如图所示。

图影片场次实体属性图用户实体属性图为如图所示。

图用户信息实体属性图全局概念E-R图三、详细设计ER图向关系模型的转换影片(影片编号,类别,票价,播放日期,名称,导演,片长)影票(影票编号,票价,播放日期,影片名称,座位号)注册用户(用户编号,用户名,密码)放映大厅(大厅编号,名字)座位(座位id,座位号)Orders(orderId,FName,Time,Hall,Number,Money);Seat(SEID,seatname);Hall(HID,HHall);User(username,password,phonenumber);Film(FID,FilmName,FDirector,FLanguage,FLong,FDate,FMoney,FNumber,FTimeID);列名含义类型长度其他TId 影票号Int 主码20TFName 电影名称Nvarchar(20)50TDate 放映日期Nvarchar(50)TTime 放映时间Nvarchar(5050)HID 放映大Nvarchar(1010 外部码user(用户表)四、编码实现文件目录IOrderDAOimpl.javapackage.movie.impl;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.util.ArrayList;import java.util.List;import.movie.dao.IOrderDAO;import.movie.vo.FilmInformation;import.movie.vo.Order;public class OrderDAOImpl implements IOrderDAO{private Connection conn;private PreparedStatement pstmt = null;private PreparedStatement pstmt1 = null;private PreparedStatement pstmt2 = null;private PreparedStatement pstmt3 = null;public OrderDAOImpl(Connection conn) {this.conn=conn;}Overridepublic boolean doUpdate(Order vo) throws Exception {boolean flag = false;return false;}Overridepublic boolean doRemove(int id,String hall,String filmname,String seatname) throws Exception {boolean flag = false;//System.out.println(id);String sql = "DELETE FROM orders WHERE orderId=?";this.pstmt = this.conn.prepareStatement(sql);this.pstmt.setInt(1,id );String sql1 = "select seatnamea from hall where hall='"+hall+"' ";this.pstmt1 = this.conn.prepareStatement(sql1);ResultSet rs = this.pstmt1.executeQuery();rs.next();//System.out.println("++++++++++"+rs.getString(1));String sql2="insert into "+rs.getString(1)+"(seatname) values(?)" ;this.pstmt2 = this.conn.prepareStatement(sql2);this.pstmt2.setString(1,seatname);this.pstmt2.executeUpdate();String sql3="update film set number=number+1 where filmName=?";this.pstmt3=this.conn.prepareStatement(sql3);this.pstmt3.setString(1,filmname);this.pstmt3.executeUpdate();//System.out.println(id);if (this.pstmt.executeUpdate() > 0) {flag = true;}return flag;}Overridepublic Order findById(String id) throws Exception {// TODO Auto-generated method stubreturn null;}Overridepublic List<Order> findAll(String keyWord, int currentPage, int lineSize) throws Exception {List<Order> all = new ArrayList<Order>();String sql = "select * from orders where username=?";this.pstmt = this.conn.prepareStatement(sql);this.pstmt.setString(1, keyWord);ResultSet rs = pstmt.executeQuery();while (rs.next()) {Order order = new Order();order.setOrderId(rs.getInt(1));order.setSeatname(rs.getString(3));order.setFilmname(rs.getString(4));order.setTime(rs.getString(6));order.setHall(rs.getString(5));order.setMoney(rs.getInt(7));all.add(order);}return all;}public boolean doCreate(Order order) throws Exception {boolean flag = false;String sql = "INSERT INTO orders(username,seatname,filmname,hall,time,money) VALUES (?,?,?,?,?,?) ";this.pstmt = this.conn.prepareStatement(sql);this.pstmt.setString(1,order.getUsername());this.pstmt.setString(2, order.getSeatname());this.pstmt.setString(3,order.getFilmname());this.pstmt.setString(4,order.getHall());this.pstmt.setString(5,order.getTime());this.pstmt.setInt(6, order.getMoney());String sql1="update film set number=number-1 where filmName=?";this.pstmt1=this.conn.prepareStatement(sql1);this.pstmt1.setString(1,order.getFilmname());this.pstmt1.executeUpdate();String sql2 = "select seatnamea from hall where hall='"+order.getHall()+"' ";this.pstmt2 = this.conn.prepareStatement(sql2);ResultSet rs = pstmt2.executeQuery();rs.next();String sql3="delete from "+rs.getString(1)+" where seatname=?";this.pstmt3 = this.conn.prepareStatement(sql3);this.pstmt3.setString(1,order.getSeatname());this.pstmt3.executeUpdate();if (this.pstmt.executeUpdate() > 0) {flag = true;//System.out.println("判断");}//System.out.println(flag);return flag;}public long getAllCount(String keyWord) throws Exception { return 0;}Overridepublic List<Order> findAll() throws Exception {List<Order> all = new ArrayList<Order>();String sql = "select * from orders";this.pstmt = this.conn.prepareStatement(sql);ResultSet rs = pstmt.executeQuery();while (rs.next()) {Order order=new Order();order.setOrderId(rs.getInt(1));order.setUsername(rs.getString(2));order.setSeatname(rs.getString(3));order.setHall(rs.getString(4));order.setTime(rs.getString(5));order.setMoney(rs.getInt(6));all.add(order);}return all;}Overridepublic boolean doRemove(String id) throws Exception {// TODO Auto-generated method stubreturn false;}Overridepublic List<String> getAllseat(String keyWord) throws Exception { //System.out.println(keyWord);String sql = "select seatnamea from hall where hall='"+keyWord+"' ";this.pstmt = this.conn.prepareStatement(sql);ResultSet rs = pstmt.executeQuery();rs.next();//System.out.println("++++++++++"+rs.getString(1));String sql1="select seatname from "+rs.getString(1);this.pstmt1 = this.conn.prepareStatement(sql1);ResultSet rs1 = pstmt1.executeQuery();List<String> seatname =new ArrayList<String>();int i=0;while (rs1.next()) {//System.out.println(rs.getString(1));seatname.add(rs1.getString(1));}return seatname;}}OrderServlet.javapackage.movie.servlet;import java.io.IOException;import java.io.PrintWriter;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.http.HttpSession;import.movie.factory.DAOFactory;import.movie.vo.FilmInformation;import.movie.vo.Order;public class OrderServlet extends HttpServlet {public OrderServlet() {super();}public void destroy() {super.destroy(); // Just puts "destroy" string in log// Put your code here}public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {response.setContentType("text/html;charset=GBK");request.setCharacterEncoding("GBK");String status = request.getParameter("status"); // 接收操作的状态if(request.getParameter("film")!=null){String filmname= new String(request.getParameter("film").getBytes("iso8859-1"),"GBK");String hall = new String(request.getParameter("hall").getBytes("iso8859-1"),"GBK");String time=request.getParameter("time");int money =Integer.parseInt(request.getParameter("money"));HttpSession se=request.getSession();se.setAttribute("film", filmname);se.setAttribute("hall", hall);se.setAttribute("time", time);se.setAttribute("money",money);}if (!(status == null || "".equals(status))) {if ("list".equals(status)) {this.seatlist(request, response);}if ("listdetails".equals(status)) {//this.listdetails(request, response);}if ("insert".equals(status)) {this.insert(request, response);}if ("update".equals(status)) {//this.update(request, response);}if ("delete".equals(status)) {this.delete(request, response);}if ("show".equals(status)) {//this.show(request, response);}} else { // 如果没有的话才执行此跳转//request.getRequestDispatcher(pages).forward(request, response);}}private void seatlist(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("GBK") ;String hall = new String(request.getParameter("hall").getBytes("iso8859-1"),"GBK");try {//System.out.println("-----------"+hall);request.setAttribute("seat",DAOFactory.getIOrderDAOinstance().getAllseat(hall));} catch (Exception e) {e.printStackTrace();}request.getRequestDispatcher("seat_list.jsp").forward(request, response);}public void insert(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {String seatname = request.getParameter("seatname");//System.out.println("zhixing1");try {HttpSession session=request.getSession();String username =(String) session.getAttribute("username");String filmname=(String) session.getAttribute("film");String hall=(String) session.getAttribute("hall");String time=(String) session.getAttribute("time");//System.out.println("zhixing2");int money=(Integer) session.getAttribute("money");/*String filmname= new String(request.getParameter("film").getBytes("iso8859-1"),"GBK");String hall = new String(request.getParameter("hall").getBytes("iso8859-1"),"GBK");String time=request.getParameter("time");int money =Integer.parseInt(request.getParameter("money"));*/System.out.println("------------------"+filmname+username+hall+time+seatnam e);//System.out.println(money);//System.out.println("zhixing2");Order order=new Order();order.setFilmname(filmname);order.setHall(hall);order.setMoney(money);order.setSeatname(seatname);order.setTime(time);order.setUsername(username);if (DAOFactory.getIOrderDAOinstance().doCreate(order)) {request.setAttribute("msgs", "订单提交成功!");} else {request.setAttribute("msgs","订单提交失败");}} catch (Exception e) {e.printStackTrace();}request.getRequestDispatcher("order_operate_do.jsp").forward(request, response);}public void delete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {String pages = ""; // 默认让其跳转到错误的处理页try {int orderid = Integer.parseInt(request.getParameter("orderid"));String filmname= new String(request.getParameter("filmname").getBytes("iso8859-1"),"GBK");String seatname= new String(request.getParameter("seatname").getBytes("iso8859-1"),"GBK");String hall = new String(request.getParameter("hall").getBytes("iso8859-1"),"GBK");//System.out.println(orderid);System.out.println(filmname+seatname+hall);if (DAOFactory.getIOrderDAOinstance().doRemove(orderid, hall,filmname, seatname)) {request.setAttribute("msg", "删除成功!");} else {request.setAttribute("msg", "删除失败!");}pages = "orders_operate_do.jsp";} catch (Exception e) {e.printStackTrace();}request.getRequestDispatcher(pages).forward(request, response);}public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {this.doPost(request, response);}public void init() throws ServletException {// Put your code here}}五、测试登陆界面注册界面登陆成功界面电影信息页面选择座位号页面订单提交成功我的订单页面六、心得体会通过这次实验,让我学会了基于B/S模式,并采用MVC架构,减少了代码的重复,实验过程中还有一些未解决的问题,人机交互方面还有待改进,需要今后继续努力,平时应该多加练习,不止要学会课本上的知识,也要尽量多涉及一些与课程有关的知识。

相关主题