当前位置:文档之家› java课程设计航空订票管理系统设计

java课程设计航空订票管理系统设计

《面向对象程序设计》课程设计报告题目: xx 专业: xx 班级: x 姓名: xx 指导教师: x成绩:xxxx 年 x 月x 日xx目录1 设计内容及要求 (1)1.1 设计任务与要求 (1)1.2硬件可靠性 (1)1.3系统运行的稳定性 (1)1.4系统功能齐全、开放性好 (1)2 需求分析 (2)2.1 数据的输入 (2)2.2 数据的修改 (2)2.3 数据的删除 (2)2.4 数据的查询 (2)3 概要设计 (3)3.1系统用例图 (3)3.2用例描述 (3)3.3 基本描述 (4)3.4 功能 (4)3.5 算法 (5)3.5 流程逻辑 (6)4系统数据结构设计 (11)4.1 逻辑结构设计要点 (11)4.2 物理结构设计要点 (11)4.3 数据结构与程序的关系 (12)4.4 数据库分析 (12)4.5 程序系统的组织结构 (14)6 系统运行效果与操作 (16)参考文献: (36)1 设计内容及要求1.1 设计任务与要求对航空公司来说,航空订票管理系统既能扩大服务范围,扩大公司影响,减少营业费用,又对稳固航空公司的客源有着重要的辅助作用;站在旅客的角度,航空公司提供的这种服务提供了更多的方便,节省了很多时间。

建设航空订票管理系统是体现和提高航空公司领导业绩的一条捷径,此外还具有重要意义:1、改善航空公司服务质量;2、创造和提升航空公司的品牌优势;3、优化航空公司的服务流程;4、提升信息化的水平;1.2硬件可靠性数据库服务器:数据库服务器用于存放用户及航班信息等资料,配一台专用服务器,安装数据库SQL server2000。

1.3系统运行的稳定性系统支持操作系统如下:Windows vista、Windows XP(服务器版本)(推荐)或Windows 2000,系统运行稳定可靠,可以保证365天*24小时的不间断运行,并安装杀毒软件,防止病毒的干扰,保证系统的运行稳定。

SQL Server数据库服务器版, 可以存储管理大量数据信息1.4系统功能齐全、开放性好订票,退票,查询,管理等业务,全部使用软件来控制,因此今后功能变动、业务改动很灵活。

2 需求分析2.1 数据的输入管理员根据需要来输入航班、订票人、乘客等信息的具体数据,但必须保证其正确性和准确性。

2.2 数据的修改管理员根据需要对指定的数据进行修改,由于记录繁多,因此用户首先要输入一定的查询条件,缩小记录范围,然后再从该范围中找到指定的记录进行修改,保证修改的内容的正确性和准确性后可更新数据库的数据。

2.3 数据的删除管理员根据需要对指定的数据进行删除,由于记录繁多,因此用户首先要输入一定的查询条件,缩小记录范围,然后再从该范围中找到制定的记录进行删除,保证将要删除的内容的正确性和准确性后可删除掉数据库中的数据。

2.4 数据的查询管理员根据需要查询数据库中的所有数据,输入一定的查询条件,然后可按照输入的查询依据查询新数据库的数据。

3 概要设计3.1系统用例图图 1 系统用例图3.2用例描述(1)航班查询查看航班信息基本查询,从下拉列表中选择航班或起点或终点信息综合查询,手动输入航班的基本信息(2)订票输入航班信息显示航班信息,以及打折后的票价信息,询问信息是否(3)退票输入将退票的序号显示票的具体信息,并询问是否退票退票成功,更新顾客数据库(4)管理登陆进入管理界面选择添加、更新、删除航班,或查看航班具体信息等业务添加输入添加航班的具体信息更新航班数据库更新输入所要更改航班的具体信息更新航班数据库删除选择所要删除的航班更新航班数据库查看航班具体信息显示数据库中所有航班的具体信息3.3 基本描述(1)服务器端程序:本套航空订票系统软件的服务器端应用程序,使用java编写前台控制软件,管理员通过使用该软件来进行对数据库中的数据进行管理。

(2)后台数据库:本套航空订票系统软件的后台数据库使用Microsoft SQL Server 2000来搭建后台数据库服务器,用来存放所有的数据。

3.4 功能(1)服务器端的主要功能订票信息的查询功能:1)查询航班信息包括航班号、地点等信息。

2)查询及票价格包括起始地、抵达地、、机票价格等信息。

3)查询订票人的详细信息:精确查询:输入订票人身份证号码查询订票人详细信息。

