Пример #1
0
    def OnKel(self, event):
        selectedKecamatanID = fetch.cmbID(self.combo_kecamatan)
	selectedKabupatenID = fetch.cmbID(self.combo_kabupaten)
	selectedProvinceID  = fetch.cmbID(self.combo_province)
	
        if selectedKecamatanID:    return

        # kecamatan -----------------------------
        kecamatanList = fetch.kecamatanForKelurahanID(kelurahanID)
        kecamatanID   = self.setKecamatan(selectedKecamatanID, kecamatanList) 
        kabupatenID   = self.doForKabupaten(kecamatanID, selectedKecamatanID)
        provinceID    = self.provincesForKabupaten(kabupatenID, selectedKabupatenID)
	
        self.countriesForProvince(provinceID, selectedProvinceID)
Пример #2
0
    def OnCountry(self, evt):
        countryID = fetch.cmbID(self.combo_country)
	if countryID:
	    provinceList        = fetch.provincesForCountryID(countryID)
	    selectedProvinceID  = fetch.cmbID(self.combo_province)
	    provinceID          = self.setComboItems(self.combo_province, provinceList)
	    provinceIDlist      = self.idList(provinceList)
	    if provinceID:
		if provinceID != selectedProvinceID:
		    kabupatenID = self.kabupatenForProvince(provinceIDlist)
	    else:
		# combo_province may have been loaded with a list of provinces
		# or none
		if provinceList:
		    kabupatenID = self.kabupatenForProvince(provinceIDlist)
Пример #3
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)
Пример #4
0
 def OnSelect(self, event):
     self.new_id = fetch.cmbID(self)
     if self.new_id == -1:
         self.new_id=0
         self.Freeze()
         self.Select(1)
         
         # new something 
         dlg = self.dlg.create(None)
         try:
             if dlg.ShowModal() == wx.ID_OK:
                 self.new_id = dlg.getNewID()
                 self.GetParent().ComboChanged(self.GetId())
         finally:
             dlg.Destroy()
             
         self.Thaw()
     
     else:
         try:
             self.GetParent().ComboChanged('school')  
         except:
             try:
                 self.GetGrandparent().ComboChanged('school')
             except:
                 pass
Пример #5
0
def gen(cmb, sql , first_item='') : #sql should be designed to return two items 'id' and 'title'
    try:    origional_id = fetch.cmbID(cmb)
    except: origional_id=0
    
    dataSet      = fetch.getAllCol(sql)
    
    cmb.Freeze()  # locks the combo so that other processes are not called
    cmb.Clear()
    
    try:
        if first_item:   cmb.Append(first_item, 0)
            
        for row in dataSet:
            ##rint row
            cmb.Append(str(row[1]), row[0])
            
        restored = restore(cmb, origional_id)
        
        cmb.Thaw()
        
        if restored: return origional_id
        else:        return 0
        
    except:
        #rint 'load cmb error'
        cmb.Thaw()
        return 0
    
    cmb.Thaw()
Пример #6
0
    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)    
Пример #7
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
Пример #8
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)
Пример #9
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)
    origional_id = fetch.cmbID(cmb)
    cmb.Freeze()  # locks the combo so that other processes are not called
    #rint 'dataSet:', dataSet
    cmb.Clear()
    if first_item:      cmb.Append(first_item,0)
    for row in dataSet:
        txt, iid = str(row[1]), row[0]
        #rint txt, iid
        cmb.Append(txt , iid)
    restored = restore(cmb, origional_id)
    
    cmb.Thaw()    
    if restored: return origional_id
    else:        return 0
Пример #10
0
 def openItemEditor(self, itemType_id):
     cmb = self.addrCmbs[str(itemType_id)]
     id = int(fetch.cmbID(cmb))
         
     dlg=DlgAddrItemEdit.create(None)
     dlg.displayData(int(itemType_id), int(id))
     try:
         if dlg.ShowModal() == wx.ID_OK:
             pass##rint"ok"
         else:
             pass##rint"cancel"
     finally:    
         dlg.Destroy()
