0% found this document useful (0 votes)
4 views16 pages

Cs Project

The document outlines a Computer Science investigatory project focused on developing a Railway Management System for ticket booking and train management using Python and Tkinter. It addresses issues in traditional railway systems by automating processes for both passengers and administrators, ensuring efficiency and reducing human error. The project includes system design, code explanations, user interface design, and future enhancement suggestions.

Uploaded by

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

Cs Project

The document outlines a Computer Science investigatory project focused on developing a Railway Management System for ticket booking and train management using Python and Tkinter. It addresses issues in traditional railway systems by automating processes for both passengers and administrators, ensuring efficiency and reducing human error. The project includes system design, code explanations, user interface design, and future enhancement suggestions.

Uploaded by

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

D.A.

V Public School, New Panvel


2024 - 2025
COMPUTER SCIENCE
INVESTIGATORY
PROJECT
Topic:-Ticket Booking and Train
Management System

NAME : Gaurang Sambare


STD : XI – A
ROLL NO: 32
Table of Contents
1.Introduction
2.Problem Statement
3.Objectives
4.Tools and Technologies Used
5.System Design and Architecture
6.Code Explanation
1. Admin Functions
2. User Functions
3. Main Menu
7.User Interface Design
8.Features of the System
9.Challenges Faced and Solutions
10.Future Enhancements
11.Conclusion
12.References
Introduction
This project aims to create a Railway
Management System that automates the
process of train management and ticket
booking using a graphical user interface (GUI).
In real-world train systems, there is a need for
efficient management of train schedules,
ticket booking, and cancellations. The system
is developed using Python and Tkinter,
making it accessible and user-friendly for both
passengers and railway administrators.
The system provides functionalities for adding
and viewing trains, booking and canceling
tickets, and viewing the list of bookings made.
This ensures a smooth operation for both
admins and passengers.
Problem Statement
In many traditional railway systems, managing
train schedules, ticket bookings, and
cancellations can be cumbersome and error-
prone. Passengers may face issues with seat
availability, delayed bookings, and manual
cancellations. Similarly, administrators may
find it challenging to keep track of train
schedules and bookings.
The objective of this project is to address
these issues by creating an automated system
where:
•Admins can manage trains and bookings with
ease.
•Passengers can book and cancel tickets
without any hassle.
By automating these processes, we aim to
reduce human error, save time, and improve
efficiency.
Objectives

Main Objective:
Develop a GUI-based Railway
Management System that automates
ticket booking, train management,
and ensures smooth communication
between users and administrators.
Secondary Objectives:
•Allow admins to add, view, and
manage trains.
•Enable passengers to book and
cancel tickets with ease.
•Provide real-time seat availability
updates and booking information.
Tools and Technologies
Used
•Python:
Python was chosen for this project due to its
simplicity, ease of use, and strong community
support. It also comes with powerful libraries that
are useful for developing applications like this one.
•Tkinter:
Tkinter is a standard Python library used to create
GUI applications. It allows us to design windows,
buttons, labels, and other interactive components
needed for our Railway Management System.
•Random Module:
Used to generate random booking IDs, ensuring
each booking has a unique identifier.
•Messagebox:
Tkinter’s message box is used to display error
messages, success messages, and alerts to users.
System Design and
Architecture
The system follows a client-server architecture,
where:
•The Client is the GUI interface that users interact
with (both admin and passengers).
•The Server is the backend logic (in Python) that
processes the data and handles the operations like
adding trains, booking tickets, and displaying
booking statuses.
Main Components of the System:
1.Admin Functions:
1. Add trains, view available trains, and
manage seat availability.
2.User Functions:
1. Book tickets, cancel tickets, and view
booking information.
Data Structure:
•Trains Dictionary: Stores information about each
train (train number, name, source, destination,
total seats, available seats).
•Bookings Dictionary: Stores booking details
(booking ID, passenger name, age, train number)
Code Explanation
Admin Functions:
Add Train Function:
def add_train():
def save_train():
train_number = train_number_entry.get()
train_name = train_name_entry.get()
source = source_entry.get()
destination = destination_entry.get()
seats = int(seats_entry.get())

if train_number in trains:
messagebox.showerror("Error", "Train already exists!")
return

