Professional Documents
Culture Documents
Hotel Reservation - Group 1
Hotel Reservation - Group 1
Hotel Reservation - Group 1
Program Code
if room_type==1:
room_type="Suite"
elif room_type==2:
room_type="Delux"
elif room_type==3:
room_type="Standard"
else:
query=(str.format(cust_id,cust_name,address,roomno,mobileno,
check_in,check_out,adv_payment, room_type))
mycur.execute(query)
mydb.commit()
print("\nCustomer record inserted\n")
ch=input("Want to Add more records(y/n): ")
Computer Science with Python–XII
def search():
mydb=mysql.connector.connect(host="localhost",user="root",
passwd="", database="dbproject")
mycur = mydb.cursor()
cno = int(input("Enter the Customer id: "))
str = "Select * from hotel where cust_id={}"
query=str.format(cno)
print("==========================================")
P.2
mycur.execute(query)
myrec=mycur.fetchall()
for x in myrec:
cust_id = x[0]
cust_name = x[1]
address = x[2]
roomno = x[3]
mobileno = x[4]
check_in = x[5]
check_out = x[6]
adv_payment = x[7]
room_type = x[8]
print(cust_id,cust_name,address,roomno,mobileno,check_in,
check_out,adv_payment,room_type)
def display():
mydb=mysql.connector.connect(host="localhost",user="root",
passwd="",database="dbproject")
mycur=mydb.cursor()
for x in myrec:
cust_id = x[0]
cust_name = x[1]
address = x[2]
roomno = x[3]
mobileno = x[4]
check_in = x[5]
check_out = x[6]
adv_payment = x[7]
room_type = x[8]
print(cust_id,cust_name,address,roomno,mobileno,check_in,
check_out,adv_payment,room_type)
def edit():
Project Work
mydb=mysql.connector.connect(host="localhost",user="root",passwd="",
database="dbproject")
mycur=mydb.cursor() P.3
mycur.execute("Select * from hotel")
print("==========================================")
print("Before Updation")
myrec=mycur.fetchall()
for x in myrec:
cust_id=x[0]
cust_name=x[1]
address=x[2]
roomno=x[3]
mobileno=x[4]
check_in=x[5]
check_out=x[6]
adv_payment=x[7]
room_type=x[8]
print(cust_id,cust_name,address,roomno,mobileno,check_in,
check_out,adv_payment,room_type)
if room_type==1:
room_type = "Suite"
elif room_type==2:
room_type = "Deluxe"
elif room_type==3:
Computer Science with Python–XII
room_type = "Standard"
else:
mycur=mydb.cursor()
str="Update hotel set
cust_name='{}',address='{}',roomno='{}',mobileno={},check_in='{}',
check_out='{}',adv_payment={},room_type='{}'
P.4 where cust_id={}"
query = str.format(cust_name,address,roomno,mobileno,check_in,
check_out,adv_payment,room_type,cust_id)
mycur.execute(query)
mydb.commit()
print("After Update")
myrec = mycur.fetchall()
for x in myrec:
cust_id=x[0]
cust_name=x[1]
address=x[2]
roomno=x[3]
mobileno=x[4]
check_in=x[5]
check_out=x[6]
adv_payment=x[7]
room_type=x[8]
print(cust_id,cust_name,address,roomno,mobileno,check_in,check_out,
adv_payment,room_type)
def delete():
mydb=mysql.connector.connect(host="localhost",user="root",
passwd="",database="dbproject")
mycur=mydb.cursor()
for x in myrec:
cust_id = x[0]
cust_name = x[1]
address = x[2]
roomno = x[3]
mobileno = x[4]
check_in = x[5]
Project Work
check_out = x[6]
adv_payment = x[7]
room_type = x[8]
P.5
print(cust_id,cust_name,address,roomno,mobileno,check_in,
check_out,adv_payment,room_type)
print(cust_id,cust_name,address,roomno,mobileno,check_in,
check_out,adv_payment,room_type)
def generate():
Tax=0
mydb=mysql.connector.connect(host="localhost",user="root",
passwd="",database="dbproject")
Computer Science with Python–XII
mycur=mydb.cursor()
cust_id=int(input("Enter the Customer id: "))
str="Select
cust_id,cust_name,address,roomno,mobileno,check_in,check_out,
adv_payment,room_type,dayofyear(check_out)-dayofyear(check_in)
from hotel wherecust_id={}"
query=str.format(cust_id)
print("==========================================")
P.6
mycur.execute(query)
myrec=mycur.fetchall()
for x in myrec:
cust_id = x[0]
cust_name = x[1]
address = x[2]
roomno = x[3]
mobileno = x[4]
check_in = x[5]
check_out = x[6]
adv_payment = x[7]
room_type = x[8]
days = x[9]
print('=================================================')
print(" Hotel The Lalit ")
print(" 500, South Extension ")
print(" Delhi ")
print('=================================================')
print("Customer No",cust_id)
print("Customer Name",cust_name)
print("Customer Address",address)
print('=================================================')
print("Room No", roomno)
print("Mobile No", mobileno)
print('=================================================')
print("Check In", check_in)
print("Check Out", check_out)
print("Room Type", room_type)
print('=================================================')
print("No. of Days :", days)
if room_type == "Suite":
price = 1500
elif room_type=="Deluxe":
price = 1000
else:
price = 500
Project Work
P.7
Total = days*price
print("Total", Total)
print("Advance", adv_payment)
Tax = Total*0.10
print("Tax: ",Tax)
net = float(adv_payment)-(float(Total)+float(Tax))
netamt = float(Total)+float(Tax)
print("Net Amount",netamt)
print("Total Balance Payable to Customer",net)
ch = 'y'
while ch=='y' or ch=='Y':
print("======================================")
print("MENU")
print("1. To ADD New Record")
print("2.To Search a Record")
print("3.To Update the Record")
print("4.To Delete the Record")
print("5.To View all the Record")
print("6.To Generate the Report\n")
print("==========================================")
ch=int(input("Enter your choice: "))
Tax=0
if ch==1:
add()
elif ch==2:
search()
elif ch==3:
edit()
elif ch==4:
delete()
elif ch==5:
display()
Computer Science with Python–XII
elif ch==6:
generate()
print("==========================================")
ch=input("Want to display Main Menu(y/n): ")
P.8
OUTPUT SCREENSHOTS
Project Work
P.9
Computer Science with Python–XII
P.10