Description: It is a airways reservation system developed in java
//Login.java
import java.awt.*;
import java.awt.event.*;
public class Login extends Frame implements ActionListener
{
String username = "iamavnish";
String password = "sachin";
TextField t1,t2;
Label l1,l2,l3,l4,l5,l6;
Button b2,b3,b4;
GridBagLayout gbl;
GridBagConstraints gbc;
Font f1,f2;
public Login()
{
//setTitle("Login Screen");
//g = new GridLayout(4,2,0,60);
//setLayout(g);
setBackground(Color.cyan);
f1 = new Font("TimesRoman",Font.BOLD,20);
f2 = new Font("TimesRoman",Font.BOLD,15);
gbl=new GridBagLayout();
gbc=new GridBagConstraints();
setLayout(gbl);
l1 = new Label("Username",Label.CENTER);
l1.setFont(f1);
l2 = new Label("Password",Label.CENTER);
l2.setFont(f1);
l3 = new Label("");
l4 = new Label("");
l5 = new Label("");
l6 = new Label("");
t1 = new TextField(15);
t2 = new TextField(15);
t2.setEchoChar('*');
//b1 = new Button("Change Login Details");
b2 = new Button("Reset");
b2.setFont(f2);
b3 = new Button("Submit");
b3.setFont(f2);
b4 = new Button("Close");
b4.setFont(f2);
gbc.gridx=0;
gbc.gridy=0;
gbl.setConstraints(l1,gbc);
add(l1);
gbc.gridx=2;
gbc.gridy=0;
gbl.setConstraints(t1,gbc);
add(t1);
gbc.gridx=0;
gbc.gridy=2;
gbl.setConstraints(l2,gbc);
add(l2);
gbc.gridx=2;
gbc.gridy=2;
gbl.setConstraints(t2,gbc);
add(t2);
gbc.gridx=0;
gbc.gridy=4;
gbl.setConstraints(l3,gbc);
add(l3);
gbc.gridx=2;
gbc.gridy=4;
gbl.setConstraints(l4,gbc);
add(l4);
gbc.gridx=0;
gbc.gridy=6;
gbl.setConstraints(b2,gbc);
add(b2);
gbc.gridx=2;
gbc.gridy=6;
gbl.setConstraints(b3,gbc);
add(b3);
gbc.gridx=0;
gbc.gridy=8;
gbl.setConstraints(l4,gbc);
add(l4);
gbc.gridx=2;
gbc.gridy=8;
gbl.setConstraints(l5,gbc);
add(l5);
gbc.gridx=0;
gbc.gridy=10;
gbl.setConstraints(b4,gbc);
add(b4);
//add(l1);
//add(t1);
//add(l2);
//add(t2);
//add(b1);
//add(b2);
//add(b3);
//add(b4);
//b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
}
/*public Insets getInsets()
{
return new Insets(40,40,40,40);
}*/
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b2)
{
t1.setText("");
t2.setText("");
}
if(ae.getSource()==b4)
{
System.exit(0);
}
if(ae.getSource()==b3)
{
if((t1.getText().equals(username))&&(t2.getText().equals(password)))
{
MainMenu m = new MainMenu();
setVisible(false);
m.setSize(400,400);
m.setVisible(true);
m.setTitle("Main Menu");
}
else
{
//Warning w = new Warning();
//w.setSize(300,200);
//w.setVisible(true);
//w.setTitle("Message Box");
MessageBox mb = new MessageBox(this);
mb.setLocation(200,200);
mb.setVisible(true);
}
}
/*if(ae.getSource() == b1)
{
Change c = new Change();
c.setSize(400,400);
c.setVisible(true);
c.setTitle("Screen for Changing Login Details");
}*/
}
}
//project.java
import java.awt.*;
import java.awt.event.*;
public class Project extends Frame
{
public static void main(String args[])
{
Login L = new Login();
L.setLocation(200,100);
L.setSize(300,300);
L.setVisible(true);
L.setTitle("Login Screen");
}
}
//Reservation.java
import java.awt.*;
import java.awt.event.*;
public class Reservation extends Frame implements ActionListener
{
Button b1,b2,b3;
Label l1,l2;
GridBagLayout gbl;
GridBagConstraints gbc;
Font f;
Reservation()
{
setBackground(Color.cyan);
f = new Font("TimesRoman",Font.BOLD,20);
gbl=new GridBagLayout();
gbc=new GridBagConstraints();
setLayout(gbl);
b1=new Button("Check Availability");
b1.setFont(f);
b2=new Button(" Create Passenger ");
b2.setFont(f);
// b3=new Button(" Fare Teller ");
// b3.setFont(f);
l1= new Label("");
l2= new Label("");
gbc.gridx=0;
gbc.gridy=0;
gbl.setConstraints(b1,gbc);
add(b1);
gbc.gridx=0;
gbc.gridy=4;
gbl.setConstraints(l1,gbc);
add(l1);
gbc.gridx=0;
gbc.gridy=8;
gbl.setConstraints(b2,gbc);
add(b2);
/* gbc.gridx=0;
gbc.gridy=12;
gbl.setConstraints(l2,gbc);
add(l2);
gbc.gridx=0;
gbc.gridy=16;
gbl.setConstraints(b3,gbc);
add(b3);
*/
b1.addActionListener(this);
b2.addActionListener(this);
// b3.addActionListener(this);
addWindowListener(new W());
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
Check m = new Check();
//setVisible(false);
m.setSize(400,400);
m.setVisible(true);
m.setTitle("Check Availability Screen");
}
if(ae.getSource()==b2)
{
Create v = new Create();
//setVisible(false);
v.setSize(400,500);
v.setVisible(true);
v.setTitle("Create Passenger Screen");
}
/* if(ae.getSource()==b3)
{
Fare f = new Fare();
//setVisible(false);
f.setSize(400,500);
f.setVisible(true);
f.setTitle("Fare Teller Screen");
}
*/
}
class W extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
dispose();
}
}
}
//waiting.java
import java.awt.*;
import java.awt.event.*;
public class Waiting extends Frame
{
Waiting()
{
addWindowListener(new W());
}
class W extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
//dispose();
System.exit(0);
}
}
}
//Warning.java
import java.awt.*;
import java.awt.event.*;
public class Warning extends Frame
{
GridLayout g;
Button b1;
Label l;
Warning()
{
g = new GridLayout(2,1,10,40);
setLayout(g);
l = new Label("Incorrect username or password",Label.CENTER);
b1 = new Button("Ok");
add(l);
add(b1);
b1.addActionListener(new Y());
addWindowListener(new X());
}
class Y implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
//dispose();
System.exit(0);
}
}
}
class X extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
dispose();
}
}
public Insets getInsets()
{
return new Insets(40,40,40,40);
}
/*public static void main(String args[])
{
Warning m = new Warning();
m.setTitle("Message Box");
m.setSize(300,200);
m.setVisible(true);
}*/
}
//Ticket.java
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
public class Ticket extends Frame implements ActionListener
{
TextField t1;
Label l1;
Button b1;
GridBagLayout gbl;
GridBagConstraints gbc;
Connection con;
PreparedStatement ps;
Statement stmt;
ResultSet rs;
int count;
Font f;
Ticket()
{
setBackground(Color.cyan);
t1 = new TextField(20);
l1 = new Label("PNR NO ");
l1.setFont(f);
gbc.gridx=0;
gbc.gridy=0;
gbl.setConstraints(l1,gbc);
add(l1);
gbc.gridx=0;
gbc.gridy=2;
gbl.setConstraints(t1,gbc);
add(t1);
addWindowListener(new W());
}
public void actionPerformed(ActionEvent ae)
{
}
class W extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
dispose();
}
}
/* public static void main(String args[])
{
Ticket t = new Ticket();
t.setSize(400,500);
t.setVisible(true);
t.setTitle("Ticket Screen");
}*/
}
//Messagebox.java
import java.awt.*;
import java.awt.event.*;
public class MessageBox extends Dialog implements ActionListener
{
GridBagLayout gbl;
GridBagConstraints gbc;
FlowLayout F;
Button b1;
Label l;
Font f1,f2;
MessageBox(Frame fm)
{
super(fm,true);
setBackground(Color.cyan);
f1 = new Font("Times Roman",Font.BOLD,20);
f2 = new Font("Times Roman",Font.BOLD,15);
gbl=new GridBagLayout();
gbc=new GridBagConstraints();
setLayout(gbl);
l=new Label("Incorrect username or password",Label.CENTER);
l.setFont(f1);
b1 = new Button(" OK ");
b1.setFont(f2);
gbc.gridx=0;
gbc.gridy=0;
gbl.setConstraints(l,gbc);
add(l);
gbc.gridx=0;
gbc.gridy=4;
gbl.setConstraints(b1,gbc);
add(b1);
setSize(350,200);
setTitle("Message Box");
b1.addActionListener(this);
addWindowListener(new X());
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
setVisible(false);
dispose();
}
}
class X extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
dispose();
}
}
}
//Mainmenu.java
import java.awt.*;
import java.awt.event.*;
public class MainMenu extends Frame implements ActionListener
{
MenuBar mbar;
Menu m1,m2,m3;
MenuItem m1_1,m1_2,m2_1,m2_2,m2_3,m3_1;
public MainMenu()
{
mbar = new MenuBar();
setMenuBar(mbar);
m1=new Menu("Bookings");
mbar.add(m1);
m1_1 = new MenuItem("Reservation");
m1.add(m1_1);
m1_2 = new MenuItem("Cancellation");
m1.add(m1_2);
m2=new Menu("Reports");
mbar.add(m2);
m2_1 = new MenuItem("Confirmed Passengers");
m2.add(m2_1);
m2_2 = new MenuItem("Waiting");
m2.add(m2_2);
m2_3 = new MenuItem("Daily Collection Report");
m2.add(m2_3);
m3=new Menu("Close");
mbar.add(m3);
m3_1 = new MenuItem("Close");
m3.add(m3_1);
m1_1.addActionListener(this);
m1_2.addActionListener(this);
m2_1.addActionListener(this);
m2_2.addActionListener(this);
m2_3.addActionListener(this);
m3_1.addActionListener(this);
addWindowListener(new M());
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==m1_1)
{
Reservation r = new Reservation();
r.setSize(400,400);
r.setVisible(true);
r.setTitle("Reservation Screen");
}
if(ae.getSource()==m1_2)
{
Cancellation c = new Cancellation();
c.setSize(400,400);
c.setVisible(true);
c.setTitle("Cancellation Screen");
}
if(ae.getSource()==m2_1)
{
Confirmed cr = new Confirmed();
cr.setSize(400,400);
cr.setVisible(true);
cr.setTitle("Confirmed Passengers List");
}
if(ae.getSource()==m2_2)
{
Waiting wr = new Waiting();
wr.setSize(400,400);
wr.setVisible(true);
wr.setTitle("Waiting List");
}
if(ae.getSource()==m2_3)
{
Collection dcr = new Collection();
dcr.setSize(400,400);
dcr.setVisible(true);
dcr.setTitle("Daily Collection Report");
}
if(ae.getSource()==m3_1)
{
System.exit(0);
}
}
/*public static void main(String args[])
{
MainMenu m = new MainMenu();
m.setTitle("Main Menu");
m.setSize(400,400);
m.setVisible(true);
}*/
class M extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
dispose();
}
}
}
//Create.java
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
public class Create extends Frame implements ActionListener
{
TextField t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
Label l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12,l13,l14,l15,l16,l17;
Choice c;
Button b1,b2,b3;
GridBagLayout gbl;
GridBagConstraints gbc;
Connection con;
PreparedStatement ps;
Statement stmt;
ResultSet rs;
int count;
Font f;
Create()
{
setBackground(Color.cyan);
f = new Font("TimesRoman",Font.BOLD,20);
gbl=new GridBagLayout();
gbc=new GridBagConstraints();
setLayout(gbl);
l15 = new Label("Flight No");
l15.setFont(f);
l1 = new Label("Travel Date");
l1.setFont(f);
l2 = new Label("FName");
l2.setFont(f);
l3 = new Label("LName");
l3.setFont(f);
l4 = new Label("Age");
l4.setFont(f);
l5 = new Label("Gender");
l5.setFont(f);
l6 = new Label("Address");
l6.setFont(f);
l7 = new Label("Phone");
l7.setFont(f);
l8= new Label("Class");
l8.setFont(f);
l9= new Label("Status");
l9.setFont(f);
t10 = new TextField(20);
t1 = new TextField(20);
t2 = new TextField(20);
t3 = new TextField(20);
t4 = new TextField(20);
t5 = new TextField(20);
t6 = new TextField(20);
t7 = new TextField(20);
t8 = new TextField(20);
t9 = new TextField(20);
c = new Choice();
b1 = new Button("Submit");
b2 = new Button("Reset");
b3 = new Button("Generate Ticket");
l10 = new Label("");
l11 = new Label("");
l12 = new Label("");
l13 = new Label("");
l14 = new Label("");
gbc.gridx=0;
gbc.gridy=0;
gbl.setConstraints(l10,gbc);
add(l10);
c.add("DL - BGR : HA101");
c.add("BGR - DL : HA102");
c.add("DL - BY : HA201");
c.add("BY - DL : HA202");
c.add("DL - KLA : HA301");
c.add("KLA - DL : HA302");
c.add("DL - CHN : HA401");
c.add("CHN - DL : HA402");
c.add("DL - HYD : HA501");
c.add("HYD - DL : HA502");
c.add("DL - PUN : HA601");
c.add("PUN - DL : HA602");
gbc.gridx=2;
gbc.gridy=0;
gbl.setConstraints(c,gbc);
add(c);
gbc.gridx=0;
gbc.gridy=2;
gbl.setConstraints(l13,gbc);
add(l13);
gbc.gridx=2;
gbc.gridy=2;
gbl.setConstraints(l14,gbc);
add(l14);
gbc.gridx=0;
gbc.gridy=4;
gbl.setConstraints(l15,gbc);
add(l15);
gbc.gridx=2;
gbc.gridy=4;
gbl.setConstraints(t10,gbc);
add(t10);
gbc.gridx=0;
gbc.gridy=6;
gbl.setConstraints(l1,gbc);
add(l1);
gbc.gridx=2;
gbc.gridy=6;
gbl.setConstraints(t1,gbc);
add(t1);
gbc.gridx=0;
gbc.gridy=8;
gbl.setConstraints(l2,gbc);
add(l2);
gbc.gridx=2;
gbc.gridy=8;
gbl.setConstraints(t2,gbc);
add(t2);
gbc.gridx=0;
gbc.gridy=10;
gbl.setConstraints(l3,gbc);
add(l3);
gbc.gridx=2;
gbc.gridy=10;
gbl.setConstraints(t3,gbc);
add(t3);
gbc.gridx=0;
gbc.gridy=12;
gbl.setConstraints(l4,gbc);
add(l4);
gbc.gridx=2;
gbc.gridy=12;
gbl.setConstraints(t4,gbc);
add(t4);
gbc.gridx=0;
gbc.gridy=14;
gbl.setConstraints(l5,gbc);
add(l5);
gbc.gridx=2;
gbc.gridy=14;
gbl.setConstraints(t5,gbc);
add(t5);
gbc.gridx=0;
gbc.gridy=16;
gbl.setConstraints(l6,gbc);
add(l6);
gbc.gridx=2;
gbc.gridy=16;
gbl.setConstraints(t6,gbc);
add(t6);
gbc.gridx=0;
gbc.gridy=18;
gbl.setConstraints(l7,gbc);
add(l7);
gbc.gridx=2;
gbc.gridy=18;
gbl.setConstraints(t7,gbc);
add(t7);
gbc.gridx=0;
gbc.gridy=20;
gbl.setConstraints(l8,gbc);
add(l8);
gbc.gridx=2;
gbc.gridy=20;
gbl.setConstraints(t8,gbc);
add(t8);
gbc.gridx=0;
gbc.gridy=22;
gbl.setConstraints(l9,gbc);
add(l9);
gbc.gridx=2;
gbc.gridy=22;
gbl.setConstraints(t9,gbc);
add(t9);
gbc.gridx=0;
gbc.gridy=24;
gbl.setConstraints(l11,gbc);
add(l11);
gbc.gridx=2;
gbc.gridy=24;
gbl.setConstraints(l12,gbc);
add(l12);
gbc.gridx=0;
gbc.gridy=26;
gbl.setConstraints(b1,gbc);
add(b1);
gbc.gridx=2;
gbc.gridy=26;
gbl.setConstraints(b2,gbc);
add(b2);
/* gbc.gridx=0;
gbc.gridy=28;
gbl.setConstraints(l16,gbc);
add(l16);
gbc.gridx=2;
gbc.gridy=28;
gbl.setConstraints(l17,gbc);
add(l17);
gbc.gridx=0;
gbc.gridy=30;
gbl.setConstraints(b3,gbc);
add(b3);
*/
b1.addActionListener(this);
b2.addActionListener(this);
// b3.addActionListener(this);
addWindowListener(new W());
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:MyDataSource1");
ps=con.prepareStatement("insert into Passengers(FlightNo,TravelDate,FName,LName,Age,Gender,Address,Phone,Class,Status)values(?,?,?,?,?,?,?,?,?,?)");
String age = t4.getText();
ps.setString(1,t10.getText());
ps.setString(2,t1.getText());
ps.setString(3,t2.getText());
ps.setString(4,t3.getText());
ps.setInt(5,Integer.parseInt(age));
ps.setString(6,t5.getText());
ps.setString(7,t6.getText());
ps.setString(8,t7.getText());
ps.setString(9,t8.getText());
ps.setString(10,t9.getText());
ps.executeUpdate();
if(t8.getText().equals(String.valueOf('F')))
{
String str = "update Reservation set FSeats=FSeats-1 where FlightNo=? and TravelDate = ?";
ps = con.prepareStatement(str);
ps.setString(1,t10.getText());
ps.setString(2,t1.getText());
count = ps.executeUpdate();
}
if(t8.getText().equals(String.valueOf('B')))
{
String str = "update Reservation set BSeats=BSeats-1 where FlightNo=? and TravelDate = ?";
ps = con.prepareStatement(str);
ps.setString(1,t10.getText());
ps.setString(2,t1.getText());
count = ps.executeUpdate();
}
if(t8.getText().equals(String.valueOf('E')))
{
String str = "update Reservation set ESeats=ESeats-1 where FlightNo=? and TravelDate = ?";
ps = con.prepareStatement(str);
ps.setString(1,t10.getText());
ps.setString(2,t1.getText());
count = ps.executeUpdate();
}
con.close();
t1.setText("");
t2.setText("");
t3.setText("");
t4.setText("");
t5.setText("");
t6.setText("");
t7.setText("");
t8.setText("");
t9.setText("");
t10.setText("");
Ticket t = new Ticket();
//setVisible(false);
t.setSize(400,500);
t.setVisible(true);
t.setTitle("Ticket Screen");
}
catch(SQLException e)
{
System.out.println("2 Error : "+e);
}
catch(Exception ex)
{
System.out.println("Error 1:"+ex);
}
}
if(ae.getSource()==b2)
{
t1.setText("");
t2.setText("");
t3.setText("");
t4.setText("");
t5.setText("");
t6.setText("");
t7.setText("");
t8.setText("");
t9.setText("");
t10.setText("");
}
}
class W extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
dispose();
}
}
public static void main(String args[])
{
Create v = new Create();
v.setSize(400,500);
v.setVisible(true);
v.setTitle("Create Passenger Screen");
}
}
//confirmed.java
import java.awt.*;
import java.awt.event.*;
public class Confirmed extends Frame
{
Confirmed()
{
addWindowListener(new W());
}
class W extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
//dispose();
System.exit(0);
}
}
}
//Collection.java
import java.awt.*;
import java.awt.event.*;
public class Collection extends Frame
{
Collection()
{
addWindowListener(new W());
}
class W extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
dispose();
}
}
}
//check.java
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class Check extends Frame implements ActionListener
{
Label l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,l11,l12;
TextField t1,t2,t3,t4,t5;
Choice c;
Button b1,b2;
GridBagLayout gbl;
GridBagConstraints gbc;
Connection con;
PreparedStatement ps;
Statement stmt;
ResultSet rs;
int count;
Font f;
Check()
{
setBackground(Color.cyan);
f = new Font("TimesRoman",Font.BOLD,20);
gbl=new GridBagLayout();
gbc=new GridBagConstraints();
setLayout(gbl);
l1 = new Label("");
l4 = new Label("");
l5 = new Label("");
l6 = new Label("");
l7 = new Label("");
l2 = new Label("Travel Date");
l2.setFont(f);
l3 = new Label("Flight No");
l3.setFont(f);
l8 = new Label("First Class Seats");
l8.setFont(f);
l9 = new Label("Business Class Seats");
l9.setFont(f);
l10 = new Label("Economy Class Seats");
l10.setFont(f);
l11 = new Label("");
l12 = new Label("");
t1 = new TextField(20);
t2 = new TextField(20);
t3 = new TextField(20);
t4 = new TextField(20);
t5 = new TextField(20);
c = new Choice();
b1 = new Button("Submit");
b2 = new Button("Reset");
gbc.gridx=0;
gbc.gridy=0;
gbl.setConstraints(l1,gbc);
add(l1);
c.add("DL - BGR : HA101");
c.add("BGR - DL : HA102");
c.add("DL - BY : HA201");
c.add("BY - DL : HA202");
c.add("DL - KLA : HA301");
c.add("KLA - DL : HA302");
c.add("DL - CHN : HA401");
c.add("CHN - DL : HA402");
c.add("DL - HYD : HA501");
c.add("HYD - DL : HA502");
c.add("DL - PUN : HA601");
c.add("PUN - DL : HA602");
gbc.gridx=2;
gbc.gridy=0;
gbl.setConstraints(c,gbc);
add(c);
gbc.gridx=0;
gbc.gridy=2;
gbl.setConstraints(l4,gbc);
add(l4);
gbc.gridx=2;
gbc.gridy=2;
gbl.setConstraints(l5,gbc);
add(l5);
gbc.gridx=0;
gbc.gridy=4;
gbl.setConstraints(l2,gbc);
add(l2);
gbc.gridx=2;
gbc.gridy=4;
gbl.setConstraints(t1,gbc);
add(t1);
gbc.gridx=0;
gbc.gridy=6;
gbl.setConstraints(l3,gbc);
add(l3);
gbc.gridx=2;
gbc.gridy=6;
gbl.setConstraints(t2,gbc);
add(t2);
gbc.gridx=0;
gbc.gridy=8;
gbl.setConstraints(l6,gbc);
add(l6);
gbc.gridx=2;
gbc.gridy=8;
gbl.setConstraints(l7,gbc);
add(l7);
gbc.gridx=0;
gbc.gridy=10;
gbl.setConstraints(b1,gbc);
add(b1);
gbc.gridx=2;
gbc.gridy=10;
gbl.setConstraints(b2,gbc);
add(b2);
gbc.gridx=0;
gbc.gridy=12;
gbl.setConstraints(l11,gbc);
add(l11);
gbc.gridx=2;
gbc.gridy=12;
gbl.setConstraints(l12,gbc);
add(l12);
gbc.gridx=0;
gbc.gridy=14;
gbl.setConstraints(l8,gbc);
add(l8);
gbc.gridx=2;
gbc.gridy=14;
gbl.setConstraints(t3,gbc);
add(t3);
gbc.gridx=0;
gbc.gridy=16;
gbl.setConstraints(l9,gbc);
add(l9);
gbc.gridx=2;
gbc.gridy=16;
gbl.setConstraints(t4,gbc);
add(t4);
gbc.gridx=0;
gbc.gridy=18;
gbl.setConstraints(l10,gbc);
add(l10);
gbc.gridx=2;
gbc.gridy=18;
gbl.setConstraints(t5,gbc);
add(t5);
b1.addActionListener(this);
b2.addActionListener(this);
addWindowListener(new W());
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b1)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:MyDataSource1");
ps=con.prepareStatement("Select * from Reservation where TravelDate=? and FlightNo=?");
ps.setString(1,t1.getText());
ps.setString(2,t2.getText());
rs=ps.executeQuery();
rs.next();
t3.setText(Integer.toString(rs.getInt(3)));
t4.setText(Integer.toString(rs.getInt(4)));
t5.setText(Integer.toString(rs.getInt(5)));
con.close();
}
catch(Exception e)
{
System.out.println("2 Error : "+e);
}
}
if(ae.getSource()==b2)
{
t1.setText("");
t2.setText("");
t3.setText("");
t4.setText("");
t5.setText("");
}
}
class W extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
dispose();
}
}
}
//change.java
import java.awt.*;
import java.awt.event.*;
public class Change extends Frame
{
Label l1,l2;
TextField t1,t2;
GridLayout g;
Button b1,b2;
Change()
{
g = new GridLayout(3,2,20,40);
setLayout(g);
l1 = new Label("Username",Label.CENTER);
l2 = new Label("Password",Label.CENTER);
t1 = new TextField(20);
t2 = new TextField(20);
t2.setEchoChar('*');
b1 = new Button("Submit");
b2 = new Button("Close");
b2.addActionListener(new W());
addWindowListener(new L());
add(l1);
add(t1);
add(l2);
add(t2);
add(b1);
add(b2);
}
class W implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b2)
{
dispose();
}
}
}
class L extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
//dispose();
System.exit(0);
}
}
public Insets getInsets()
{
return new Insets(40,40,40,40);
}
public static void main(String args[])
{
Change m = new Change();
m.setTitle("Change Login Details");
m.setSize(400,300);
m.setVisible(true);
}
}
//Cancellation.java
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
public class Cancellation extends Frame implements ActionListener
{
Label l1,l2,l3;
TextField t1;
Button b1,b2;
GridBagLayout gbl;
GridBagConstraints gbc;
Connection con;
PreparedStatement ps;
Statement stmt;
ResultSet rs;
int count;
Font f;
Cancellation()
{
setBackground(Color.cyan);
f = new Font("TimesRoman",Font.BOLD,20);
gbl=new GridBagLayout();
gbc=new GridBagConstraints();
setLayout(gbl);
l1 = new Label("PNR No");
l1.setFont(f);
t1 = new TextField(20);
l2 = new Label("");
l3 = new Label("");
b1 = new Button("Submit");
b2 = new Button("Reset");
gbc.gridx=0;
gbc.gridy=0;
gbl.setConstraints(l1,gbc);
add(l1);
gbc.gridx=2;
gbc.gridy=0;
gbl.setConstraints(t1,gbc);
add(t1);
gbc.gridx=0;
gbc.gridy=2;
gbl.setConstraints(l2,gbc);
add(l2);
gbc.gridx=2;
gbc.gridy=2;
gbl.setConstraints(l3,gbc);
add(l3);
gbc.gridx=0;
gbc.gridy=4;
gbl.setConstraints(b1,gbc);
add(b1);
gbc.gridx=2;
gbc.gridy=4;
gbl.setConstraints(b2,gbc);
add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
addWindowListener(new TU());
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==b2)
{
t1.setText("");
}
if(ae.getSource()==b1)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:MyDataSource1");
ps=con.prepareStatement("select FlightNo,TravelDate,Class from Passengers where PNRNo=?");
String pnrno = t1.getText();
ps.setInt(1,Integer.parseInt(pnrno));
rs=ps.executeQuery();
rs.next();
System.out.println(rs.getString(1)+""+rs.getString(2)+" "+rs.getString(3));
/* if(rs.getString(3).equals(String.valueOf('F')))
{
ps=con.prepareStatement("update Reservation set FSeats=FSeats+1 where FlightNo=? and TravelDate=?");
ps.setString(1,rs.getString(1));
ps.setString(2,rs.getString(2));
count=ps.executeUpdate();
}
if(rs.getString(3).equals(String.valueOf('B')))
{
ps=con.prepareStatement("update Reservation set BSeats=BSeats+1 where FlightNo= ? and TravelDate= ? ");
ps.setString(1,rs.getString(1));
ps.setString(2,rs.getString(2));
count=ps.executeUpdate();
}
if(rs.getString(3).equals(String.valueOf('E')))
{
ps=con.prepareStatement("update Reservation set ESeats=ESeats+1 where FlightNo=? and TravelDate=?");
ps.setString(1,rs.getString(1));
ps.setString(2,rs.getString(2));
count=ps.executeUpdate();
}
*/
ps=con.prepareStatement("delete from Passengers where PNRNo=?");
ps.setInt(1,Integer.parseInt(pnrno));
count = ps.executeUpdate();
con.close();
t1.setText("");
}
catch(Exception e)
{
System.out.println("Error : "+e);
}
}
}
class TU extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
dispose();
}
}
}
END
Best Projects
Bug Trackingsystem,Books online shopping,college management system,HR management system,Internet banking,Online chat room ,Online exam,Telephone billing system,Banking application,ATM database,airways reservation system,virtual network computing ,calculator,SMTP(simple mail transfer protocol)
Archives
-
▼
2008
(101)
-
▼
July
(67)
- Adapter_Demo__Mini
- Applet_Add__Mini
- Applet_Frame__Mini
- Applet_Window__Mini
- Banner__Mini
- Browser__Mini
- Choice_List__Mini
- Clint_Test__Mini
- Color_Demo__Mini
- Double_Buffer__Mini
- First_Applet__Mini
- Grid__Mini
- HServlet__Mini
- Image_Load__Mini
- Image_Swing__Mini
- Inetaddress_Demo1__Mini
- InnerClassdemo__Mini
- Java_Buttons__Mini
- Java_Label__Mini
- Jdbc_test1__Mini
- Jdbc update__Mini
- Jlabeldemo__Mini
- JScrollPaneDemo_Mini
- Key_Events_Mini
- Lawte_Mini
- List_Demo_Mini
- Logo_Mini
- Observed_ImageLoad_Mini
- Rectangles_Mini
- Resize_Me_Mini
- Sample_Applet_Mini
- Sb_Demo_Mini
- Server_Test_Mini
- Servlet_Database_Mini
- servlet_To_Applet_Mini
- Simple_Key_Mini
- Text_Demo_Mini
- Textarea_Demo_Mini
- UDP_Server_Mini
- UDPClient_Mini
- Window_Events_Mini
- Advertising Agency
- Books Online Shopping
- BugTracking System
- College Management Sysyetm
- Doctors
- Human Resource Management System
- Internet Banking
- Intranet Chatting
- Java_Mail_Filter
- MIS Coding Nokia Soft
- Online Cources
- Online Exam
- Power Point Sliding
- Practical_Aircraft_Position
- project planning management
- Puyo Puyo game
- Sliding Window Protocol
- Telephone Billing system
- Voice over internet protocol
- No title
- Banking Application
- ATM Database
- airways reservation system
- Chat Room Application
- Snake(applet)
- Poor Man's PaintShop
-
▼
July
(67)
1 comment:
Database is not provided with java source code.Please provide it as soon as possible because I am requiring the database for running this java project on my PC.Please...........provide it
Post a Comment