模糊查询:输入订票人的姓名(或订票人的姓或是年龄或是性别)查询出一系列相关的信息,然后可从小范围内找到订票人的详细信息。

4)查询乘客的详细信息:输入乘客的身份证号码查询乘客的详细信息。

1)填写订票人的详细信息其中包括:姓名、身份证号码、联系电话、地址等信息。

2)填写订票的详细信息,其中包括:航班编号、订票时间、订票数量等信息。

录入信息功能1)取票功能:根据输入的订票人身份证号验证订票人身份后,输入详细的乘客信息并进行保存。

2)直接购票:直接输入乘客详细信息并保存(不通过订票人)。

3)录入航班信息:录入航班的相关信息。

4)订票人取消订票:保存订票人取消订票信息。

④修改功能1)修改乘客信息:将查找到的乘客信息,进行修改,然后进行保存。

2)修改订票人信息:将查找到的订票人的信息进行修改然后进行保存。

3)修改航班信息:将查找到的航班信息进行修改后保存。

⑤删除功能1)删除乘客信息:将查找到的乘客信息,进行删除。

2)删除订票人信息:将查找到的订票人的信息进行删除。

3)删除航班信息:将查找到的航班信息进行删除。

3.5 算法1)将管理员输入的数据,按字段保存到数据库中。

2)将数据库中的数据,按字段提取到用户界面中。

3)必要的去除重复项的算法。

4)按条件修改、删除数据中的数据。

5)保持表间数据的一致性。

3.5 流程逻辑(1)服务器端各模块的流程图查询模块流程图图 2 服务器查询模块添加模块流程图图 3 服务器添加模块修改模块流程图图 4 服务器修改模块删除模块流程图开始运行是否继续运行程序初始选择要删除的内容是判断数据是否符合规定删除数据结束删除功能图 5 服务器删除模块(2)客户端各模块的流程图查询模块的流程图图 6 客户端查询模块订票模块的流程图开始运行是否继续运行程序初始输入相应的订票人的信息将数据添加到数据库判断数据是否符合规定结束添加功能不符合是符合图7 客户端添加模块4系统数据结构设计4.1 逻辑结构设计要点按照需求分析设计数据库中的字段,建立一个逻辑上的数据库的结构。

4.2 物理结构设计要点在数据库软件(SQL Server2000)中建立数据库,并要保证数据库最低要符合第二范式。

4.3 数据结构与程序的关系(1)静态数值需求支持并行操作的用户。

处理多条记录数据。

表或文件的最小为2048字节,最大无限制。

(2)精度需求在进行提取数据库数据时,要求数据记录定位准确,在向数据库中添加数据时,要求输入数据准确。

主要的精度适应系统要求,不接受违规操作。

(3)时间特性需求响应时间应在人的感觉和视觉事件范围内;更新处理时间,随着应用软件的版本升级,以及网络的定期维护更新。

(4) 灵活性当需求发生某些变化时,管理应用软件操作方式、数据结构、运行环境基本不会发生变化,变化只是将对应的数据库文件内的记录改变,或将过滤条件改变即可。

(5) 数据管理能力需求本应用软件可管理多条记录,本应用软件基本约用1,300千字节空间,所有文件均放置在数据库中调用,查询数据、文件、记录时,通过库文件名直接进行操作或通过存储过程来完成操作。

4.4 数据库分析(1)数据表建立需将数据库设计成关系模式最低符合第二范式的标准。

按照需求分析,确定系统的实体。

根据实体分析的结果,在数据库中应建立如下数据表:adtor(管理员表)Flight(航班信息表)destine(客户信息表)④user(用户信息表)(2)数据库设计说明destine(订票人信息表)在该信息表中包含以下字段:destine_id(订票人身份证号码)、flight_no(航班号)、destine_count(订票数量)、destine_date(定票日期)、destine_status(订票状态)、destine _id (订票人身份证号码)、destine_phone(订票人联系电话)、destine_address(订票人地址)、destine_sex(订票人性别)、destine_age(订票人年龄)等字段。

flight(航班信息表)在该信息表中包含以下字段:flight_no(航班号)、begin_from(起飞地点)、end_address(降落地点)、begin_time(起飞时间)、end_time(降落时间) ticket_price(机票价格)等字段。

