0% found this document useful (0 votes)
68 views22 pages

Cs Project PDF

This document appears to be a computer science project report submitted by two students, Megha Acharya and Shabana Khanam, to their teacher Kamlesh Sir. The project is on developing a "Railway Reservation System" using Python and SQL. The report includes sections on importing modules, database details, source code, outputs and references. The source code section provides details on the code developed for the home page interface, booking tickets, viewing trains and bookings.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views22 pages

Cs Project PDF

This document appears to be a computer science project report submitted by two students, Megha Acharya and Shabana Khanam, to their teacher Kamlesh Sir. The project is on developing a "Railway Reservation System" using Python and SQL. The report includes sections on importing modules, database details, source code, outputs and references. The source code section provides details on the code developed for the home page interface, booking tickets, viewing trains and bookings.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Lucky Bal Niketan Sr. Sec.

School

Affiliated to CBSE

“Every Lbnite is an Achiever”

COMPUTER SCIENCE PROJECT


‘RAILWAYS RESERVATION SYSTEM’

SUBMITTED BY:
Megha Acharya (PCM) and Shabana Khanam (PCB)

SUBMITTED TO:
Kamlesh Sir (Computer Science)

SIGNATURE

Page | 1
CERTIFICATE
This is to certify that Megha Acharya of class 12-A (PCM)
and Shabana Khanam of class 12-B (PCB) has
successfully completed their cs project of “Railway
reservation” under the guidance of their cs teacher Mr.
Kamlesh in the session 2022-23 as per the guidelines
issued by Central Board of Secondary Education.

Kamlesh Sir Megha and Shabana


cs teacher class: 12-A & 12-B

Page | 2
ACKNOWLEDGEMENT

 We are deeply indebted to all those who helped us


in completing this project. Firstly, our teacher Mr.
Kamlesh Sir who encouraged, instructed, guided us
with their valuable experiences and advises that
enhanced our performance to its best.

 We are grateful to our family whose blessings and


wishes were with us all the time. Thanks for
supporting us.

 We would like to thank our Friends, who always


backed us whenever we needed.

 Last but not the least thanks to God who helped us


learn every day

Page | 3
INDEX

1 Introduction
2 Imported modules and functions
3 About Database
4 Source Code
5 Outputs
6 References

Page | 4
INTRODUCTION

This project is a mini replica of


Actual Travel bookings. Here we
have taken Railways.

The project suggests the working


Of Railways reservations with the
help of programming language python
and DBMS like SQL. We have used tkinter library in python for
better interface along with other modules and commands and
SQL to store the data in form of relational databases.

The project first takes to home page where the user interacts.
He/she can then view available trains, book their seats in
particular and can view their bookings by ease.

This project is mini project but can be further enhanced with


more facilities and option as per the requirements.

Page | 5
Imported modules and required
functions

MODULES
 Import mysql.connector
 Import tkinter
 Import PIL
 Import tkinter.messagebox

Fucntions
 Connect()
 Cursor()
 Execute()
 Commit()
 Fetchall()
 Fetchone()

Page | 6
About Databases

 DATABASE NAME: TRAINS

 TABLES IN DATABASE:

1. Train-data
2. Passengers
3. login

Page | 7
SOURCE CODE
from tkinter import *

import tkinter.messagebox as tmsg

import mysql.connector as mys

from PIL import Image,ImageTk

from bookings_tr import book_myticketwin

from show_trains import show_alltrains

from bookdetails import show_allbookings

from updatepage import updatepage

from about_us_pg import aboutus

class rail_system:

def __init__(self,root):

wroot=root

wroot.title("THE ROYAL RAILWAYS")

wroot.geometry("1550x800")

def searchbox():

tmsg.showinfo("INFO","SORRY!! IT IS NOT AVAILABLE AT THE MOMENT BUT WILL BE AVAILABLE SOON.")

def settings():

tmsg.showinfo("INFO","WE DONT THINK THE APP NEEDS ANY SETTINGS AT THE MOMENT! :)")

#setting background image

pic=Image.open(r"D:\python programs\pic4.jpg")

pic=pic.resize((1550,160),Image.Resampling.LANCZOS)

root.photo=ImageTk.PhotoImage(pic)

photo_label=Label(image=wroot.photo,padx=3,bg="black",relief=SUNKEN)

photo_label.place(x=0,y=0,width=1550,height=160)

class book_myticketwin:

def __init__(self,root):

self.root=root

self.root.title(" BOOKINGS")

self.root.geometry("1480x520+80+380")

self.root.maxsize(1390,400)

var_sno=StringVar()

x=random.randint(1000,9999)

var_sno.set(str(x))

Page | 8
var_fstname=StringVar()

var_lstname=StringVar()

var_age=StringVar()

var_contactno=StringVar()

var_seatchoice=StringVar()

var_cost=StringVar()

var_modepay=StringVar()

var_initial=StringVar()

var_destined=StringVar()

#amount defing fuction

def counter():

if firstname_rep.get()==""or lastname_rep==""or contactno_rep=="":

tmsg.showerror("ERROR","PLEASE FILL UP THE REQUIRED DETAIL FIRST",parent=self.root)

else:

amt=0

seat=seat_rep.get()

if seat=="Upper Berth":

amt+=150

elif seat=="Lower Berth":

amt+=160

elif seat=="Side Lower":

amt+=130

elif seat=="Side Upper":

amt+=120

elif seat=="Upper Berth":

amt+=155

elif seat=="Window Seat":

amt+=165

elif seat=="":

pass

pay_label.config(text=amt)

def adddata():

confirmpay=confirmpay_rep.get()

amt=pay_label.cget("text")

cp=int(confirmpay)

Page | 9
if confirmpay=="":

tmsg.showerror("ERROR","FIRST FILL UP THE AMOUNT PLEASE",parent=self.root)

elif tname_rep.get()==fname_rep.get():

tmsg.showwarning("WARNING","YOU CANT BOOK TICKET WHERE START AND FINAL STATIONS ARE SAME",parent=self.root)

else:

reply=tmsg.askyesnocancel("CONFIRM","Are You Sure to continue",parent=self.root)

if reply==1:

if cp==amt:

try:

conn=mys.connect(host="localhost",user="root",passwd='0626G7',auth_plugin="mysql_native_password")

curs=conn.cursor()

curs.execute("use trains") #creating a cursor object

curs.execute('insert into passengers values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)',(var_sno.get(),

var_fstname.get(),var_lstname.get(),

var_age.get(),var_contactno.get(),

var_seatchoice.get(),var_cost.get(),

var_modepay.get(),var_fstname.get(),

var_destined.get()))

conn.commit()

conn.close()

tmsg.showinfo("MESSAGE","REGISTRATION HAS BEEN DONE",parent=self.root)

except Exception as ex:

tmsg.showwarning("WARNING",f"SOMETHING WENT WRONG")

else:

tmsg.showerror("ERROR","PLZ ENTER THE RIGHT AMOUNT")

#booking label

namelabel=Label(self.root,text="BOOK MY TICKETS",font=("CALIBRI",30,"bold"),bg="orange",relief=GROOVE,fg="black",bd=4)

namelabel.place(x=0,y=0,width=1390,height=60)

#frame

bframe=Frame(root,bd=4,relief=RIDGE,bg="grey")

bframe.place(x=0,y=60,width=1390,height=340)

#TRAIN FROM LABEL

fname_lbl=Label(bframe,text="TRAIN FROM ",font=("calibri",15,"italic",'bold'),bg="grey",fg="black")

fname_lbl.place(x=50,y=25)
fname_rep=ttk.Combobox(bframe,font=("calibri",16,"italic",'bold'),textvariable=var_initial,values=["Ajmer","Barmer","Bharatpur","Bundi","Bika
ner","Delhi","Jodhpur","Jaiselmer","Jaipur","Kota","Udaipur"],height=4)

fname_rep.current(3)

Page | 10
fname_rep['state']='readonly'

fname_rep.place(y=29,x=210)

#TO STATION LABEL

tname_lbl=Label(bframe,text="TO STATION ",font=("calibri",15,"italic",'bold'),bg="grey",fg="black")

tname_lbl.place(x=50,y=100)
tname_rep=ttk.Combobox(bframe,font=("calibri",16,"italic",'bold'),textvariable=var_destined,values=["Ajmer","Barmer","Bharatpur","Bundi","Bi
kaner","Jodhpur","Jaiselmer","Jaipur","Kota","Kolkata","Luni","Udaipur"],height=4)

tname_rep.current(5)

tname_rep['state']='readonly'

tname_rep.place(y=100,x=210)

#FIRSTNAME LABEL

firstname_lbl=Label(bframe,text="FIRSTNAME",font=("calibri",20,"italic",'bold'),bg="grey",fg="black")

firstname_lbl.place(x=500,y=20)

firstname_rep=Entry(bframe,font=("calibri",15,"italic",'bold'),textvariable=var_fstname,width=15,relief=SUNKEN,bd=3)

firstname_rep.place(x=660,y=23)

#LAST NAME LABEL

lastname_lbl=Label(bframe,text="LASTNAME",font=("calibri",20,"italic",'bold'),bg="grey",fg="black")

lastname_lbl.place(x=500,y=70)

lastname_rep=Entry(bframe,font=("calibri",15,"italic",'bold'),textvariable=var_lstname,width=15,relief=SUNKEN,bd=3)

lastname_rep.place(x=660,y=70)

#CONTACT LABEL

contactno_lbl=Label(bframe,text="CONTACT NO.",font=("calibri",20,"italic",'bold'),bg="grey",fg="black")

contactno_lbl.place(x=500,y=120)

contactno_rep=Entry(bframe,font=("calibri",15,"italic",'bold'),textvariable=var_contactno,width=15,relief=SUNKEN,bd=3)

contactno_rep.place(x=660,y=120)

#DOB LABEL

dob_lbl=Label(bframe,text="DOB",font=("calibri",20,"italic",'bold'),bg="grey",fg="black")

dob_lbl.place(x=900,y=23)

dob_rep=ttk.Spinbox(bframe,font=("calibri",15,"italic",'bold'),width=3,from_=1,to=31,wrap=True)

dob_rep['state']='readonly'

dob_rep.set(1)

dob_rep.place(x=970,y=28)

#month label

month_lbl=Label(bframe,text="MONTH",font=("calibri",20,"italic",'bold'),bg="grey",fg="black")

month_lbl.place(x=1040,y=23)

data=["January","February","March","April","May","June","July","August",'September',"October","November","December"]

month_rep=ttk.Spinbox(bframe,font=("calibri",15,"italic",'bold'),width=7,values=data,wrap=True)

Page | 11
month_rep.set("May")

month_rep['state']='readonly'

month_rep.place(x=1140,y=27)

#year label

yr_lbl=Label(bframe,text="YR",font=("calibri",20,"italic",'bold'),bg="grey",fg="black")

yr_lbl.place(x=1250,y=23)

yr_rep=ttk.Spinbox(bframe,font=("calibri",15,"italic",'bold'),width=5,from_=1920,to=2020,wrap=True)

yr_rep.set("2000")

yr_rep['state']='readonly'

yr_rep.place(x=1290,y=27)

#SEAT BOOKING

seat_lbl=Label(bframe,text="SEAT PREFER",font=("calibri",20,"italic",'bold'),bg="grey",fg="black")

seat_lbl.place(x=500,y=170)

data=["Upper Berth","Lower Berth","Side Lower","Side Upper","Window Seat"]

seat_rep=ttk.Combobox(bframe,font=("calibri",16,"italic",'bold'),width=12,textvariable=var_seatchoice,values=data)

#seat_rep.set("Upper Berth")

seat_rep['state']='readonly'

seat_rep.place(x=660,y=170)

#AGE LABEL

age_lbl=Label(bframe,text="AGE",font=("calibri",20,"italic",'bold'),bg="GREY",fg="black")

age_lbl.place(x=500,y=210)

age_rep=ttk.Spinbox(bframe,font=("calibri",15,"italic",'bold'),textvariable=var_age,width=4,from_=1,to=100,wrap=True)

age_rep['state']='readonly'

age_rep.set(1)

age_rep.place(x=660,y=215)

#RESERVATION ON BOX

reserv_on=Label(bframe,text="RESERVATION ON",font=("times new roman",20,"italic","bold"),bg="black",fg="white",relief=RIDGE)

reserv_on.place(x=50,y=180,width=300,height=40)

re_frame=Frame(bframe,bd=4,relief=RIDGE,bg="grey")

re_frame.place(x=10,y=230,width=450,height=100)

#Date for reservation LABEL

date_lbl=Label(re_frame,text="DATE: ",font=("calibri",25,"italic",'bold'),bg="grey",fg="black")

date_lbl.place(x=15,y=3)

date_rep=ttk.Spinbox(re_frame,font=("calibri",18,"italic",'bold'),width=3,from_=1,to=31,wrap=True)

date_rep['state']='readonly'

date_rep.set(1)

date_rep.place(x=120,y=9)

data=["January","February","March","April","May","June","July","August",'September',"October","November","December"]

Page | 12
month_rep=ttk.Spinbox(re_frame,font=("calibri",18,"italic",'bold'),width=7,values=data,textvariable=StringVar,wrap=True)

month_rep.set("January")

month_rep['state']='readonly'

month_rep.place(x=200,y=9)

yr_rep=ttk.Label(re_frame,font=("calibri",19,"italic",'bold'),text="2023",width=5,relief=SUNKEN)

yr_rep.place(x=320,y=8)

#payment of label

pay_button=Button(bframe,text="AMOUNT",font=("CALIBRI",20,"italic"),command=counter,relief=GROOVE,bg="black",fg="yellow")

pay_button.place(x=500,y=270)

pay_labelsamp=Label(bframe,text="₹",width=1,height=1,font=("CALIBRI",20,"italic"))

pay_labelsamp.place(y=280,x=680)

pay_label=Label(bframe,text="0",width=6,height=1,font=("CALIBRI",20,"italic"))

pay_label.place(y=280,x=700)

#mode of payment frame

modepay_frame=Frame(bframe,bd=4,relief=RIDGE,bg="pink")

modepay_frame.place(x=910,y=100,width=460,height=220)

#title

modepaytitle_lbl=Label(bframe,text="CHOOSEYOURMODEOFPAYMENT",font=("timesnew

roman",15,"italic","bold"),bg="black",fg="white",relief=RIDGE)

modepaytitle_lbl.place(x=915,y=90,width=450,height=30)

#title2

modepay_lbl=Label(bframe,text="HOWDoYOUWANTTOPAY?",font=("timesnew
roman",15,"italic","bold"),bg="magenta",fg="BLACK",relief=RIDGE)

modepay_lbl.place(x=915,y=125,width=450,height=20)

#MODE TO PAY CHOICE

data_pay=["UPI","PAYTM","GOOGLE PAY","CREDIT","DEBIT"]

modepay_rep=ttk.Combobox(bframe,font=("calibri",16,"italic",'bold'),textvariable=var_modepay,width=35,values=data_pay)

modepay_rep['state']='readonly'

modepay_rep.current(0)

modepay_rep.place(x=940,y=160)

#CONFIRMATION BOX

confirmpay_lbl=Label(bframe,text="Enter the amount to confirm",font=("times new


roman",18,"italic","bold"),bg="magenta",fg="BLACK",relief=RIDGE)

confirmpay_lbl.place(x=920,y=210,width=320,height=25)

confirmpay_rep=ttk.Entry(bframe,textvariable=var_cost,font=("times new roman",18,"italic","bold"))

confirmpay_rep.place(x=1280,y=210,width=70,height=25)

conf_button=Button(bframe,text="CONFIRM",font=("CALIBRI",15,"italic"),command=adddata,relief=GROOVE,bg="black",fg="yellow")

Page | 13
conf_button.place(x=1090,y=265)

warninglbl=Label(bframe,text="Fill All The Required Details Properly.Ensure To Recheck The Form Again Before Submitting! Happy
Journey!!",font=("times new roman",7,"bold"))

warninglbl.pack(side=TOP,fill=X)

if __name__=="__main__":

root=Tk()

obj=book_myticketwin(root)

root.mainloop()

class show_allbookings

def __init__(self,root):

root=root

root.title("SHOW TRAINS")

root.geometry("1480x520+80+380")

root.maxsize(1390,400)

var_sno=StringVar()

x=random.randint(1000,9999)

var_sno.set(str(x))

var_fstname=StringVar()

var_lstname=StringVar()

var_age=StringVar()

var_contactno=StringVar()

var_seatchoice=StringVar()

var_cost=StringVar()

var_modepay=StringVar()

var_initial=StringVar()

var_destined=StringVar()

var_dlt=StringVar()

#NAME LABEL

namelabel=Label(root,text="S H O W A N D S E A R C H A L L B O O K I N G
S",font=("IMPACT",30,"bold"),bg="YELLOW",relief=GROOVE,fg="black",bd=4)

namelabel.place(x=0,y=0,width=1390,height=40)

#frame

bframe=Frame(root,bd=4,relief=RIDGE,bg="ORANGE")

Page | 14
bframe.place(x=0,y=40,width=300,height=360)

tframe=Frame(root,bd=4,relief=RIDGE,bg="pink")

tframe.place(x=305,y=40,width=1080,height=360)

#scroll bar

scroll_x=ttk.Scrollbar(tframe,orient=HORIZONTAL)

scroll_y=ttk.Scrollbar(tframe,orient=VERTICAL)

book_table=ttk.Treeview(tframe,column=("SNO","FIRSTNAME","LASTNAME","AGE","CONTACT NO",

"SEAT CHOICE","COST","MODE OF PAY","INITIAL","DESTINED"),xscrollcommand=scroll_x.set,yscrollcommand=scroll_y.set)

scroll_x.pack(side=BOTTOM,fill=X)

scroll_y.pack(side=RIGHT,fill=Y)

scroll_x.config(command=book_table.xview)

scroll_y.config(command=book_table.yview)

book_table.heading("SNO",text="REFERAL CODE")

book_table.heading("FIRSTNAME",text="FIRSTNAME")

book_table.heading("LASTNAME",text="LASTNAME")

book_table.heading("AGE",text="AGE")

book_table.heading("CONTACT NO",text="CONTACT NO")

book_table.heading("SEAT CHOICE",text="SEAT CHOICE")

book_table.heading("COST",text="COST")

book_table.heading("MODE OF PAY",text="MODE OF PAY")

book_table.heading("INITIAL",text="TRAIN FROM")

book_table.heading("DESTINED",text="TO STATION")

book_table["show"]="headings"

book_table.column("SNO",width=100)

book_table.column("FIRSTNAME",width=200)

book_table.column("LASTNAME",width=200)

book_table.column("AGE",width=100)

book_table.column("CONTACT NO",width=200)

book_table.column("SEAT CHOICE",width=200)

book_table.column("COST",width=100)

book_table.column("MODE OF PAY",width=200)

book_table.column("INITIAL",width=200)

book_table.column("DESTINED",width=200)

book_table.pack(fill=BOTH,expand=2)

def show():

conn=mys.connect(host="localhost",user="root",passwd='0626G7',auth_plugin="mysql_native_password")

curs=conn.cursor() #creating a cursor object

curs.execute('use TRAINS')

Page | 15
curs.execute("select * from passengers")

row=curs.fetchall()

if len(row)!=0:

book_table.delete(*book_table.get_children())

for i in row:

book_table.insert("",END,values=i)

conn.commit()

conn.close()

def update():

tmsg.showinfo("APOLOGISE","SORRY THIS FUNCTIONALITY IS NOT AVAILABLE AT THE MOMENT!!!")

def deleting():

def exit():

dframe.destroy()

def sure():

if var_dlt.get()=="":

tmsg.showerror("ERROR","PLEASE ENTER THE DETAIL FIRST",parent=root)

else:

var=var_dlt.get()

#var=int(c)

conn=mys.connect(host="localhost",user="root",passwd='0626G7',auth_plugin="mysql_native_password")

curs=conn.cursor() #creating a cursor object

curs.execute('use TRAINS')

query="delete from passengers where contactno=%s"

val=(var,)

curs.execute(query,val)

conn.commit()

conn.close()

tmsg.showinfo("MESSAGE","SUCCESSFULLY DELETED",parent=root)

dframe=Frame(root,bd=4,relief=RIDGE,bg="cyan")

dframe.place(x=640,y=80,width=200,height=200)

delrow_lbl=Label(dframe,text="ENTER THE CONTACT NO to dlt",font=("calibri",10,"italic",'bold'),bg="grey",fg="black")

delrow_lbl.place(x=10,y=10)

delrow_rep=Entry(dframe,font=("calibri",15,"italic",'bold'),textvariable=var_dlt,width=15,relief=SUNKEN,bd=3)

delrow_rep.place(x=20,y=53)
sure_button=Button(dframe,text="SURE?",font=("CALIBRI",15,"italic"),relief=GROOVE,bd=4,height=1,command=sure,bg="black",fg="white",acti
vebackground="grey")

sure_button.place(x=40,y=100,width=120)

Page | 16
exit_button=Button(dframe,text="EXIT?",font=("CALIBRI",10,"italic"),relief=GROOVE,bd=4,command=exit,bg="black",fg="white",activebackgrou
nd="grey")

exit_button.place(x=50,y=160,width=100)

show_button=Button(bframe,text="SHOW
ALL",font=("CALIBRI",15,"italic"),command=show,relief=GROOVE,bd=15,height=1,bg="red",fg="BLACK",activebackground="grey")
show_button.place(x=0,y=2,width=200)
update_button=Button(bframe,text="UPDATES",font=("CALIBRI",15,"italic"),relief=GROOVE,bd=15,command=update,height=1,bg="red",fg="BLA
CK",activebackground="grey")

update_button.place(x=0,y=80,width=200)

dlt_button=Button(bframe,text="DELETE
BOOKING",font=("CALIBRI",15,"italic"),command=deleting,relief=GROOVE,bd=15,height=1,bg="red",fg="BLACK",activebackground="grey")

dlt_button.place(x=0,y=160,width=200)

if __name__=="__main__":

root=Tk()

obj=show_allbookings(root)

root.mainloop()

Page | 17
OUTPUTS
THE HOME PAGE

SHOWING TRAINS

Page | 18
BOOKING SEAT

SHOWING BOOKINGS

Page | 19
DELETING BOOKINGS

Page | 20
HARDWARE /SOFTWARE
REQUIREMENT

HARDWARE
 Processor-Pentium
 Processor speed-533 MHz
 Ram-2GB or more
 Hard disk-2GB

SOFTWARE
 Operating system-Windows 7 or above
 IDE-IDLE Python
 Front end-Python 3.7 or above
 Back end-MySQL server 3.8.1 or above

Page | 21
REFERENCES

1. www.google.com
2. en.wikipedia.org
3. www.geeksforgeeks.org
4. stackoverflow.com

THANKYOU

Page | 22

You might also like