欢迎来到三一办公! | 帮助中心 三一办公31ppt.com(应用文档模板下载平台)
三一办公
全部分类
  • 办公文档>
  • PPT模板>
  • 建筑/施工/环境>
  • 毕业设计>
  • 工程图纸>
  • 教育教学>
  • 素材源码>
  • 生活休闲>
  • 临时分类>
  • ImageVerifierCode 换一换
    首页 三一办公 > 资源分类 > DOCX文档下载  

    火车票售票系统源代码.docx

    • 资源ID:3639752       资源大小:41.54KB        全文页数:29页
    • 资源格式: DOCX        下载积分:6.99金币
    快捷下载 游客一键下载
    会员登录下载
    三方登录下载: 微信开放平台登录 QQ登录  
    下载资源需要6.99金币
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    火车票售票系统源代码.docx

    火车票售票系统源代码import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.*;import javax.swing.*;import javax.swing.border.TitledBorder;import java.io.BufferedWriter;import java.io.File;import java.io.FileNotFoundException;import java.io.FileReader;import java.io.FileWriter;import java.io.IOException;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.Statement;public class TrainInformationQuery extends JFrameprivate Container file;private Component open;public TrainInformationQueryJPanel p1=new JPanel(new FlowLayout(FlowLayout.CENTER);JPanel p2=new JPanel(new FlowLayout(FlowLayout.CENTER);JPanel p3=new JPanel(new FlowLayout(FlowLayout.CENTER);JPanel p4=new JPanel;JLabel jlb1=new JLabel("火车站列车时刻表");JLabel jlb2=new JLabel("车次");final JTextField jtf=new JTextField(8);JButton jbt1=new JButton("查询");JButton jbt2=new JButton("全部火车信息");final JTextArea jta=new JTextArea(10,30);p1.add(jlb1);p2.add(jta);p2.setBorder(new TitledBorder(" ");p3.add(jlb2);p3.add(jtf);p3.add(jbt1);p3.add(jbt2);p4.add(p1,BorderLayout.NORTH);p4.add(p2,BorderLayout.CENTER);p4.add(p3,BorderLayout.SOUTH);p4.setBorder(new TitledBorder(" ");add(p4);/查询按钮final JPanel panel = new JPanel;jbt1.addActionListener(new ActionListenerpublic void actionPerformed(ActionEvent e)JFileChooser openfile = new JFileChooser;openfile.setDialogTitle("打开文件");openfile.setApproveButtonText("打开");openfile.showOpenDialog(panel);File filename = openfile.getSelectedFile;StringBuffer strBF = new StringBuffer;String error_message = "Error"FileInputStream inputfile = null;try char buffer = new char1024;inputfile = new FileInputStream(filename);int len = 0;/ 如下为依次读取文件中的每一行内容,将其加入StringBuffer数据类型便利strBF中FileReader in = new FileReader(filename.getAbsoluteFile);while (len = in.read(buffer) != -1) strBF.append(buffer, 0, len);inputfile.close;/ 文本框对象text使用函数setText将StringBuffer的String写入文本框中jta.setText(strBF.toString);String openfilename = filename.getName;setTitle(openfilename); catch (IOException ioEX) JOptionPane.showMessageDialog(panel, error_message); );/查询全部火车信息按钮final JPanel panel1 = new JPanel;jbt2.addActionListener(new ActionListenerpublic void actionPerformed(ActionEvent e2)JFileChooser openfile = new JFileChooser;openfile.setDialogTitle("打开文件");openfile.setApproveButtonText("打开");openfile.showOpenDialog(panel1);File filename = openfile.getSelectedFile;StringBuffer strBF = new StringBuffer;String error_message = "Error"FileInputStream inputfile = null;try char buffer = new char1024;inputfile = new FileInputStream(filename);int len = 0;/ 如下为依次读取文件中的每一行内容,将其加入StringBuffer数据类型便利strBF中FileReader in = new FileReader(filename.getAbsoluteFile);while (len = in.read(buffer) != -1) strBF.append(buffer, 0, len);inputfile.close;/ 文本框对象text使用函数setText将StringBuffer的String写入文本框中jta.setText(strBF.toString);String openfilename = filename.getName;setTitle(openfilename); catch (IOException ioEX) JOptionPane.showMessageDialog(panel1, error_message); );public static void main(String args)TrainInformationQuery q=new TrainInformationQuery;q.setTitle("始发列车时刻表");q.setSize(500,400);q.setVisible(true);class Zhuce extends JFrameprotected static final String Path = null;public ZhuceJLabel jlb1=new JLabel("旅客注册信息");JLabel jlb2=new JLabel(" 姓名 ");JLabel jlb3=new JLabel(" 密码 ");JLabel jlb4=new JLabel(" 性别 ");JLabel jlb5=new JLabel(" 身份证号");JLabel jlb6=new JLabel(" 工作");JLabel jlb7=new JLabel(" 电话");final JTextField jtf1=new JTextField(10);final JTextField jtf2=new JTextField(10);final JTextField jtf3=new JTextField(10);final JTextField jtf4=new JTextField(10);final JTextField jtf5=new JTextField(10);final JTextField jtf6=new JTextField(10);JButton jbt1=new JButton(" 注 册 ");JPanel p1=new JPanel(new FlowLayout(FlowLayout.LEFT,10,20);JPanel p2=new JPanel(new GridLayout(7,2,10,10);JPanel p3=new JPanel(new BorderLayout(5,5);p2.add(jlb2);p2.add(jtf1);p2.add(jlb3);p2.add(jtf2);p2.add(jlb4);p2.add(jtf3);p2.add(jlb5);p2.add(jtf4);p2.add(jlb6);p2.add(jtf5);p2.add(jlb7);p2.add(jtf6);p2.add(jbt1);p3.add(p1,BorderLayout.NORTH);p3.add(p2,BorderLayout.CENTER);add(p3,BorderLayout.CENTER);jbt1.addActionListener(new ActionListenerpublic void actionPerformed(ActionEvent e)FileInputStream fin;FileOutputStream fout = null;String name=jtf1.getText;String password=jtf2.getText;String sex=jtf3.getText;String id=jtf4.getText;String job=jtf5.getText;String tel=jtf6.getText;try File f=new File("e:cgjmyfile.txt");BufferedWriter br=new BufferedWriter(new FileWriter(f);br.write(name);br.write(password);br.write(sex);br.write(id);br.write(job);br.write(tel);br.flush;br.close; catch (FileNotFoundException e1) e1.printStackTrace; catch (IOException e1)e1.printStackTrace;JOptionPane.showMessageDialog(null,"恭喜您,注册成功!");private void readTextFile(String path) String filePath="e:cgjmyfile.txt"readTextFile(Path););public static void main(String args)Zhuce z=new Zhuce;z.setTitle("火车票订票系统");z.setSize(250,300);z.setVisible(true);class TicketQuery extends JFramepublic TicketQueryJPanel p1=new JPanel(new FlowLayout(FlowLayout.LEFT,5,5);JPanel p2=new JPanel;JLabel jlb=new JLabel("请输入旅客姓名:");final JTextField jtf=new JTextField(12);JButton jbt=new JButton("查询");JButton jbt3=new JButton("退票");final JTextArea jta=new JTextArea(10,30);p1.add(jlb);p1.add(jtf);p1.add(jbt);p1.add(jbt3);add(p1,BorderLayout.SOUTH);p2.add(jta);add(p2);p2.setBorder(new TitledBorder("内容");/查询按钮/ 简单的布局String openFilePath;String openFileName;String title = "ERROR MESSAGE"int type = JOptionPane.ERROR_MESSAGE; final JTextArea text = new JTextArea;final JPanel panel = new JPanel;panel.setLayout(new GridLayout(1, 1);panel.add(new JScrollPane(text);this.getContentPane.add(panel); / 菜单项JMenuBar Mbar = new JMenuBar;this.setJMenuBar(Mbar);JMenu file = new JMenu("文件");Mbar.add(file); JMenuItem open = new JMenuItem("打开");open.setMnemonic('O');open.setAccelerator(KeyStroke.getKeyStroke('O',java.awt.Event.CTRL_MASK, true);jbt.addActionListener(new ActionListenerpublic void actionPerformed(ActionEvent e)JFileChooser openfile = new JFileChooser;openfile.setDialogTitle("打开文件");openfile.setApproveButtonText("打开");openfile.showOpenDialog(panel);File filename = openfile.getSelectedFile;StringBuffer strBF = new StringBuffer;String error_message = "Error"FileInputStream inputfile = null;try char buffer = new char1024;inputfile = new FileInputStream(filename);int len = 0;/ 如下为依次读取文件中的每一行内容,将其加入StringBuffer数据类型便利strBF中FileReader in = new FileReader(filename.getAbsoluteFile);while (len = in.read(buffer) != -1) strBF.append(buffer, 0, len);inputfile.close;/ 文本框对象text使用函数setText将StringBuffer的String写入文本框中text.setText(strBF.toString);String openfilename = filename.getName;setTitle(openfilename); catch (IOException ioEX) JOptionPane.showMessageDialog(panel, error_message); );file.add(open);file.addSeparator;/退票按钮jbt3.addActionListener(new ActionListenerpublic void actionPerformed(ActionEvent e)FileOutputStream testfile = null;try testfile = new FileOutputStream(" e:cgjmyfile.txt");testfile.write(new String("").getBytes); catch (IOException e1) / TODO Auto-generated catch blocke1.printStackTrace;JOptionPane.showMessageDialog(null,"退票成功!"););public static void main(String args)TicketQuery t=new TicketQuery;t.setTitle("火车票查询系统");t.setSize(400,250);t.setVisible(true);class DingPiao extends JFrameString trainnum=null;String dstation=null;String ordernum;String seattype1;String seattype2;String name;String sql;ResultSet rs;String sstation=null;int num,num1;public DingPiaoJPanel p1=new JPanel(new GridLayout(2,1,5,5);JPanel p2=new JPanel(new GridLayout(3,4,5,5);JPanel p3=new JPanel(new GridLayout(1,4,5,5);/JPanel p4=new JPanel(new GridLayout);JLabel jlb1=new JLabel("1 订票时间必须为三天以内的票");JLabel jlb2=new JLabel("2 本系统只属模拟不涉及票额的计算");JLabel jlb3=new JLabel("车次");JLabel jlb4=new JLabel("始发车站");JLabel jlb5=new JLabel("座位号");JLabel jlb6=new JLabel("终点站");ButtonGroup group=new ButtonGroup;final JRadioButton jrb1=new JRadioButton("硬座");final JRadioButton jrb2=new JRadioButton("卧铺");group.add(jrb1);group.add(jrb2);JLabel jlb9=new JLabel(" ");JLabel jlb8=new JLabel(" ");JLabel jlb10=new JLabel(" 姓 名 ");final JTextField jft1=new JTextField(8);final JTextField jft2=new JTextField(8);final JTextField jft3=new JTextField(8);final JTextField jft4=new JTextField(8);final JTextField jft5=new JTextField(8);JButton jbt1=new JButton("打印预览"); final JButton jbt3=new JButton(" 订 票 ");p1.add(jlb1);p1.add(jlb2);p1.setBorder(new TitledBorder(""); p2.add(jlb3);p2.add(jft1); p2.add(jlb4);p2.add(jft2); p2.add(jlb5);p2.add(jft3);p2.add(jrb1); p2.add(jrb2);p2.add(jlb10);p2.add(jft4); p2.add(jlb6);p2.add(jft5); p3.add(jbt1); p3.add(jbt3);p3.add(jlb8);p3.add(jlb9);add(p1,BorderLayout.NORTH);add(p2,BorderLayout.CENTER);add(p3,BorderLayout.SOUTH); jbt3.addActionListener(new ActionListenerpublic void actionPerformed(ActionEvent e)String trainnum=jft1.getText;String dstation=jft2.getText;String seattype1=jrb1.isSelected?"硬座":" "String seattype2=jrb2.isSelected?"卧铺":" "String name=jft4.getText;String sstation=jft5.getText;try File f=new File("e:cgjdingpiao.txt");BufferedWriter br=new BufferedWriter(new FileWriter(f);br.write(trainnum);br.write(dstation);br.write(seattype1);br.write(seattype2);br.write(name);br.write(sstation);br.flush;br.close; catch (FileNotFoundException e1) e1.printStackTrace; catch (IOException e1)e1.printStackTrace;jft3.setText(String.valueOf(num);JOptionPane.showMessageDialog(null,"恭喜您!订票成功!"); );jbt1.addActionListener(new ActionListenerpublic void actionPerformed(ActionEvent e)trainnum=jft1.getText;dstation=jft2.getText;ordernum=jft3.getText;seattype1=jrb1.isSelected?"硬座":" "seattype2=jrb2.isSelected?"卧铺":" "name=jft4.getText;sstation=jft5.getText;YuLan y=new YuLan;y.setTitle("火车票订票系统");y.setSize(500,250);y.setVisible(true);); class YuLan extends JFramepublic YuLanJMenuBar jmb=new JMenuBar;setJMenuBar(jmb);JMenu wen=new JMenu("文件"); JMenuItem print=new JMenuItem("打印"); jmb.add(wen);wen.add(print); JPanel p1=new JPanel(new GridLayout(2,1,5,5);JPanel p2=new JPanel(new GridLayout(3,2,5,5);JLabel jlb1=new JLabel("1 订票时间必须为三天以内的票");JLabel jlb2=new JLabel("2 本系统只属模拟不涉及票额的计算");p1.add(jlb1);p1.add(jlb2);add(p1,BorderLayout.NORTH);JLabel jlb3=new JLabel("座位号: "+ordernum); JLabel jlb4=new JLabel("姓名: "+name);JLabel jlb5=new JLabel("车次: "+trainnum);JLabel jlb6=new JLabel("始发车站: "+dstation); JLabel jlb7=new JLabel("终点站: "+sstation);JLabel jlb8=new JLabel("座位类型: "+seattype1+seattype2); p2.add(jlb3);p2.add(jlb5);p2.add(jlb4);p2.add(jlb6);p2.add(jlb7);p2.add(jlb8);add(p2,BorderLayout.CENTER);print.addActionListener(new ActionListenerpublic void actionPerformed(ActionEvent e)JOptionPane.showMessageDialog(null,"请稍等,正在为您打印!");); public void main(String args)YuLan y=new YuLan;y.setTitle("火车票订票系统");y.setSize(500,250);y.setVisible(true);public static void main(String args)tryFileReader fr=new FileReader("e:cgjjava.txt");FileWriter fw=new FileWriter("e:cgjjavaCopy.txt");int b=fr.read;while(b!=-1)fw.write(b);System.out.print(char)b);b=fr.read;fw.close;fr.close;catch(Exception e)e.printStackTrace;DingPiao d=new DingPiao;d.setTitle("火车票订票系统");d.setSize(500,250);d.setVisible(true);class CustomLogin extends JFramepublic CustomLoginJPanel p1=new JPanel(new FlowLayout(FlowLayout.CENTER,10,10);JLabel jlb1=new JLabel("火车票管理系统");p1.add(jlb1);JPanel p2=new JPanel(new GridLayout(5,1,10,10);JButton jbt1=new JButton("剩余车票查询");JButton jbt2=new JButton(" 订 票 ");JButton jbt3=new JButton("订票信息查询");p2.add(jbt1);p2.add(jbt2);p2.add(jbt3);ImageIcon usIcon = new ImageIcon("image/flower.gif");JLabel jlb2=new JLabel(usIcon);JPanel p3=new JPanel(new FlowLayout);p3.add(jlb2);JPanel p4=new JPanel(new BorderLayout);p4.add(p1,BorderLayout.NORTH);p3.add(p2,BorderLayout.EAST);p4.add(p3,BorderLayout.CENTER);add(p4,BorderLayout.CENTER);jbt1.addActionListener(new ActionListenerpublic void actionPerformed(ActionEvent e)TrainInformationQuery q=new TrainInformationQuery;q.setTitle("始发车时刻表查询");q.setSize(500,400);q.show;);jbt2.addActionListener(new ActionListenerpublic void actionPerformed(ActionEvent e)DingPiao d=new DingPiao;d.setTitle("订票");d.setSize(450,230);d.show;);jbt3.addActionListener(new ActionListenerpublic void actionPerformed(ActionEvent e)TicketQuery t=new TicketQuery;t.setTitle("订票信息查询");t.setSize(500,250);t.show;);public static void main(String args)CustomLogin c=new CustomLogin;c.setTitle("火车站订票系统");c.setSize(400,250);c.setVisible(true);class Custom extends JFramepublic CustomJPanel p1=new JPanel;p1.setLayout(new FlowLayout(FlowLayout.CENTER,10,10);JLabel jlb2=new JLabel(" 用户名: ");final JTextField jtfName=new JTextField(10);JLabel jlb3=new JLabel(" 密 码: ");final JPasswordField jtfScret=new JPasswordField(10);JButton jbt1=new JButton("登 录");JButton jbt2=new JButton("注 册");p1.add(jlb2);p1.add(jtfName); p1.add(jlb3);p1.add(jtfScret); p1.add(jbt1);p1.add(jbt2);JPanel p2=new JPanel(new FlowLayout(FlowLayout.CENTER,10,10);JPanel p3=new JPanel(new BorderLayout);JLabel jlb1=new JLabel("火车票管理系统");p2.add(jlb1);p3.add(p2,BorderLayout.NORTH);p3.add(p1,BorderLayout.CENTER);add(p3,BorderLayout.CENTER);jbt1.addActionListener(new ActionListenerpublic void actionPerformed(ActionEvent e)String jtfname="jack"String scret="1234"if(jtfname.equals("")|!scret.equals("")setVisible(false);CustomLogin c=new CustomLogin;c.setTitle("火车站订票系统");c.setSize(400,300);c.show;elseJOptionPane.showMessageDialog(null,"对不起,您的用户名或密码错误");JOptionPane.showMessageDialog(null,"输入不能为空"););jbt2.addActionListener(new ActionListenerpublic void actionPerformed(ActionEvent e)Zhuce z=new Zhuce;z.setTitle("信息注册");z.setSize(250,300);z.show;);public static void main(String args)C

    注意事项

    本文(火车票售票系统源代码.docx)为本站会员(小飞机)主动上传,三一办公仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一办公(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    备案号:宁ICP备20000045号-2

    经营许可证:宁B2-20210002

    宁公网安备 64010402000987号

    三一办公
    收起
    展开