def getIDListObjs(obj, ci, si, pi): # Transforms the lists of obj ids in the GUI # back into their respective objects # Returns a tuple with 3 lists of objects. cObj = [] sObj = [] pObj = [] print("Running List IDs in " + str(obj) + " into Objects...") print("Custs Ids: " + str(ci)) print("Staff Ids: " + str(si)) print("Prods Ids: " + str(pi)) for custs in ci: cObj.append(db.getObjFromList("customerList", custs)) print("Customer Objects: " + str(cObj)) for staff in si: sObj.append(db.getObjFromList("staffList", staff)) print("Staff Objects: " + str(sObj)) for prods in pi: pObj.append(db.getObjFromList("prodList", prods)) print("Product Objects: " + str(pObj)) return (cObj, sObj, pObj)
def createTransportDepots_SQL(tuplist): for depot in tuplist: t = db.getObjFromList("transporterList", int(depot[0])) c = str(depot[1]) b = str(depot[2]) d = str(depot[3]) g = str(depot[4]) cl = c.split("|") bl = b.split("|") dl = d.split("|") gl = g.split("|") co = [] bo = [] do = [] go = [] for ci in cl: co.append(db.getObjFromList("carsList", int(ci))) for bi in bl: bo.append(db.getObjFromList("bikesList", int(bi))) for di in dl: do.append(db.getObjFromList("driveList", int(di))) for gi in gl: go.append(db.getObjFromList("gearList", int(gi))) nt = Transport(t, co, bo, do, go)
def splitTickets(tickets): # Splits a pipe-separated ticket ID string in into Ticket objects. tix = tickets.split("|") tlist = [] for t in tix: try: tlist.append(db.getObjFromList("airTicketList", int(t))) except ValueError: print("Banana! ValueError in splitting tickets!") continue return tlist
def createHotelProduct_SQL(prods): for product in prods: #print(product) name = product[0] desc = product[1] hotelier = db.getObjFromList("hotelierList", product[2]) rooms_ids = product[3].split("|") feats_ids = product[4].split("|") rooms = [] feats = [] for room in rooms_ids: rooms.append(db.getObjFromList("hotelRoomList", int(room))) for feature in feats_ids: feats.append(db.getObjFromList("hotelFeatureList", int(feature))) newHotel = Hotel(hotelier, rooms, feats) newHotel.updateName(name) newHotel.updateDesc(desc) newHotel.calcRoomPrices()
def menuCB_Location(event): #print(event) # Callback for location selection. self.locationObj = db.getObjFromList("locationList", self.locations.index(event))
def menuCB_Room(event): #print(event) # Callback for room selection. self.roomObj = db.getObjFromList("hotelRoomList", self.rooms.index(event))
def menuCB_Hotelier(event): #print(event) # Callback for hotelier selection. self.hotelierObj = db.getObjFromList("hotelierList", self.hoteliers.index(event))
SELECT products.name, -- 0 products.desc, -- 1 prods_hotel.hotelier, -- 2 prods_hotel.room_types, -- 3 prods_hotel.hotel_features, -- 4 prods_hotel.location -- 5 FROM products INNER JOIN prods_hotel ON products.pid = prods_hotel.pid WHERE products.pid = ? """, (p, )) product = dbCur.fetchone() # Build Hotel Product name = str(product[0]) desc = str(product[1]) hotelier = db.getObjFromList("hotelierList", product[2]) rooms_ids = product[3].split("|") feats_ids = product[4].split("|") loc_id = int(product[5]) rooms = [] feats = [] for room in rooms_ids: rooms.append(db.getObjFromList("hotelRoomList", int(room))) for feature in feats_ids: feats.append(db.getObjFromList("hotelFeatureList", int(feature))) from cl_Products import Hotel newHotel = Hotel(hotelier, rooms, feats) newHotel.updateName(name) newHotel.updateDesc(desc)
def populateTransactions_SQL(tuplelist): for transac in tuplelist: date_y = int(transac[0]) date_m = int(transac[1]) date_d = int(transac[2]) custIDs = str(transac[3]).split("|") staffIDs = str(transac[4]).split("|") prodIDs = str(transac[5]).split("|") bill = str(transac[6]) payStat = str(transac[7]) notes = str(transac[8]).replace('\\n', '\n') # Yes, its really dumb, but Python is also dumb. # You gotta spell out to it that a newline is a newline # because it auto-converts any instance of \ into \\. # Which is REALLY DUMB AND I HATE IT. if (bill in ["true", "True", "TRUE", True]): bill = True else: bill = False if (payStat in ["true", "True", "TRUE", True]): payStat = True else: payStat = False try: ampaid = float(transac[9]) except: ampaid = 0.00 try: due_y = int(transac[10]) except: due_y = 1970 try: due_m = int(transac[11]) except: due_m = 1 try: due_d = int(transac[12]) except: due_d = 1 custObjs = [] staffObjs = [] prodsObjs = [] for customer in custIDs: custObjs.append(db.getObjFromList("customerList", int(customer))) for staff in staffIDs: staffObjs.append(db.getObjFromList("staffList", int(staff))) for product in prodIDs: prodsObjs.append(db.getObjFromList("prodList", int(product))) if (bill == True): newObj = Bill(cu=custObjs, st=staffObjs, pr=prodsObjs, date=dt.datetime(date_y, date_m, date_d), due=dt.datetime(due_y, due_m, due_d), pay=ampaid, paid=payStat) newObj.notes = notes else: newObj = Transaction(cu=custObjs, st=staffObjs, pr=prodsObjs, date=dt.datetime(date_y, date_m, date_d)) newObj.notes = notes