Hey guys i'm relatively new to python and i have this problem that i cant solve. i need to create a python code which works like a scheduler for a hotel reception. it has to search in a list which contain the single bookings. these specific bookings contain the arrival and departure date but i dont know how to check and compare those ranges. i have limited amount of room, so thats another criteria.
rooms = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
booking = []
booking_id = 0
def make_booking():
bframe = Tk()
bframe.geometry('200x150+150+150')
bframe.title('New booking')
nameLabel = Label(bframe, text='Name').grid(row=0, column=0)
name = Entry(bframe)
name.grid(row=0, column=1)
ArrivalLabel = Label(bframe, text='Arrival in: DD.MM.YYYY').grid(row=2, column=0)
arrival = Entry(bframe)
arrival.grid(row=2, column=1)
deptLabel = Label(bframe, text='Departure in: DD.MM.YYYY').grid(row=3, column=0)
dept = Entry(bframe)
dept.grid(row=3, column=1)
def save_booking():
arrival = time.strptime(arrival.get(), "%d.%m.%y")
dept = time.strptime(dept.get(), "%d.%m.%y")
global booking_id
booking_id += 1
b = [booking_id, name.get(), arrival, dept]
booking.append(b)
else:
messagebox.showinfo(title="Whops", message="""
Something went wrong with your booking entry. Did you check the room availability?""")
bframe.destroy()
saveButton = Button(bframe, text="Save", command=save_booking).grid(row=4, column=0)
this is my code atm. the else case is from my older version which kinda worked but didnt check for the room availabilty for a certain date range
def save_booking():
b = (name.get(), room_number.get(), arrival.get(), dept.get())
if rooms[int(room_number.get())] == 0:
global booking_id
booking_id += 1
b.append(booking_id)
rooms[int(room_number.get())] = b
any ideas on how to solve this?