Hotel Reservation - Group 1

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Project Work

Project using Python-MySQL Connectivity for CS Class XII


HOTEL RESERVATION SYSTEM

About the Project


The project is based on hotel management and room booking system. It has been developed
using Python-MySQL connectivity. This system can insert records, update records, delete records,
display records and generate reports for any customer(s).
Name of databases: dbproject
Name of table: Hotel
Structure of the table: Hotel

Program Code

#Project on Hotel Reservation System - Python-MySQL connectivity


import mysql.connector
def add():
  mydb=mysql.connector.connect(host="localhost",user="root", passwd="",
                      database="dbproject")
  mycur=mydb.cursor( )
  ch='y'
   while ch=='y' or ch=='Y':
     cust_id = int(input("\nEnter The Customer id: "))
     cust_name = input("Enter the Customer name: ")
     address = input("Enter The Address: ")
     roomno = int(input("Enter The Room No: "))
     mobileno = int(input("Enter The Mobile No: "))

     check_in = input("Enter the Check In Date (YYYY-MM-DD): ")


     check_out = input("Enter Check Out Date (YYYY-MM-DD): ")
        adv_payment = float(input("Enter the Advance Amt: "))

     room_type = int(input("Room Type:-\n 1:Suite (Rs.1500 /day) \n 2:


                  Delux (Rs. 1000 / day) \n 3: Standard
                  (Rs. 500/day)"))

    if room_type==1:
      room_type="Suite"
    elif room_type==2:
      room_type="Delux"
    elif room_type==3:
      room_type="Standard"
    else:

      print("Enter the correct Choice")

   str="INSERT INTO hotel VALUES({},'{}','{}',{},{},'{}','{}',{},'{}')"

  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()

   mycur.execute("Select * from hotel")


  print("==========================================")
  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 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)

   cust_id=int(input("Enter Customer id whose record is to be Updated: "))


   print("Enter the new data\n")
   cust_name = input("Enter Customer name: ")
   address = input("Enter Address: ")
   roomno = int(input("Enter Room No: "))
   mobileno = int(input("Enter Mobile No: "))
   check_in = input("Check In Date (YYYY-MM-DD): ")
   check_out = input("Check Out Date (YYYY-MM-DD): ")
    adv_payment = float(input("Enter the Advance Amt paid: "))
   room_type = int(input("Room Type:-(1:Suite 2: Deluxe 3:Common)"))

  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:

    print("Enter your Choice")

  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()

   mycur.execute("Select * from hotel")


  print("==========================================")

  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()

   mycur.execute("Select * from hotel")


  print("==========================================")
  print("Before Deletion")
  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]
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)

   cust_id=int(input("Enter the Customer id: "))


   str="Delete from hotel where cust_id={}"
  query=str.format(cust_id)
  mycur.execute(query)
  mydb.commit()
  mycur.execute(query)
  print("Record Deleted")
   mycur.execute("Select * from hotel")
  print("==========================================")
  print("After Deletion")
  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_in = 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 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

You might also like