(3)数据库ER图图8 数据库ER图4.5 程序系统的组织结构(1)系统组织结构图服务器端的组织结构图图9 系统层次结构图6 系统运行效果与操作图10 主操作界面代码如下:package flight;import java.awt.GridLayout;import javax.swing.*;import java.awt.event.*;public class Register extends JFrame implements ActionListener{ JTextField user;JPasswordField psw1,psw2;JLabel a,b,c;JButton ok,no;public Register(){a=new JLabel("订票");a.setBounds(70,70,60,25);b=new JLabel("管理");b.setBounds(77,130,60,25);c=new JLabel("退出");c.setBounds(60,190,60,25);user=new JTextField(20);user.setBounds(130,70,180,25);psw1=new JPasswordField(20);psw1.setBounds(130,130,180,25);psw2=new JPasswordField(20);psw2.setBounds(130,190,180,25);add(a);add(user);add(b);add(psw1);add(c);add(psw2);setLayout(null);setBounds(100,200,500,350);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setResizable(false);setVisible(true);}public void actionPerformed(ActionEvent e){String a,b,c;if (e.getSource() == ok) {a=user.getText();b=psw1.getText();c=psw2.getText();dispose(); //关闭窗口System.exit(0); //退出程序}}图11 用户登录界面代码如下:public class AdminLogin extends JFrame implements ActionListener{database datalink;JTextField input1;JPasswordField input2;JLabel prompt1;JLabel prompt2;JButton ok;public AdminLogin() {super("管理员登陆");setSize(400, 100);Dimension size = Toolkit.getDefaultToolkit().getScreenSize();setLocation((size.width - getWidth()) / 2,(size.height - getHeight()) / 2);setLayout(new FlowLayout());prompt1 = new JLabel(" 账号:");prompt2 = new JLabel(" 密码:");input1 = new JTextField(8);input2 = new JPasswordField(8);ok = new JButton("确定");ok.setSize(50, 100);ok.addActionListener(this);add(prompt1);add(input1);add(prompt2);add(input2);add(ok);datalink=new database();setVisible(true);}public void actionPerformed(ActionEvent e){if(e.getSource()==ok){if(input1.getText().length()==0||input2.getText().length()==0){JOptionPane.showMessageDialog(this,"请输入用户名或密码!","提示错误",JOptionPane.ERROR_MESSAGE);}else {try{boolean b=true;Connection con=datalink.getCon();Statement stm=datalink.getStm();ResultSet rs=stm.executeQuery("SELECT * FROM admin_info");if(rootPaneCheckingEnabled){while(rs.next()){String us=input1.getText();String ps=input2.getText();if(us.equals(rs.getString("admtor"))&&ps.equals(rs.getString("admpsw" ))){new Manager();this.dispose();b=false;}InetAddress address =InetAddress.getLocalHost();String IP_name = address.getHostAddress();Calendar E=Calendar.getInstance();int year = E.get(Calendar.YEAR);int month =E.get(Calendar.MONTH)+1;int day = E.get(Calendar.DAY_OF_MONTH);int hour = E.get(Calendar.HOUR_OF_DAY);FileWriter out;out = new FileWriter("D:\\Adminfile.txt");out = new FileWriter("D:\\Adminfile.txt");out.write("登陆用户:"+input1.getText()+" 密码:"+ps+" 登陆时间"+year+"-"+month+"-"+day+" "+hour+" IP:"+IP_name);out.close();}if(b){JOptionPane.showMessageDialog(this,"请输入正确的用户名或密码!","提示错误",JOptionPane.ERROR_MESSAGE);}//con.close();}}catch (IOException ex) {Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) {Logger.getLogger(AdminLogin.class.getName()).log(Level.SEVERE, null, ex);}}}}public static void main(String[] args) {new AdminLogin();}}图12 按班次查询航班图13 按终始站查询图12和图13代码如下:public class FTable extends AbstractTableModel{private Object[][] data;private String[] head = { "航班号","航班公司", "始发站", "终点站" ,"最大乘客数","现有乘客数","起飞时间","普通舱","商务舱"};public FTable(List<ticktInfo> list){data = new Object[list.size()][];for(int i = 0;i < list.size();i++){ticktInfo f = list.get(i);data[i]=newObject[]{f.getFlightID(),f.getCompany(),f.getSstation(),f.getEstation (),getStartTime(),f.getMax(),f.getCurrent(),f.getPutongcang(),f.getShang wucang()};}}public int getColumnCount(){return head.length;}public int getRowCount(){return data.length;}public String getColumnName(int col){return head[col];}public Object getValueAt(int row,int col){return data[row][col];}public Class getColumnClass(int c){return getValueAt(0,c).getClass();}}图14 添加航班代码如下:public class AddF extends JFrame implements ActionListener{String[] title = {"航班号","航班公司","起飞地点","到达地点","起飞时间","最大乘客数","现有乘客数","普通舱 ","商务舱"};JTextField txt1 = new JTextField(20);JTextField txt2 = new JTextField(20);JTextField txt3 = new JTextField(20);JTextField txt4 = new JTextField(20);JTextField txt5 = new JTextField(20);JTextField txt6 = new JTextField(10);JTextField txt7 = new JTextField(10);JTextField txt8 = new JTextField(10);JTextField txt9 = new JTextField(10);JButton OK = new JButton("保存");JButton Cancel = new JButton("取消");ticktInfo flight;ArrayList plst=null;boolean success;public AddF(){Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); setLocation((size.width - getWidth()) / 3,(size.height - getHeight()) / 3);Container con = getContentPane();con.setLayout(new GridLayout(9,1));JPanel p[] = new JPanel[9];for (int i=0;i<9;i++){p[i] = new JPanel(new FlowLayout(FlowLayout.LEFT));p[i].add(new JLabel(title[i]+":"));}p[0].add(txt1);p[1].add(txt2);p[2].add(txt3);p[3].add(txt4);p[4].add(txt5);p[5].add(txt6);p[6].add(txt7);p[7].add(txt8);p[8].add(txt9);for (int i=0;i<9;i++){con.add(p[i]);}JPanel bottom = new JPanel();bottom.add(OK);bottom.add(Cancel);con.add(bottom);OK.addActionListener(this);Cancel.addActionListener(this);setTitle("航班信息添加窗口");setSize(800,500);setVisible(true);}public void actionPerformed(ActionEvent e) { if(e.getSource()==OK){String a=txt1.getText();String b=txt2.getText();String c=txt3.getText();String d=txt4.getText();String e1=txt5.getText();String f=txt6.getText();String g=txt7.getText();String h=txt8.getText();String j=txt9.getText();Solution.AddFlight(a, b, c, d, e1, f, g, h, j);dispose();}else if(e.getSource()==Cancel){dispose();}}public static void main(String[] args) {new AddF();}}图15 删除航班代码如下:public class DeletF extends JFrame implements ActionListener{String[] title = {"航班号","航班公司","起飞地点","到达地点","起飞时间","最大乘客数","现有乘客数","普通舱 ","商务舱"};JTextField txt1 = new JTextField(20);JTextField txt2 = new JTextField(20);JTextField txt3 = new JTextField(20);JTextField txt4 = new JTextField(20);JTextField txt5 = new JTextField(20);JTextField txt6 = new JTextField(10);JTextField txt7 = new JTextField(10);JTextField txt8 = new JTextField(10);JTextField txt9 = new JTextField(10);JButton OK = new JButton("保存");JButton Cancel = new JButton("取消");ticktInfo flight;ArrayList plst=null;boolean success;public AddF(){Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); setLocation((size.width - getWidth()) ;Container con = getContentPane();con.setLayout(new GridLayout(9,1));JPanel p[] = new JPanel[9];for (int i=0;i<9;i++){p[i] = new JPanel(new FlowLayout(FlowLayout.LEFT));p[i].delete(new JLabel(title[i]+":"));}p[0].delete(txt1);p[1].delete(txt2);p[2].delete(txt3);p[3].delete(txt4);p[4].delelte(txt5);p[5].delete(txt6);for (int i=0;i<6;i++){con.add(p[i]);}JPanel bottom = new JPanel();bottom.delete(OK);bottom.delete(Cancel);con.delete(bottom);OK.deleteActionListener(this);Cancel.deleteActionListener(this);setTitle("航班信息删除窗口:”);setVisible(true);setSize(800,500);}public void actionPerformed(ActionEvent e) {if(e.getSource()==OK){String a=txt1.getText();String b=txt2.getText();String c=txt3.getText();String d=txt4.getText();String e1=txt5.getText();String f=txt6.getText();String g=txt7.getText();String h=txt8.getText();String j=txt9.getText();Solution.AddFlight(a, b, c, d, e1, f, g, h, j); dispose();}else if(e.getSource()==Cancel){dispose();}}public static void main(String[] args) {new deleteF();}}图16 乘客购票信息图17 购票成功代码如下:class ClientInfo extends JFrame implements ActionListener{String title[] = {"航班号","起点","终点","起飞日期","姓名","身份证","联系电话","邮箱","座位号","购买票数"};JTextField txtFid = new JTextField(10);JTextField txtStart = new JTextField(10);JTextField txtEnd = new JTextField(10);JTextField txtTime = new JTextField(10);JTextField txtName = new JTextField(10);JTextField txtID = new JTextField(20);JTextField txtTelNum = new JTextField(20);JTextField txtEmail = new JTextField(20);JTextField txtSeatNum = new JTextField(10);JTextField txtCount = new JTextField(10);JButton btnOK = new JButton("确定");JButton btnCancel = new JButton("取消");public ClientInfo() {Container con = getContentPane();con.setLayout(new GridLayout(11,1));JPanel p[] = new JPanel[10];for (int i=0;i<10;i++){p[i] = new JPanel(new FlowLayout(FlowLayout.LEFT));p[i].add(new JLabel(title[i]+":"));}p[0].add(txtFid);p[1].add(txtStart);p[2].add(txtEnd);p[3].add(txtTime);p[4].add(txtName);p[5].add(txtID);p[6].add(txtTelNum);p[7].add(txtEmail);p[8].add(txtSeatNum);p[9].add(txtCount);for (int i=0;i<10;i++){con.add(p[i]);}JPanel bottom = new JPanel();bottom.add(btnOK);bottom.add(btnCancel);con.add(bottom);btnOK.addActionListener(this);btnCancel.addActionListener(this);Dimension size = Toolkit.getDefaultToolkit().getScreenSize();setLocation((size.width - getWidth()) ;setTitle("乘客订票信息填写窗口");setSize(450,600);setVisible(true);}public void actionPerformed(ActionEvent e) {if(e.getSource()==btnOK){try{String a = txtName.getText();String b = txtID.getText();String c = txtTelNum.getText();String d = txtEmail.getText();String e1 = txtSeatNum.getText();String f = txtFid.getText();String g = txtStart.getText();String h = txtEnd.getText();String i = txtTime.getText();Solution.AddClientInfo(a, b, c, d, e1, f, g, h, i); database link=new database();Connection con=link.getCon();Statement stm=link.getStm();String sql="select max,current from flight_info where flightID="+"'"+txtFid.getText().trim()+"'"+"";try{int max=0,cur=0;int udrem=0;ResultSet rs=stm.executeQuery(sql);String s1=txtFid.getText().trim();int ct=Integer.parseInt(txtCount.getText().trim());while(rs.next()){max=rs.getInt("max");cur=rs.getInt("current");}if(cur>0){if(cur-ct>0){udrem=cur-ct;String str1="update flight_info set max="+"'"+max+"'"+",current="+"'"+udrem+"'"+"whereflightID="+"'"+s1+"'"+"";stm.executeUpdate(str1);JOptionPane.showConfirmDialog(this,"订票成功","购票提示",JOptionPane.YES_NO_OPTION);dispose();}else{udrem=cur-ct;JOptionPane.showConfirmDialog(this,"剩余票数为:"+String.valueOf(udrem)+"张","购票提示",JOptionPane.YES_NO_OPTION);}}else{JOptionPane.showConfirmDialog( this,"票已售完","提示错误",JOptionPane.YES_NO_OPTION);}con.close();dispose();}catch(Exception ex){JOptionPane.showConfirmDialog(this,"订票失败","购票提示",JOptionPane.YES_NO_OPTION);}}catch(Exception ex){}}else if(e.getSource()==btnCancel){dispose();}}public static void main(String[] args) {new ClientInfo();}}图18 退出系统代码如下:public class Login extends JFrame implements ActionListener{JTextField user;JPasswordField psw;JLabel a,b;public Login(String s) {super(s);cno.addActionListener(this);cno.setBounds(230,180,60,30);add(a);add(user);add(b);add(psw);add(cfg);add(cno);setLayout(null);setBounds(200,200,430,280);setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setResizable(false);setVisible(true);}public void actionPerformed(ActionEvent e){if(e.getSource()==cno){new Register();this.dispose();}}public static void main(String args[]){new Login("用户退出");}参考文献:[1]《信息系统分析与设计》,陈禹主编,杨善林梁昌勇左美云副主编高等教育出版社,2005.[2]《信息系统开发方法教程》,陈佳主编,清华大学出版社,1999 .[3]《信息系统设计原理与应用》,刘鲁,北京航空航天大学出版社,1995.[4]《企业管理信息系统开发的理论和方法》,葛世伦,代逸生,清华出版社,1996年(中文著作).[5]《java案例开发集锦(第二版)》,袁然,郑自国,来为国,电子工业出版社,2008年[6] 闫建红. 基于UML的机票预定系统的开发研究[J]. 太原师范学院学报(自然科学版), 2005,(03).。

相关主题