trains[train_number] = {
"train_name": train_name,
"source": source,
"destination": destination,
"seats": seats,
"available_seats": seats
}
messagebox.showinfo("Success", f"Train {train_name} added
successfully!")
add_train_window.destroy()

This function allows admins to add a new train to the


system. It checks if the train already exists and
ensures the correct train details are entered
View Trains Function:
def view_trains():
view_trains_window = tk.Toplevel()
view_trains_window.title("View Trains")

if not trains:
tk.Label(view_trains_window, text="No trains available.",
font=("Arial", 12)).pack(padx=10, pady=10)
return

for train_number, details in trains.items():


train_info = (f"Train Number: {train_number}\nName:
{details['train_name']}\nSource: {details['source']}\n"
f"Destination: {details['destination']}\nAvailable
Seats: {details['available_seats']}\n")
tk.Label(view_trains_window, text=train_info,
font=("Arial", 12), justify="left", bg="lightblue", relief="ridge",
padx=10, pady=5).pack(padx=10, pady=5, fill="x")

This function displays a list of all available


trains, showing the train number, name,
source, destination, and available seats.
User Functions:
Book Ticket Function:
def book_ticket():
def save_booking():
name = name_entry.get()
age = age_entry.get()
train_number = train_number_entry.get()

if train_number not in trains:


messagebox.showerror("Error", "Train not found!")
return

train = trains[train_number]
if train['available_seats'] <= 0:
messagebox.showerror("Error", "No seats available on this train.")
return

booking_id = random.randint(1000, 9999)


while booking_id in bookings:
booking_id = random.randint(1000, 9999)

trains[train_number]['available_seats'] -= 1
bookings[booking_id] = {
"name": name,
"age": age,
"train_number": train_number,
"train_name": train['train_name']
}
messagebox.showinfo("Success", f"Ticket booked successfully! Your booking ID
is {booking_id}")
book_ticket_window.destroy()

This function handles ticket bookings, ensuring that available


seats are updated and a unique booking ID is generated for each
passenger.
Code Explanation (Continued)
Main Menu:
The main menu is the entry point of the program, where
users can choose to add trains, view available trains, book
tickets, or cancel tickets.
python
def main():
root = tk.Tk()
root.title("Railway Management System")
root.geometry("600x500")
root.config(bg="lightgray")

tk.Label(root, text="--- Railway Management System ---", font=("Arial",


20, "bold"), bg="darkblue", fg="white", padx=10, pady=10).pack(fill="x")

tk.Button(root, text="Add Train", font=("Arial", 14), bg="dodgerblue",


fg="white", command=add_train).pack(pady=10, fill="x")
tk.Button(root, text="View Trains", font=("Arial", 14),
bg="mediumseagreen", fg="white",
command=view_trains).pack(pady=10, fill="x")
tk.Button(root, text="Book Ticket", font=("Arial", 14), bg="darkorange",
fg="white", command=book_ticket).pack(pady=10, fill="x")
tk.Button(root, text="Cancel Ticket", font=("Arial", 14), bg="crimson",
fg="white", command=cancel_ticket).pack(pady=10, fill="x")
tk.Button(root, text="Exit", font=("Arial", 14), bg="black", fg="white",
command=root.destroy).pack(pady=10, fill="x")

root.mainloop()

This function sets up the GUI layout, showing buttons for all
available actions. When a user selects an action, the
corresponding function is called.
User Interface Design
The GUI is designed with simplicity in mind, providing
easy-to-use components such as buttons, labels, and text
fields.
•Add Train Window:
Allows the admin to enter train details such as train
number, name, source, destination, and available seats.
•Book Ticket Window:
Passengers can enter their name, age, and the train
number they wish to book.
•View Trains Window:
Displays all the trains available, including their details.

Features of the System


•Admin Features: Add, view, and manage trains.
•User Features: Book and cancel tickets, view available
seats.
•Real-time Updates: Seat availability is updated in real-
time.
•Error Handling: The system provides user-friendly error
messages for invalid inputs and unavailable seats.
Conclusion
The Railway Management System
provides an efficient and automated
way to manage train bookings and
schedules. By automating the ticket
booking and management process,
we eliminate human errors and
improve efficiency for both
passengers and administrators. The
system can be further enhanced by
integrating databases, user
authentication, and supporting
online bookings.
ACKNOWLEDGEMENT
I wish to express my deep gratitude and sincere thanks to
my Respected Principal Sir, Mr. Sumanth Ghosh of
D.A.V. Public School, New Panvel for his encouragement
and for all the facilities that he provided for this project
work on Ticket Booking and Train Management System
which also encouraged me to do a lot of research work and
learn about new things.
I extend my thanks to my subject teacher Mrs. Neelu
Raina Ma’am .I take this opportunity to express my deep
sense of gratitude for their invaluable guidance, useful
suggestions and constant encouragement, which has
sustained my efforts at all stages of this project work. I
can’t forget to offer my sincere thanks to my parents and
friends who helped me to carry out this project work and
thank them for their valuable advice and support, which I
received from time to time.
TEACHER’S
EVALUATION AND
REMARK

You might also like