Пример #11
0
def inv_students(cmb, filter_panel):
    school_id, course_id, batch_id = filter_panel.getSelectedIDs()
    #rint 'inv_students', cmb, school_id, course_title_id, batch_id
    
    if batch_id:
        sql ="SELECT s.id, s.first_name, s.middle_name, s.last_name \
                FROM students s \
                JOIN batch_students bs ON s.id = bs.student_id \
                JOIN batches b ON b.id = bs.batch_id \
               WHERE s.is_active = 1 \
                 AND b.id = %d" % batch_id
        
    elif course_id:
        sql ="SELECT s.id, s.first_name, s.middle_name, s.last_name \
                FROM students s \
                JOIN batch_students bs ON s.id = bs.student_id \
                JOIN batches b ON b.id = bs.batch_id \
               WHERE s.is_active = 1 \
                 AND b.course_id = %d" % course_id
        
    sql += " AND reg_year < %d" % gVar.schYr
    
    origional_id = fetch.cmbID(cmb)
    
    dataSet      = fetch.getAll_col(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:
        return origional_id
    else:
        cmb.SetSelection(1)
Пример #12
0
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.getAll_col(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()
Пример #13
0
    def setComboItems(self, cmb, itemsList):
        selectedID = fetch.cmbID(cmb)
        cmb.Freeze()
	cmb.Clear()
        for row in itemsList:
            cmb.Append(str(row[1]), row[0])
        cmb.Insert(' ', 0)
        cmb.Thaw()
        
        selectedID = loadCmb.restore(cmb, selectedID)
        if not selectedID:
            if len(itemsList) == 1:
                selectedID = itemsList[0][0]
                loadCmb.restore(cmb, selectedID)
        return selectedID
Пример #14
0
def restore(cmb, origional_id=0):
    cmb.Freeze()
    try:
        if origional_id:
            for y in range(cmb.GetCount()):
                cmb.Select(y) # select first item
                itemId = fetch.cmbID(cmb)
                if itemId == origional_id:
                    cmb.Thaw()
                    return True
    except:
        pass
    
    cmb.Select(0)
    cmb.Thaw()
    return False
Пример #15
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()
Пример #16
0
    def provincesForKabupaten(self, setID, selectedID):
	cmb = self.combo_province
	cmbID = fetch.cmbID(cmb)
        if selectedID: aList = fetch.provinceForKabupatenID(selectedKabupatenID)
        else:          aList = fetch.provinceForKabupatenID(setID)
        return self.setGen(cmbID, aList, cmb)
Пример #17
0
    def countriesForProvince(self, setID, selectedID):
	cmb = self.combo_country
	cmbID = fetch.cmbID(cmb)
        if selectedID: aList = fetch.countriesForProvinceID(selectedID)
        else:          aList = fetch.countriesForProvinceID(setID)
	return self.setGen(cmbID, aList, cmb)
Пример #18
0
 def getValues(self):
     return (self.num_ctrl_postcode.GetValue(),
             fetch.cmbID(self.combo_kelurahan),
             fetch.cmbID(self.combo_kecamatan),
             fetch.cmbID(self.combo_kabupaten),
             fetch.cmbID(self.combo_province))
Пример #19
0
    def doForKabupaten(self, kecamatanID, selectedKecamatanID):
	selectedKabupatenID = fetch.cmbID(self.combo_kabupaten)
        if kecamatanID: kabupatenList = fetch.provinceForKabupaten(selectedKecamatanID)
        else:           kabupatenList = fetch.proviceForKecamatan(selectedKecamatanID)
        return self.setGen(selectedKabupatenID, kabupatenList, self.combo_kabupaten)
Пример #20
0
    def bForA(self, AID, selectedID, cmb, call):
	cmbID = fetch.cmbID(cmb)
        if selectedAID: aList = call(selecteID)
        else:           aList = call(AID)
        return self.setGen(cmbID, aList, cmb)
Пример #21
0
    def kecForKel(self, kelID, selectedKelID):
	cmb = self.combo_kecamatan
	cmbID = fetch.cmbID(cmb)
        if selectedID: aList = fetch.kecForKelID(selectedKelID)
        else:          aList = fetch.kecForKelID(kelID)
        return self.setGen(cmbID, aList, cmb)
Пример #22
0
    def kabupatenForKecamatan(self,  setID, selectedID):
	cmb = self.combo_kabupaten
	cmbID = fetch.cmbID(cmb)
        if selectedID: aList = fetch.kabForKacID(selectedID)
        else:          aList = fetch.kabForKacID(setID)
        return self.setGen(cmbID, aList, cmb)