Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 50

COMPUTER SCIENCE

INVESTIGATORY PROJECT
COMPUTER SCIENCE
INVESTIGATORY PROJECT
2023-2024

TOPIC: RAILWAY TICKET


RESERVATION SYSTEM

DONE BY:
SHREYA YADAV
CLASS: XII
RNO:
INDEX
CONTENT PAGE NO.
ACKNOWLEDGEMENT 3
CERTIFICATE 4
INTRODUCTION 5
REQUIREMENTS 6
MODULES 7
CODE 17
OUTPUT 27
CONCLUSION 29
ANALYSIS 30
BIBLIOGRAPHY 31
TEACHER’S REMARK 32

ACKNOWLEDGEMENT
I would like to acknowledge the support and
help that was provided by my teachers and
friends for helping me to complete the given
project within the stipulated time.
I would like to thank our respected Principal,
Mr. Chaitanya Chilamkuri Sir for his mutual
support. I would also like to express my
gratitude to my computer science teacher
Mrs. Neelu Raina madam for giving me the
golden opportunity to work on the wonderful
computer science project. Finally I would like to
thank CBSE for giving me this opportunity to
undertake this project.

CERTIFICATE
EXAMINATION ROLL NO:
This is to certify that Miss Shreya Yadav of Class
XII-F has satisfactorily completed his computer
science project work on the topic BANKING
SYSTEM, for AISSCE as prescribed by CBSE for
the year 2023-2024.
Date: _____________

_________________ ________________
Staff member in charge of Signature of the Principal
the batch

__________________ _________________
Rubber stamp of the school Signature of the External
Examiner

INTRODUCTION
Welcome to the Railway Ticket Reservation System, a
Python-based project designed to transform the way you
book train tickets. In a world where technology simplifies
our lives, this system aims to bring convenience to the
traditional ticketing process. By leveraging Python's
Tkinter library for a user-friendly interface and MySQL
for organized data management, we've crafted a platform
where reserving your train seats becomes effortless.
Picture this: choosing your preferred route, checking train
schedules, and making secure payments—all in one place,
at your fingertips. This system streamlines these tasks,
making them easy for users of all ages and technical
backgrounds.
Our project not only focuses on user convenience but also
ensures robust data handling and security. By centralizing
all booking-related information, it becomes a reliable and
efficient tool for passengers. Our mission is to simplify
the complexity of train ticketing, making it accessible and
stress-free for everyone.
Join us on this journey as we redefine the ticket booking
experience, making train travel planning a seamless and
enjoyable endeavour.
REQUIREMENTS

HARDWARE REQUIRED
 Printer, to print the required documents of the
project
 Compact Drive
 Processor : Pentium III
 Ram : 64 MB
 Harddisk : 20 Gb.

SOFTWARE REQUIRED
 Operating system : Windows XP
 IDLE(Python 3.6 32-bit), for execution of program
 MYSQL
Ms word for presentation of output.

MODULES USED
Mysql.Connector Module:

MySQL Connector is a standardized database driver


provided by MySQL to access the MySQL database from
Python. In order to use this module, the mysql connector
is to be downloaded and installed as follows:

C:\Users\Your Name\AppData\Local\Programs\Python\
Python36-32\Scripts>python -m

pip install mysql-connector

import mysql.connector

If the above code is executed with no errors, "MySQL

Connector" is installed and ready to be used.

Tkinter Module:
Before we proceed, let's define some of the common terms.
Window:This term has different meanings in different
contexts, but in general it refers to a rectangular area
somewhere on your display screen.
Top-level window:A window that exists independently
on your screen. It will be decorated with the standard
frame and controls for your system's desktop manager.
You can move it around on your desktop. You can
generally resize it, although your application can prevent
this

Widget:The generic term for any of the building blocks


that make up an application in a graphical user interface.
Examples of widgets: buttons, radio buttons, text fields,
frames, and text labels.

Frame:In Tkinter, the Frame widget is the basic unit of


