def displayData(self): # collect the variables gVar.schYr = self.spc_schYr.Value #g_semester_no = self.spin_semester.Value sch_id = fetch.cmbID(self.c_schools) dayNo = fetch.cmbID(self.c_day)+1
def displayData(self): # clear the panel self.scrolledPanel.DestroyChildren() self.gbs_excul.Clear() # collect the variables #gVar.schYr = self.spc_schYr.Value gVar.semester = self.spc_semester.Value sch_id = fetch.cmbID(self.c_schools) dayNo = fetch.cmbID(self.c_day)+1 if not sch_id: return studentIDs_list=[] # get the excul list exculIDs = fetch.exculIDs_forSch(dayNo, gVar.semester, sch_id) if exculIDs: exculCount = len(exculIDs) i = 0 for excul_id in exculIDs: myLV = self.createLV(excul_id, i) # fill each listView with members studentIDs = lv.populateExcul(myLV, excul_id) studentIDs_list.extend(studentIDs) i += 1 remainingStudents = fetch.exculRemainingStudents(sch_id, studentIDs_list) lv.populateExculRemainingStudents(self.lv1, remainingStudents) dt1 = TextDropTarget(self.lv1) # Make this control a Drop Target self.lv1.SetDropTarget(dt1) # Link to Control self.scrolledPanel.FitInside() self.Layout()
def OnSave(self, evt): print #rint'OnSave--------------' division_id = fetch.cmbID(self.choice_divisioan) date = self.datepicker_ctrl_1.GetDbReadyValue() description = self.text_ctrl_description.GetValue() ckRef = self.text_ctrl_ckrefno.GetValue() supplierRef = self.text_ctrl_supplierrefno.GetValue() supplier_id = fetch.cmbID(self.choice_supplier) pettycash = self.checkbox_pettycash.GetValue() debit_items_count = self.grid_debits.getItemCount() credit_items_count = self.grid_credits.getItemCount() msg = '' if not division_id: msg += '- division\n' if not tran_description: msg += '-transaction description\n' if not supplier_id: msg += '-supplier\n' if not date: msg += '-transaction date\n' if not ckRef: msg += '-ck ref missing\n' if debit_items_count + credit_items_count == 0: msg += '-credit or debit entries\n' if msg: msg = 'Missing Items:\n' + msg fetch.msg(msg) return if self.debit_total != self.credit_total: fetch.msg('transaction totals do not match') data = (supplier_id, date, description, ckRef, supplier_id, supplierRef, pettycash) if self.journal_id: self.updateEntries(data) else: self.newEntry(data)
def OnEnter(self, event): self.course_name = '"%s"' % self.text_ctrl_course_name.GetValue() self.code = '"%s"' % self.text_ctrl_short_name.GetValue() self.course_level = fetch.cmbID(self.choice_levels) self.school_id = fetch.cmbID(self.choice_schools) if not self.course_title or not self.course_level: txt = "Must have course title and a course level" fetch.msg(txt) return elif self.courseNameAvailable(self.course_title): if self.editMode == 'update': self.updateCourse() else: self.insertNewCourse() self.EndModal(wx.ID_OK)
def getData(self): description = self.text_ctrl_description.GetValue() qnty = self.num_ctrl_qnty.GetValue() price = self.num_ctrl_price.GetValue() account = self.combo_box_account.GetID() taxCode = fetch.cmbID(self.combo_box_tax) net = qnty*price return (qnty, description, price, taxCode, net, account)
def OnAddDebit(self, evt): #rint'OnAddDebit' account_id = fetch.cmbID(self.choice_debits) #rintaccount_id if self.id_inListCtrl(account_id, self.list_ctrl_debits): return account = fetch.cmbValue(self.choice_debits) #rint account addedDebits.append((account_id, 0)) self.list_ctrl_debits.Append((account_id, account, '0'))
def OnCourse(self, evt): #rint'OnCourse' course_id = fetch.cmbID(self.choice_course) sql = "SELECT course_fee_monthly \ FROM courses_by_year \ WHERE id =%d" % course_id res = fetch.getDig(sql) #rint'course_fee_monthly', res self.text_ctrl_course_fee.SetValue(str(res)) self.calcFeeTotal()
def displayData(self): #rint'PanelExculViewer2: displayData' self.semester_no = self.choice_semester.GetStringSelection() # clear the panel self.scrolledPanel.DestroyChildren() self.scrolledPanelSizer.Clear() # collect the variables #gVar.schYr = self.spc_schYr.Value self.semester = self.choice_semester.GetStringSelection() school_id = fetch.cmbID(self.choice_school) dayNo = fetch.cmbID(self.choice_day) #rint">>>", self.semester, ">>>",school_id,">>>", dayNo if not (school_id and self.semester and dayNo): return studentIDs_list=[] # get the excul list exculIDs = fetch.exculIDs_forSch(dayNo, self.semester, school_id) exculIDs = [1,2,3,5,6,7,8,9,11,112,12,13,14,15,16,17,18,19,21,23,24,25,26,27,28] if exculIDs: exculCount = len(exculIDs) i = 0 for excul_id in exculIDs: myLV = self.createLV(excul_id, i) #rint'createLV ed:', myLV # fill each listView with members #studentIDs = lv.populateExcul(myLV, excul_id) #studentIDs_list.extend(studentIDs) i += 1 remainingStudents = fetch.exculRemainingStudents(school_id, studentIDs_list) lv.populateExculRemainingStudents(self.list_ctrl_pool, remainingStudents) dt1 = TextDropTarget(self.list_ctrl_pool) # Make this control a Drop Target self.list_ctrl_pool.SetDropTarget(dt1) # Link to Control self.scrolledPanel.FitInside() self.Layout()
def OnAdd(self, evt): #rint'OnAdd' product_id = fetch.cmbID(self.choice_products) #rint'product_id.GetSelection():', product_id if not product_id or self.grid_product.inGrid(product_id): return description = fetch.cmbValue(self.choice_products) price = fetch.product_price(product_id) qnty = 1 total = qnty*price product_type_id = fetch.get_product_type_id(product_id) if product_type_id == 1: # school fee #rint' append fee ' month_no = fetch.month_last_paid(student_id, gVar.schYr, 9)+1 if month_no > 12: self.panel_fees.Hide() fetch.msg('month 12 already paid for') return else: self.panel_fees.Show() month = fetch.monthName(month_no) description = 'Schoolfee for %s' % month elif product_type_id == 9: # bus fee #rint' append bus ' # last paid for month # if last month == 12 : return month_no = fetch.month_last_paid(student_id, gVar.schYr, 9)+1 if month_no > 12: fetch.msg('month 12 already paid for') # what we really need to know is if all months have been paid for return else: self.panel_bus.Show() self.Layout() month = fetch.monthName(month_no) description = 'Bus fee for %s' % month data = {'product_id':product_id, 'qnty':qnty, 'description':description, 'price':price, 'total':total} self.grid_product.appendItem(data) r = self.grid_product.GetNumberRows() self.grid_product.setCellReadOnly(r, 0)
def fillCmb(cmb, dataSet, first_item=''): origional_id = fetch.cmbID(cmb) cmb.Freeze() # locks the combo so that other processes are not called cmb.Clear() if first_item: cmb.Append(first_item,0) for row in dataSet: cmb.Append(str(row[1]), row[0]) restored = restore(cmb, origional_id) cmb.Thaw() if restored: return origional_id else: return 0
def restore(cmb, origional_id=0): #rint'restore', origional_id cmb.Freeze() if origional_id: for y in range(cmb.Count): cmb.Select(y) # select first item cmbID = fetch.cmbID(cmb) if cmbID == origional_id: cmb.Thaw() return True cmb.Select(0) cmb.Thaw() return False
def bus_details_changed(self): #rint'bus_details_changed' month_from = fetch.cmbID(self.choice_bus_from) month_to = fetch.cmbID(self.choice_bus_to) #rint'month_from=', month_from, ' month_to=', month_to self.months = months = month_to - month_from +1 #rint'months=', months if months == 1: month = fetch.cmbValue(self.choice_bus_from) txt = 'Transport for %s' % month else: month_from = fetch.cmbValue(self.choice_bus_from) month_to = fetch.cmbValue(self.choice_bus_to) txt = 'Transport for %s to %s' % (month_from, month_to) self.text_ctrl_bus_details.SetValue(txt) self.grid_product.update_bus_details(months,txt)
def OnSave(self, event): g_sch_id = fetch.cmbID(self.c_schools) g_day_no = fetch.cmbID(self.c_day)+1 g_semester_no = self.spc_semester.Value g_schYr = self.spc_schYr.Value lvA = self.lv_activitiesSelected lvT = self.lv_teachersSelected tCount, aCount = lvT.ItemCount, lvA.ItemCount #rint 'tCount, aCount',tCount, aCount listT, listA =[],[] if aCount: for i in range(aCount): #rint 'saving activity index ', i listA.append(lvA.GetItem(i,0).GetText()) if tCount: for i in range(tCount): #rint 'saving teacher index ', i listT.append(lvT.GetItem(i,0).GetText()) teacherIDs = "'%s'" % ','.join(listT) activityIDs = "'%s'" % ','.join(listA) if self.exculrange_id: sql = "UPDATE exculrange SET activityIDS=%s, teacherIDs=%s \ WHERE exculrange_id=%d" % (activityIDs, teacherIDs, self.exculrange_id) else: sql = "INSERT INTO exculrange \ SET activityIDS=%s, teacherIDs=%s, \ sch_id=%d, schYr=%d, semester_no=%d, day_no=%d" % ( activityIDs, teacherIDs, g_sch_id, g_schYr, g_semester_no, g_day_no) #rint sql updateDB.generic(sql)
def inv_students(cmb, filter_panel): school_id, course_id, form_id = filter_panel.getSelectedIDs() #rint 'inv_students', cmb, school_id, course_title_id, batch_id if form_id: sql ="SELECT s.id, s.name \ FROM students s \ JOIN students_by_form sbf ON s.id = sbf.student_id \ JOIN forms f ON f.id = sbf.form_id \ WHERE s.is_active = 1 \ AND f.id = %d" % form_id elif course_id: sql ="SELECT s.id, s.name \ FROM students s \ JOIN students_by_form sbf ON s.id = sbf.student_id \ JOIN forms f ON f.id = sbf.batch_id \ WHERE s.is_active = 1 \ AND f.course_id = %d" % course_id sql += " AND register_schYr < %d" % gVar.schYr origional_id = fetch.cmbID(cmb) dataSet = fetch.getAllCol(sql) cmb.Freeze() # locks the combo so that other processes are not called cmb.Clear() first_item = "" if first_item: cmb.Append(first_item, -1) cmb.Append('', 0) for row in dataSet: if row[1]: fn = "%s " % row[1] else: fn='' if row[2]: mn = "%s " % row[2] else: mn = '' if row[3]: ln = "%s " % row[3] else: ln='' ful_name = "%s%s%s" % (fn,mn,ln) cmb.Append(ful_name, row[0]) restored = restore(cmb, origional_id) cmb.Thaw() if restored: cmb.Thaw() return origional_id else: cmb.SetSelection(1) cmb.Thaw()
def genNoBlank(cmb, sql, first_item='') : #rint 'loadCmb: genNoBlank:', sql, fetch.getAll_dict(sql) #sql should be designed to return first two items 'id' , 'title' dataSet = fetch.getAllCol(sql) origional_id = fetch.cmbID(cmb) cmb.Freeze() # locks the combo so that other processes are not called cmb.Clear() if first_item: cmb.Append(first_item, '0') for row in dataSet: cmb.Append(str(row[1]), row[0]) restore(cmb, origional_id) cmb.Thaw()
def OnAddCredit(self, evt): #rint'Add credit' gVar.listCtrl = 'c' account_id=fetch.cmbID(self.choice_credits) if self.id_in_grid(account_id, self.grid_credits): return if self.id_in_grid(account_id, self.grid_debits): fetch.msg('can add this account, already in debits') account = fetch.cmbValue(self.choice_credits) #rint'OnAddCredit', account self.grid_credits.appendItem((account_id, account, 0)) self.grid_credits.calcTotal()
def OnNewItem(self, event): iid = fetch.cmbID(self.choice_product) if not iid in iid_list: iid_list.append(iid) #iid = fetch.cmbValue(self.choice_product) self.number_of_inv_items += 1 name = "inv%s" % self.number_of_inv_items new_inv_item = PanelInvoiceItem(self.panel_invoice_items, -1) new_inv_item.displayData(iid, self.student_id) self.sizer_inv_items.Add(new_inv_item, 0, wx.TOP | wx.BOTTOM, 5) self.panel_invoice_items.Layout() self.panel_invoice_items.Fit() self.updateTotal() self.GetTopLevelParent().onAdd()
def gen(cmb, sql , first_item='') : #sql should be designed to return two items 'id' and 'title' ##rint"loadCmb gen:", sql, len(fetch.getAllCol(sql)) origional_id = fetch.cmbID(cmb) dataSet = fetch.getAllCol(sql) ##rint'dataSet:' , dataSet cmb.Freeze() # locks the combo so that other processes are not called cmb.Clear() if first_item: cmb.Append(first_item, 0) for row in dataSet: #rint 'cmb load , id=', row[0],' str=', row[1] cmb.Append(str(row[1]), int(row[0])) restored = restore(cmb, origional_id) cmb.Thaw() if restored: return origional_id else: return 0
def genAdd(cmb, sql , first_item='') : #sql should be designed to return two items 'id' and 'title' origional_id = fetch.cmbID(cmb) dataSet = fetch.getAllCol(sql) cmb.Freeze() # locks the combo so that other processes are not called cmb.Clear() if first_item: cmb.Append(first_item, -1) cmb.Append('', 0) for row in dataSet: #rint 'x' cmb.Append(str(row[1]), row[0]) restored = restore(cmb, origional_id) cmb.Thaw() if restored: cmb.Thaw() return origional_id else: cmb.SetSelection(1) cmb.Thaw() return
def displayData(self): self.GetTopLevelParent().showSemester(True) gVar.school_id = fetch.cmbID(self.choice_school) gVar.semester = fetch.cmbID(self.choice_semester) gVar.day = fetch.cmbID(self.choice_day) pub.sendMessage('exculFilter.changed')
def OnSelectcourse(self, evt): course_by_year_id = fetch.cmbID(self.choice_rereg_course) course_fee = "SELECT course_fee FROM courses_by_year WHERE id = course_by_year_id"
def OnSchool(self, event): school_id = fetch.cmbID(self.choice_schools) loadCmb.courseLevels_forSchool(self.choice_levels, school_id)
def OnBusMonthFrom(self, evt): min_month = fetch.cmbID(self.choice_bus_from) loadCmb.schMonths(self.choice_bus_to, min_month-1) self.bus_details_changed()