Exemple #1
0
    def loadCmbsUnderKec(self, kecamatan):
        # self.postcodeClear()
        self.postcodeForKecamatan(kecamatan)
        # rint'loadCmbsUnderKec', kecamatan

        # step 1: working down -------------------------------

        # do for kabupaten --------------------------------
        kabupatenList = fetch.kabupatenForKecamatan(kecamatan)
        selectedKabupaten = fetch.cmbValue(self.combo_kabupaten)

        if selectedKabupaten in kabupatenList:
            return

        kabupaten = self.setKabupaten(selectedKabupaten, kabupatenList)

        #  do for province -------------------------------
        selectedProvince = fetch.cmbValue(self.combo_province)
        if kabupaten:
            provinceList = fetch.provinceForKabupaten(selectedKabupaten)
            self.setProvinces(selectedProvince, provinceList)

        else:
            provinceList = fetch.proviceForKecamatan(kecamatan)
            self.setProvinces(selectedProvince, provinceList)

        # step 2 - work up
        kelurahanList = fetch.kelurahanForKecamatan(kecamatan)
        self.upFillKel(kelurahanList)
Exemple #2
0
    def loadCmbsUnderProv(self, province):
        kabupatenList = fetch.kabupatenForProvince(province)
        kecamatenList = fetch.kecamatanForProvince(province)

        selectedKabupaten = fetch.cmbValue(self.combo_kabupaten)
        selectedKecamtan = fetch.cmbValue(self.combo_kecamatan)
        selectedKelurahan = fetch.cmbValue(self.combo_kelurahan)

        if selectedKabupaten in kabupatenList:
            return

        #  kabupaten --------------------------
        self.clearPostcodeCtrls((self.combo_kabupaten,))
        self.clearPostcodeCtrls((self.combo_kecamatan, self.combo_kabupaten, self.combo_kelurahan))

        if kabupatenList:
            kabupaten = self.setComboItems(self.combo_kabupaten, kabupatenList)
            if kabupaten in kabupatenList:
                return

        #  kecamaten --------------------------
        if selectedKecamaten in kecamatenList:
            return

        self.clearPostcodeCtrls((self.combo_kecamatan,))
        if kecamatenList:
            kecamaten = self.setComboItems(self.combo_kacamatan, kecamatenList)
            if kecamaten in kecamatenList:
                self.postcodeForKecamatan(kecamaten)
                return

        self.loadKelurahanProvince(province)
Exemple #3
0
    def loadCmbsUnderKel(self, kelurahan):
        # self.postcodeClear()
        # rint'loadCmbsUnderKel'

        selectedKecamatan = fetch.cmbValue(self.combo_kecamatan)
        if selectedKecamatan:
            return

        # kecamatan -----------------------------
        kecamatanList = fetch.kecamatanForKelurahan(kelurahan)
        # rintkelurahan, ' kelurahan > kecamatan', kecamatanList
        selectedKecamatan = self.setKecamatan(selectedKecamatan, kecamatanList)

        # kabupaten ------------------------------
        kabupatenList = fetch.kabupatenForKecamatan(selectedKecamatan)

        selectedKabupaten = fetch.cmbValue(self.combo_kabupaten)

        if selectedKabupaten in kabupatenList:
            return

        kabupaten = self.setKabupaten(selectedKabupaten, kabupatenList)

        # province -------------------------------
        selectedProvince = fetch.cmbValue(self.combo_province)
        if kabupaten:
            provinceList = fetch.provinceForKabupaten(selectedKabupaten)
            self.setProvinces(selectedProvince, provinceList)

        else:
            provinceList = fetch.proviceForKecamatan(selectedKecamatan)
            self.setProvinces(selectedProvince, provinceList)
    def getValues(self):
        pc = self.num_ctrl_postcode.GetValue()
        kal = fetch.cmbValue(self.combo_box_kel)
        kec = fetch.cmbValue(self.combo_box_kec)
        kab = fetch.cmbValue(self.combo_box_kab)

        values  = "%d, %s, %s, %s" % (pc, kal, kec, kab, 'Sumatra Utara', 'Indonesia')

        return values
