课程设计报告-民航订票系统.doc_第1页
课程设计报告-民航订票系统.doc_第2页
课程设计报告-民航订票系统.doc_第3页
课程设计报告-民航订票系统.doc_第4页
课程设计报告-民航订票系统.doc_第5页
已阅读5页,还剩20页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

民航订票系统一、设计目的与内容1设计目的熟练掌握数据的存储表示和基本操作的实现,能够利用存储设计算法解决简单的航空订票问题。2设计内容:录入:可以录入航班情况(数据可以存储在一个数据文件中,数据结构、具体数据自定)查询:可以查询某个航线的情况(如,输入航班号,查询起降时间,起飞抵达城市,航班票价,票价折扣,确定航班是否满仓);可以输入起飞抵达城市,查询飞机航班情况; 订票:(订票情况可以存在一个数据文件中,结构自己设定)可以订票,如果该航班已经无票,可以提供相关可选择航班;输出:可以按照航班号为顺序输出订票信息。二、 算法的基本思想飞机订票系统 主界面管理员客户录入航班信息查看航班信息查看客户信息修改航班信息查看航班信息查看订票信息订票退票算法的主要思路是:1首先对界面的设计,可以对操作的人员来说简单上手。对系统的应用都能进行相应的操作。(1)设置管理员的功能。(2)设置客户的功能(3)管理员的主要操作界面(4)客户的主要操作界面(5)结束2类dingpiao用来显示客户订票的事件;基本思路如下:(1) 客户提交自己的详细信息。(2) 管理员处理相应的内容并给票给客户。(3) 订票结束3类tuipiao将处客户的退票的信息,释放存储空间,基本思路如下:(1) 客户提交自己的详细信息。(2) 管理员把客户的票取出,(3) 结束三、E-R图系统流程图客户端启动该系统的数据流程图如图3-3:登陆有效数据?Noyes出票修改密码航班查询输入查询条件No已查航班?输入新密码No验证有效?输入乘客信息验证有 效Noyes验证有效?No封装requset对象yesyes将request对象写向服务器分拣请求登陆请求修改密码请求查询航班请求出票请求调用BranchDao调用BranchDao调用TicketOrderDAO调用FligthDao封装response对象将response对象写往客户端解析request对象将结果显示在客户端四、测试数据程序运行实例如下:1 主界面的进入:2 管理员的相应功能3 用户的相应功能4管理员录入订票信息5客户注册模块6 客户添加信息模块10 客户订票界面11 客户退票界面五、源程序及系统文件使用说明1 用java写的飞机订票系统的主界面可以直观的观察操作的界面,所应用的代码如下所示:package FlightManagementSystem;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.*;public class Welcome extends JFrame implements ActionListener /* * */private static final long serialVersionUID = 1L;public static final String Flight = null;/声明JButton组件对象JButton jbutton1,jbutton2,jbutton3,jbutton4;public Welcome()super(欢迎进入民航订票系统!);/设置内容面板的布局模式为:流动布局getContentPane().setLayout(new FlowLayout(); jbutton1=new JButton(管理系统);jbutton2=new JButton(客户系统);jbutton4=new JButton( 退 出 系 统 );getContentPane().add(jbutton1);getContentPane().add(jbutton2);getContentPane().add(jbutton4);this.setBounds(300,200,240,120);this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setResizable(false);/注册监听器jbutton1.addActionListener(this);jbutton2.addActionListener(this);jbutton4.addActionListener(this);public void actionPerformed(ActionEvent e)if(e.getSource()=jbutton1) SuppressWarnings(unused)LoginOfManager s=new LoginOfManager();this.dispose(); if(e.getSource()=jbutton2) try new Login(); catch (Exception e1) / TODO Auto-generated catch blocke1.printStackTrace();this.dispose(); if(e.getSource()=jbutton4) System.exit(0);public void airportInformation()System.out.println(谢谢光临!);public static void main(String args)SuppressWarnings(unused)Welcome welcome=new Welcome();2 管理员的操作界面也是简单易懂,利于上手。实现的代码如下所示:package FlightManagementSystem;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import javax.swing.*;public class ManagementFrame extends JFrame implements ActionListener/声明JButton组件对象JButton jbutton1,jbutton2,jbutton3,jbutton4,jbutton5;public ManagementFrame()super(欢迎进入管理系统!);/设置内容面板的布局模式为:流动布局getContentPane().setLayout(new FlowLayout(); jbutton1=new JButton(录入航班信息);jbutton2=new JButton(查看航班信息);jbutton3=new JButton(修改航班信息);jbutton4=new JButton(查看客户信息);jbutton5=new JButton( 返 回 );getContentPane().add(jbutton1);getContentPane().add(jbutton2);getContentPane().add(jbutton3);getContentPane().add(jbutton4);getContentPane().add(jbutton5);this.setBounds(300,200,360,130);this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);/注册监听器jbutton1.addActionListener(this);jbutton2.addActionListener(this);jbutton3.addActionListener(this);jbutton4.addActionListener(this);jbutton5.addActionListener(this);public void actionPerformed(ActionEvent e)if(e.getSource()=jbutton1) new InsertInfomation();this.dispose(); if(e.getSource()=jbutton2) new Queryflight();this.dispose(); if(e.getSource()=jbutton3)new ReviseInformation();this.dispose(); if(e.getSource()=jbutton4)new Queryclient();this.dispose();if(e.getSource()=jbutton5)new Welcome();this.dispose();public static void main(String args)new ManagementFrame();3 客户进入后的操作界面,可是实现用户的各种操作,例如订票,退票,查询信息等。package FlightManagementSystem;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.*;import javax.swing.*;public class Book extends JFrame implements ActionListener /* * */int dingdannum=10000000; /设置初始订单号; private static final long serialVersionUID = 1L; JLabel l4 = new JLabel(订票数量 :); JLabel l2 = new JLabel( 航 班 号 : ); JLabel l3 = new JLabel(请输入您要订票的航班号和机票数量!一次不能超过5张票!); JLabel l1 = new JLabel( 姓 名 : ); JTextField t1 = new JTextField(, 12); JTextField t2 = new JTextField(, 12); JTextField t3 = new JTextField(, 12); JButton b1 = new JButton(确认订票); JButton b2 = new JButton( 返 回 ); JPanel p1 = new JPanel(); JPanel p2 = new JPanel(); JPanel p3 = new JPanel(); JPanel p4 = new JPanel(); JPanel p5 = new JPanel(); String flight; Connection con; Statement stmt=null; ResultSet rs; String url = jdbc:odbc:ylb; Book()throws Exception super(欢迎进入订票界面!); p1.add(l3); p2.add(l1); p2.add(t1); p3.add(l2); p3.add(t2); p4.add(l4); p4.add(t3); p5.add(b1); p5.add(b2); b1.addActionListener(this); b2.addActionListener(this); setLayout(new GridLayout(5,1); this.add(p1); this.add(p2); this.add(p3); this.add(p4); this.add(p5); setBounds(300, 200, 320, 240); setResizable(false); setVisible(true); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SuppressWarnings(null)public void actionPerformed(ActionEvent e) if(e.getSource() = b2) new Enterance(); this.dispose(); if(e.getSource() = b1) /获取用户输入的信息 String jt1=t1.getText(); String jt2=t2.getText(); String jt3=t3.getText(); int tt=Integer.parseInt(jt3); if(tt5)l3.setText(请减少购票数量!); else if(jt1.equals()| jt2.equals()|jt3.equals() l3.setText(所填信息不能为空!); elsetryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver);con = DriverManager.getConnection(url, , );stmt = con.createStatement(); int count=stmt.executeUpdate(insert into book values(+jt1+,+jt2+,+tt+); rs = stmt.executeQuery(select * from flight where 航班号=+jt2+); if(rs.next()System.out.println(查询航班信息成功!); /获取该航班信息 String fl1=null; String fl2=null; String fl3=null; fl1=rs.getString(2); /起飞时间 fl2=rs.getString(3); /起飞地点 fl3=rs.getString(4); String fl5=null; fl5=rs.getString(5); /票价 int fl6=rs.getInt(6); /最大人数 int fl4=rs.getInt(7); /当前人数 int shengyu=fl6-fl4; /计算该航班剩余票数 if(shengyu0) l3.setText(该航班已剩+shengyu+张票!); else for(int i=0;i0) stmt.executeUpdate(update flight set 目前人数=+fl4+where 航班号=+jt2+); if(shengyu=0) stmt.executeUpdate(update flight set 目前人数=+fl4+是否满仓=是+where 航班号=+jt2+); catch(Exception e2)e2.printStackTrace(); /* public void treat(int i,String a,String b) String hangbanhao=a; /获得航班号 System.out.println(航班号为:+hangbanhao); String name=b; int zuoweihao=0; /座位号 int ticketnum=i; /获得订票数 int max=0; /航班最大人数 System.out.println(订票数为:+ticketnum); tryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver);Connection cc=DriverManager.getConnection(url, , );if(cc!=null)System.out.println(查询连接成功!);Statement sta=cc.createStatement();/查询预定航班的人数,以便获得座位号ResultSet res=sta.executeQuery(select * from flight where +航班号=+hangbanhao+);while(res.next()System.out.println(rs存在!);String shijian=res.getString(2);System.out.println(时间=+shijian);String qifeididian=res.getString(3);System.out.println(起飞地点=+qifeididian);String daodadidian=res.getString(4);System.out.println(到达地点=+daodadidian);int piaojia =res.getInt(5);System.out.println(票价=+piaojia);max=res.getInt(6);System.out.println(最大人数=+max);zuoweihao=res.getInt(7);System.out.println(座位号=+zuoweihao); try Class.forName(sun.jdbc.odbc.JdbcOdbcDriver); Connection ccc=DriverManager.getConnection(url, , ); Statement stat=ccc.createStatement(); for(int j=0;jmax) this.dispose(); new Book(); l3.setText(该航班:+hangbanhao+票数已超出!);catch(Exception e) /更新座位号 System.out.println(更改后的人数=+zuoweihao); catch(Exception e) */ public static void main(String args) throws Exception new Book(); 4 录入修改航班的代码,对订票信息的确定,并且对相应的信息进行修改。package FlightManagementSystem;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.Statement;import javax.swing.*;public class Queryclient extends JFrame implements ActionListener /* * */private static final long serialVersionUID = 1L; JLabel jl1=new JLabel( 姓 名 :); JLabel jl6=new JLabel(登机时间:); JLabel jl7=new JLabel(出发地点: ); JLabel jl8=new JLabel(目的地点:); JLabel jl2=new JLabel(证 件 号 :); JLabel jl5=new JLabel(所乘航班:); JLabel jl3=new JLabel( 性 别 :); JLabel jl4=new JLabel( 年 龄 :); private JTextField jd1=new JTextField(15); private JTextField jd2=new JTextField(15); private JTextField jd3=new JTextField(15); private JTextField jd8=new JTextField(15); private JTextField jd4=new JTextField(15); private JTextField jd5=new JTextField(15); private JTextField jd6=new JTextField(15); private JTextField jd7=new JTextField(15); JButton query=new JButton( 查 询 ); JButton outuran=new JButton( 返 回 ); JLabel jl=jl1,jl2,jl3,jl4,jl5,jl6,jl7,jl8; private JTextField jt=jd1,jd2,jd3,jd4,jd5,jd6,jd7,jd8; Box box1=Box.createVerticalBox(); /创建纵向Box容器private Box box2=Box.createVerticalBox();Box box3=Box.createHorizontalBox(); /创建横向Box容器 Connection con; Statement stmt; ResultSet rs; String url = jdbc:odbc:ylb; public Queryclient() this.setTitle(查询客户信息); this.setBounds(300,200,260,365);this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);this.setResizable(false); this.add(box3); /将横向Box容器box3添加到窗体中 box3.add(Box.createRigidArea(new Dimension(20,20); box3.add(box1); /将纵向Box容器box1添加到横向Box容器box3中 box3.add(box2); /将纵向Box容器box2添加到横向Box容器box3中 query.addActionListener(this);outuran.addActionListener(this); for(int i=0;i8;i+) box1.add(jli); box1.add(Box.createVerticalStrut(20); box1.add(query); for(int i=0;i8;i+) box2.add(jti); box2.add(Box.createVerticalStrut(16); box2.add(outuran); jd1.setText(请输入需查询的姓名!); public void actionPerformed(ActionEvent e) String getflight=null; /定义该客户航班号if(e.getSource()=query) String t1=jd1.getText();jd3.setText(t1);tryClass.forName(sun.jdbc.odbc.JdbcOdbcDriver);con = DriverManager.getConnection(url, , );stmt = con.createStatement();rs = stmt.executeQuery(select * from client where 姓名= +t1+ );while(rs.next() for(int i=1;i4;i+)jti.setText(rs.getString(i+1); ResultSet res = stmt.executeQuery(select * from book where 姓名= +t1+ );while(res.next()getflight=res.getString(2); jt4.setText(getflight);ResultSet ress = stmt.executeQuery(select * from flight where 航班号= +getflight+ );while(ress.next()jt5.setText(ress.getString(2);jt6.setText(ress.getString(3);jt7.setText(ress.getString(4);catch(Exception e2) if(e.getSource()=outuran) try new ManagementFrame(); catch (Exception e1) / TODO Auto-generated catch blocke1.printStackTrace();this.dispose(); public static void main(String args)new Queryclient();5 顾客订票退票的代码,package FlightManagementSystem;import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.*;import javax.swing.*;public class Return extends JFrame implements ActionListener /* * */ private static final long serialVersionUID = 1L; JLabel l1 = new JLabel( 姓 名 :); JLabel l2 = new JLabel(航班号 : ); JLabel l3 = new JLabel(请输入您要退票的订单号和航班号!); JLabel l4 = new JLabel(订单号 : ); JTextField t1 = new JTextField(, 12); JTextField t2 = new JTextField(, 12); JTextField t3 = new JTextField(, 12); JButton b1 = new JButton(确认退票); JButton b2 = new JButton( 返 回 ); JPanel p1 = new JPanel(); JPanel p2 = new JPanel(); JPanel p3 = new JPanel(); JPanel p4 = new JPanel(); JPanel p5 = new JPanel(); String name; Connection con; Statement stmt; ResultSet rs; ResultSet rs1; String url = jdbc:odbc:ylb; Return()throws Exception super(欢迎进入退票界面!); this.add(p1); this.add(p2); this.add(p3); this.add(p5); this.add(p4); p1.add(l3); p2.add(l1); p2.add(t1); p3.add(l2); p3.add(t2); p5.add(l4); p5.add(t3); p4.add(b1); p4.add(b2); b1.addActionListener(this); b2.addActionListener(this); setLayout(new GridLayout(5,1); this.add(p1); this.add(p2); this.add(p3); this.add(p5); this.add(p4); setBounds(300, 200, 320, 240); setResizable(false); setVisible(true); public static void main(String args) throws Exception new Return(); public void actionPerformed(ActionEvent e) String jt1=t1.getText(); String jt2=t2.getText(); String jt3=t3.getText(); String fli=null; int tt=Integer.parseInt(jt3); int zuoweihao=0; if(e.getSource() = b2) new Enterance(); dispose(); if(e.getSource() = b1)

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论