火车售票系统完整代码Word文档格式.docx

上传人:b****6 文档编号:21176402 上传时间:2023-01-28 格式:DOCX 页数:56 大小:30.31KB
下载 相关 举报
火车售票系统完整代码Word文档格式.docx_第1页
第1页 / 共56页
火车售票系统完整代码Word文档格式.docx_第2页
第2页 / 共56页
火车售票系统完整代码Word文档格式.docx_第3页
第3页 / 共56页
火车售票系统完整代码Word文档格式.docx_第4页
第4页 / 共56页
火车售票系统完整代码Word文档格式.docx_第5页
第5页 / 共56页
点击查看更多>>
下载资源
资源描述

火车售票系统完整代码Word文档格式.docx

《火车售票系统完整代码Word文档格式.docx》由会员分享,可在线阅读,更多相关《火车售票系统完整代码Word文档格式.docx(56页珍藏版)》请在冰豆网上搜索。

火车售票系统完整代码Word文档格式.docx

);

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,

this.add(buyButton,con);

this.setBorder(BorderFactory.createTitledBorder("

订票操作区"

));

}

*定义下面一个JList用于显示车票的所有信息面板pan4

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());

this.add(btId,con);

this.add(bt1,con);

con=getGridBagConstraints(2,0,1,1,0,100,

this.add(bt2,con);

con=getGridBagConstraints(3,0,1,1,0,100,

this.add(bt3,con);

con=getGridBagConstraints(4,0,1,1,0,100,

this.add(bt4,con);

con=getGridBagConstraints(5,0,1,1,0,100,

this.add(bt5,con);

con=getGridBagConstraints(6,0,1,1,0,100,

this.add(bt6,con);

con=getGridBagConstraints(7,0,1,1,0,100,

this.add(bt7,con);

this.add(bt8,con);

this.add(bt9,con);

con=getGridBagConstraints(0,1,11,1,0,100,

this.add(jtArea,con);

jtArea.setBackground(Color.GREEN);

*定义最下面的按钮面板pan5

classpan5extendsJPanel{

退出登录"

JLabellab1=newJLabel("

publicpan5(){

this.add(lab1,con);

bt1.addActionListener(newActionListener(){

System.exit(0);

*放回一个网格包约束

*@paramx

*@paramy

*@paramwidth

*@paramheigh

*@paramweighx

*@paramweighy

*@paramfill

*@paramanchor

*@return

privateGridBagConstraintsgetGridBagConstraints(intx,inty,intwidth,

intheigh,intweighx,intweighy,intfill,intanchor){

GridBagConstraintscon=newGridBagConstraints();

con.gridx=x;

con.gridy=y;

con.gridwidth=width;

con.gridheight=heigh;

con.weightx=weighx;

con.weighty=weighy;

con.fill=fill;

con.anchor=anchor;

returncon;

*按车票号码搜索所有的车票信息

*@throwsSQLException

privatevoidselect(){

Connectionconn=null;

Statementstmt=null;

ResultSetticket=null;

try{

conn=DriverManager.getConnection(

"

jdbc:

oracle:

thin:

@127.0.0.1:

1521:

ORCL"

"

store"

}catch(SQLExceptione1){

e1.printStackTrace();

stmt=conn.createStatement();

Stringtext="

select*fromtrain_table"

+"

wheretid="

'

"

+fId.getText()+"

;

ticket=stmt.executeQuery(text);

while(ticket.next()){

Stringstarter=ticket.getString("

starter"

Stringreacher=ticket.getString("

reacher"

StringticketNumber=ticket.getString("

ticketNumber"

StringstartTime=ticket.getString("

startTime"

StringendTime=ticket.getString("

endTime"

StringseatIdNumber=ticket.getString("

seatIdNumber"

StringbusDate=ticket.getString("

busDate"

intticketNum=ticket.getInt("

ticketNum"

doubleprice=ticket.getDouble("

price"

sb.append("

+fId.getText()+"

\t"

+"

+starter+"

+reacher

+"

+ticketNumber+"

+startTime+"

+endTime+"

+seatIdNumber+"

+busDate+"

+ticketNum+"

+price+"

\n"

}

jtArea.setText(sb.toString());

if(sb.length()>

0){

sb.delete(1,sb.length());

}else{

JOptionPane.showMessageDialog(newTestFrame(),"

无此车!

}catch(SQLExceptione){

}finally{

if(ticket!

=null){

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 解决方案 > 工作计划

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

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