火车售票系统完整代码Word文档格式.docx
《火车售票系统完整代码Word文档格式.docx》由会员分享,可在线阅读,更多相关《火车售票系统完整代码Word文档格式.docx(55页珍藏版)》请在冰豆网上搜索。
![火车售票系统完整代码Word文档格式.docx](https://file1.bdocx.com/fileroot1/2022-10/28/dbcd855e-96d3-447d-98ea-0e2f9413bded/dbcd855e-96d3-447d-98ea-0e2f9413bded1.gif)
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,
pan.add(newpan3(),con);
con=getGridBagConstraints(0,3,1,1,100,100,
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(){
@Override
publicvoidactionPerformed(ActionEvente){
UpdateUser();
if(flag==true){
UpdateTrain();
System.out.println("
hjkasfhjkaf"
}
}
});
sureButton.addActionListener(newActionListener(){
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,
this.add(fId,con);
con=getGridBagConstraints(8,0,1,1,0,100,
this.add(la2,con);
con=getGridBagConstraints(9,0,1,1,0,100,
this.add(sureButton,con);
con=getGridBagConstraints(0,1,1,1,0,100,
this.add(ltid,con);
con=getGridBagConstraints(1,1,1,1,0,100,
this.add(ftid,con);
con=getGridBagConstraints(2,1,1,1,0,100,
this.add(che,con);
con=getGridBagConstraints(3,1,1,1,0,100,
this.add(fche,con);
con=getGridBagConstraints(4,1,1,1,0,100,
this.add(lbodyId,con);
con=getGridBagConstraints(5,1,1,1,0,100,
this.add(fbodyId,con);
con=getGridBagConstraints(0,2,1,1,0,100,
this.add(password,con);
con=getGridBagConstraints(1,2,1,1,0,100,
this.add(jpField,con);
con=getGridBagConstraints(2,2,1,1,0,100,
this.add(lzhangshu,con);
con=getGridBagConstraints(3,2,1,1,0,100,
this.add(fzhangshu,con);
con=getGridBagConstraints(8,2,1,1,0,100,
this.add(la1,con);
con=getGridBagConstraints(9,2,1,1,0,100,