Com Puther
Com Puther
)
return connection
cursor = conn.cursor()
cursor.execute('''INSERT INTO rooms (room_type, status, price)
VALUES (%s, %s, %s)''', (room_type, 'Available', float(price)))
conn.commit()
conn.close()
email = email_entry.get()
cursor = conn.cursor()
payment_date = datetime.now().strftime('%Y-%m-%d')
rooms = cursor.fetchall()
conn.close()
rooms_text = ""
for room in rooms:
rooms_text += f"Room ID: {room[0]} | Type: {room[1]} | Status: {room[2]}
| Price: ${room[3]}\n"
messagebox.showinfo("Rooms", rooms_text)
conn.close()
guests_text = ""
for guest in guests:
guests_text += f"Guest ID: {guest[0]} | Name: {guest[1]} {guest[2]} |
Phone: {guest[3]} | Email: {guest[4]}\n"
messagebox.showinfo("Guests", guests_text)
# Room section
room_label = tk.Label(window, text="Room Type:")
room_label.grid(row=0, column=0)
room_type_entry = tk.Entry(window)
room_type_entry.grid(row=0, column=1)
price_label.grid(row=1, column=0)
price_entry = tk.Entry(window)
price_entry.grid(row=1, column=1)
# Guest section
first_name_label = tk.Label(window, text="First Name:")
first_name_label.grid(row=3, column=0)
first_name_entry = tk.Entry(window)
first_name_entry.grid(row=3, column=1)
phone_label.grid(row=5, column=0)
phone_entry = tk.Entry(window)
phone_entry.grid(row=5, column=1)
email_label.grid(row=6, column=0)
email_entry = tk.Entry(window)
email_entry.grid(row=6, column=1)
# Booking section
guest_id_label = tk.Label(window, text="Guest ID:")
guest_id_label.grid(row=8, column=0)
guest_id_entry = tk.Entry(window)
guest_id_entry.grid(row=8, column=1)
check_in_label.grid(row=10, column=0)
check_in_entry = tk.Entry(window)
check_in_entry.grid(row=10, column=1)
# Payment section
booking_id_label = tk.Label(window, text="Booking ID:")
booking_id_label.grid(row=13, column=0)
booking_id_entry = tk.Entry(window)
booking_id_entry.grid(row=13, column=1)
view_guests_button.grid(row=16, column=1)
window.mainloop()
Expected Output
1. View Rooms:
yaml
Copy code
2. View Guests:
yaml
Copy code
3. Book Room: Success message confirming the booking and total price
calculated based on room price and duration.