火车售票系统完整代码

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

packagecom.yue;importjava.awt.Color;importjava.awt.GridBagConstraints;importjava.awt.GridBagLayout;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.sql.CallableStatement;importjava.sql.Connection;importjava.sql.DriverManager;importjava.sql.ResultSet;importjava.sql.SQLException;importjava.sql.Statement;importjavax.swing.BorderFactory;importjavax.swing.JButton;importjavax.swing.JLabel;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjavax.swing.JPasswordField;importjavax.swing.JTextArea;importjavax.swing.JTextField;publicclassBuyPanelextendsJPanel{StringBuffersb=newStringBuffer();privatebooleanflag=false;JTextAreajtArea=newJTextArea(10,78);JLabelbuyLabel=newJLabel(订票);JTextFieldfId=newJTextField(7);JTextFieldftid=newJTextField(7);JTextFieldfche=newJTextField(7);JTextFieldfzhangshu=newJTextField(7);JTextFieldfbodyId=newJTextField(7);JPasswordFieldjpField=newJPasswordField(7);publicJPanelgetBuypn(){JPanelpan=newJPanel();GridBagLayoutlayout=newGridBagLayout();pan.setLayout(layout);GridBagConstraintscon=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(newpan3(),con);con=getGridBagConstraints(0,3,1,1,100,100,GridBagConstraints.NONE,GridBagConstraints.WEST);pan.add(newpan4(),con);con=getGridBagConstraints(0,4,1,1,100,100,GridBagConstraints.NONE,GridBagConstraints.EAST);pan.add(newpan5(),con);this.setLocation(270,150);this.add(pan);returnpan;}/***定义下面购票操作区面板pan3**@authorAdministrator**/classpan3extendsJPanel{JLabellId=newJLabel(车票号码);JLabelltid=newJLabel(车票号码);JLabelche=newJLabel(车次);JLabellbodyId=newJLabel(身份证号);JLabelpassword=newJLabel(密码);JLabellzhangshu=newJLabel(所需张数);JLabella1=newJLabel();JLabella2=newJLabel();JButtonsureButton=newJButton(查询确认);JButtonbuyButton=newJButton(确认购票);publicpan3(){buyButton.addActionListener(newActionListener(){@OverridepublicvoidactionPerformed(ActionEvente){UpdateUser();if(flag==true){UpdateTrain();System.out.println(hjkasfhjkaf);}}});sureButton.addActionListener(newActionListener(){@OverridepublicvoidactionPerformed(ActionEvente){select();}});GridBagLayoutlayout=newGridBagLayout();this.setLayout(layout);GridBagConstraintscon=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**@authorAdministrator**/classpan4extendsJPanel{JButtonbtId=newJButton(车票号码);JButtonbt1=newJButton(起点站);JButtonbt2=newJButton(终点站);JButtonbt3=newJButton(车次);JButtonbt4=newJButton(发车时间);JButtonbt5=newJButton(到达时间);JButtonbt6=newJButton(座位类型);JButtonbt7=newJButton(发车日期);JButtonbt8=newJButton(剩余票数);JButtonbt9=newJButton(车票价格);publicpan4(){this.setLayout(newGridBagLayout());GridBagConstraintscon=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,GridBag

1 / 39
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功