def OnCellChange(self, evt): col = evt.GetCol() #rint"OnCellChange", col if col == 2 or col == 4: return row = evt.GetRow() pos = evt.GetPosition() cellstr = self.GetCellValue(row, col).replace(',','') cellval = int(cellstr) if col == 1 and cellval==0:return self.SetCellValue(row, col, format(int(cellstr), '0,.0f')) self.calcTotal() row = self.GetGridCursorRow() product_id = self.get_product_id(row) product_type_id = fetch.get_product_type_id(product_id) if product_type_id == 1: # school fee #rint' change fee description' # prevent excess months elif product_type_id == 9: # bus fee # prevent excess months #rint' change bus description' pub.sendMessage('bus.grid.change')
def update_bus_details(self, months, txt): # find which row hold holds bus data rows = self.GetNumberRows() for row in range(rows): product_id = self.get_product_id(row) product_type_id = fetch.get_product_type_id(product_id) if product_type_id == 9: self.SetCellValue(row, 2, txt)
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)