CS FLYTX PROJECT 2024-25 CBSE

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

COMPUTER SCIENCE

INVESTIGATORY
PROJECT
TOPIC - FLIGHT MANAGMENT AND BOOKING
SYSTEM “FLYTX”

SUBMITTED TO: MRS.SANDHYA SINGH


SUBMITTED BY: SHUBHAM SRIVASTAVA

BOARD ROLL NO.-_____________________

CLASS- XII-S1

2024-25
INDEX

SERIAL NO. TOPIC

1 CERTIFICATE

2 ACKNOWLEDEGMENT

3 INTRODUCTION TO PROJECT

4 SOURCE CODE

5 DATABSE

6 BIBLIOGRAPHY
CERTIFICATE

This is to certify that Shubham Srivastava, a student of


Class XII-S1, has completed the project titled (FLIGHT
MANAGMENT AND BOOKING SYSTEM “FLYTX”)
under the guidance of Mrs Sandhya Singh (Computer
Science Teacher) during the academic year 2024-25 in
fulfilment of the Computer Science Project Practical
Examination conducted by the Central Board of
Secondary Education.

SIGNATURE SIGNATURE
EXTERNAL EXAMINER INTERNAL EXAMINER

SIGNATURE OF PRINCIPAL
Acknowledgement

I would like to express my heartfelt gratitude to my


Computer Science teacher, Mrs. Sandhya Singh,
whose invaluable guidance and support were
instrumental in completing this project successfully.
Her suggestions and instructions provided the clarity
and direction needed to make this project a success. I
deeply appreciate her patience and dedication
throughout the process.

I am also profoundly grateful to our respected Principal,


Mr. Gaurav Bedi, for his encouragement and support,
which motivated me to strive for excellence. His
leadership and vision have been a constant source of
inspiration.

Lastly, I extend my sincere thanks to my parents and


friends, whose unwavering support and valuable
suggestions played a crucial role in completing this
project. Their encouragement and cooperation during
various phases have been a pillar of strength for me.
INTRODUCTION
The Flight Management and Booking System "FlyteX" is a
comprehensive software solution designed to streamline the
processes of flight scheduling, passenger registration, and
booking management. Developed by Shubham Srivastava
under the guidance of Mrs. Sandhya Singh, this project aims
to provide an efficient, user-friendly platform for both
administrators and passengers.

The system utilizes a MySQL database to store and manage


data related to flights, passengers, and bookings. It includes
features for adding new flights, registering passengers,
booking flights, and displaying available flights. The system is
designed with separate functionalities for admin and user
roles, ensuring that each can perform their respective tasks
efficiently.

The code begins with the creation of a connection to the


MySQL database and the setup of necessary tables for flights,
passengers, and bookings. The admin interface allows for the
addition of new flights and viewing of all available flights. The
user interface includes passenger registration, flight booking,
and viewing of available flights.

Overall, FlyteX provides a robust framework for managing


flight operations, making it easier for administrators to handle
flight schedules and bookings, and for passengers to book
flights conveniently.
SOURCE CODE
Creating Database and Table
import mysql.connector
def cr_con():
con =
mysql.connector.connect(host='localhost',user='root',password='cheeku@18',dat
abase='flightmanage')
return con
def tb(cur):
cur.execute("CREATE DATABASE IF NOT EXISTS flightmanage")
cur.execute("USE flightmanage")
cur.execute("""
CREATE TABLE IF NOT EXISTS flights (
fid INT AUTO_INCREMENT PRIMARY KEY,
fname VARCHAR(100) NOT NULL,
departure VARCHAR(100) NOT NULL,
destination VARCHAR(100) NOT NULL,
departure_time TIME NOT NULL,
arrival_time TIME NOT NULL,
total_seats INT NOT NULL,
available_seats INT NOT NULL)""")
cur.execute("""
CREATE TABLE IF NOT EXISTS passengers (
pid INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
phone BIGINT NOT NULL,
email VARCHAR(100) NOT NULL,
password VARCHAR(100) NOT NULL)""")
cur.execute("""
CREATE TABLE IF NOT EXISTS bookings (
bid INT AUTO_INCREMENT PRIMARY KEY,
pid INT NOT NULL,
fid INT NOT NULL,
bookdate DATE NOT NULL,
FOREIGN KEY (pid) REFERENCES passengers(pid),
FOREIGN KEY (fid) REFERENCES flights(fid))""")
ADDING NEW FLIGHT
def addflight(cur, a):
fname = input("Enter flight name: ")
departure = input("Enter departure city: ")
destination = input("Enter destination city: ")
departure_time = input("Enter departure time : ")
arrival_time = input("Enter arrival time : ")
total_seats = int(input("Enter total seats: "))
available_seats = total_seats
cur.execute("""
INSERT INTO flights (fname, departure, destination, departure_time,
arrival_time, total_seats, available_seats)
VALUES (%s, %s, %s, %s, %s, %s, %s)
""", (fname, departure, destination, departure_time, arrival_time,
total_seats, available_seats))
a.commit()
print("Flight added successfully!")

