ImageVerifierCode 换一换
格式:DOCX , 页数:66 ,大小:30.25KB ,
资源ID:8882420      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/8882420.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(火车售票系统完整代码.docx)为本站会员(b****8)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

火车售票系统完整代码.docx

1、火车售票系统完整代码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

2、;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 c

3、lass 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 fzhang

4、shu = 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,

5、 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.WES

6、T); 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

7、= 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(查询确认); JBut

8、ton buyButton = new JButton(确认购票); public pan3() buyButton.addActionListener(new ActionListener() Override public void actionPerformed(ActionEvent e) UpdateUser(); if (flag=true) UpdateTrain(); System.out.println(hjkasfhjkaf); ); sureButton.addActionListener(new ActionListener() Override public void

9、 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, G

10、ridBagConstraints.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(sur

11、eButton, 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, 10

12、0, 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.ad

13、d(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,

14、 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, GridBagConstrai

15、nts.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(Bord

16、erFactory.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(发车时间); JButto

17、n 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,

18、 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 = getGridB

19、agConstraints(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, Gri

20、dBagConstraints.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 = getGridBagCon

21、straints(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, GridBag

22、Constraints.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); Gri

23、dBagConstraints 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() Ov

24、erride public 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,

25、 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

26、 */ 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

27、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 e

28、ndTime = 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)

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1