organization for complex layouts. A frame is a
rectangular area that can contain other widgets.

There are two main methods which the user needs to

remember while creating the Python application with

GUI.

1. Tk():To create a main window, tkinter offers a


method ‘Tk()’. The basic code used to create the main
window of the application is:
from tkinter import *
top = Tk()
Then title, geometry, resizable properties of the master
window are set.
2. Mainloop():There is a method known by the name
mainloop() which is used when you are ready for the
application to run. mainloop() is an infinite loop used
to run the application, wait for an event (e.g. clicking a
mouse button, moving the mouse cursor, pressing a
key etc.) to occur and process the event till the
window is not closed.

top.mainloop()

Tkinter also offers access to the geometric configuration of


the widgets (e.g. label, entry, button, listbox, scrollbar,
canvas, image etc.) which can organize the widgets in the
parent windows

Grid(row=value, column=value, sticky=value)


method:Grid geometry manager places the widgets in a 2-
dimensional table, which consists of a number of rows and
columns. The position of a widget is defined by a row and
a column number. Correspondingly, widgets with the same
row number but different column numbers will be on the
same "line" and will be beside of each other, i.e. to the left
or the right. Sticky is a string that defines how this element
is to be positioned within its parent. This string may
contain zero or more of the characters 'n', 's', 'e', and 'w'.
For example, the value sticky='ns' would stretch this
element to adhere to the north and south sides of the
cavity within its parent element.

There are a number of widgets which you can put in your

tkinter application. Some of the major widgets are

explained below:

Label widget: It refers to the display box where you can


put any text or image which can be updated any time as
per the code. The general syntax is: lbl=Label(master,
text = value) where master is the parameter used to
represent the parent window. The text parameter is set to
the text to be displayed in the label widget. The configure
method of Label widget is used to set font, fg
(foreground colour) of the text.

Button widget:The Button widget is a standard Tkinter


widget, which is used for various kinds of buttons. A
button is a widget which is designed for the user to
interact with, i.e. if the button is pressed by mouse click
some action might be started. They can also contain text
and images like labels. While labels can display text in
various fonts, a button can only display text in a single
font. The text of a button can span

more than one line. A Python function or method can be


associated with a button. This function or method will be
executed, if the button is pressed in some way. The
general syntax is:

w=Button(top , text=value, width=value, command=value)


where top is the parent window where the button widget is
be placed, text is button text, width is button width,
command is the function or method to be called when the
button is clicked. The configure method of the button
widget can be used set value for font, fg (foreground colour
of the button text)

Frame widget:A frame is basically just a container for


other widgets. Each frame has its own grid layout, so the
gridding of widgets within each frame works
independently.

Frame widgets are a valuable tool in making your

application modular. It is used for grouping and

organizing the widgets. The general syntax is:

w = Frame(top)

Mysql.connector.connect() :A connection with the


MySQL server can be established using either the
mysql.connector.connect() function. The syntax is as
follows:

conn = mysql.connector.connect(host=value, user=value,


password=value, database=value)
where host is the host name or IP address of the MySQL

server, user and password are used to login to the MySQL


server and database is the database name to use when

connecting with the MySQL server.

Mysql.connector.connect() :A connection with the


MySQL server can be established using either the
mysql.connector.connect() function. The syntax is as
follows:

conn = mysql.connector.connect(host=value, user=value,


password=value, database=value)
where host is the host name or IP address of the MySQL

server, user and password are used to login to the MySQL

server and database is the database name to use when

connecting with the MySQL server.

Cursor() Function:A database cursor is a useful control


structure of database connectivity. When you connect to a
database from within a program, the sql query gets sent to
the database server, where it gets executed and the result
set (the set of records retrieved as per query) is sent over
the connection to you in one go. But you may want to
access the retrieved data, one row at a time. But query
processing cannot happen as one row at a time, so a special
type of control structure called database cursor can be
created that gets access of all the records as per

