def findHousehold(self): ''' Find a household matching the criteria entered by user ''' hhid = self.txtHouseholdNo.text() hhname = self.txtHouseholdName.text() SQLcondition = "" if ( hhid != "" ): SQLcondition = " hhid='%s'" % ( hhid ) if ( hhname != "" ): if ( SQLcondition == "" ): SQLcondition = "householdname LIKE '%" + "%s" % ( hhname ) + "%'" else: SQLcondition = "(" + SQLcondition + " OR householdname LIKE '%" + "%s" % ( hhname ) + "%' )" if ( SQLcondition != "" ): query = ''' SELECT hhid FROM households WHERE pid=%i AND %s ''' % ( self.parent.projectid, SQLcondition ) else: query = ''' SELECT hhid FROM households WHERE pid=%i ''' % ( self.parent.projectid ) recordset = self.executeResultsQuery(query) count = len(recordset) if ( count != 0 ): form = FrmFindHouseholdResults( self.parent, hhid, hhname ) subWin = self.parent.mdi.addSubWindow( form ) self.parent.centerSubWindow( subWin ) # close this form self.parent.mdi.closeActiveSubWindow() # show the details form form.showMaximized() else: msg = "No household matching the criteria specified exists." QMessageBox.information( self, "Find Household", msg )
def viewAllHouseholds(self): ''' shows all households ''' if self.projectid == -1: msg = "No project is active. First create a new project or open an existing project." QtGui.QMessageBox.information(self,"Notice",msg) else: form = FrmFindHouseholdResults(self) subWin = self.mdi.addSubWindow(form) self.centerSubWindow(subWin) form.showMaximized()