def exculActivitiesPool(cmb, exculset_id, edited_activity_id=0): # collect activity_ids for exculset_id sql = " SELECT ea.id \ FROM excul ex \ JOIN excul_activity_titles ea ON ea.id = ex.activity_id \ WHERE ex.exculset_id = %d " % (exculset_id, ) activityIDs = fetch.getList(sql) if edited_activity_id: l = [] for x in activityIDs: #rint x if not x == edited_activity_id: l.append(x) activityIDs = l activityIDs = [str(x) for x in activityIDs] #rint 'activityIDs',activityIDs listStr = "'%s'" % ','.join(activityIDs) sql = " SELECT id, name \ FROM excul_activity_titles \ WHERE NOT FIND_IN_SET(id, %s) \ ORDER BY name" % listStr #rint sql, fetch.getAll_col(sql) fillCmb(cmb, fetch.getAll_col(sql), 'without activity') restore(cmb, int(edited_activity_id))
def genNoId(cmb, sql , first_item = '') : #sql should be designed to return two items 'id' and 'title' try: origional_str = fetch.cmbValue(cmb) except: origional_str = '' dataSet = fetch.getList(sql) #rint dataSet cmb.Freeze() # locks the combo so that other processes are not called cmb.Clear() try: if first_item: cmb.Append(first_item, 0) x = 1 for item in dataSet: #rint row cmb.Append(str(item), x) x += 1 #if x%10==0: rint x restored = restore_str(cmb, origional_str) cmb.Thaw() if restored: return origional_str else: return 0 except: #rint 'load cmb error' return 0
def estates(cmb): sql = "SELECT estate FROM addresses GROUP BY (estate) ORDER BY (estate)" res = fetch.getList(sql) cmb.SetItems(res) cmb.Insert('-new-', 0) cmb.Insert('', 0) return cmb
def courseLevels_forSchool(cmb, school_id = 0): school_id = int(school_id) origional_level = fetch.cmbValue(cmb) sql = "SELECT course_level, course_title \ FROM courses_levels WHERE school_id = %d ORDER BY course_level" % school_id # #rint sql return gen(cmb, sql, '') dataSet = set(fetch.getList(sql)) #rint dataSet cmb.Freeze # locks the combo so that other processes are not called cmb.Clear() index = 0 for level in dataSet: #rint index, level cmb.Append(str(level), index) index += 1 if not origional_level: cmb.SetSelection(0) else: restored = restore_str(cmb, origional_level) cmb.Thaw if restored: return origional_level else: return cmbValue(cmb)
def countries(cmb): sql = "SELECT id, itemName \ FROM addressItems \ WHERE itemType = 'country'" res = fetch.getList(sql) cmb.Freeze() for row in res: cmb.Append(row[1], row[0]) cmb.Thaw() return cmb
def displayData(self): self.number_of_grids = 0 if self.widgetSizer.GetChildren(): self.widgetSizer.Hide(0) self.widgetSizer.Remove(0) # create a new grid grid = self.grid = gridlib.Grid(self) self.set_grid_properties() self.widgetSizer.Add(grid, 1, wx.EXPAND, 0) columnlabels = [("TYPE", 80), ("ID", 30), ("COURSE NAME", 200), ("NOW", 45), ("OUT", 45), ("CONT.", 55), ("REDO", 45), ("TOTAL",85), ("NEW",45), ("TOTAL",55), ("CLASS SIZE",95), ("CLASSES",75)] self.setColumnLabels(columnlabels) self.Layout() #grid.DeleteRows(1,r) #grid.AppendRows(150) sql ="SELECT courses FROM courses_by_year WHERE schYr = %s" % gVar.schYr ##rintsql course_ids = fetch.getList(sql) sql ="SELECT course_level FROM courses_levels ORDER BY course_level" course_levels = fetch.getList(sql) row = 0 for level in range(1,20): self.formatRow(row) if level ==1: row = self.displayDataForLowerLevelNextYearsCourses(level, row) row = self.dispalyDataForLastYearsKelases (level, row) row = self.dispalyDataForNextYearsCourses(level, row)
def setItems(cmb, sql , first_item = '') : #sql should be designed to return two items 'id' and 'title' try: origional_str = fetch.cmbValue(cmb) except: origional_str = '' dataSet = fetch.getList(sql) cmb.Freeze() # locks the combo so that other processes are not called cmb.Clear() cmb.AppendItems(dataSet) restored = restore_str(cmb, origional_str) cmb.Thaw() if restored: return origional_str else: if len(dataSet)==1: cmb.SetSelection(0) return fetch.cmbValue(cmb) else:return 0