航空公司管理 java

上传人:suij****uang 文档编号:140227197 上传时间:2022-08-23 格式:DOCX 页数:19 大小:19.32KB
收藏 版权申诉 举报 下载
航空公司管理 java_第1页
第1页 / 共19页
航空公司管理 java_第2页
第2页 / 共19页
航空公司管理 java_第3页
第3页 / 共19页
资源描述:

《航空公司管理 java》由会员分享,可在线阅读,更多相关《航空公司管理 java(19页珍藏版)》请在装配图网上搜索。

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(Zhuce.name+Zhuce.ID);pt6.setText(Zhuce.name);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.St

51、atement;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 com.mysql.jdbc.Driver();Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver);St

52、ring dbURL = jdbc:sqlserver:/localhost:1433;databaseName = JPYD; con = DriverManager.getConnection(dbURL,sa”,”123456);stmt = con.createStatement();rs = stmt.executeQuery(query);/con.close();return rs;/*功能概述:添加用户*/public void userUpdate(String name, String sex, String ID) throws InstantiationExceptio

53、n, IllegalAccessException (String sql;PreparedStatement ps;Connection con;Statement stmt;/加载数据库驱动程序try Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver);try String dbURL = jdbc:sqlserver:/localhost:1433;databaseName = JPYD;con = DriverManager.getConnection(dbURL,sa”,”123456);sql = INSERT I

54、NTO zhuce VALUES(?, ?, ?);ps = con.prepareStatement(sql);ps.setString(1, name);ps.setString(2, sex);ps.setString(3, ID);ps.executeUpdate(); catch (SQLException e) System.out.println(您的ID已存在!请重新登陆”);e.printStackTrace(); catch (ClassNotFoundException e) / TODO Auto-generated catch blocke.printStackTra

55、ce();功能概述预定航班public void userUpdateDate(String starting , String destination ,String planenumber)throws InstantiationException, IllegalAccessException (String sql;PreparedStatement ps;Connection con;Statement stmt;try Class.forName(com.microsoft.sqlserver.jdbc.SQLServerDriver);try String dbURL = jdb

56、c:sqlserver:/localhost:1433;databaseName = JPYD;con = DriverManager.getConnection(dbURL,sa”,”123456);sql = INSERT INTO SPD VALUES(?, ?, ?);ps = con.prepareStatement(sql);ps.setString(1, starting );ps.setString(2, destination);ps.setString(3, planenumber);ps.executeUpdate();catch (SQLException e) e.printStackTrace(); catch (ClassNotFoundException e) / TODO Auto-generated catch blocke.printStackTrace();

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

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!