Beispiel #1
0
 def create_booking(self):
     """method to create a wedding booking and store it in the database if all validation is passed"""
     if not validation.EntriesNotEmpty(self.master):
         dialogs.not_completed(self.master)
     elif not self.band_selected():
         dialogs.not_completed(self.master, 'Band must be selected')
     elif not self.guests_entered():
         dialogs.not_completed(
             self.master,
             'Number of guests must be greater than 0 and no more than 1000'
         )
     elif not self.number_room_entered():
         dialogs.not_completed(
             self.master,
             'Number of Rooms reserved must be at least 0 and no more than 1000'
         )
     elif not self.roomSelected:
         dialogs.not_completed(self.master,
                               'Room must be selected for Wedding')
     else:
         db = da.DBAccess()
         w = Wedding(noGuests=self.noGuestsEntry.get(),
                     nameofContact=self.nameOfContactEntry.get(),
                     address=self.addressEntry.get(),
                     contactNo=self.contactNumberEntry.get(),
                     eventRoomNo=self.roomNoCombo.get(),
                     dateOfEvent=self.dateOfEventEntry.get(),
                     bandName=self.bandName.get(),
                     bandPrice=self.bandPrice,
                     costPerhead=CONST.EVENT_COST_PER_HEAD.get('Wedding'),
                     noBedroomsReserved=self.noOfRoomsEntry.get())
         db.insert_wedding(w)
         dialogs.saved(self.master)
         back_to_main(self.master)
Beispiel #2
0
    def freeRooms(self, roomList, eventType, event=None):
        """method that checks for free rooms for a given event type on a the selected date and updates the room combobox
         to show only free rooms"""
        print('checking party rooms')
        print(self.dateOfEventValue.get())
        if self.dateOfEventValue.get() != '':
            db = da.DBAccess()
            bookedRooms = db.getBookedRooms(eventType,
                                            self.dateOfEventValue.get())
            freeRooms = []
            for room in roomList:
                if room not in bookedRooms:
                    freeRooms.append(room)

            self.roomNumbers = freeRooms
            print(freeRooms)
            print(self.roomNumbers)
            print(bookedRooms)
            self.roomNoCombo.configure(values=self.roomNumbers)
            if self.roomNoCombo.get() not in freeRooms:
                self.roomSelected = False
                self.roomNoCombo.delete(0, 'end')
                if len(freeRooms) > 0:
                    self.roomComboText.set('Please Select a Room')
                else:
                    self.roomComboText.set('No Rooms available')
            else:
                self.roomSelected = True
Beispiel #3
0
 def create_booking(self):
     """method to create a party booking when and store it in the database when all validation has been passed"""
     if not validation.EntriesNotEmpty(self.master):
         dialogs.not_completed(self.master)
     elif not self.band_selected():
         dialogs.not_completed(
             self.master,
             'Band must be selected')  # extra info being passed to dialogs
     elif not self.guests_entered():
         dialogs.not_completed(
             self.master,
             'Number of guests must be greater than 0 and no more than 1000'
         )
     elif not self.roomSelected:
         dialogs.not_completed(self.master,
                               'Room must be selected for Party')
     else:
         db = da.DBAccess()
         p = Party(noGuests=self.noGuestsEntry.get(),
                   nameofContact=self.nameOfContactEntry.get(),
                   address=self.addressEntry.get(),
                   contactNo=self.contactNumberEntry.get(),
                   eventRoomNo=self.roomNoCombo.get(),
                   dateOfEvent=self.dateOfEventEntry.get(),
                   bandName=self.bandName.get(),
                   bandPrice=self.bandPrice,
                   costPerhead=CONST.EVENT_COST_PER_HEAD.get('Party'))
         db.insert_party(p)
         dialogs.saved(self.master)
         back_to_main(self.master)
