版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、import java.awt.Button;import java.awt.Font;import java.awt.Frame;import java.awt.Label;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;public class Denglu extends Frame implements ActionListener(Label pt;Bu
2、tton btn1;Button btn2;Zhuce Zhuce;GLY gly;Denglu()(init();public void init()(setLayout(null);pt=new Label(机票预订系统”);pt.setFont(new Font(宋体,Font.PLAIN,22);pt.setBounds(200,100,200,40);btn1=new Button(旅客”);btn1.setFont(new Font(宋体,Font.PLAIN,18);btn1.setBounds(150, 200, 80, 30);btn2=new Button(管理员);btn
3、2.setFont(new Font(宋体,Font.PLAIN,18);btn2.setBounds(300, 200, 100, 30);add(pt);add(btn1);add(btn2);setTitle(机票预订界面”);setSize(600,500);setVisible(true);btn1.addActionListener(this);btn2.addActionListener(this);this.addWindowListener(new WindowAdapter()(public void windowClosing(WindowEvent e)( System
4、.exit(0););Overridepublic void actionPerformed(ActionEvent e) (if(e.getSource()=btn1)this.setVisible(false);Zhuce = new Zhuce();Zhuce.setVisible(true);elsethis.setVisible(false);gly = new GLY();gly.setVisible(true);/ TODO Auto-generated method stub旅客登陆:import java.awt.Button;import java.awt.Font;imp
5、ort java.awt.Frame;import java.awt.Label;import java.awt.TextField;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import javax.swing.JButton;import javax.swing.JOptionPane;public class Zhuce extends sqltext
6、 implements ActionListenerpublic static String name,ID;Zhuce zhuce;Label pt1;Label pt2;Label pt3;Label pt4;TextField tfl;TextField tf2;TextField tf3;TextField tf4;Button btnl;Button btn2;Zhuce()(setLayout(null);pt1=new Label(姓名);pt1.setFont(new Font(宋体,Font.PLAIN,22);pt1.setBounds(150, 100, 80, 30);
7、pt2=new Label(性别);pt2.setFont(new Font(宋体,Font.PLAIN,22);pt2.setBounds(150, 150, 80, 30);pt3=new Label(身份证号”);pt3.setFont(new Font(宋体,Font.PLAIN,22);pt3.setBounds(120, 200, 100, 30);pt4=new Label(X 作地点”);pt4.setFont(new Font(宋体,Font.PLAIN,22);pt4.setBounds(120, 250, 100, 30);tf1=new TextField(15);tf
8、1.setFont(new Font(宋体,Font.BOLD, 22);tf1.setBounds(250, 100, 130, 30);tf2=new TextField(15);tf2.setFont(new Font(宋体,Font.BOLD, 22);tf2.setBounds(250, 150, 130, 30);tf3=new TextField(15);tf3.setFont(new Font(宋体,Font.BOLD, 22);tf3.setBounds(250, 200, 130, 30);tf4=new TextField(15);tf4.setFont(new Font
9、(宋体,Font.BOLD, 22);tf4.setBounds(250, 250, 130, 30);btn1=new Button(进入);btn1.setFont(new Font(宋体,Font.PLAIN,18);btn1.setBounds(90, 300, 80, 30);btn2=new Button(返回);btn2.setFont(new Font(宋体,Font.PLAIN,18);btn2.setBounds(340, 300, 80, 30);add(pt1);add(tf1);add(pt2);add(tf2);add(pt3);add(tf3);add(pt4);
10、add(tf4);add(btnl);add(btn2);setTitle(”输入信息);setSize(600,500);setVisible(true);btn1.addActionListener(this);btn2.addActionListener(this);this.addWindowListener(new WindowAdapter()(public void windowClosing(WindowEvent e)( System.exit(0);/btn2.addActionListener(new ActionListener() (/public void acti
11、onPerformed(ActionEvent e) (/dispose(); /释放当前界面,跳转到下一界面/new Denglu();/);Overridepublic void actionPerformed(ActionEvent e) (/ TODO Auto-generated method stubif(e.getSource()= btn2 )(dispose();new Denglu();setVisible(false);else if(e.getSource() = btn1)(name = tf1.getText();String sex = tf2.getText()
12、;ID = tf3.getText();if(name.equals(”)llsex.equals(”)IIID.equals(”)JOptionPane.showMessageDialog(null,”数据不能为空!”,”友情提示,JOptionPane.WARNING_MESSAGE);elsetry userUpdate(name, sex, ID);将数据输入数据库 catch (InstantiationException el) ( / TODO Auto-generated catch block e1.printStackTrace(); catch (IllegalAcces
13、sException e1) ( / TODO Auto-generated catch block e1.printStackTrace();YD yd= new YD(); dispose();setVisible(false);预定界面:import java.awt.Button;import java.awt.Font;import java.awt.Frame;import java.awt.Label;import java.awt.TextField;import java.awt.event.ActionEvent;import java.awt.event.ActionLi
14、stener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.sql.ResultSet;import javax.swing.JButton;import javax.swing.JOptionPane;public class YD extends sqltext implements ActionListener( public static String starting,distination,planenumber;YD yd;Zhuce zc;Label pt1;L
15、abel pt2;Label pt3;TextField tfl;TextField tf2;TextField tf3;Button btnl;Button btn2;YD()(setLayout(null);pt1=new Label(出发地”);pt1.setFont(new Font(宋体,Font.PLAIN,22);pt1.setBounds(150, 100, 100, 30);pt2=new Label(目的地”);pt2.setFont(new Font(宋体,Font.PLAIN,22);pt2.setBounds(150, 150, 100, 30);pt3=new La
16、bel(航班编号);pt3.setFont(new Font(宋体,Font.PLAIN,22);pt3.setBounds(130, 200, 120, 30);tf1=new TextField(15);tf1.setFont(new Font(宋体,Font.BOLD, 22);tf1.setBounds(250, 100, 130, 30);tf2=new TextField(15);tf2.setFont(new Font(宋体,Font.BOLD, 22);tf2.setBounds(250, 150, 130, 30);tf3=new TextField(15);tf3.setF
17、ont(new Font(宋体,Font.BOLD, 22);tf3.setBounds(250, 200, 130, 30);btn1=new Button(确定);btn1.setFont(new Font(宋体,Font.PLAIN,18);btn1.setBounds(100, 250, 80, 30);btn2=new Button(返回);btn2.setFont(new Font(宋体,Font.PLAIN,18);btn2.setBounds(340, 250, 80, 30);add(pt1);add(pt2);add(pt3);add(tf1);add(tf2);add(t
18、f3);add(btn1);add(btn2);setTitleC机票预订”);setSize(600,500);setVisible(true);btn1.addActionListener(this);btn2.addActionListener(this);this.addWindowListener(new WindowAdapter()( public void windowClosing(WindowEvent e)( System.exit(0););Overridepublic void actionPerformed(ActionEvent e) ( Button butto
19、n = (Button) e.getSource();if(button = btn2 )(new Zhuce();dispose();setVisible(false);else(starting = tf1.getText().trim();distination = tf2.getText().trim();planenumber = tf3.getText().trim();/System.out.print(true);ResultSet rs;try rs = connect(SELECT starting,destination,planenumber FROM SDP); /S
20、ystem.out.print(true);boolean flag=false;while(rs.next()if(starting.equals(rs.getString(starting)&distination.equals(rs.getString(destination)&planenumber.equals(rs.getString(planenumber) flag=true;System.out.print(true);System.out.print(rs.getRow();QR QR = new QR(yd);QR.QRinit();dispose();setVisibl
21、e(false );break;System.out.print(rs.getRow();if(flag=false)(JOptionPane.showMessageDialog(null, 该航班不存在 JOptionPane.WARNING_MESSAGE);catch (Exception e1) (/ TODO: handle exceptione1.printStackTrace();/ TODO Auto-generated method stub确认信息:import java.awt.Button;import java.awt.Font;import java.awt.Lab
22、el;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.sql.ResultSet;import java.util.jar.Attributes.Name;import javax.swing.JButton;import javax.swing.JLabel;import javax.swing.JOptionPane;import ja
23、vax.xml.transform.Source;import org.omg.CORBA.PUBLIC_MEMBER;public class QR extends sqltext implements ActionListener(YD yd;Zhuce zhuce;Label pt1,pt2,pt3,pt4,pt5,pt6,pt7,pt8,pt9,pt10;Button btn1,btn2;public QR(YD yd)(this.yd = yd;/ System.out.print(a);public QR(Zhuce Zhuce)(this.zhuce = Zhuce;/ Syst
24、em.out.print(aaaa);public void QRinit()( setLayout(null);btn1 =new Button(打印机票”);btn1.setFont(new Font(宋体,Font.PLAIN,18);btn1.setBounds(150, 350, 120, 30);btn2 = new Button(返回);btn2.setBounds(350, 350, 60, 30);btn2.setFont(new Font(宋体,Font.PLAIN,18);pt1 = new Label(姓名:,pt1.setFont(new Font(宋体,Font.P
25、LAIN,22);pt1.setBounds(120, 100, 80, 30);pt2 = new Label(身份证号:,pt2.setFont(new Font(宋体,Font.PLAIN,22);pt2.setBounds(100, 150, 100, 30);pt3 = new Label(始发地:,pt3.setFont(new Font(宋体,Font.PLAIN,22);pt3.setBounds(100, 200, 100, 30);pt4 = new Label(目的地:,pt4.setFont(new Font(宋体,Font.PLAIN,22);pt4.setBound
26、s(100, 250, 100, 30);pt5 = new Label(航班号:);pt5.setFont(new Font(宋体,Font.PLAIN,22);pt5.setBounds(100, 300, 100, 30);pt6 = new Label();pt6.setFont(new Font(宋体,Font.PLAIN,22);pt6.setBounds(195, 100, 150, 30);pt7 = new Label();pt7.setFont(new Font(宋体,Font.PLAIN,22);pt7.setBounds(215, 150, 150, 30);pt8 =
27、 new Label();pt8.setFont(new Font(宋体,Font.PLAIN,22);pt8.setBounds(200, 200, 150, 30);pt9 = new Label();pt9.setFont(new Font(宋体,Font.PLAIN,22);pt9.setBounds(200, 250, 150, 30);pt10 = new Label();pt10.setFont(new Font(宋体,Font.PLAIN,22);pt10.setBounds(200, 300, 150, 30);btn1.addActionListener(this);btn
28、2.addActionListener(this);System.out.print(Z+Zhuce.ID);pt6.setText(Z);pt7.setText(Zhuce.ID);ResultSet rs;try rs = connect(SELECT starting,destination,planenumber FROM SDP);while(rs.next()if(YD.starting.equals(rs.getString(starting)&YD.distination.equals(rs.getString(destination)&YD
29、.planenumber.equals(rs.getString(planenumber)pt8.setText(rs.getString(destination);pt9.setText(rs.getString(starting);pt10.setText(rs.getString(planenumber); catch (Exception e) e.printStackTrace();add(pt1);add(pt2);add(pt3);add(pt4);add(pt5);add(pt6);add(pt7);add(pt8);add(pt9);add(pt10);add(btn1 );
30、add(btn2);setSize(600, 500);setResizable(false);setLocationRelativeTo(null);setVisible(true);this.addWindowListener(new WindowAdapter() ( / 添加标题窗口关闭事件。public void windowClosing(WindowEvent e) (e.getWindow();dispose();System.exit(0););Overridepublic void actionPerformed(ActionEvent e) (/ TODO Auto-ge
31、nerated method stub/JButton button =(JButton ) e.getSource();if(e.getSource()=btn1)JOptionPane.showMessageDialog(null,机票打印成功”,”友情提示,JOptionPane.WARNING_MESSAGE);else YD yd = new YD();dispose();setVisible(false);管理员登陆:import java.awt.Button;import java.awt.Font;import java.awt.Frame;import java.awt.L
32、abel;import java.awt.TextField;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import javax.swing.JOptionPane;public class GLY extends Frame implements ActionListenerLabel ptl;Label pt2;Label pt3;TextField t
33、fl;TextField tf2;Button btnl;Button btn2;GLY()(setLayout(null);pt1=new Label(管理员登陆”);pt1.setFont(new Font(宋体,Font.PLAIN,22);pt1.setBounds(230,100,200,40);pt2=new Label(管理员 ID);pt2.setFont(new Font(宋体,Font.PLAIN,22);pt2.setBounds(150, 150, 100, 30);pt3=new Label(密码);pt3.setFont(new Font(宋体,Font.PLAIN
34、,22);pt3.setBounds(170, 200, 80, 30);tf1=new TextField(15);tf1.setFont(new Font(宋体,Font.BOLD, 22);tf1.setBounds(250, 150, 130, 30);tf2=new TextField(15);tf2.setFont(new Font(宋体,Font.BOLD, 22);tf2.setBounds(250, 200, 130, 30);btn1=new Button(登陆);btn1.setFont(new Font(宋体,Font.PLAIN,18);btn1.setBounds(
35、120, 250, 80, 30);btn2=new Button(返回);btn2.setFont(new Font(宋体,Font.PLAIN,18);btn2.setBounds(340, 250, 80, 30);add(pt1);add(pt2);add(tf1);add(pt3);add(tf2);add(btn1);add(btn2);setTitle(管理员登陆界面,setSize(600,500);setVisible(true);btn1.addActionListener(this);btn2.addActionListener(this);this.addWindowL
36、istener(new WindowAdapter()( public void windowClosing(WindowEvent e)(System.exit(0););Overridepublic void actionPerformed(ActionEvent e) (if(e.getSource() = btn1)(String adminnumber = tf1.getText();String password = tf2.getText();if(adminnumber.equals(admin)&password.equals(123”)GL gl =new GL();dis
37、pose();setVisible(false);elseJOptionPane.showMessageDialog(null,出错,友情提JOptionPane.INFORMATION_MESSAGE);elsedispose();new Denglu();/ TODO Auto-generated method stub航班管理:import java.awt.Button;import java.awt.Font;import java.awt.Frame;import java.awt.Label;import java.awt.event.ActionEvent;import jav
38、a.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import javax.swing.JButton;import javax.swing.JOptionPane;public class GL extends sqltext implements ActionListener( Label pt;Button btn1;Button btn2;GL()(setLayout(null);pt=new Label(管理查询”);pt.setFont(n
39、ew Font(宋体,Font.PLAIN,20);pt.setBounds(250, 100, 100, 40);btn1=new Button(航班查询”);btn1.setFont(new Font(宋体,Font.PLAIN,20);btn1.setBounds(250, 200, 100, 30);btn2=new Button(返回);btn2.setFont(new Font(宋体,Font.PLAIN,18);btn2.setBounds(250, 300, 80, 30);add(pt);add(btn1);add(btn2);setTitle(查询界面”);setSize(
40、600,500);setVisible(true);btn1.addActionListener(this);btn2.addActionListener(this);this.addWindowListener(new WindowAdapter()(public void windowClosing(WindowEvent e)(System.exit(0););btn2.addActionListener(new ActionListener() (public void actionPerformed(ActionEvent e) ( dispose(); /释放当前界面,跳转到下一界
41、面 new GLY(););Overridepublic void actionPerformed(ActionEvent e) (if(e.getSource() = btn2)(Denglu dl = new Denglu();dispose();setVisible(false);else (CX cx =new CX();dispose();setVisible(false);/ TODO Auto-generated method stub查询机票:import java.awt.Button;import java.awt.Font;import java.awt.Frame;im
42、port java.awt.Label;import java.awt.TextField;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.sql.ResultSet;import javax.swing.JButton;import javax.swing.JOptionPane;public class CX extends sqlte
43、xt implements ActionListener(YD YD;Label ptl;Label pt2;Label pt3;Label pt4;Label pt5;Label pt6;Label pt7;Button btn;public CX(YD yd)( this.YD = YD;CX()(setLayout(null);pt1=new Label(机票查询”);pt1.setFont(new Font(宋体,Font.PLAIN,20);pt1.setBounds(230,50,200,40);pt2=new Label(出发地);pt2.setFont(new Font(宋体,
44、Font.PLAIN,20);pt2.setBounds(170, 100, 80, 30);pt3=new Label(目的地”);pt3.setFont(new Font(宋体,Font.PLAIN,20);pt3.setBounds(170, 150, 80, 30);pt4=new Label(航班编号);pt4.setFont(new Font(宋体,Font.PLAIN,20);pt4.setBounds(150, 200, 100, 30);pt5=new Label();pt5.setFont(new Font(宋体,Font.BOLD, 22);pt5.setBounds(2
45、50, 100, 130, 30);pt6=new Label();pt6.setFont(new Font(宋体,Font.BOLD, 22);pt6.setBounds(250, 150, 130, 30);pt7=new Label();pt7.setFont(new Font(宋体,Font.BOLD, 22);pt7.setBounds(250, 200, 130, 30);btn=new Button(返回);btn.setFont(new Font(宋体,Font.PLAIN,18);btn.setBounds(230, 250, 80, 30);add(pt1);add(pt2
46、);add(pt3);add(pt4);add(pt5);add(pt6);add(pt7);add(btn);setTitleC机票查询”);setSize(600,500);setVisible(true);btn.addActionListener(this);this.addWindowListener(new WindowAdapter()( public void windowClosing(WindowEvent e)(System.exit(0););if(YD.starting.equals(null)&YD.distination.equals(null)&YD.plane
47、number.equals(null)JOptionPane.showMessageDialog(null, 请 先 预 定 JOptionPane.WARNING_MESSAGE);ResultSet rs;try rs = connect(SELECT starting,destination,planenumber FROM SDP);boolean flag = false;while(rs.next()if(YD.starting.equals(rs.getString(starting)&YD.distination.equals(rs.getString(destination)
48、&YD.planenumber.equals(rs.getString(planenumber)/*System.out.print(rs.getString(destination)+rs.getString (“starting)+rs.getString(planenumber) );*/flag = true;pt5.setText(rs.getString(destination);pt6.setText(rs.getString(starting);pt7.setText(rs.getString(planenumber);if(flag = false)JOptionPane.s
49、howMessageDialog(null, 请 先 预 定 JOptionPane.WARNING_MESSAGE); catch (Exception el) e1.printStackTrace();Overridepublic void actionPerformed(ActionEvent e) if(e.getSource() = btn )GL gl = new GL();dispose();setVisible(false);/ TODO Auto-generated method stubTEXT:public class Test (public static void m
50、ain(String args)(Denglu d=new Denglu();/Zhuce z=new Zhuce();/CX c=new CX();/GL g=new GL();/YD yd = new YD();连接数据库:import java.awt.Frame;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.JFrame;public class sqltext extends Frame (public ResultSet connect(String query) throws Exception (Connection con;Statement stmt;ResultSet rs;/加载数据库驱动程序/DriverManager.registerDriver(new
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- GB/Z 150-2025永磁体磁化行为指南
- 全国安全教育日培训课件
- 全员消防安全知识技能培训课件
- 《税法》第9章:财产和行为税法
- 快乐番薯销售话术
- 厨师职业发展路径图解
- 保安主管面试应答指南
- 人工智能简明教程
- 中国农业大学职业发展
- 安全简介手册讲解
- 2025秋人教版(2024)八年级上册英语课件 Unit 1 Happy Holiday (第2课时) Section A Pronunciation 1- 2f
- 冬季心脑血管疾病预防
- 党建阵地日常管理制度
- 车间医药箱管理制度
- T/CSPSTC 17-2018企业安全生产双重预防机制建设规范
- 遥感图像处理技术在城市更新中的应用
- 食叶草种植可行性报告
- 落叶清扫压缩机设计答辩
- 广东省建筑装饰装修工程质量评价标准
- 珍爱生命活在当下-高一上学期生命教育主题班会课件
- 楼板回顶施工方案
评论
0/150
提交评论