Guest User

Hotel Management System

a guest
Jul 15th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.03 KB | None | 0 0
  1. import datetime
  2. import getpass
  3. def newbook():
  4.     fopen =open('Details.txt','a')
  5.     now=datetime.datetime.now()
  6.     s= now.strftime("%d-%m-%Y  %I:%M:%S %p")
  7.     fopen.write(s+'\n')
  8.     name=raw_input("Enter the name: ")
  9.     fopen.write(name+' ')
  10.     address=raw_input("Enter the address: ")
  11.     fopen.write(address+' ')
  12.     contact=raw_input("Enter the contact no: ")
  13.     fopen.write(contact+'\n\n')
  14.     print "Details are added succesfully! :)"
  15.     fopen.close()
  16. def searchandview():
  17.     custname=raw_input("Enter the name of the customer for which the details are to be found: ")
  18.     fopen=open("Details.txt")
  19.     for detail in fopen:
  20.         if custname in detail:
  21.             print ("Here are the details: \n"+detail)
  22.         #print ("No results found! Try with the correct name.")
  23. def deletebook():
  24.     custname=raw_input("Enter the name of the customer for which the details are to be deleted : ")
  25.     fopen=open("Details.txt","r+")
  26.     output=list()
  27.     for detail in fopen:
  28.         if custname not in detail:
  29.             output.append(detail)
  30.     fopen.truncate()
  31.     fopen.writelines(output)
  32.     fopen.close()
  33. def rate():
  34.     print ("1. Single bed-200")
  35.     print ("2. Double bed-400")
  36.     print ("3. Couple suite-800")
  37.     print ("4. King suite-1200")
  38.  
  39. while True:
  40.     user=raw_input('Enter username: ')
  41.     password=getpass.getpass("Enter Password: ")
  42.     if user=='client' and password=="client123":
  43.         break
  44.     else:
  45.         print "Incorrect username/password.Please try again."
  46.        
  47. while True:
  48.     print "Welcome to the hotel management system".center(68,'-')
  49.     print " 1.Enter new Booking. \n 2.View saved bookings.\n 3.Delete Booking.\n 4.View Rate.\n 5.Exit."
  50.     inp=raw_input("Choose the correct option from above:-")
  51.     if  inp=='1':
  52.         newbook()
  53.     elif inp=='2':
  54.         searchandview()
  55.     elif inp=='3':
  56.         deletebook()
  57.     elif inp=='4':
  58.         rate()
  59.     elif inp=='5':
  60.         print "BYE!!"
  61.         quit()
  62.     else:
  63.         print "Wrong input! Please try again."
Add Comment
Please, Sign In to add comment