Beispiel #4
0
 def create_booking(self):
     """method to create the conference booking and store it in the database if all validation is passed"""
     if not validation.EntriesNotEmpty(self.master):
         dialogs.not_completed(self.master)
     elif not self.guests_entered():
         dialogs.not_completed(
             self.master,
             'Number of guests must be greater than 0 and no more than 1000'
         )
     elif not self.number_days_entered():
         dialogs.not_completed(
             self.master,
             'Number of days must be greater than 0 and no more than 50')
     elif not self.roomSelected:
         dialogs.not_completed(self.master,
                               'Room must be selected for Conference')
     else:
         db = da.DBAccess()
         c = Conference(
             noGuests=self.noGuestsEntry.get(),
             nameofContact=self.nameOfContactEntry.get(),
             address=self.addressEntry.get(),
             contactNo=self.contactNumberEntry.get(),
             eventRoomNo=self.roomNoCombo.get(),
             dateOfEvent=self.dateOfEventEntry.get(),
             companyName=self.companyEntry.get(),
             noOfDays=self.noOfDaysEntry.get(),
             projectorRequired=self.projectorRequired.get(),
             dateofBooking=datetime.datetime.now().date(),
             costPerhead=CONST.EVENT_COST_PER_HEAD.get('Conference'))
         db.insert_conference(c)
         dialogs.saved(self.master)
         back_to_main(self.master)
Beispiel #5
0
    def conference_room_check(self, event):
        """Method that checks for free conference rooms for a given date if the room the user has selected is not free
        then there option is removed"""
        print('checking conference rooms')
        if self.dateOfEventValue.get() != '' and self.noOfDaysEntry.get(
        ) != '':
            db = da.DBAccess()
            bookedRooms = db.booked_conference_rooms(
                datetime.datetime.strptime(self.dateOfEventValue.get(),
                                           '%Y-%m-%d'),
                int(self.noOfDaysEntry.get()))
            freeRooms = []
            for rooms in CONST.CONFERENCE_ROOMS:
                if rooms not in bookedRooms:
                    freeRooms.append(rooms)

            self.roomNumbers = freeRooms
            self.roomNoCombo.configure(values=self.roomNumbers)

            if self.roomNoCombo.get() not in freeRooms:
                self.roomSelected = False
                self.roomNoCombo.delete(0, 'end')

                if len(freeRooms) > 0:
                    self.roomComboText.set('Please select a Room')
                else:
                    self.roomComboText.set('No Rooms available')

            else:
                self.roomSelected = True
 def delete_booking(self):
     """method that will delete booking from database"""
     result = messagebox.askquestion('Delete Booking', 'Deleting booking cannot be undone\nAre you Sure?',
                                     icon='warning')
     if result == 'yes':
         db = da.DBAccess()
         print(str(self.event.__class__.__name__))
         db.delete_booking(self.event, str(self.event.__class__.__name__))
         dialogs.deleted(self.master)
         self.master.destroy()
         print('delete')
     else:
         print('not deleted')
Beispiel #7
0
 def freeBands(self, bandList, eventType, event=None):
     """method to check for free bands on the selected date and only show these is the band combobox.
     If user selected a band that is not free on a give date they must reselect their option"""
     if self.dateOfEventValue.get() != '':
         db = da.DBAccess()
         bookedBands = db.getBookedBands(self.dateOfEventValue.get(),
                                         eventType)
         freeBands = []
         for band in bandList:
             if band not in bookedBands or band == 'No band':
                 freeBands.append(band)
         self.bandOptions = freeBands
         self.bandName.configure(values=self.bandOptions)
         if self.bandName.get() not in freeBands:
             self.bandName.delete(0, 'end')
             self.bandSelected.set('Please Select a Band')
             self.band_options()
"""module contains the classes and functions needed to update a booking for party, wedding and conference"""
from abc import abstractmethod
from tkinter import *
from tkinter import messagebox
import money_convert as mc
import gui.top_level_functions as tlf
from classes import *
import tkinter.ttk as ttk
from Data_Access import data_access as da
from gui import tkinter_styling as style, dialogs
import validation
import constvalues as CONST

db = da.DBAccess()


def save_update(booking, master):
    """function to save updated booking information into database"""
    if isinstance(booking, Conference):
        db.update_conference(booking)
    elif isinstance(booking, Wedding):
        db.update_wedding(booking)
    elif isinstance(booking, Party):
        db.update_party(booking)
    dialogs.updated(master)


class UpdateUIBase:
    """class is used as the base for the UpdateConferenceUI class and UpdatePartyUI class"""

    def __init__(self, master, event):