def saveMember(self): ''' Saves changes to household to database ''' # get the data entered by user sex = self.cboSex.currentText() age = self.txtAge.text() if ( sex == "Male"): memberid = "m%s" % age else: memberid = "f%s" % age education = "" yearofbirth = self.cmbYearOfBirth.currentText() if self.chkHeadHousehold.isChecked(): headhousehold = "Yes" else: headhousehold = "No" pid = self.parent.parent.projectid periodaway = self.cmbMonthsAbsent.currentText() reason = self.txtReason.text() whereto = self.txtWhere.text() controller = Controller() household = controller.getProject(pid).getHousehold(self.hhid) household.addMember(memberid, yearofbirth, headhousehold, sex, education, periodaway, reason, whereto) # close new project window self.parent.retrieveHouseholdMembers() self.mdiClose()
def showProject(self): controller = Controller() project = controller.getProject( self.pid ) self.lblProjectName.setText( project.projectname ) self.lblStartDate.setText( str(project.startdate) ) self.lblCurrency.setText( project.currency )
def getHouseholdData(self): ''' Retrieve and display household data ''' controller = Controller() household = controller.getProject(self.projectid).getHousehold(self.hhid) hhid = household.hhid householdname = household.householdname dateofcollection = household.dateofcollection self.txtShortHouseHoldName.setText(str(hhid)) self.dtpDateVisted.setDate(dateofcollection) self.txtHouseholdName.setText(householdname)
def __init__(self, parent): ''' Set up the dialog box interface ''' QDialog.__init__(self) self.parent = parent self.dietid = 0 # selected diet item self.currentItem = "" # selected standard of living item self.setupUi(self) controller = Controller() self.project = controller.getProject( self.parent.projectid ) # show first tab first self.tabProject.setCurrentIndex(0) # display project name self.lblProjectName.setText(self.parent.projectname) # display Available and Selected Household Characteristics self.displayAvailableHouseholdCharacteristics() self.displaySelectedHouseholdCharacteristics() self.displayAvailablePersonalCharacteristics() self.displaySelectedPersonalCharacteristics() self.listDiets() self.getCropTypes() self.displayStandardOfLiving() self.getExpenseItems() self.getAgeRange(self.cmbAgeBottom, 0, 100) self.getAgeRange(self.cmbAgeTop, 1, 101) self.displayAvailableCrops() self.displaySelectedCrops() self.displayAvailableLivestock() self.displaySelectedLivestock() self.displayAvailableWildfoods() self.displaySelectedWildfoods() self.displayAvailableEmployment() self.displaySelectedEmployment() self.displayAvailableTransfers() self.displaySelectedTransfers() self.displayAvailableAssets() self.displaySelectedAssets()
def __init__(self, parent): ''' Set up the dialog box interface ''' QtGui.QDialog.__init__(self) self.setupUi(self) self.parent = parent # get current project details controller = Controller() self.getCurrencies() self.project = controller.getProject( self.parent.projectid ) self.getProjectData() # allow the calendar widget to pop up self.dtpStartDate.setCalendarPopup(True) self.dtpEndDate.setCalendarPopup(True)
def saveHousehold(self): ''' Saves newly created household data to database ''' # get the data entered by user hhid = self.txtShortHouseHoldName.text() householdname = self.txtHouseholdName.text() dateofcollection = self.dtpDateVisted.date().toString("yyyy-MM-dd") pid = self.projectid controller = Controller() project = controller.getProject(pid) project.addHousehold(hhid, householdname, dateofcollection) # close new project window self.parent.getHouseholds() self.mdiClose()
def saveCharacteristic(self): ''' Saves characteristic ''' if self.cboYesNoVal.isVisible(): charVal = self.cboYesNoVal.currentText() else: charVal = self.txtValue.text() controller = Controller() project = controller.getProject(self.pid) household = project.getHousehold(self.hhid) if not household.existsCharacteristic(self.charName): household.addCharacteristic(self.charName, charVal) else: char = household.getCharacteristic(self.charName) char.editData(self.charName, charVal) # close window and refresh characteristics self.parent.retrieveHouseholdCharacteristics() self.mdiClose()