|
| 1 | +def menu(): |
| 2 | + print("") |
| 3 | + print("") |
| 4 | + print(" Welcome to Hotel Database Management Software") |
| 5 | + print("") |
| 6 | + print("") |
| 7 | + |
| 8 | + print("1-Add new customer details") |
| 9 | + print("2-Modify already existing customer details") |
| 10 | + print("3-Search customer details") |
| 11 | + print("4-View all customer details") |
| 12 | + print("5-Delete customer details") |
| 13 | + print("6-Exit the program") |
| 14 | + print("") |
| 15 | + |
| 16 | + user_input=int(input("Enter your choice(1-6): ")) |
| 17 | + |
| 18 | + if user_input==1: |
| 19 | + add() |
| 20 | + |
| 21 | + elif user_input==2: |
| 22 | + modify() |
| 23 | + |
| 24 | + elif user_input==3: |
| 25 | + search() |
| 26 | + |
| 27 | + elif user_input==4: |
| 28 | + view() |
| 29 | + |
| 30 | + elif user_input==5: |
| 31 | + remove() |
| 32 | + |
| 33 | + elif user_input==6: |
| 34 | + exit() |
| 35 | + |
| 36 | +def add(): |
| 37 | + |
| 38 | + print("") |
| 39 | + Name1=input("Enter your first name: ") |
| 40 | + print("") |
| 41 | + |
| 42 | + Name2=input("Enter your last name: ") |
| 43 | + print("") |
| 44 | + |
| 45 | + Phone_Num=input("Enter your phone number(without +91): ") |
| 46 | + print("") |
| 47 | + |
| 48 | + print("These are the rooms that are currently available") |
| 49 | + print("1-Normal (₹500/Day)") |
| 50 | + print("2-Deluxe (₹1000/Day)") |
| 51 | + print("3-Super Deluxe (₹1500/Day)") |
| 52 | + print("4-Premium Deluxe (₹2000/Day)") |
| 53 | + print("") |
| 54 | + Room_Type=int(input("Which type you want(1-4): ")) |
| 55 | + print("") |
| 56 | + |
| 57 | + if Room_Type==1: |
| 58 | + x=500 |
| 59 | + Room_Type="Normal" |
| 60 | + elif Room_Type==2: |
| 61 | + x=1000 |
| 62 | + Room_Type='Deluxe' |
| 63 | + elif Room_Type==3: |
| 64 | + x=1500 |
| 65 | + Room_Type='Super Deluxe' |
| 66 | + elif Room_Type==4: |
| 67 | + x=2000 |
| 68 | + Room_Type='Premium' |
| 69 | + |
| 70 | + Days=int(input("How many days you will stay: ")) |
| 71 | + Money=x*Days |
| 72 | + Money='₹'+str(Money) |
| 73 | + print("") |
| 74 | + |
| 75 | + print("You have to pay ",(Money)) |
| 76 | + print("") |
| 77 | + |
| 78 | + |
| 79 | + Payment=input("Mode of payment(Card/Cash/Online): ") |
| 80 | + print("") |
| 81 | + |
| 82 | + |
| 83 | + file1 = open("Management.txt", "r") |
| 84 | + contents = file1.read() |
| 85 | + dictionary = eval(contents) |
| 86 | + file1.close() |
| 87 | + |
| 88 | + if len(dictionary.get('Room'))==0: |
| 89 | + Room_num='501' |
| 90 | + else: |
| 91 | + listt=dictionary.get('Room') |
| 92 | + tempp=len(listt)-1 |
| 93 | + temppp=int(listt[tempp]) |
| 94 | + Room_num=(1+temppp) |
| 95 | + Room_num=str(Room_num) |
| 96 | + |
| 97 | + print('You have been assigned Room Number',Room_num) |
| 98 | + |
| 99 | + dictionary['First_Name'].append(Name1) |
| 100 | + dictionary['Last_Name'].append(Name2) |
| 101 | + dictionary['Phone_num'].append(Phone_Num) |
| 102 | + dictionary['Room_Type'].append(Room_Type) |
| 103 | + dictionary['Days'].append(Days) |
| 104 | + dictionary['Price'].append(Money) |
| 105 | + dictionary['Room'].append(Room_num) |
| 106 | + |
| 107 | + File=open("Management.txt",'w') |
| 108 | + File.write(str(dictionary)) |
| 109 | + File.close() |
| 110 | + |
| 111 | + print("") |
| 112 | + print("Your data has been successfully added to our database.") |
| 113 | + |
| 114 | + exit_menu() |
| 115 | + |
| 116 | + |
| 117 | + |
| 118 | +import os |
| 119 | +filecheck = os.path.isfile('Management.txt') |
| 120 | +if filecheck == False : |
| 121 | + File = open("Management.txt", 'a') |
| 122 | + temp1 = {'First_Name': [], 'Last_Name': [], 'Phone_num': [], 'Room_Type': [], 'Days': [], 'Price': [], 'Room':[]} |
| 123 | + File.write(str(temp1)) |
| 124 | + File.close() |
| 125 | + |
| 126 | + |
| 127 | + |
| 128 | +def modify(): |
| 129 | + print("") |
| 130 | + Room=(input("Enter your Room Number: ")) |
| 131 | + |
| 132 | + file1 = open("Management.txt", "r") |
| 133 | + contents = file1.read() |
| 134 | + dictionary = eval(contents) |
| 135 | + file1.close() |
| 136 | + |
| 137 | + listt=dictionary['Room'] |
| 138 | + index=int(listt.index(Room)) |
| 139 | + |
| 140 | + print("") |
| 141 | + print("1-Change your first name") |
| 142 | + print("2-Change your last name") |
| 143 | + print("3-Change your phone number") |
| 144 | + |
| 145 | + print("") |
| 146 | + choice=(input("Enter your choice: ")) |
| 147 | + print("") |
| 148 | + |
| 149 | + File=open("Management.txt",'w') |
| 150 | + |
| 151 | + if choice == str(1): |
| 152 | + user_input=input('Enter New First Name: ') |
| 153 | + listt1=dictionary['First_Name'] |
| 154 | + listt1[index]=user_input |
| 155 | + dictionary['First_Name']=None |
| 156 | + dictionary['First_Name']=listt1 |
| 157 | + File.write(str(dictionary)) |
| 158 | + File.close() |
| 159 | + |
| 160 | + elif choice == str(2): |
| 161 | + user_input = input('Enter New Last Name: ') |
| 162 | + listt1 = dictionary['Last_Name'] |
| 163 | + listt1[index] = user_input |
| 164 | + dictionary['Last_Name'] = None |
| 165 | + dictionary['Last_Name'] = listt1 |
| 166 | + File.write(str(dictionary)) |
| 167 | + File.close() |
| 168 | + |
| 169 | + elif choice == str(3): |
| 170 | + user_input = input('Enter New Phone Number: ') |
| 171 | + listt1 = dictionary['Phone_num'] |
| 172 | + listt1[index] = user_input |
| 173 | + dictionary['Phone_num'] = None |
| 174 | + dictionary['Phone_num'] = listt1 |
| 175 | + File.write(str(dictionary)) |
| 176 | + File.close() |
| 177 | + |
| 178 | + print("") |
| 179 | + print("Your data has been successfully updated") |
| 180 | + |
| 181 | + exit_menu() |
| 182 | + |
| 183 | +def search(): |
| 184 | + |
| 185 | + file1 = open("Management.txt", "r") |
| 186 | + contents = file1.read() |
| 187 | + dictionary = eval(contents) |
| 188 | + file1.close() |
| 189 | + |
| 190 | + print("") |
| 191 | + Room = (input("Enter your Room Number: ")) |
| 192 | + print("") |
| 193 | + |
| 194 | + listt = dictionary['Room'] |
| 195 | + index = int(listt.index(Room)) |
| 196 | + |
| 197 | + listt_fname=dictionary.get('First_Name') |
| 198 | + listt_lname=dictionary.get('Last_Name') |
| 199 | + listt_phone=dictionary.get('Phone_num') |
| 200 | + listt_type=dictionary.get('Room_Type') |
| 201 | + listt_days=dictionary.get('Days') |
| 202 | + listt_price=dictionary.get('Price') |
| 203 | + listt_num=dictionary.get('Room') |
| 204 | + |
| 205 | + print("") |
| 206 | + print("First Name:",listt_fname[index]) |
| 207 | + print("Last Name:",listt_lname[index]) |
| 208 | + print("Phone number:",listt_phone[index]) |
| 209 | + print("Room Type:",listt_type[index]) |
| 210 | + print('Days staying:',listt_days[index]) |
| 211 | + print('Money paid:',listt_price[index]) |
| 212 | + print('Room Number:',listt_num[index]) |
| 213 | + |
| 214 | + exit_menu() |
| 215 | + |
| 216 | +def remove(): |
| 217 | + file1 = open("Management.txt", "r") |
| 218 | + contents = file1.read() |
| 219 | + dictionary = eval(contents) |
| 220 | + file1.close() |
| 221 | + |
| 222 | + print("") |
| 223 | + Room = (input("Enter your Room Number: ")) |
| 224 | + print("") |
| 225 | + |
| 226 | + listt = dictionary['Room'] |
| 227 | + index = int(listt.index(Room)) |
| 228 | + |
| 229 | + listt_fname = dictionary.get('First_Name') |
| 230 | + listt_lname = dictionary.get('Last_Name') |
| 231 | + listt_phone = dictionary.get('Phone_num') |
| 232 | + listt_type = dictionary.get('Room_Type') |
| 233 | + listt_days = dictionary.get('Days') |
| 234 | + listt_price = dictionary.get('Price') |
| 235 | + listt_num = dictionary.get('Room') |
| 236 | + |
| 237 | + del listt_fname[index] |
| 238 | + del listt_lname[index] |
| 239 | + del listt_phone[index] |
| 240 | + del listt_type[index] |
| 241 | + del listt_days[index] |
| 242 | + del listt_price[index] |
| 243 | + del listt_num[index] |
| 244 | + |
| 245 | + dictionary['First_Name'] = None |
| 246 | + dictionary['First_Name'] = listt_fname |
| 247 | + |
| 248 | + dictionary['Last_Name']= None |
| 249 | + dictionary['Last_Name']= listt_lname |
| 250 | + |
| 251 | + dictionary['Phone_num']= None |
| 252 | + dictionary['Phone_num']=listt_phone |
| 253 | + |
| 254 | + dictionary['Room_Type']=None |
| 255 | + dictionary['Room_Type']=listt_type |
| 256 | + |
| 257 | + dictionary['Days']=None |
| 258 | + dictionary['Days']=listt_days |
| 259 | + |
| 260 | + dictionary['Price']=None |
| 261 | + dictionary['Price']=listt_price |
| 262 | + |
| 263 | + dictionary['Room']=None |
| 264 | + dictionary['Room']=listt_num |
| 265 | + |
| 266 | + file1=open('Management.txt','w') |
| 267 | + file1.write(str(dictionary)) |
| 268 | + file1.close() |
| 269 | + |
| 270 | + print("Details has been removed successfully") |
| 271 | + |
| 272 | + exit_menu() |
| 273 | + |
| 274 | +def view(): |
| 275 | + |
| 276 | + file1 = open("Management.txt", "r") |
| 277 | + contents = file1.read() |
| 278 | + dictionary = eval(contents) |
| 279 | + file1.close() |
| 280 | + |
| 281 | + listt = dictionary['Room'] |
| 282 | + a = len(listt) |
| 283 | + |
| 284 | + index=0 |
| 285 | + while index!=a: |
| 286 | + listt_fname = dictionary.get('First_Name') |
| 287 | + listt_lname = dictionary.get('Last_Name') |
| 288 | + listt_phone = dictionary.get('Phone_num') |
| 289 | + listt_type = dictionary.get('Room_Type') |
| 290 | + listt_days = dictionary.get('Days') |
| 291 | + listt_price = dictionary.get('Price') |
| 292 | + listt_num = dictionary.get('Room') |
| 293 | + |
| 294 | + print("") |
| 295 | + print("First Name:", listt_fname[index]) |
| 296 | + print("Last Name:", listt_lname[index]) |
| 297 | + print("Phone number:", listt_phone[index]) |
| 298 | + print("Room Type:", listt_type[index]) |
| 299 | + print('Days staying:', listt_days[index]) |
| 300 | + print('Money paid:', listt_price[index]) |
| 301 | + print('Room Number:', listt_num[index]) |
| 302 | + print("") |
| 303 | + |
| 304 | + index=index+1 |
| 305 | + |
| 306 | + exit_menu() |
| 307 | + |
| 308 | +def exit(): |
| 309 | + print("") |
| 310 | + print(' Thanks for visiting') |
| 311 | + print(" Goodbye") |
| 312 | + |
| 313 | +def exit_menu(): |
| 314 | + print("") |
| 315 | + print("Do you want to exit the program or return to main menu") |
| 316 | + print("1-Main Menu") |
| 317 | + print("2-Exit") |
| 318 | + print("") |
| 319 | + |
| 320 | + user_input=int(input("Enter your choice: ")) |
| 321 | + if user_input==2: |
| 322 | + exit() |
| 323 | + elif user_input==1: |
| 324 | + menu() |
| 325 | + |
| 326 | +menu() |
0 commit comments