欢迎来到淘文阁 - 分享文档赚钱的网站! | 帮助中心 好文档才是您的得力助手!
淘文阁 - 分享文档赚钱的网站
全部分类
  • 研究报告>
  • 管理文献>
  • 标准材料>
  • 技术资料>
  • 教育专区>
  • 应用文书>
  • 生活休闲>
  • 考试试题>
  • pptx模板>
  • 工商注册>
  • 期刊短文>
  • 图片设计>
  • ImageVerifierCode 换一换

    火车售票系统完整代码(共39页).doc

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

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

    火车售票系统完整代码(共39页).doc

    精选优质文档-倾情为你奉上package com.yue;import java.awt.Color;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.sql.CallableStatement;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import javax.swing.BorderFactory;import javax.swing.JButton;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JTextArea;import javax.swing.JTextField;public class BuyPanel extends JPanel StringBuffer sb = new StringBuffer();private boolean flag = false;JTextArea jtArea = new JTextArea(10, 78);JLabel buyLabel = new JLabel("订票");JTextField fId = new JTextField(7);JTextField ftid = new JTextField(7);JTextField fche = new JTextField(7);JTextField fzhangshu = new JTextField(7);JTextField fbodyId = new JTextField(7);JPasswordField jpField = new JPasswordField(7);public JPanel getBuypn() JPanel pan = new JPanel();GridBagLayout layout = new GridBagLayout();pan.setLayout(layout);GridBagConstraints con = getGridBagConstraints(0, 0, 1, 1, 100, 100,GridBagConstraints.NONE, GridBagConstraints.WEST);pan.add(buyLabel, con);con = getGridBagConstraints(0, 2, 1, 1, 100, 100,GridBagConstraints.NONE, GridBagConstraints.WEST);pan.add(new pan3(), con);con = getGridBagConstraints(0, 3, 1, 1, 100, 100,GridBagConstraints.NONE, GridBagConstraints.WEST);pan.add(new pan4(), con);con = getGridBagConstraints(0, 4, 1, 1, 100, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);pan.add(new pan5(), con);this.setLocation(270, 150);this.add(pan);return pan;/* * 定义下面购票操作区面板pan3 * * author Administrator * */class pan3 extends JPanel JLabel lId = new JLabel(" 车票号码 ");JLabel ltid = new JLabel(" 车票号码 ");JLabel che = new JLabel(" 车 次 ");JLabel lbodyId = new JLabel(" 身份证号 ");JLabel password = new JLabel(" 密码 ");JLabel lzhangshu = new JLabel(" 所需张数 ");JLabel la1 = new JLabel(" ");JLabel la2 = new JLabel(" ");JButton sureButton = new JButton("查询确认");JButton buyButton = new JButton("确认购票");public pan3() buyButton.addActionListener(new ActionListener()Overridepublic void actionPerformed(ActionEvent e) UpdateUser();if (flag=true)UpdateTrain();System.out.println("hjkasfhjkaf"););sureButton.addActionListener(new ActionListener() Overridepublic void actionPerformed(ActionEvent e) select(););GridBagLayout layout = new GridBagLayout();this.setLayout(layout);GridBagConstraints con = getGridBagConstraints(0, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(lId, con);con = getGridBagConstraints(1, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(fId, con);con = getGridBagConstraints(8, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(la2, con);con = getGridBagConstraints(9, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(sureButton, con);con = getGridBagConstraints(0, 1, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(ltid, con);con = getGridBagConstraints(1, 1, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(ftid, con);con = getGridBagConstraints(2, 1, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(che, con);con = getGridBagConstraints(3, 1, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(fche, con);con = getGridBagConstraints(4, 1, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(lbodyId, con);con = getGridBagConstraints(5, 1, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(fbodyId, con);con = getGridBagConstraints(0, 2, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(password, con);con = getGridBagConstraints(1, 2, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(jpField, con);con = getGridBagConstraints(2, 2, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(lzhangshu, con);con = getGridBagConstraints(3, 2, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(fzhangshu, con);con = getGridBagConstraints(8, 2, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(la1, con);con = getGridBagConstraints(9, 2, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(buyButton, con);this.setBorder(BorderFactory.createTitledBorder("订票操作区");/* * 定义下面一个JList用于显示车票的所有信息面板pan4 * * author Administrator * */class pan4 extends JPanel JButton btId = new JButton("车票号码");JButton bt1 = new JButton("起 点 站");JButton bt2 = new JButton("终 点 站");JButton bt3 = new JButton("车 次");JButton bt4 = new JButton("发车时间");JButton bt5 = new JButton("到达时间");JButton bt6 = new JButton("座位类型");JButton bt7 = new JButton("发车日期");JButton bt8 = new JButton("剩余票数");JButton bt9 = new JButton("车票价格");public pan4() this.setLayout(new GridBagLayout();GridBagConstraints con = getGridBagConstraints(0, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(btId, con);con = getGridBagConstraints(1, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt1, con);con = getGridBagConstraints(2, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt2, con);con = getGridBagConstraints(3, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt3, con);con = getGridBagConstraints(4, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt4, con);con = getGridBagConstraints(5, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt5, con);con = getGridBagConstraints(6, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt6, con);con = getGridBagConstraints(7, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt7, con);con = getGridBagConstraints(8, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt8, con);con = getGridBagConstraints(9, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt9, con);con = getGridBagConstraints(0, 1, 11, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(jtArea, con);jtArea.setBackground(Color.GREEN);/* * 定义最下面的按钮面板pan5 * * author Administrator * */class pan5 extends JPanel JButton bt1 = new JButton("退出登录");JLabel lab1 = new JLabel(" ");public pan5() GridBagLayout layout = new GridBagLayout();this.setLayout(layout);GridBagConstraints con = getGridBagConstraints(0, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(bt1, con);con = getGridBagConstraints(1, 0, 1, 1, 0, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);this.add(lab1, con);bt1.addActionListener(new ActionListener() Overridepublic void actionPerformed(ActionEvent e) System.exit(0););/* * 放回一个网格包约束 * * param x * param y * param width * param heigh * param weighx * param weighy * param fill * param anchor * return */private GridBagConstraints getGridBagConstraints(int x, int y, int width,int heigh, int weighx, int weighy, int fill, int anchor) GridBagConstraints con = new GridBagConstraints();con.gridx = x;con.gridy = y;con.gridwidth = width;con.gridheight = heigh;con.weightx = weighx;con.weighty = weighy;con.fill = fill;con.anchor = anchor;return con;/* * 按车票号码搜索所有的车票信息 * * throws SQLException */private void select() Connection conn = null;Statement stmt = null;ResultSet ticket = null;try conn = DriverManager.getConnection("jdbc:oracle:thin:127.0.0.1:1521:ORCL", "store", "store"); catch (SQLException e1) e1.printStackTrace();try stmt = conn.createStatement();String text = "select * from train_table " + "where tid=" + "'"+ fId.getText() + "'"ticket = stmt.executeQuery(text);while (ticket.next() String starter = ticket.getString("starter");String reacher = ticket.getString("reacher");String ticketNumber = ticket.getString("ticketNumber");String startTime = ticket.getString("startTime");String endTime = ticket.getString("endTime");String seatIdNumber = ticket.getString("seatIdNumber");String busDate = ticket.getString("busDate");int ticketNum = ticket.getInt("ticketNum");double price = ticket.getDouble("price");sb.append(" " + fId.getText() + "t"+ " " + starter + "t"+ " " + reacher+ "t"+ " " + ticketNumber + "t" + startTime + "t"+ endTime + "t" + seatIdNumber + "t" + busDate + "t"+ ticketNum + "t" + price + " " + "n");jtArea.setText(sb.toString();if (sb.length() > 0) sb.delete(1, sb.length(); else JOptionPane.showMessageDialog(new TestFrame(), "无此车!"); catch (SQLException e) finally if (ticket != null) try ticket.close(); catch (SQLException e) e.printStackTrace();if (stmt != null) try stmt.close(); catch (SQLException e) e.printStackTrace();if (conn != null) try conn.close(); catch (SQLException e) e.printStackTrace();/* * 订票时更新数据库中的车票表 */private void UpdateTrain() String tId=ftid.getText();int num=0;if (fzhangshu.getText().length()>0)num=Integer.parseInt(fzhangshu.getText();Connection conn = Getgbc.getconnect();CallableStatement cst = null;try conn.setAutoCommit(false);cst = conn.prepareCall("call train_proc (?,?)");cst.setString(1, tId);cst.setInt(2, num);cst.execute();mit(); catch (SQLException e1) try conn.rollback();JOptionPane.showMessageDialog(new TestFrame(), "客户订票失败!"); catch (SQLException e2) JOptionPane.showMessageDialog(new TestFrame(), "客户订票失败!"); finally if (cst != null) try cst.close(); catch (SQLException e1) e1.printStackTrace();if (conn != null) try conn.close(); catch (SQLException e1) e1.printStackTrace();/* * 订票时更新数据库中的用户表 */private void UpdateUser() String tId=ftid.getText();String bId=fbodyId.getText();String cID=fche.getText();String pwd=String.valueOf(jpField.getPassword();int num=0;if(bId.equals(EnterFrame.ID)&&(pwd.equals(EnterFrame.password)if(fzhangshu.getText().length()>0)num=Integer.parseInt(fzhangshu.getText();Connection conn = Getgbc.getconnect();Statement cst = null;try cst = conn.createStatement();cst.executeUpdate("insert into order_table(tid,id_number,t_num,trainsum)"+ " values('"+ tId+ "','"+ bId+ "','"+ cID + "','"+num+"')");JOptionPane.showMessageDialog(new TestFrame(), "客户订票成功!");flag=true; catch (SQLException e1) JOptionPane.showMessageDialog(new TestFrame(), "订票失败!");flag=false; finally if (cst != null) try cst.close(); catch (SQLException e1) e1.printStackTrace();if (conn != null) try conn.close(); catch (SQLException e1) e1.printStackTrace();elseJOptionPane.showMessageDialog(new TestFrame(), "您的身份证或密码有误!请查证后再订票"); package com.yue;import java.awt.Color;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;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.SQLException;import java.sql.Statement;import javax.swing.BorderFactory;import javax.swing.JButton;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextArea;import javax.swing.JTextField;public class CheckPanel extends JPanel StringBuffer sb = new StringBuffer();JTextField trainField = new JTextField(9);JTextField dateField = new JTextField(9);JTextField stationField = new JTextField(9);JTextField zhiField = new JTextField(9);JTextArea jtArea = new JTextArea(10, 80);JLabel checkLabel = new JLabel("查询");public JPanel getCheckpn() JPanel pan = new JPanel();GridBagLayout layout = new GridBagLayout();pan.setLayout(layout);GridBagConstraints con = getGridBagConstraints(0, 0, 1, 1, 100, 100,GridBagConstraints.NONE, GridBagConstraints.WEST);pan.add(checkLabel, con);con = getGridBagConstraints(0, 1, 1, 1, 100, 100,GridBagConstraints.NONE, GridBagConstraints.WEST);pan.add(new pan2(), con);con = getGridBagConstraints(0, 3, 1, 1, 100, 100,GridBagConstraints.NONE, GridBagConstraints.WEST);pan.add(new pan4(), con);con = getGridBagConstraints(0, 4, 1, 1, 100, 100,GridBagConstraints.NONE, GridBagConstraints.EAST);pan.add(new pan5(), con);this.setLocation(270, 150);this.add(pan);return pan;/* * 定义上部查询区面pan2 * * author Administrator * */class pan2 extends JPanel JLabel trainLabel = new JLabel(" 车 次 ");JLabel dateLabel = new JLabel(" 日 期 ");JLabel stationLabel = new JLabel(" 起点站 ");JLabel zhiLabel = new JLabel(" 终点站 ");JLabel l1 = new JLabel(" ");JLabel l2 = new JLabel(" ");JButton checkButton = new JButton("查 询");J

    注意事项

    本文(火车售票系统完整代码(共39页).doc)为本站会员(飞****2)主动上传,淘文阁 - 分享文档赚钱的网站仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知淘文阁 - 分享文档赚钱的网站(点击联系客服),我们立即给予删除!

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




    关于淘文阁 - 版权申诉 - 用户使用规则 - 积分规则 - 联系我们

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

    工信部备案号:黑ICP备15003705号 © 2020-2023 www.taowenge.com 淘文阁 

    收起
    展开