REGISTERATION
def register(cur, a):
name = input("Enter passenger name: ")
phone = int(input("Enter phone number: "))
email = input("Enter email: ")
password = input("Set a password: ")
cur.execute("""
INSERT INTO passengers (name, phone, email, password)
VALUES (%s, %s, %s, %s)
""", (name, phone, email, password))
a.commit()
print("Passenger added successfully! Remember your password for booking
flights")

BOOKING
def book(cur, a):
try:
phone = int(input("Enter your phone number: "))
password = input("Enter your password: ")
cur.execute("SELECT pid FROM passengers WHERE phone = %s AND password
= %s", (phone, password))
passenger = cur.fetchone()
if not passenger:
print("Invalid phone number or password. Please try again.")
return
pid = passenger[0]
departure = input("Enter flight departure place: ")
destination = input("Enter flight destination place: ")
bookdate = input("Enter booking date (YYYY-MM-DD):")
cur.execute("SELECT fid, available_seats FROM flights WHERE departure
= %s AND destination = %s", (departure, destination))
flights = cur.fetchall()
if not flights:
print("No flights available for this route.")
return
fid = flights[0][0]
available_seats = flights[0][1]

AVAILABLE SEATS
if available_seats > 0:
cur.execute("""
INSERT INTO bookings (pid, fid, bookdate)
VALUES (%s, %s, %s)
""", (pid, fid, bookdate))
cur.execute("UPDATE flights SET available_seats = available_seats
- 1 WHERE fid = %s", (fid,))
a.commit()
print("Flight booked successfully!")
else:
print("No available seats on this flight.")
except ValueError:
print("Invalid input. Please enter valid values.")

AVAILABLE FLIGHTS
def show_flights(cur):
cur.execute("SELECT * FROM flights")
flights = cur.fetchall()
print("Available Flights:")
for i in flights: #flight = "i"
print(f"Flight ID: {i[0]}, Flight Name: {i[1]}, Departure: {i[2]},
Destination: {i[3]}, Departure Time: {i[4]}, Arrival Time: {i[5]}, Available
Seats: {i[7]}")
ADMIN INTERFACE
def admin(cur, a):
while True:
print("\nAdmin Menu:")
print("1. Add Flight")
print("2. Show Flights")
print("3. Exit")
try:
choice = int(input("Enter your choice: "))
if choice == 1:
addflight(cur, a)
elif choice == 2:
show_flights(cur)
elif choice == 3:
break
else:
print("Please choose a correct option.")
except ValueError:
print("Invalid choice. Please enter a number.")

USER INTERFACE
def user(cur, a):
while True:
print("\nUser Menu:")
print("1. Register Passenger")
print("2. Book Flight")
print("3. Show Flights")
print("4. Exit")
try:
choice = int(input("Enter your choice: "))
if choice == 1:
register(cur, a)
elif choice == 2:
book(cur, a)
elif choice == 3:
show_flights(cur)
elif choice == 4:
break
else:
print("Please choose a correct option.")
except ValueError:
print("Invalid choice. Please enter a number.")
MAIN
def main():
con = cr_con()
cur = con.cursor()
tb(cur)
while True:
print("\nMain Menu:")
print("1. Admin")
print("2. User")
print("3. Exit")
try:
choice = int(input("Enter your choice: "))
if choice == 1:
admin(cur, con)
elif choice == 2:
user(cur, con)
elif choice == 3:
break
else:
print("Please choose a correct option.")
except ValueError:
print("Invalid choice. Please enter a number.")

con.close()
print("Welcome to the FlyteX Flight Management & Booking System!")
main()
WORKING SCREENSHOTS
➢ MAIN INTERFACE

➢ ADMIN INTERFACE

➢ ADD FLIGHTS

➢ SHOW FLIGHTS
➢ USER INTERFACE

➢ REGISTER PASSENGER

➢ BOOK FLIGHT
➢ SHOW FLIGHTS (AFTER BOOKING)

➢ EXITING
DATABASE (MY SQL)
➢ FLIGHTMANAGE

➢ TABLES

➢ DATA IN BOOKINGS

➢ DATA IN FLIGHTS
➢ DATA IN PASSENGERS

You might also like