0% found this document useful (0 votes)
53 views51 pages

Welcome Page: //coding For "NEXT" Button

This document contains code snippets from a Java-based cab booking system. It includes code for buttons to navigate between pages for login, signup, viewing and entering customer and taxi details, and booking a taxi. Database connections are established using JDBC to save and retrieve user and taxi information.

Uploaded by

Abhi Raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views51 pages

Welcome Page: //coding For "NEXT" Button

This document contains code snippets from a Java-based cab booking system. It includes code for buttons to navigate between pages for login, signup, viewing and entering customer and taxi details, and booking a taxi. Database connections are established using JDBC to save and retrieve user and taxi information.

Uploaded by

Abhi Raj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 51

Welcome Page

//Coding for “NEXT” button


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
new p2().setVisible(true);

Page 1 of 51
Home Page for Cab Booking System

//Coding for “CREATE NEW ACCOUNT” button

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {


new p13().setVisible(true);

//Coding for “LOG IN” button

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
new p3().setVisible(true);

Page 2 of 51
Log In Window

// Import package

import java.sql.*;
import javax.swing.JOptionPane;

// Coding for “LOG IN” button

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
String userid=p1.getText();
String password=new String(p2.getPassword());
Page 3 of 51
try
{
Class.forName("java.sql.DriverManager");
Connection
con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/x11","r
oot","123");
Statement st=(Statement)con.createStatement();
String q="Select * from login";
ResultSet rs=st.executeQuery(q);
if(rs.next())
{
String us=rs.getString("userid");
String pwd=rs.getString("password");
if((userid.equals(us))&&(password.equals(pwd)))
{
JOptionPane.showMessageDialog(this,"Login Successfully!!");
new p4().setVisible(true);
}
else
{
JOptionPane.showMessageDialog(this,"Sorry! User not found");
p1.setText(" ");
p2.setText(" ");
}
}
con.close();
st.close();
}
catch(Exception e)

Page 4 of 51
{
JOptionPane.showMessageDialog(this, e.getMessage());
}

Page 5 of 51
Input Window for Sign up

// Import package

import java.sql.*;
import javax.swing.JOptionPane;

// Coding for back button

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {


new p2().setVisible(true);
Input for login frame

Page 6 of 51
// Coding for “SAVE” button

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
int customer_id=Integer.parseInt(t20.getText());
String first_name=t21.getText();
String last_name=t22.getText();
int phone_no=Integer.parseInt(t23.getText());
String email_id=t24.getText();
String city=t25.getText();
String state=t26.getText();
String address=t27.getText();
try
{
Class.forName("java.sql.DriverManager");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost/x11","root","123");
Statement stmt = con.createStatement();
String query="insert into signup
values('"+customer_id+"','"+first_name+"','"+last_name+"','"+phone_no+"','"+email_i
d+"','"+city+"','"+state+"','"+address+"');";
stmt.executeUpdate(query);
JOptionPane.showMessageDialog(this, "your details have been saved");
}
catch (Exception e)
{
JOptionPane.showMessageDialog(this, e.getMessage());
}

Page 7 of 51
Output Window for Sign up

Page 8 of 51
Homepage For Main Menu

//Click on “MAIN MENU”BUTTON


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new p5().setVisible(true);

Coding for “EXIT” button


int choice = JOptionPane.showOptionDialog(null,
"Do you really want to exit??",
"Quit?",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, null, null);
Page 9 of 51
if (choice == JOptionPane.YES_OPTION)
{
JOptionPane.showMessageDialog(this, "THANKS FOR VISITING");
System.exit(0);
}

Page 10 of 51
Cab Booking Window

Coding for “ TAXI DETAILS”


private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
new p6().setVisible(true);

Page 11 of 51
Enter Cab Details

Import package//

import java.sql.*;
import javax.swing.JOptionPane;

Coding for “ SAVE” Button


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String taxi_no = t1.getText();
String model_type= t2.getText();
String driver = t3.getText();
String capacity= t4.getText();

Page 12 of 51
String price
= t5.getText();

try
{
Class.forName("java.sql.Driver");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost/x11","root","123");
Statement stmt = con.createStatement();
String query="insert into cab
values('"+taxi_no+"','"+model_type+"','"+driver+"','"+capacity+"','"+price+"');";
int executeUpdate = stmt.executeUpdate(query);
JOptionPane.showMessageDialog(this, "record add successfully");
t1.setText(" ");
t2.setText(" ");
t3.setText(" ");
t4.setText(" ");
t5.setText(" ");
}
catch (Exception e)
{
JOptionPane.showMessageDialog(this, e.getMessage());
}

Coding for “ CLEAR”Button


private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
t1.setText(" ");
t2.setText(" ");
t3.setText(" ");

Page 13 of 51
t4.setText(" ");
t5.setText(" ");

Coding for “ BACK TO MAIN MENU”Button

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
new p5().setVisible(true);

Page 14 of 51
Coding for “EXIT” button

int choice = JOptionPane.showOptionDialog(null,


"Do you really want to exit??",
"Quit?",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, null, null);
if (choice == JOptionPane.YES_OPTION)
{
JOptionPane.showMessageDialog(this, "THANKS FOR VISITING");
System.exit(0);
}

Page 15 of 51
Output Window for Cab Detail

Coding for “ CUSTOMER DETAILS”Button


private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new p7().setVisible(true);

Page 16 of 51
Enter Customer Details

// Import package

import java.sql.*;
import javax.swing.JOptionPane;

Coding for “ SAVE”Button

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
String id= t6.getText();
String name= t7.getText();
String address = t8.getText();
String mobile_no= t9.getText();

Page 17 of 51
try
{
Class.forName("java.sql.DriverManager");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost/x11","root","123");
Statement stmt = con.createStatement();
String query="insert into cust
values('"+id+"','"+name+"','"+address+"','"+mobile_no+"')";
stmt.executeUpdate(query);
JOptionPane.showMessageDialog(this, "record add successfully");
// t6.setText(" ");
// t7.setText(" ");
//t8.setText(" ");
// t9.setText(" ");
}
catch (Exception e)
{
JOptionPane.showMessageDialog(this,"record could not be added");
}

Coding for “ CLEAR”Button


private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
t6.setText(" ");
t7.setText(" ");
t8.setText(" ");
t9.setText(" ");

Page 18 of 51
Coding for “ BACK TO MAIN MENU”Button

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
new p5().setVisible(true);

Page 19 of 51
Coding for “QUIT” button

int choice = JOptionPane.showOptionDialog(null,


"Do you really want to exit??",
"Quit?",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, null, null);
if (choice == JOptionPane.YES_OPTION)
{
JOptionPane.showMessageDialog(this, "THANKS FOR VISITING");
System.exit(0);
}

Page 20 of 51
Output Window for Customer Details

Coding for “ BOOK TAXI”Button

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
new p8().setVisible(true);

Page 21 of 51
BOOK TAXI

// Import package

import java.sql.*;
import javax.swing.JOptionPane;

Coding for “ BOOKING CONFIRM”Button

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {


String Book_id= t10.getText();
String pick= t11.getText();
String cust_id = t12.getText();
int person= Integer.parseInt(t13.getText());

Page 22 of 51
int amount= 0;
int discount= Integer.parseInt(t14.getText());
String date= t15.getText();
String drop= t16.getText();
String taxi_id= t17.getText();
int price= Integer.parseInt(t18.getText());

try
{
Class.forName("java.sql.DriverManager");
Connection
con=DriverManager.getConnection("jdbc:mysql://localhost/x11","root","123");
Statement stmt = con.createStatement();
String query="insert into book
values('"+Book_id+"','"+date+"','"+cust_id+"','"+taxi_id+"','"+person+"','"+price+"','"+
discount+"','"+amount+"');";
stmt.executeUpdate(query);
if (r1.isSelected())
amount=(price*person-(price*discount/100));
else
amount=(price*person);
t19.setText(""+amount);

JOptionPane.showMessageDialog(this, "BOOK SUCCESSFULLY");


}
catch (Exception e)
{
JOptionPane.showMessageDialog(this,"record could not be added");
}

Page 23 of 51
Coding for “ BACK TO MAIN MENU”Button
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new p5().setVisible(true);

Page 24 of 51
Coding for “QUIT” button
int choice = JOptionPane.showOptionDialog(null,
"Do you really want to exit??",
"Quit?",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, null, null);
if (choice == JOptionPane.YES_OPTION)
{
JOptionPane.showMessageDialog(this, "THANKS FOR VISITING");
System.exit(0)

Page 25 of 51
Output Window for BOOKING TAXI

Coding for “ BACK TO MAIN MENU”CAB BOOKING WINDOW


Button

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {


// TODO add your handling code here:
new p4().setVisible(true);

Page 26 of 51
Coding for “QUIT” button
int choice = JOptionPane.showOptionDialog(null,
"Do you really want to exit??",
"Quit?",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, null, null);
if (choice == JOptionPane.YES_OPTION)
{
JOptionPane.showMessageDialog(this, "THANKS FOR VISITING");
System.exit(0);

//Click on “VIEW/SHOW”BUTTON
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new p12().setVisible(true);

Page 27 of 51
VIEW /SHOW WINDOW

Coding for “QUIT” button


int choice = JOptionPane.showOptionDialog(null,
"Do you really want to exit??",
"Quit?",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, null, null);
if (choice == JOptionPane.YES_OPTION)
{
JOptionPane.showMessageDialog(this, "THANKS FOR VISITING");
System.exit(0);

Page 28 of 51
Coding for “ CAB DETAIL” Button
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new p9().setVisible(true);

Page 29 of 51
VIEW ENTER CAB DETAIL

// Import package

import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

Coding for “ DISPLAY” Button


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
DefaultTableModel model=(DefaultTableModel)tab1.getModel();
try
{

Class.forName("java.sql.DriverManager");

Page 30 of 51
Connection
con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/x11",
"root", "123");
Statement st =(Statement)con.createStatement();
String query="select* from cab;";
ResultSet rs=st.executeQuery(query);
while (rs.next())
{
String d1=rs.getString("Taxi_no");
String d2=rs.getString("model_type");
String d3=rs.getString("Driver");
String d4=rs.getString("Capacity");
String d5=rs.getString("Price");

model.addRow(new Object[]{d1,d2,d3,d4,d5});
}
rs.close();
con.close();
st.close();
}
catch (Exception e)
{
JOptionPane.showMessageDialog(this, e.getMessage());
}

Page 31 of 51
Output VIEW ENTER CAB DETAIL

Coding for “ BACK TO MAIN MENU”Button


private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new p12().setVisible(true);

Page 32 of 51
Coding for “QUIT” button
int choice = JOptionPane.showOptionDialog(null,
"Do you really want to exit??",
"Quit?",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, null, null);
if (choice == JOptionPane.YES_OPTION)
{
JOptionPane.showMessageDialog(this, "THANKS FOR VISITING");
System.exit(0);
}

Coding for “ CUSTOMER DETAIL” Button


private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new p10().setVisible(true);
}

Page 33 of 51
VIEW ENTER CUSTOMER DETAIL

// Import package

import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

Coding for “ DISPLAY” Button

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

Page 34 of 51
// TODO add your handling code here:

DefaultTableModel model=(DefaultTableModel)tab2.getModel();
try
{

Class.forName("java.sql.DriverManager");
Connection
con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/x11",
"root", "123");
Statement st =(Statement)con.createStatement();
String query="select* from cust;";
ResultSet rs=st.executeQuery(query);
while (rs.next())
{
String d1=rs.getString("id");
String d2=rs.getString("Name");
String d3=rs.getString("Address");
String d4=rs.getString("Mobile_no");
model.addRow(new Object[]{d1,d2,d3,d4,});
}
rs.close();
con.close();
st.close();
}
catch (Exception e)
{
JOptionPane.showMessageDialog(this, e.getMessage());
}

Page 35 of 51
Output VIEW ENTER CUSTOMER
DETAIL

Coding for “ BACK TO MAIN MENU”Button


private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new p12().setVisible(true);

Page 36 of 51
Coding for “QUIT” button
int choice = JOptionPane.showOptionDialog(null,
"Do you really want to exit??",
"Quit?",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, null, null);
if (choice == JOptionPane.YES_OPTION)
{
JOptionPane.showMessageDialog(this, "THANKS FOR VISITING");
System.exit(0);
}

Coding for “ BOOKING DETAIL” Button


private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new p10().setVisible(true);
}

Page 37 of 51
VIEW ENTER BOOKING DETAIL

// Import package

import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

Page 38 of 51
Coding for “ DISPLAY” Button
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
DefaultTableModel model=(DefaultTableModel)tab3.getModel();
try
{

Class.forName("java.sql.DriverManager");
Connection
con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/x11",
"root", "123");
Statement st =(Statement)con.createStatement();
String query="select* from book;";
ResultSet rs=st.executeQuery(query);
while (rs.next())
{
String d1=rs.getString("Book_id");
String d2=rs.getString("Date");
String d3=rs.getString("Customer_id");
String d4=rs.getString("Cab_id");
String d5=rs.getString("Person");
String d6=rs.getString("Price");
String d7=rs.getString("Discount");
String d8=rs.getString("Amount");

model.addRow(new Object[]{d1,d2,d3,d4,d5,d6,d7,d8});
}
rs.close();

Page 39 of 51
con.close();
st.close();
}
catch (Exception e)
{
JOptionPane.showMessageDialog(this, e.getMessage());
}

Page 40 of 51
Output VIEW ENTER BOOK TAXI
DETAIL

Coding for “ BACK TO MAIN MENU”Button


private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new p12().setVisible(true);

Page 41 of 51
Coding for “QUIT” button
int choice = JOptionPane.showOptionDialog(null,
"Do you really want to exit??",
"Quit?",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, null, null);
if (choice == JOptionPane.YES_OPTION)
{
JOptionPane.showMessageDialog(this, "THANKS FOR VISITING");
System.exit(0);
}

Coding for “ SIGNUP” Button


private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new p14().setVisible(true);

Page 42 of 51
VIEW ENTER SIGNUP DETAIL

// Import package
import java.sql.*;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

Coding for “ DISPLAY” Button


private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
DefaultTableModel model=(DefaultTableModel)tab4.getModel();

Page 43 of 51
try
{
Class.forName("java.sql.DriverManager");
Connection
con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/x11",
"root", "123");
Statement st =(Statement)con.createStatement();
String query="select* from Signup;";
ResultSet rs=st.executeQuery(query);
while (rs.next())
{
String d1=rs.getString("Customer_id");
String d2=rs.getString("First_name");
String d3=rs.getString("Last_name");
String d4=rs.getString("Phone_no");
String d5=rs.getString("Email_id");
String d6=rs.getString("City");
String d7=rs.getString("State");
String d8=rs.getString("Address");
model.addRow(new Object[]{d1,d2,d3,d4,d5,d6,d7,d8});
}
rs.close();
con.close();
st.close();
}
catch (Exception e)
{
JOptionPane.showMessageDialog(this, e.getMessage());
}

Page 44 of 51
Output VIEW ENTER SIGNUP
DETAIL

Coding for “ BACK TO MAIN MENU”Button


private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new p12().setVisible(true);

Page 45 of 51
Coding for “QUIT” button
int choice = JOptionPane.showOptionDialog(null,
"Do you really want to exit??",
"Quit?",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,
null, null, null);
if (choice == JOptionPane.YES_OPTION)
{
JOptionPane.showMessageDialog(this, "THANKS FOR VISITING");
System.exit(0);
}

Page 46 of 51
MySQL
Tables

Page 47 of 51
Database Name : “XII”

List of tables in database ‘XII’

Structure of table ‘BOOK :

Page 48 of 51
Records in table ‘BOOK’ :

Structure of table ‘CAB’ :

Records in table ‘CAB’ :

Page 49 of 51
Structure of table ‘CUST’ :

Records in table ‘CUST’ :

Structure of table ‘LOGIN’ :

Page 50 of 51
Records in table ‘LOGIN’ :

Structure of table ‘SIGNUP’ :

Records in table ‘SIGNUP’ :

Page 51 of 51

You might also like