📄 customerdetails.java
字号:
package airline;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class CustomerDetails extends Frame implements ActionListener
{
String title="Customer Details";
public Frame f;
Label lbl_formname=new Label("Customer Details");
Label lbl_cid=new Label("Customer ID");
Label lbl_cname=new Label("Customer Name");
Label lbl_passw=new Label("Password");
Label lbl_address=new Label("Address");
Label lbl_email=new Label("Email");
Label lbl_mno=new Label("Mobile no");
Label lbl_ccno=new Label("Credit card no.");
Label lbl_compname=new Label("Compony Name");
Label lbl_cvv=new Label("CVV");
Label lbl_exp=new Label("Expiery Date");
Button cmd_add,cmd_save,cmd_edit,cmd_delete,cmd_next,cmd_prev,cmd_first,cmd_last;
int cmd_hieght=30;
int cmd_x=250;
int cmd_y=435;
int cmd_width=60;
TextField tf_cid,tf_cname,tf_passw,tf_address,tf_email,tf_ccno,tf_mno,tf_compname,tf_cvv,tf_exp;
Font font=new Font("Times New Roman",0,14);
Font fontform=new Font("Times New Roman",0,25);
int lbl_x=80;
int txt_x=200;
int lbl_y=180;
int txt_y=175;
int lbl_width=105; //105
int txt_width=120;
int lbl_hieght=20;
int txt_hieght=25;
Connection con;
Statement s1;
ResultSet rs;
//yes.resize(20,30);
// f=new CustomerDetails("A Frame Window");
public CustomerDetails()
{
super("Customer Details");
f=new Frame(title);
MyWindowAdapter adapter=new MyWindowAdapter(this);
f.addWindowListener(adapter);
f.setLayout(null);
lbl_formname.setFont(fontform);
lbl_formname.setBounds(300,75,300,75);
f.add(lbl_formname);
lbl_cid.setFont(font);
lbl_cid.setBounds(lbl_x,lbl_y,lbl_width,lbl_hieght);
f.add(lbl_cid);
lbl_cname.setFont(font);
lbl_cname.setBounds(lbl_x,lbl_y+40,lbl_width,lbl_hieght);
f.add(lbl_cname);
lbl_passw.setFont(font);
lbl_passw.setBounds(lbl_x,lbl_y+80,lbl_width,lbl_hieght);
f.add( lbl_passw);
lbl_address.setFont(font);
lbl_address.setBounds(lbl_x,lbl_y+120,lbl_width,lbl_hieght);
f.add( lbl_address);
lbl_email.setFont(font);
lbl_email.setBounds(lbl_x,lbl_y+160,lbl_width,lbl_hieght);
f.add( lbl_email);
tf_cid=new TextField(25);
tf_cid.setBounds(txt_x,txt_y,txt_width,txt_hieght);
f.add(tf_cid);
tf_cname=new TextField(25);
tf_cname.setBounds(txt_x,txt_y+40,txt_width,txt_hieght);
f.add(tf_cname);
tf_passw=new TextField(25);
tf_passw.setBounds(txt_x,txt_y+80,txt_width,txt_hieght);
f.add(tf_passw);
tf_address=new TextField(25);
tf_address.setBounds(txt_x,txt_y+120,txt_width,txt_hieght);
f.add(tf_address);
tf_email=new TextField(25);
tf_email.setBounds(txt_x,txt_y+160,txt_width,txt_hieght);
f.add(tf_email);
lbl_x=400;
lbl_mno.setFont(font);
lbl_mno.setBounds(lbl_x,lbl_y,lbl_width,lbl_hieght);
f.add( lbl_mno);
lbl_ccno.setFont(font);
lbl_ccno.setBounds(lbl_x,lbl_y+40,lbl_width,lbl_hieght);
f.add( lbl_ccno);
lbl_compname.setFont(font);
lbl_compname.setBounds(lbl_x,lbl_y+80,lbl_width,lbl_hieght+10);
f.add( lbl_compname);
lbl_cvv.setFont(font);
lbl_cvv.setBounds(lbl_x,lbl_y+120,lbl_width,lbl_hieght);
f.add( lbl_cvv);
lbl_exp.setFont(font);
lbl_exp.setBounds(lbl_x,lbl_y+160,lbl_width,lbl_hieght);
f.add( lbl_exp);
txt_x=520;
tf_mno=new TextField(25);
tf_mno.setBounds(txt_x,txt_y,txt_width,txt_hieght);
f.add(tf_mno);
tf_ccno=new TextField(8);
tf_ccno.setBounds(txt_x,txt_y+40,txt_width,txt_hieght);
f.add(tf_ccno);
tf_compname=new TextField(25);
tf_compname.setBounds(txt_x,txt_y+80,txt_width,txt_hieght);
f.add(tf_compname);
tf_cvv=new TextField(3);
tf_cvv.setBounds(txt_x,txt_y+120,txt_width,txt_hieght);
f.add(tf_cvv);
tf_exp=new TextField(25);
tf_exp.setBounds(txt_x,txt_y+160,txt_width,txt_hieght);
f.add(tf_exp);
cmd_add=new Button("Add");
cmd_add.setBounds(cmd_x,cmd_y,cmd_width,cmd_hieght);
cmd_add.addActionListener(this);
f.add(cmd_add);
cmd_save=new Button("Save");
cmd_save.setBounds(cmd_x+90,cmd_y,cmd_width,cmd_hieght);
cmd_save.addActionListener(this);
f.add(cmd_save);
cmd_edit=new Button("Edit");
cmd_edit.setBounds(cmd_x+180,cmd_y,cmd_width,cmd_hieght);
cmd_edit.addActionListener(this);
f.add(cmd_edit);
cmd_delete=new Button("Delete");
cmd_delete.setBounds(cmd_x+270,cmd_y,cmd_width,cmd_hieght);
cmd_delete.addActionListener(this);
f.add(cmd_delete);
cmd_y=485;
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_first=new Button("First");
cmd_first.setBounds(cmd_x+180,cmd_y,cmd_width,cmd_hieght);
cmd_first.addActionListener(this);
f.add(cmd_first);
cmd_last=new Button("Last");
cmd_last.setBounds(cmd_x+270,cmd_y,cmd_width,cmd_hieght);
cmd_last.addActionListener(this);
f.add(cmd_last);
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 customer");
rs.next();
//rs.next();
}catch(Exception e)
{
System.out.print("Exception occure 11 "+e);
}
tf_cid.setText(rs.getString(1));
tf_passw.setText(rs.getString(2));
tf_cname.setText(rs.getString(3));
tf_mno.setText(rs.getString(4));
tf_ccno.setText(rs.getString(5));
tf_cvv.setText(rs.getString(6));
tf_compname.setText(rs.getString(7));
tf_exp.setText(rs.getString(8));
tf_address.setText(rs.getString(9));
tf_email.setText(rs.getString(10));
}catch(Exception e)
{
System.out.print("Exception occure 12 "+e);
}
f.setSize(1800,1800);
f.setVisible(true);
}
public void paint(Graphics g)
{
}
public void visible()
{
f.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
try{
if(e.getSource()==cmd_next)
{
rs.next();
tf_cid.setText(rs.getString(1));
tf_passw.setText(rs.getString(2));
tf_cname.setText(rs.getString(3));
tf_mno.setText(rs.getString(4));
tf_ccno.setText(rs.getString(5));
tf_cvv.setText(rs.getString(6));
tf_compname.setText(rs.getString(7));
tf_exp.setText(rs.getString(8));
tf_address.setText(rs.getString(9));
tf_email.setText(rs.getString(10));
}
if(e.getSource()==cmd_prev)
{
rs.previous();
tf_cid.setText(rs.getString(1));
tf_passw.setText(rs.getString(2));
tf_cname.setText(rs.getString(3));
tf_mno.setText(rs.getString(4));
tf_ccno.setText(rs.getString(5));
tf_cvv.setText(rs.getString(6));
tf_compname.setText(rs.getString(7));
tf_exp.setText(rs.getString(8));
tf_address.setText(rs.getString(9));
tf_email.setText(rs.getString(10));
}
if(e.getSource()==cmd_add)
{
tf_cid.setText("");
tf_passw.setText("");
tf_cname.setText("");
tf_mno.setText("");
tf_ccno.setText("");
tf_cvv.setText("");
tf_compname.setText("");
tf_exp.setText("");
tf_address.setText("");
tf_email.setText("");
}
if(e.getSource()==cmd_save)
{
s1.executeUpdate("insert into customer values('"+tf_cid.getText()+"','"+tf_passw.getText()+"','"+tf_cname.getText()+"','"+tf_mno.getText()+"','"+tf_ccno.getText()+"','"+tf_cvv.getText()+"','"+tf_compname.getText()+"','"+tf_exp.getText()+"','"+tf_address.getText()+"','"+tf_email.getText()+"')");
}
}catch(Exception er){
System.out.println(er);
}
}
class MyWindowAdapter extends WindowAdapter
{
//CustomerDetails sampleFrame;
Frame sampleFrame;
public MyWindowAdapter(CustomerDetails 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 + -