Example #1
0
    def edit(self, cmb1, cmb2, itemType):
	#rint'editing type:',itemType
	nextItem = ''
        self.restore_id, restoreString = fetch.cmbIDV(cmb1)
	if not self.restore_id:
	    # prepare data for new entry
	    if itemType=='country':
		self.nextItemID = 0
	    else:
		#rintitemType
		nextItemID, nextItem = fetch.cmbIDV(cmb2)
		if not nextItemID:
		    fetch.msg('Please Select A Follow On Item')
		    return
        
        dlg = DlgAddrItemEditor.create(None)
        try:
            dlg.displayData(self.restore_id, itemType, nextItem)
            if dlg.ShowModal() == wx.ID_OK:
                itemName = dlg.itemName
		if not itemName: return
		
		# prevent duplicate name if country
		# prevent duplicate name where next item same
		# warning of other duplicate names -if not kelurahan
		
                if self.restore_id: # editing an item
		    if itemName == restoreString:
			return
                    else:
			sql = "UPDATE addressItems \
				  SET itemName ='%s' \
				WHERE %id = %d" % (itemName, self.restore_id)
			#rintsql
			cmb1.SetValue(itemName)
			
                else: # insert a new item
		    #  
                    sql = "INSERT INTO addressItems \
		                  (itemName, itemType, nextItemID) \
                           VALUES ('%s', '%s', '%s')" % (
			           itemName, itemType, self.nextItemID)
		    #rintsql
                      
        finally:    
            dlg.Destroy()
Example #2
0
    def OnKab(self, event):
	selectedKabupatenID, kabupaten = fetch.cmbIDV(self.combo_kabupaten)
        provinceList       = fetch.provincesForKabupaten(kabupaten)
	selectedProvinceID = fetch.cmbID(self.combo_province)
	provinceID         = self.setGen(selectedProvinceID, provinceList, self.combo_province)
	if selectedProvinceID != provinceID:
	    self.countriesForProvince(provinceID, selectedProvinceID)
	
        # step 2: work upward -----------------------
        kecamatenList = fetch.kecamatanForKabupatenID(selectedKabupatenID)
        if kecamatenList:
	    selectedKecamatenID = fetch.cmbID(self.combo_kecamatan)
            kecamatenID = self.setComboItems(self.combo_kecamatan, kecamatenList)
            if kecamatenID != selectedKecamatenID:
                self.resetCmb(self.combo_kelurahan)
Example #3
0
    def OnProvince(self, event):
	selectedProvinceID, province = fetch.cmbIDV(self.combo_province)
	if selectedProvinceID:
	    countryList = fetch.countriesForProvinceID(selectedProvinceID)
	    if countryList:
		selectedCountryID = fetch.cmbID(self.combo_country)
		self.setGen(selectedCountryID, countryList, self.combo_country)
	# work up ---------------------
	kabupatenList       = fetch.kabupatenForProvinceID(selectedProvinceID)
	selectedKabupatenID = fetch.cmbID(self.combo_kabupaten)
	if selectedKabupatenID in self.idList(kabupatenList):
	    return
	self.clearPostcodeCtrls((self.combo_kecamatan,
				 self.combo_kabupaten,
				 self.combo_kelurahan))
        #  kabupaten --------------------------
        if kabupatenList:
            kabupatenID = self.setComboItems(self.combo_kabupaten, kabupatenList)
            if selectedKabupatenID != kabupatenID:
		pass
Example #4
0
    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)