Exemple #5
0
    def loadCmbsUnderCountry(self, country):
	provinceList  = fetch.provincesForCountry(country)
	kabupatenList = fetch.kabupatenForCountry(country)
	
	selectedProvince  = fetch.cmbValue(self.combo_province)
	selectedKabupaten = fetch.cmbValue(self.combo_kabupaten)
	selectedKecamatan = fetch.cmbValue(self.combo_kecamatan) 
        selectedKelurahan = fetch.cmbValue(self.combo_kelurahan)
	
	if selectedProvince in provinceList:  return
Exemple #6
0
    def gen(self, cmbA, cmbB, btnA, msg, x):
	self.restoreStr = itemA = fetch.cmbValue(cmbA)
	itemB = fetch.cmbValue(cmbB)
	if itemA == '-new-':
	    if itemB and itemB != '-new-':
		btnA.Show()
		self.disableCombos(cmbA)
	    else: 
		self.resetCmb(cmbA, msg)
	else:
	    self.enableCombos()
	    x(itemA)
Exemple #7
0
    def getValues(self):
        house = self.text_ctrl_house.GetValue()
        street = self.text_ctrl_street.GetValue()
        estate = fetch.cmbValue(self.combo_box_estate)
        block = self.text_ctrl_block.GetValue()
        road = self.text_ctrl_road.GetValue()
        post = self.num_ctrl_postcode.GetValue()
        kal = fetch.cmbValue(self.combo_kelurahan)
        kec = fetch.cmbValue(self.combo_kecamatan)
        kab = fetch.cmbValue(self.combo_kabupaten)
        prov = fetch.cmbValue(self.combo_province)

        # if not estate in listEstates:

        return (house, street, estate, block, road, post, kal, kec, kab, prov)
Exemple #8
0
    def loadCmbsUnderKab(self, kabupaten):
        # self.postcodeClear()
        # rint'loadCmbsUnderKab',kabupaten

        # step 1: work down -------------------------------
        provinceList = fetch.provinceForKabupaten(kabupaten)
        selectedProvince = fetch.cmbValue(self.combo_province)
        self.setComboItems(self.combo_province, provinceList)

        # step 2: work upward -----------------------
        kecamatenList = fetch.kecamatanForKabupaten(kabupaten)
        if kecamatenList:
            selectedKecamaten = self.setComboItems(self.combo_kecamatan, kecamatenList)

            if selectedKecamaten in kecamatenList:
                pass
            elif len(kecamatenList) == 1:
                kecamaten = kecamatenList[0]
                loadCmb.restore_str(self.combo_kecamatan, kecamatenList)
                self.postcodeForKecamatan(kecamaten)
                return

            else:  #  ----------------- check / load :  kelurahan  --------------------------
                kelurahanList = fetch.kelurahanForKabupaten(kabupaten)

                self.upFillKel(kelurahanList)
Exemple #9
0
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
Exemple #10
0
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)
Exemple #11
0
    def OnCountry(self, evt):
	self.restoreStr = country = fetch.cmbValue(self.combo_country)
	if country == '-new-':
	    button_country_cancel.Show()
	    self.disableCombos(self.combo_country)
	else:
	    self.enableCombos()
	    self.loadCmbsUnderCountry(country)
Exemple #12
0
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
Exemple #13
0
    def loadKelurahanProvince(self, province):
	#rint'loadKelurahanProvince'
	selectedKelurahan = fetch.cmbValue(self.combo_kelurahan)
	kelurahanList     = fetch.kelurahanForProvince(province)	    
	if kelurahanList:
	    if selectedKelurahan in kelurahanList: return
	    
	    kelurahan = self.setComboItems(self.combo_kelurahan, kelurahanList)
	    if not (kelurahan in kelurahanList) and len(kelurahanList)==1:
		loadCmb.restore_str(self.combo_box_kel, kelurahan)
