Example #1
0
 def importSelected(self):
     ''' Import selected projects '''
     numSelected = self.countRowsSelected(self.tblProjects)
     if  numSelected != 0:
         # confirm import
         if numSelected == 1:
             msg = "Are you sure you want to import the selected project?"
         else:
             msg = "Are you sure you want to to import the selected projects?"
         
         ret = QMessageBox.question(self,"Confirm Import", msg, QMessageBox.Yes|QMessageBox.No)
         # if import is rejected return without deleting
         if ret == QMessageBox.No:
             return
             
         # get project id of the selected projects
         selectedRows = self.getSelectedRows(self.tblProjects)
         selectedProjects = []
         for row in selectedRows:
             selectedProjects.append( self.tblProjects.model().item(row,0).text() )
         
         # import selected projects
         controller = Controller()
         controller.importProjects( str(self.txtFilename.text()),  selectedProjects )
         
         # import message
         QMessageBox.information(self,"Importing Data from Access","The selected projects have been imported.") 
         
         self.close()
     else:
         QMessageBox.information(self,"Import Data from Access","Please select the rows containing projects to be imported.") 
Example #2
0
     def importAll(self):
         ''' Import all projects '''
         msg = "Are you sure you want to to import all listed projects?"    
         ret = QMessageBox.question(self,"Confirm Import", msg, QMessageBox.Yes|QMessageBox.No)
         # if import is rejected return without deleting
         if ret == QMessageBox.No:
             return

         selectedProjects = []
         # get all project ids as selected items
         for row in range(0, self.tblProjects.model().rowCount()) :
             selectedProjects.append( self.tblProjects.model().item(row,0).text() )
         
         # import projects    
         controller = Controller()
         controller.importProjects( str(self.txtFilename.text()),  selectedProjects )  
       
         # import message
         QMessageBox.information(self,"Importing Data from Access","All projects in the database have been imported.") 
             
         self.close()