Cs Project
Cs Project
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()
if not trains:
tk.Label(view_trains_window, text="No trains available.",
font=("Arial", 12)).pack(padx=10, pady=10)
return
train = trains[train_number]
if train['available_seats'] <= 0:
messagebox.showerror("Error", "No seats available on this train.")
return
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()
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.