def loadAddress(self, address_id): #rint'loadAddress' sql = "SELECT postcode \ FROM addresses \ WHERE id = %d" % address_id #rintsql postcode = fetch.getDig(sql) #if postcode: self.num_ctrl_postcode.SetValue(str(postcode)) sql = "SELECT id, itemName \ FROM addressItems \ WHERE itemType = 'kecamatan' \ AND postcode = %d " % postcode dataSet = fetch.getAllCol(sql) if len(dataSet)!=1: # as it should #rint' what to do ?' return kecamatanID = dataSet[0][0] loadCmb.restore(self.combo_kecamatan, kecamatanID) selectedKabupatenID = fetch.cmbID(self.combo_kabupaten) selectedProvinceID = fetch.cmbID(self.combo_province) # step 1: working down ------------------------------- #kecamatan = # do for kabupaten -------------------------------- kabupatenList = fetch.kabupatenForKecamatanID(kecamatanID) if selectedKabupatenID in self.idList(kabupatenList): return kabupatenID = self.setGen(selectedKabupatenID, kabupatenList, self.combo_kabupaten) provinceID = self.provincesForKabupaten(kabupatenID, selectedKabupatenID) self.countriesForProvince(provinceID, selectedProvinceID) return # step 2 - work up kelurahanList = fetch.kelurahanForKecamatanID(kecamatanID) #rint 'upFillKel kelurahanList', kelurahanList self.upFillKel(kelurahanList)
def OnKec(self, event): selectedKecamatanID, kecamatan = fetch.cmbIDV(self.combo_kecamatan) selectedKabupatenID = fetch.cmbID(self.combo_kabupaten) selectedProvinceID = fetch.cmbID(self.combo_province) if selectedKecamatanID: self.postcodeForKecamatan(selectedKecamatanID) # working down ---------------- kabupatenList = fetch.kabupatenForKecamatanID(selectedKecamatanID) if kabupatenList: kabupatenID = self.setGen(selectedKabupatenID, kabupatenList, self.combo_kabupaten) if selectedKabupatenID != kabupatenID: provinceList = fetch.provincesForKabupatenID(kabupatenID) selectedProvinceID = fetch.cmbID(self.combo_province) provinceID = self.setGen(selectedProvinceID, provinceList, self.combo_province) if selectedProvinceID != provinceID: self.countriesForProvince(provinceID, provinceID) # step 2 - work up self.resetCmb(self.combo_kelurahan) alist = fetch.kelurahanForKecamatanID(selectedKecamatanID) self.setComboItems(self.combo_kelurahan, alist)