示例#1
0
    def insertAddress(self):
        house, street, estate, block, road, post, kal, kec, kab, prov = self.getValues()
        if house and (street or road) and post:
            sql = """INSERT INTO addresses \
			  (house, street, estate, block, road, postcode) \
		   VALUES (?,  ?,   ?,   ?,  ?,  ?) """
            data = [house, street, estate, block, road, post]
            ##rintsql, data; return
            fetch.updateDB_data(sql, data)
        else:
            fetch.msg("house, post code street or road missing")
示例#2
0
    def setGen(self, selectedItemID, aList, cmb):
        if aList:
	    r = aList[0]
	    if len(r) != 2:
		fetch.msg('list error')
	    
            if len(aList)  > 1: selectedItemID = self.setComboItems(cmb, aList)
            elif len(aList)==1:
		selectedItemID =  aList[0][0]
		loadCmb.restore(cmb, selectedItemID)
            else:               self.clearPostcodeCtrls((cmb,))
        return selectedItemID
示例#3
0
    def updatePostcode(self):
        house, street, estate, block, road, post, kal, kec, kab, prov = self.getValues()
        if post:
            sql = (
                "UPDATE postcodes \
		      (kelurahan, kecamatan, kabupaten, province) \
		   VALUES (?, ?, ?, ?) \
		    WHERE postcode =%d"
                % post
            )
            data = [kal, kec, kab, prov]
            # rint'updatePostcode' , sql, data; return
            fetch.updateDB_data(sql, data)

        else:
            fetch.msg("house, post code street or road missing")
示例#4
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()
示例#5
0
    def OnPostcode(self, evt):
        #rint 'OnPostcode'
        if self.numCtrlActive:  return
        
        postcode = self.num_ctrl_postcode.GetValue()
        if postcode:
            for c in self.combos: c.SetSelection(-1)
            sql = "SELECT id, itemName \
                     FROM addressItems \
                    WHERE postcode = %d" % postcode
            res = fetch.getOneDict(sql)
            if res:
                iid  = res['id']
                kecamatan = res['itemName']
                if kecamatan:
                    loadCmb.restore(self.combo_kecamatan, iid)
		    fetch.msg('postcode')
                    self.loadCmbsUnderKecID(iid)
 def OnSave(self, evt):
     course_ids_list = self.item_picker.GetAllSelectionIds()
     course_ids = str(course_ids_list).strip('[]')
     if self.update:
         sql = "UPDATE courses_by_year SET courses = '%s' WHERE schYr =%d" % (course_ids, gVar.schYr)
         fetch.updateDBtransaction(sql)
         txt ="List Saved"
         fetch.msg(txt)
         
     else:
         sql = "SELECT * WHERE schYr = %d" % gVar.schYr
         result = fetch.getCount(sql)
         if not result:
             sql = "INSERT INTO courses_by_year (courses, schYr) VALUES ('%s', %d)" % (course_ids, gVar.schYr)
             fetch.updateDBtransaction(sql)
             self.update=True
         else:
             txt ="Error - check coding"
             fetch.msg(txt)
    def OnAdd(self,evt): # add new course to courses
        txt = "Not Yet Fully Functional : Please ask administrator to assist"
        fetch.msg(txt)
        #return
	
	import wx.grid as gridlib
	
	g = gridlib.Grid(self, -1)
	g.GetNumberRows()
    
        dlg = DlgNewEditCourse.create(None)
        try:
            if dlg.ShowModal():
                #rint'Dlg Created New Course'
                source_list = self.PopulateSourceList()
                self.item_picker.RepopulateSourceList(source_list)
            else:
                #rint'do nothing'
            
        finally:
            dlg.Destroy()
示例#8
0
    def resetCmb(self, cmb, msg):
	fetch.msg(msg)
	cmb.Freeze()
	cmb.SetSelection(-1)
	cmb.Thaw()