Beruflich Dokumente
Kultur Dokumente
Data Tables
Coding
import mysql.connector
import webbrowser
def add_roomtype():
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
result = cursor.execute(sql_insert_query)
connection.commit()
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
def modify_roomtype_type():
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
def modify_roomtype_capacity():
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
def modify_roomtype_rent():
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
def add_guest():
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
result = cursor.execute(sql_insert_query)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
def modify_guest_firstname():
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
+"'",id1))
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
def modify_guest_lastname():
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
def modify_guest_mdate():
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
def modify_guest_address():
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
def modify_guest_city():
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
def modify_guest_pincode():
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
def modify_guest_mobileno():
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
def add_room():
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
print(sql_insert_query)
cursor = connection.cursor()
result = cursor.execute(sql_insert_query)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
def modify_room_roomno():
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
def modify_room_status():
status=int(input("Enter Status of Room 1 for WORKING AND 0 FOR NOT WORKING "))
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
print ("Record inserted successfully into python_users table")
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
def new_booking():
cindate=parse(cindate2)
cindate1=datetime.date(cindate)
reservationdate=datetime.date(datetime.now())
reservationdate1=reservationdate.strftime('%Y-%m-%d')
coutdate=cindate1+relativedelta(days=noofdaysstay)
coutdate2=coutdate.strftime('%Y-%m-%d')
print(cindate2)
print(coutdate2)
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
print(sql_insert_query)
cursor = connection.cursor()
result = cursor.execute(sql_insert_query)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
try:
for i in range(0,noofrooms):
id2=int(input("Enter Room ID "))
roomtypeid1=roomtypeid
reservationid1=id1
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
print(sql_insert_query)
cursor = connection.cursor()
result = cursor.execute(sql_insert_query)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
def cancel_booking():
val=1
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
cancelleddate=datetime.date(datetime.now())
cancelleddate1=cancelleddate.strftime('%Y-%m-%d')
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
val1=0
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
def guest_arrived():
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
print(sql_insert_query)
cursor = connection.cursor()
result = cursor.execute(sql_insert_query)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
print(sql_insert_query)
cursor = connection.cursor()
result = cursor.execute(sql_insert_query)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
def guest_checkout():
val=0
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
print ("Record inserted successfully into python_users table")
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
result = cursor.execute(sql_update)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
#sql_select = ("SELECT id, GUESTID FROM RESERVEDROOM where cancelled=True and billpaid is
null")
#SELECT ID, GUESTID FROM RESERVATION WHERE CANCELLED=1 AND BILLPAID IS NULL
sql_select = ("SELECT ID, GUESTID FROM RESERVATION WHERE CANCELLED=0 AND BILLPAID =
0")
cursor = connection.cursor()
cursor.execute(sql_select)
result = cursor.fetchall()
for x in result:
print(x[0]," ",x[1])
#for x in result:
# print(x[0],x[1],x[2],x[3])
#generate_pdf()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
def billpay():
print("Do you wnat to Make Paymnet Y(1)")
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
cursor.execute(sql_select)
result = cursor.fetchall()
for x in result:
fname=x[0]
sname=x[1]
rent=x[2]
nod=x[3]
cindate=x[4]
coutdate=x[5]
amtpayable=rent*nod
gst=amtpayable*18/100
netamt=amtpayable+gst
finally:
#closing database connection.
if(connection.is_connected()):
cursor.close()
connection.close()
try:
val=1
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
#result = cursor.execute(sql_update_cancelled)
result = cursor.execute(sql_update_billpaid)
connection.commit()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
def generate_bill():
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
#sql_select = ("SELECT id, GUESTID FROM RESERVEDROOM where cancelled=True and billpaid is
null")
#SELECT ID, GUESTID FROM RESERVATION WHERE CANCELLED=1 AND BILLPAID IS NULL
sql_select = ("SELECT ID, GUESTID FROM RESERVATION WHERE CANCELLED=0 AND BILLPAID =
1")
cursor = connection.cursor()
cursor.execute(sql_select)
result = cursor.fetchall()
for x in result:
print(x[0]," ",x[1])
#for x in result:
# print(x[0],x[1],x[2],x[3])
#generate_pdf()
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
try:
connection =
mysql.connector.connect(host='localhost',database='hotel',user='root',password='')
cursor = connection.cursor()
cursor.execute(sql_select)
result = cursor.fetchall()
for x in result:
fname=x[0]
sname=x[1]
rent=x[2]
nod=x[3]
cindate=x[4]
coutdate=x[5]
amtpayable=rent*nod
gst=amtpayable*18/100
netamt=amtpayable+gst
#generate_pdf()
pdf = FPDF()
pdf.add_page()
pdf.set_font("Arial", size=12)
pdf.cell(0,0,"------------------------------------------------------------------------------------------------------------
----------------------------",ln=1,align="L")
pdf.cell(160,10,"Guest Name",ln=0,align="L")
pdf.cell(160,10,fname+" "+sname,ln=1,align="L")
pdf.cell(0,0,"------------------------------------------------------------------------------------------------------------
----------------------------",ln=1,align="L")
pdf.cell(160,10,str(cindate),ln=1,align="L")
pdf.cell(160,10,str(coutdate),ln=1,align="L")
pdf.cell(160,10,str(nod),ln=1,align="L")
pdf.cell(160,10,str(rent),ln=1,align="L")
pdf.cell(160,10,str(amtpayable),ln=1,align="L")
pdf.cell(160,10,str(gst),ln=1,align="L")
pdf.cell(160,10,str(netamt),ln=1,align="L")
pdf.cell(0,0,"------------------------------------------------------------------------------------------------------------
----------------------------",ln=1,align="L")
pdf.cell(0,100,"Signature ",ln=1,align="R")
pdf.output("simple_demo.pdf")
url = 'file:///G:/PERSONAL/SCHOOL/IN-SERVICE-COURSE/SPELL-2-BPL-NO-
2/simple_demo.pdf'
webbrowser.open(url)
pdf.cell(0,0,"------------------------------------------------------------------------------------------------------------
----------------------------",ln=1,align="L")
pdf.cell(0,100,"Signature ",ln=1,align="R")
finally:
if(connection.is_connected()):
cursor.close()
connection.close()
while(True):
while(True):
print()
print("*****************************************************************************
******* Main Menu
***********************************************************************")
print()
break;
if (ch==9):
break
if (ch==1):
while(True):
while(True):
print()
print("************************************************************************
Room Type Details Menu
**************************************************************************")
print()
break;
if (ch1==5):
break
if (ch1==1):
add_roomtype()
if (ch1==2):
modify_roomtype_type()
if (ch1==3):
modify_roomtype_capacity()
if (ch1==4):
modify_roomtype_rent()
if (ch==3):
while(True):
while(True):
print()
print("************************************************************************
Guest Details Menu
**************************************************************************")
print()
if (ch_guest==9):
break
if (ch_guest==1):
add_guest()
if (ch_guest==2):
modify_guest_firstname()
if (ch_guest==3):
modify_guest_lastname()
if (ch_guest==4):
modify_guest_mdate()
if (ch_guest==5):
modify_guest_address()
if (ch_guest==6):
modify_guest_city()
if (ch_guest==7):
modify_guest_pincode()
if (ch_guest==8):
modify_guest_mobileno()
if (ch==4):
while(True):
while(True):
print()
print("************************************************************************
Room Details Menu
**************************************************************************")
print()
print("1. Add New Room ")
break
if (ch_room==4):
break
if (ch_room==1):
add_room()
if (ch_room==2):
modify_room_roomno()
if (ch_room==3):
modify_room_status()
if (ch==2):
while(True):
while(True):
print()
print("************************************************************************
Reservation Menu
**************************************************************************")
print()
break
if (ch_res==4):
break
if (ch_res==1):
new_booking()
if (ch_res==2):
cancel_booking()
new_booking()
if (ch_res==3):
cancel_booking()
if (ch==5):
guest_arrived()
if (ch==6):
guest_checkout()
if (ch==7):
billing()
billpay()
if (ch==8):
generate_bill()
Output Screen
Main Menu
**********************************************************************************
** Main Menu
***********************************************************************
2. Reservation
3. Guest Details
4. Romm Details
7. Billing
8. Exit
5. Exit
2. Reservation
3. Guest Details
4. Romm Details
7. Billing
8. Exit
************************************************************************ Reservation
Menu **************************************************************************
1. New Booking
3. Cancel Booking
4. Exit
************************************************************************ Reservation
Menu **************************************************************************
1. New Booking
2. Modify Booking Date
3. Cancel Booking
4. Exit
**********************************************************************************
** Main Menu
***********************************************************************
2. Reservation
3. Guest Details
4. Romm Details
7. Billing
8. Exit
************************************************************************ Guest
Details Menu
**************************************************************************
9. Exit
**********************************************************************************
** Main Menu
***********************************************************************
2. Reservation
3. Guest Details
4. Romm Details
7. Billing
8. Exit
************************************************************************ Room
Details Menu
**************************************************************************
2. Mofigy Room No
4. Exit
Enter Choice from above 4
**********************************************************************************
** Main Menu
***********************************************************************
2. Reservation
3. Guest Details
4. Romm Details
7. Billing
8. Exit