📄 paymentdetails.java
字号:
package airline;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class PaymentDetails extends Frame implements ActionListener
{
String title="Payment Details";
Frame f;
Label lbl_formname=new Label("Payment Details");
Label lbl_pnrno=new Label("PNR no.");
Label lbl_cid=new Label("CustomerID");
Label lbl_noseat=new Label("No of Seats");
Label lbl_amount=new Label("Total Amount");
Label lbl_search=new Label("Search Record With PNR No.");
Button cmd_search,cmd_next,cmd_prev,cmd_first,cmd_last;
int cmd_hieght=30;
int cmd_x=145;
int cmd_y=310;
int cmd_width=60;
int count=0;
TextField tf_pnrno,tf_cid,tf_noseat,tf_amount,tf_search;
Font font=new Font("Times New Roman",0,14);
Font fontform=new Font("Times New Roman",0,25);
int lbl_x=50;
int txt_x=180;
int lbl_y=130;
int txt_y=125;
int lbl_width=120;
int txt_width=150;
int lbl_hieght=20;
int txt_hieght=25;
Connection con;
Statement s1;
ResultSet rs;
int flag=0;
public PaymentDetails()
{
super("Payment Details");
f=new Frame(title);
PayWindowAdapter adapter=new PayWindowAdapter(this);
f.addWindowListener(adapter);
f.setLayout(null);
lbl_formname.setFont(fontform);
lbl_formname.setBounds(150,40,300,75);
f.add(lbl_formname);
lbl_pnrno.setFont(font);
lbl_pnrno.setBounds(lbl_x,lbl_y,lbl_width,lbl_hieght);
f.add(lbl_pnrno);
lbl_cid.setFont(font);
lbl_cid.setBounds(lbl_x,lbl_y+40,lbl_width,lbl_hieght);
f.add(lbl_cid);
lbl_noseat.setFont(font);
lbl_noseat.setBounds(lbl_x,lbl_y+80,lbl_width,lbl_hieght);
f.add( lbl_noseat);
lbl_amount.setFont(font);
lbl_amount.setBounds(lbl_x,lbl_y+120,lbl_width,lbl_hieght);
f.add( lbl_amount);
lbl_search.setFont(font);
lbl_search.setBounds(390,140,200,lbl_hieght);
f.add(lbl_search);
tf_pnrno=new TextField(25);
tf_pnrno.setBounds(txt_x,txt_y,txt_width,txt_hieght);
f.add(tf_pnrno);
tf_cid=new TextField(25);
tf_cid.setBounds(txt_x,txt_y+40,txt_width,txt_hieght);
f.add(tf_cid);
tf_noseat=new TextField(25);
tf_noseat.setBounds(txt_x,txt_y+80,txt_width,txt_hieght);
f.add(tf_noseat);
tf_amount=new TextField(25);
tf_amount.setBounds(txt_x,txt_y+120,txt_width,txt_hieght);
f.add(tf_amount);
tf_search=new TextField(25);
tf_search.setBounds(390,180,txt_width,txt_hieght);
f.add(tf_search);
cmd_next=new Button("Next");
cmd_next.setBounds(cmd_x,cmd_y,cmd_width,cmd_hieght);
cmd_next.addActionListener(this);
f.add(cmd_next);
cmd_prev=new Button("Previous");
cmd_prev.setBounds(cmd_x+90,cmd_y,cmd_width,cmd_hieght);
cmd_prev.addActionListener(this);
f.add(cmd_prev);
cmd_y=350;
cmd_first=new Button("First");
cmd_first.setBounds(cmd_x,cmd_y,cmd_width,cmd_hieght);
cmd_first.addActionListener(this);
f.add(cmd_first);
cmd_last=new Button("Last");
cmd_last.setBounds(cmd_x+90,cmd_y,cmd_width,cmd_hieght);
cmd_last.addActionListener(this);
f.add(cmd_last);
cmd_search=new Button("Search");
cmd_search.setBounds(432,230,cmd_width,cmd_hieght);
cmd_search.addActionListener(this);
f.add(cmd_search);
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Reservation","reservation","varun");
//System.out.print("aaaa ");
s1=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
try{
rs=s1.executeQuery("select * from payment");
rs.next();
}catch(Exception e)
{
System.out.print("Exception occure 11 "+e);
}
tf_cid.setText(rs.getString(1));
tf_pnrno.setText(rs.getString(2));
tf_amount.setText(rs.getString(3));
tf_noseat.setText(rs.getString(4));
}catch(Exception e)
{
System.out.print("Exception occure 12 "+e);
}
flag=0;
f.setSize(600,400);
f.setVisible(true);
}
public void visible()
{
f.setVisible(true);
}
public void paint(Graphics g)
{
}
public void actionPerformed(ActionEvent e)
{
try{
if(e.getSource()==cmd_next)
{
if(flag==0)
{
rs.next();
}
else if(flag==1)
{
rs=s1.executeQuery("select * from payment");
rs.next();
flag=0;
}
tf_cid.setText(rs.getString(1));
tf_pnrno.setText(rs.getString(2));
tf_amount.setText(rs.getString(3));
tf_noseat.setText(rs.getString(4));
}
if(e.getSource()==cmd_prev)
{
if(flag==0)
{
rs.previous();
}
else if(flag==1)
{
rs=s1.executeQuery("select * from payment");
rs.next();
flag=0;
}
tf_cid.setText(rs.getString(1));
tf_pnrno.setText(rs.getString(2));
tf_amount.setText(rs.getString(3));
tf_noseat.setText(rs.getString(4));
}
if(e.getSource()==cmd_search)
{
rs=s1.executeQuery("select * from payment where pnr_no='"+tf_search.getText()+"'");
rs.next();
tf_cid.setText(rs.getString(1));
tf_pnrno.setText(rs.getString(2));
tf_amount.setText(rs.getString(3));
tf_noseat.setText(rs.getString(4));
flag=1;
}
}catch(Exception er){
System.out.println(er);
}
}
class PayWindowAdapter extends WindowAdapter
{
//CustomerDetails sampleFrame;
Frame sampleFrame;
public PayWindowAdapter(PaymentDetails sFrame)
{
System.out.println("window");
this.sampleFrame=sFrame;
}
public void windowClosing(WindowEvent we)
{
System.out.println("terminating");
f.hide();
//System.exit(0);
//sampleFrame.setVisible(false);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -