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

SOURCE CODE

#project name : Railway Ticket Reservation System


#Made by : Swayam Ritiraj Dash, Anwesa Mishra, Satwik Padhee
#session : 2023-24
#Rollno. : 53,06,36 (class rollno.)

# CONNECT DATABASE

import mysql.connector as a
con = a.connect(host="localhost",user="root",passwd = "1234" ,database="mo_railway")
c = con.cursor()

#system password login

def signin():
print("\n")
print(" ------->>>>>>>> JAI SHRI RAM, APAN MANKU SWAGAT AMAR RAILWAY SYSTEM RE
[ Swayam,Anwesa,Satwik ] <<<<<<<<-------")
print("\n")
p = input("system password :")
if p == "sas1":
options()
else:
signin()

#working options

def options():
print("""
1. Add Train
2. Book Train
3. Add Bill
4. Add Worker
5. Display Train
6. Display Payments
7. Display Bills
8. Display Workers

""")
choice = input("select Option :")
while True:
if(choice =='1'):
AddTrain()
elif(choice =='2'):
BookTrain()
elif(choice =='3'):
AddBill()
elif(choice =='4'):
AddWorker()
elif(choice =='5'):
dTrain()
elif(choice =='6'):
dPayments()
elif(choice =='7'):
dBills()
elif(choice =='8'):
dWorker()
else:
print("Enter Again......")
options()

def AddTrain():
n = input("Train Name : ")
c = input("Cost : ")
b = input("Distance :")
d = input("Date :")
data = (n,c,b,d)
sql = 'insert into Train values(%s,%s,%s,%s)'
c = con.cursor()
c.execute(sql,data)
con.commit()
print("data inserted succesfully")
options()

def dTrain():
sql = 'select * from Train'
c = con.cursor()
c.execute(sql)
d = c.fetchall()
for i in d:
print(" Name : ",i[0])
print(" Cost : ",i[1])
print(" Distance : ",i[2])
print(" Date : ",i[3])
print("....................................................")
options()

# to add selling data into customer table

def BookTrain():
n=input("customer name:")
s=input("Train:")
py=int(input("payment:"))
d=input("date:")
p=input("phone:")
data=(n,s,py,d,p)
sql='insert into customer values(%s,%s,%s,%s,%s)'
c=con.cursor()
c.execute(sql,data)
con.commit()
print("data inserted successfully")
options()

# to display selling data from customer table

def dPayments():
sd=input("date:")
sql='select * from customer'
c=con.cursor()
c.execute(sql)
d=c.fetchall()
for i in d:
if i[3] == sd:
print("name:",i[0])
print("train:",i[1])
print("payment:",i[2])
print("date:",i[3])
print("phone:",i[4])
print("................................")
options()

# function to add new bills

def AddBill():
dt=input("detail:")
c=input("cost:")
d=input("date:")
data=(dt,c,d)
sql='insert into bills values(%s,%s,%s)'
c=con.cursor()
c.execute(sql,data)
con.commit()
print("data inserted successfully")
options()

# function to display all previous bills

def dBills():
#sd=input("date:")
sql='select * from Bills'
c=con.cursor()
c.execute(sql)
d=c.fetchall()
for i in d:
print("detail:",i[0])
print("cost:",i[1])
print("date:",i[2])
print(".................................")
options()

# function to add new worker

def AddWorker():
n=input("name:")
w=input("work:")
s=input("salary:")
data=(n,w,s)
sql='insert into worker values(%s,%s,%s)'
c=con.cursor()
c.execute(sql,data)
con.commit()
print("data inserted successfully")
options()

# function to display all workers

def dWorker():
sql='select * from Worker'
c=con.cursor()
c.execute(sql)
d=c.fetchall()
for i in d:
print("name:",i[0])
print("work:",i[1])
print("salary:",i[2])
print("................................")
options()

signin()

You might also like