query (called the result set) and allows you to traverse the
resultset row by row. The syntax to create a database cursor
is as follows: cur = conn.cursor()where we established
database connection through connection object “conn”
earlier and we have created a cursor object “cur” using the
same connection object “conn”.

Execute() Function:Once you have created a cursor, you


can execute SQL query using execute() function with the
cursor object as per following syntax: cur.execute(“select *
from book”)

where the above code will execute the given SQL query and

retrieve the records (i.e. the resultset) in the cursor object

“cur” which you can then use in your program as required.

Fetchall() Function:Once the result of SQL query is


available in the form of a resultset stored in a cursor
object, you can extract data from the resultset using
fetchall() function. The syntax is as follows:
rows=cur.fetchall()where the above command will return
all the records retrieved as per query in a tuple “rows”.

Rowcount:It is a property of cursor object that returns


the number of rows retrieved from the cursor so far (e.g.
cur.rowcount ).

Commit() Function: With INSERT, UPDATE, DELETE


queries which make changes to the database, you must
commit your query after executing the queries. For this
you must run commit() function of the connection object
(e.g. conn.commit() )

Close() Function:After going through all the processing,


you need to close the connection established (e.g.
cnx.close() )

Main.py Module:
The master window has two buttons (Enter and Exit).
Login_command() function is called when the user
clicks on the Enter button and the master window is
closed when Exit button is clicked.

len() function :The len() function returns the number


of items (length) of an object.

The syntax of len() is: len(s)


where s is sequence (string, bytes, tuple, list, or range) or a
collection.

Int() function: The int() function returns an integer

object from any number or string.

The syntax is: int(value, base)

Where value is a number or a string that can be

converted into an integer number and base is a

number representing the number format. Default

value: 10
str() function:This function converts the specified

value into a string.

The syntax is: str(obj=”)

Return a string containing a nicely printable

representation of an object. For strings, this returns

the string itself.

EXECUTION CODE

import mysql.connector
mydb=mysql.connector.connect(host="localhost",user="r
oot",passwd="tiger")
import tkinter
from tkinter import StringVar
from tkinter import OptionMenu
from tkinter import Text
from tkinter import Entry

def main():
main_menu=tkinter.Tk()
main_menu.geometry("900x900")
main_menu.title("RAILWAY RESERVATION
SYSTEM")

l_1=tkinter.Label(main_menu,text="Welcome To Indian
Railway Online Booking",font=("times new
roman",35),fg="black",bg="yellow").pack()#l_1 is the
label displaying text
book_ticket=tkinter.Button(main_menu,text="BOOK
TICKET",font=("times new
roman",35),fg="black",bg="red",command=lambda:book
_ticket_window()).pack()

cancel_ticket=tkinter.Button(main_menu,text="CANCEL
TICKET",font=("times new
roman",35),fg="black",bg="#00BFFF",command=lambda
:cancel_ticket_window()).pack()
check_status=tkinter.Button(main_menu,text="CHECK
STATUS",font=("times new
roman",35),fg="black",bg="purple",command=lambda:ch
eck_status_window()).pack()

exit_key_1=tkinter.Button(main_menu,text="EXIT",com
mand=main_menu.destroy,font=("times new
roman",35),fg="black",bg="violet").pack()
def book_ticket_window():
book_ticket=tkinter.Toplevel()
book_ticket.geometry("300x300")
book_ticket.title("BOOK TICKET")
book_ticket.configure(bg="pink")

def callback():
def confirmation_1():
confirmation_window=tkinter.Toplevel()
confirmation_window.geometry("300x300")
confirmation_window.title("CONFIRM TICKET")
confirmation_window.configure(bg="pink")

l_2=tkinter.Label(confirmation_window,text="TRAIN
AVAILABLE",font=("times new
roman",15),fg="green",bg="pink").grid(row=0,column=0
) #l_2 is a lable

train_data_label_2=tkinter.Label(confirmation_window,te
xt="TRAIN NO: "+str(x[0]),font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=40)

train_data_label_3=tkinter.Label(confirmation_window,te
xt="TRAIN NAME: "+str(x[1]),font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=60)

train_data_label_4=tkinter.Label(confirmation_window,te
xt="DATE OF DEPARTURE: "+str(x[2]),font=("times
new roman",10),fg="black",bg="pink").place(x=0,y=80)

train_data_label_5=tkinter.Label(confirmation_window,te
xt="DATE OF ARRIVAL: "+str(x[3]),font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=100)
train_data_label_6=tkinter.Label(confirmation_window,te
xt="DEPARTURE: "+str(x[4]),font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=120)

train_data_label_7=tkinter.Label(confirmation_window,te
xt="ARRIVAL: "+str(x[5]),font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=140)
if x[6]>0:

train_data_label_8=tkinter.Label(confirmation_window,te
xt="STATUS: "+"AVAILABLE",font=("times new
roman",10),fg="green",bg="pink").place(x=0,y=160)
else:

train_data_label_8=tkinter.Label(confirmation_window,te
xt="STATUS: "+"WAITING",font=("times new
roman",10),fg="red",bg="pink").place(x=0,y=160)

proceed_button=tkinter.Button(confirmation_window,text
="PROCEED",command=payment,font=("times new
roman",10),fg="black",bg="light blue").place(x=0,y=200)

def confirmation_2():
confirmation_window=tkinter.Toplevel()
confirmation_window.geometry("300x300")
confirmation_window.title("CONFIRM TICKET")
confirmation_window.configure(bg="pink")

l_2=tkinter.Label(confirmation_window,text="SORRY!
NO SCHEDULE TRAIN FOUND",font=("times new
roman",10),fg="red",bg="pink").pack()

exit_key_2=tkinter.Button(confirmation_window,text="G
O
BACK",command=confirmation_window.destroy,font=("
times new roman",10),fg="black",bg="light blue").pack()

def payment():
payment_window=tkinter.Toplevel()
payment_window.geometry("300x300")
payment_window.title("PAYMENT WINDOW")
payment_window.configure(bg="pink")
card_var=StringVar()
card_var.set(" ")

card_menu=OptionMenu(payment_window,card_var,"CR
EDIT CARD","DEBIT
CARD","UPI").grid(row=0,column=1)

card_label=tkinter.Label(payment_window,text="PAYM
ENT METHOD",font=("times new
roman",10),fg="black",bg="pink").grid(row=0,column=0)

card_no_label=tkinter.Label(payment_window,text="CA
RD NO.",font=("times new
roman",10),fg="black",bg="pink").grid(row=1,column=0)

card_no=Entry(payment_window,width=14,show="*").gr
id(row=1,column=1)

cvv_label=tkinter.Label(payment_window,text="CVV",f
ont=("times new
roman",10),fg="black",bg="pink").grid(row=2,column=0)

cvv=Entry(payment_window,show="*",width=3).grid(ro
w=2,column=1)

exp_mon_label=tkinter.Label(payment_window,text="E
XPIRY MONTH",font=("times new
roman",10),fg="black",bg="pink").grid(row=3,column=0)
exp_mon=Text(payment_window,width=2,height=0.25).g
rid(row=3,column=1)

exp_year_label=tkinter.Label(payment_window,text="EX
PIRY YEAR",font=("times new
roman",10),fg="black",bg="pink").grid(row=4,column=0)

exp_year=Text(payment_window,width=4,height=0.25).g
rid(row=4,column=1)

payment_button=tkinter.Button(payment_window,text="
MAKE PAYMENT",font=("times new
roman",10),fg="black",bg="light
blue",command=final_confirmation).grid(row=5,column=
0)
def final_confirmation():
final_window=tkinter.Tk()
final_window.geometry("300x300")
final_window.title("PNR NUMBER")
final_window.configure(bg="pink")

query_2="select * from Reservation_Table"


cursor_object.execute(query_2)
l=cursor_object.fetchall()#gets everything from the
table in form of tuple in a series
for i in l:
pnr_no=i[0]

if pnr_no==None:
pnr_no=100001
else:
pnr_no=pnr_no+1
password=random.randint(10000,99999)
if x[6]>0:
st="CONFIRMED"
m=x[6]
cursor_object.execute("update ticket_booking_table
set SEAT_AVAILABLE=%s where t_no=%s",(m-
1,x[0]))
database.commit()
else:
st="WAITING"
cursor_object.execute("insert into Reservation_Table
values(%s,%s,%s,%s,%s,%s,%s,%s,%s)",
(pnr_no,password,x[0],x[1],x[2],x[3],x[4],x[5],st))
database.commit()

l_3=tkinter.Label(final_window,text="PAYMENT
SUCCESSFULL \n YOUR TICKET HAS BEEN
BOOKED",font=("times new
roman",10),fg="green",bg="pink").grid(row=0,column=0
)
pnr_no_label=tkinter.Label(final_window,text="PNR
NO. :"+ str(pnr_no),font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=50)

password_label=tkinter.Label(final_window,text="PASS
WORD :"+str(password),font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=70)
l_4=tkinter.Label(final_window,text="(PLEASE
SAVE FOR FUTURE REFERENCE)",font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=90)

exit_key_3=tkinter.Button(final_window,text="EXIT",co
mmand=final_window.destroy,font=("times new
roman",10),fg="black",bg="light blue").place(x=0,y=130)
a=from_var.get()
b=to_var.get()
c=date_input.get("1.0","end-1c")
cursor_object=database.cursor()
query_1 ="select * from ticket_booking_table"
cursor_object.execute(query_1)
m=cursor_object.fetchall()#gets everything from the
table in form of tuple in a series
for x in m:
if x[4]==a and x[5]== b and x[2]==c:

h=1
break
else:

h=0
if h==1:
confirmation_1()
elif h==0:
confirmation_2()

from_var=StringVar()
from_var.set(" ")

from_menu=OptionMenu(book_ticket,from_var,"MUMB
AI","KOLKATA","CHENNAI","DELHI","BHOPAL","J
AIPUR","SEALDAH","JAMMU","DURG","PUNE","K
ANPUR CENTRAL","AGARTALA,DHANBAD
JN","GANDHINAGAR").grid(row=0,column=1)

from_label=tkinter.Label(book_ticket,text="DEPARTUR
E",font=("times new
roman",10),fg="black",bg="pink").grid(row=0,column=0)
to_var=StringVar()
to_var.set(" ")

to_menu=OptionMenu(book_ticket,to_var,"MUMBAI","
KOLKATA","CHENNAI","DELHI","BHOPAL","JAIPU
R","SEALDAH","JAMMU","DURG","PUNE","KANPU
R CENTRAL","AGARTALA,DHANBAD
JN","GANDHINAGAR").grid(row=2,column=1)

to_label=tkinter.Label(book_ticket,text="ARRIVAL",fon
t=("times new
roman",10),fg="black",bg="pink").grid(row=2,column=0)
class_var=StringVar()
class_var.set(" ")

class_menu=OptionMenu(book_ticket,class_var,"EC","1
AC","2AC","3AC","FC","CC","SL").grid(row=3,column
=1)

class_label=tkinter.Label(book_ticket,text="CLASS",font
=("times new
roman",10),fg="black",bg="pink").grid(row=3,column=0)
date_var=StringVar()

date_label=tkinter.Label(book_ticket,text="DATE",font=
("times new
roman",10),fg="black",bg="pink").grid(row=4,column=0)
date_input=Text(book_ticket,width=10,height=0.25)
date_input.grid(row=4,column=1)
date_label_2=tkinter.Label(book_ticket,text="(YYYY-
MM-DD)",font=("times new
roman",10),fg="black",bg="pink").grid(row=5,column=0)

check_avail_button=tkinter.Button(book_ticket,text="CH
ECK AVAILABILITY",font=("times new
roman",10),fg="black",bg="light
blue",command=callback).place(x=0,y=140)

def check_status_window():
def information():
def ticket_details_1():
ticket_details_window=tkinter.Toplevel()
ticket_details_window.geometry("300x300")
ticket_details_window.title("TICKET DETAILS")
ticket_details_window.configure(bg="pink")

l_2=tkinter.Label(ticket_details_window,text="TICKET
DETAILS",font=("times new
roman",15),fg="blue",bg="pink").grid(row=0,column=0)
#l_2 is a lable

train_data_label_2=tkinter.Label(ticket_details_window,t
ext="TRAIN NO: "+str(i[2]),font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=40)

train_data_label_3=tkinter.Label(ticket_details_window,t
ext="TRAIN NAME: "+str(i[3]),font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=60)

train_data_label_4=tkinter.Label(ticket_details_window,t
ext="DATE OF DEPARTURE: "+str(i[4]),font=("times
new roman",10),fg="black",bg="pink").place(x=0,y=80)

train_data_label_5=tkinter.Label(ticket_details_window,t
ext="DATE OF ARRIVAL: "+str(i[5]),font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=100)

train_data_label_6=tkinter.Label(ticket_details_window,t
ext="DEPARTURE: "+str(i[6]),font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=120)

train_data_label_7=tkinter.Label(ticket_details_window,t
ext="ARRIVAL: "+str(i[7]),font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=140)
print(i[8])
if i[8]=="CONFIRMED":

train_data_label_8=tkinter.Label(ticket_details_window,t
ext="STATUS: "+"AVAILABLE",font=("times new
roman",10),fg="green",bg="pink").place(x=0,y=160)
else:
train_data_label_8=tkinter.Label(ticket_details_window,t
ext="STATUS: "+"WAITING",font=("times new
roman",10),fg="red",bg="pink").place(x=0,y=160)

exit_button=tkinter.Button(ticket_details_window,text="
EXIT",command=ticket_details_window.destroy,font=("t
imes new roman",10),fg="black",bg="light
blue").place(x=10,y=190)
def ticket_details_2():
ticket_details_window=tkinter.Toplevel()
ticket_details_window.geometry("300x300")
ticket_details_window.title("TICKET DETAILS")
ticket_details_window.configure(bg="pink")

l_4=tkinter.Label(ticket_details_window,text="INVALID
PNR.NO. OR PASSWORD",font=("times new
roman",10),fg="red",bg="pink").pack() #l_4 is a lable

l_5=tkinter.Label(ticket_details_window,text="PLEASE
TRY AGAIN",font=("times new
roman",10),fg="red",bg="pink").pack() #l_5 is a lable

go_back_button=tkinter.Button(ticket_details_window,te
xt="GO
BACK",command=ticket_details_window.destroy,font=("
times new roman",10),fg="black",bg="light blue").pack()

cursor_object=database.cursor()
d=password_input.get("1.0","end-1c")
e=pnr_no_input.get("1.0","end-1c")
query_3="select * from Reservation_Table"
cursor_object.execute(query_3)
l=cursor_object.fetchall()#gets everything from the
table in form of tuple in a series
for i in l:

if e==str(i[0]) and d==str(i[1]):


ticket_details_1()
break
else:
ticket_details_2()

check_status=tkinter.Toplevel()
check_status.geometry("300x300")
check_status.title("CHECK STATUS")
check_status.configure(bg="pink")
l_2=tkinter.Label(check_status,text="PLEASE ENTER
YOUR PNR. NO. AND PASSWORD",font=("times new
roman",10),fg="black",bg="pink").grid(row=0,column=0)
pnr_no_label=tkinter.Label(check_status,text="PNR.
NO.",font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=40)
pnr_no_input=Text(check_status,width=10,height=0.25)
pnr_no_input.place(x=120,y=40)

password_label=tkinter.Label(check_status,text="PASS
WORD",font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=70)

password_input=Text(check_status,width=10,height=0.25
)
password_input.place(x=120,y=70)

submit_button=tkinter.Button(check_status,text="SUBMI
T",command=information,font=("times new
roman",10),fg="black",bg="light
blue").place(x=10,y=120)
def cancel_ticket_window():
def information():
def cancellation():
cancel_ticket=tkinter.Toplevel()
cancel_ticket.geometry("300x300")
cancel_ticket.title("CANCEL TICKET")
cancel_ticket.configure(bg="pink")

cancel_ticket_label=tkinter.Label(cancel_ticket,text="YO
UR TICKET HAS BEEN CANCELLED",font=("times
new roman",10),fg="red",bg="pink").place(x=30,y=0)

return_payment_label=tkinter.Label(cancel_ticket,text="
YOUR PAYMENT WILL BE RETURNED \n WITHIN
1 TO 2 WORKING DAYS",font=("times new
roman",10),fg="red",bg="pink").place(x=30,y=20)

exit_key_1=tkinter.Button(cancel_ticket,text="EXIT",co
mmand=cancel_ticket.destroy,font=("times new
roman",12),fg="black",bg="lightblue").place(x=120,y=60
)
cursor_object.execute("delete from reservation_table
where PNR_NO=%s",(i[0],))
database.commit()
t=[]
if i[8]=="CONFIRMED":
for x in l:
if x[2]==i[2] and x[8]=="WAITING":
t.append(x[0])
if t==[]:
cursor_object.execute("update
ticket_booking_table set
SEAT_AVAILABLE=SEAT_AVAILABLE+1 where
t_no=%s",(i[2],))
database.commit()
else:
cursor_object.execute("update reservation_table set
STATUS='CONFIRMED' where PNR_NO=%s",
(min(t),))
database.commit()
def ticket_details():
ticket_details_window=tkinter.Toplevel()
ticket_details_window.geometry("300x300")
ticket_details_window.title("TICKET DETAILS")
ticket_details_window.configure(bg="pink")

l_2=tkinter.Label(ticket_details_window,text="TICKET
DETAILS",font=("times new
roman",15),fg="blue",bg="pink").grid(row=0,column=0)
#l_2 is a lable

train_data_label_2=tkinter.Label(ticket_details_window,t
ext="TRAIN NO: "+str(i[2]),font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=40)

train_data_label_3=tkinter.Label(ticket_details_window,t
ext="TRAIN NAME: "+str(i[3]),font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=60)

train_data_label_4=tkinter.Label(ticket_details_window,t
ext="DATE OF DEPARTURE: "+str(i[4]),font=("times
new roman",10),fg="black",bg="pink").place(x=0,y=80)

train_data_label_5=tkinter.Label(ticket_details_window,t
ext="DATE OF ARRIVAL: "+str(i[5]),font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=100)

train_data_label_6=tkinter.Label(ticket_details_window,t
ext="DEPARTURE: "+str(i[6]),font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=120)
train_data_label_7=tkinter.Label(ticket_details_window,t
ext="ARRIVAL: "+str(i[7]),font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=140)
if i[8]=="CONFIRMED":

train_data_label_8=tkinter.Label(ticket_details_window,t
ext="STATUS: "+"AVAILABLE",font=("times new
roman",10),fg="green",bg="pink").place(x=0,y=160)
else:

train_data_label_8=tkinter.Label(ticket_details_window,t
ext="STATUS: "+"WAITING",font=("times new
roman",10),fg="red",bg="pink").place(x=0,y=160)

cancel_button=tkinter.Button(ticket_details_window,text
="CANCEL TICKET",font=("times new
roman",10),command=cancellation,fg="black",bg="light
blue").place(x=10,y=190)
def ticket_details_2():
ticket_details_window=tkinter.Toplevel()
ticket_details_window.geometry("300x300")
ticket_details_window.title("TICKET DETAILS")
ticket_details_window.configure(bg="pink")
l_4=tkinter.Label(ticket_details_window,text="INVALID
PNR.NO. OR PASSWORD",font=("times new
roman",10),fg="red",bg="pink").pack() #l_4 is a lable

l_5=tkinter.Label(ticket_details_window,text="PLEASE
TRY AGAIN",font=("times new
roman",10),fg="red",bg="pink").pack() #l_5 is a lable

go_back_button=tkinter.Button(ticket_details_window,te
xt="GO
BACK",command=ticket_details_window.destroy,font=("
times new roman",10),fg="black",bg="light blue").pack()
cursor_object=database.cursor()
d=password_input.get("1.0","end-1c")
e=pnr_no_input.get("1.0","end-1c")
query_3="select * from Reservation_Table"
cursor_object.execute(query_3)
l=cursor_object.fetchall()#gets everything from the
table in form of tuple in a series
for i in l:

if e==str(i[0]) and d==str(i[1]):


ticket_details()
break
else:
ticket_details_2()
cancel_ticket=tkinter.Toplevel()
cancel_ticket.geometry("300x300")
cancel_ticket.title("CANCEL TICKET")
cancel_ticket.configure(bg="pink")
l_2=tkinter.Label(cancel_ticket,text="PLEASE ENTER
YOUR PNR. NO. AND PASSWORD",font=("times new
roman",10),fg="black",bg="pink").grid(row=0,column=0)
pnr_no_label=tkinter.Label(cancel_ticket,text="PNR.
NO.",font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=40)
pnr_no_input=Text(cancel_ticket,width=10,height=0.25)
pnr_no_input.place(x=120,y=40)

password_label=tkinter.Label(cancel_ticket,text="PASS
WORD",font=("times new
roman",10),fg="black",bg="pink").place(x=0,y=70)
password_input=Text(cancel_ticket,width=10,height=0.2
5)
password_input.place(x=120,y=70)

submit_button=tkinter.Button(cancel_ticket,text="SUBM
IT",command=information,font=("times new
roman",10),fg="black",bg="light
blue").place(x=10,y=120)

#__MAIN__

main()
Outputtt
Main System Page:

Book ticket button opens DEPARTURE:


After DEPARTURE comes ARRIVAL:

CLASS CATEGORY:
CANCELLATION OF TICKET:

CHECKING OF STATUS:
CONCLUSION

In conclusion, the development of a railway ticket reservation


system stands as a testament to the modernization of traditional
ticketing processes. Through the utilization of technology,
particularly with the integration of a user-friendly graphical
interface using Tkinter in Python and MySQL for database
management, this system aims to streamline and enhance the
ticket booking experience for passengers.
The system's functionalities span from booking tickets, checking
ticket availability, managing reservations, and even facilitating
cancellation processes. By providing users with an intuitive
interface, the system ensures ease of access and efficient
navigation through the various booking stages.
Moreover, the utilization of a robust database management
system like MySQL empowers the system to handle extensive
data efficiently, maintaining accurate records of reservations,
train schedules, and passenger information.
However, it's crucial to note that the system's effectiveness and
scalability rely heavily on continuous maintenance, security
measures, and updates to cater to evolving user needs and
technological advancements.
In essence, this railway ticket reservation system project not
only aims to revolutionize the booking experience but also
serves as a foundational framework that can adapt and evolve to
meet the ever-changing demands of the railway industry."
Analysis

This project has helped me to understand the basics


of python programming and to gain hands-on
experience on testing this knowledge of python
Tkinter GUI(Graphical User Interface)module, error
handling, data validation, connectivity between
python frontend and MYSQL database backend
BIBLIOGRAPHY

 Stationary referred:
o Computer Science With PYTHON By
Sumita Arora
 Websites:
o https://docs.python.org/3/tutorial
o https://www.w3school.com/python/
o https://www.nmt.edu/tcc/help/pubs/
tkinter//tkinter.pdf
o https://tkdocs.com

Teachers remark

Remark:
Signature:

You might also like