Exemple #14
0
 def setComboItems(self, cmb, items):
     selected = fetch.cmbValue(cmb)
     cmb.Freeze()
     cmb.SetItems(items)
     cmb.Thaw()
     selected = loadCmb.restore_str(cmb, selected)
     # rint' restored item',selected
     if not selected:
         # rint' nothing selected'
         if len(items) == 1:
             selected = items[0]
             # rint'only one in the list', selected
             loadCmb.restore_str(cmb, selected)
     return selected
Exemple #15
0
    def edit(self, cmb1, cmb2):
	self.restore_str = fetch.cmbValue(cmb1)
	nextItem = fetch.cmbValue(cmb2)
	if not nextItem: return
	
	
	sql = "SELECT " # warning - how may records will be effected
	
	if not self.restore_str: return
	
	dlg = DlgAddrItemEditor.create(None)
	try:
	    dlg.displayData(self.restore_str)
	    if dlg.ShowModal() == wx.ID_OK:
		itemName = dlg.itemName
		
		if itemName and itemName != self.restore_str:
		    # test to make sure name is unique
		    #rint'save ', itemName
		    #rint'next item id ='
		    cmb1.SetValue(itemName)
		    
	finally:    
	    dlg.Destroy()
Exemple #16
0
    def edit(self, cmb1, cmb2, itemType):
	self.restore_str = fetch.cmbValue(cmb1)
	nextItem = fetch.cmbValue(cmb2)
	if not nextItem: return
	
	nextItemID = fetch.cmbID(cmb2)
	
	dlg = DlgAddrItemEditor.create(None)
	try:
	    dlg.displayData(self.restore_str)
	    if dlg.ShowModal() == wx.ID_OK:
		itemName = dlg.itemName
		if self.restore_str: # update an edited item
		    if itemName and itemName != self.restore_str:
			# test to make sure name is unique
			#rint'save ', itemName
			#rint'next item id ='
			cmb1.SetValue(itemName)
		    else: # insert a new item
			sql = "INSERT INTO addressItems (itemName, itemType, nextItemID) \
	                                         VALUES ('%s', '%s', '%s')" % (itemName, itemType, self.nextItemID)
		      
	finally:    
	    dlg.Destroy()
Exemple #17
0
 def OnKab(self, event):
     self.num_ctrl_postcode.Clear()
     kabupaten = fetch.cmbValue(self.combo_box_kab)
     self.loadCmbsUnderKab(kabupaten)
Exemple #18
0
 def OnKec(self, event):
     self.num_ctrl_postcode.Clear()
     kecamatan = fetch.cmbValue(self.combo_box_kec)
     
     self.loadCmbsUnderKec(kecamatan)
Exemple #19
0
 def OnKel(self, event):
     self.num_ctrl_postcode.Clear()
     kelurahan = fetch.cmbValue(self.combo_box_kel)
     
     self.loadCmbsUnderKel(kelurahan)
Exemple #20
0
 def OnKel(self, event):
     kelurahan = fetch.cmbValue(self.combo_kelurahan)
     self.loadCmbsUnderKel(kelurahan)
Exemple #21
0
 def OnKec(self, event):
     kecamatan = fetch.cmbValue(self.combo_kecamatan)
     self.loadCmbsUnderKec(kecamatan)
Exemple #22
0
 def OnKab(self, event):
     kabupaten = fetch.cmbValue(self.combo_kabupaten)
     self.loadCmbsUnderKab(kabupaten)
Exemple #23
0
 def OnProvince(self, event):
     # rint'on province'
     return
     province = fetch.cmbValue(self.combo_province)
     self.loadCmbsUnderProv(province)
Exemple #24
0
 def OnEstate(self, evt):
     # rint'OnEstate'
     if fetch.cmbValue(self.combo_box_estate) == "Perum. Cemara Asri":
         # rint'Perum. Cemara Asri'
         self.InCemaraAsri(wx.Event)
Exemple #25
0
    def getValues(self):
        return (self.num_ctrl_postcode.GetValue(),
		fetch.cmbValue(self.combo_kelurahan),
		fetch.cmbValue(self.combo_kecamatan),
		fetch.cmbValue(self.combo_kabupaten),
		fetch.cmbValue(self.combo_province))