예제 #1
0
 def GetByID(self, Id):
     self.Cursor.execute("SELECT * FROM tblTimeRecord where TRE_ID = ?",
                         (str(Id), ))
     rows = self.Cursor.fetchall()
     TimeRecords = []
     for row in rows:
         timeRecord = TimeRecord.TimeRecord(row[0], row[1], row[2], row[3],
                                            row[4], row[5], row[6], row[7],
                                            row[8], row[9])
         TimeRecords.append(timeRecord)
     if len(TimeRecords) > 0:
         return TimeRecords[0]
     else:
         return TimeRecord.TimeRecord(None, None, None, None, None, None,
                                      None, None, None, None)
예제 #2
0
    def StartRecording(self):
        recordIndex = self.RecordTypeCombo.current()
        projectIndex = self.ProjectsCombo.current()
        if recordIndex == -1: recordType = ''
        else: recordType = self.Cache.RecordTypes[recordIndex].ID
        if projectIndex == -1: project = None
        else: project = self.Cache.ActiveProjects[projectIndex].ID
        timeRecord = TimeRecord.TimeRecord(
            None, Globals.GetCurrentTime(), None, project, recordType,
            self.DescriptionValue.get(),
            TimeRecordStatusEnum.TimeRecordStatusEnum.Gestart.value, 0, None,
            None)

        valid = TimeRecordValidation.TimeRecordValidation()
        validationMessage = valid.ValidateOnCreation(timeRecord)
        if not len(validationMessage) == 0:
            errorMessage = ''
            for i in validationMessage:
                errorMessage = errorMessage + i + '\n'
            messagebox.showerror('Error', errorMessage)
        else:
            index = self.DaysCombo.current()
            blTr = BLTimeRecord.BLTimeRecord(self.dbConnection)
            blTr.Create(timeRecord)
            self.Cache.RefreshAllStaticData()
            self.FillCombos()
            if index == -1: index = 0
            self.DaysCombo.current(index)
            self.RefreshTimeRecords()
예제 #3
0
 def CheckForUpdatesFromController(self):
     if not self.Queue.empty():
         queue = self.Queue.get()
         blPr = BLProject.BLProject(self.dbConnection)
         project = blPr.GetByButton(queue)
         if project is not None:
             print(project.Description)
             recordType = 1
             blTr = BLTimeRecord.BLTimeRecord(self.dbConnection)
             for record in self.Cache.TimeRecords:
                 if record.StatusID == TimeRecordStatusEnum.TimeRecordStatusEnum.Gestart.value:
                     record.StatusID = TimeRecordStatusEnum.TimeRecordStatusEnum.Gestopt.value
                     record.EndHour = Globals.GetCurrentTime()
                     blTr.Update(record)
             timeRecord = TimeRecord.TimeRecord(
                 None, Globals.GetCurrentTime(), None, project.ID,
                 recordType, 'Automatically generated',
                 TimeRecordStatusEnum.TimeRecordStatusEnum.Gestart.value, 0,
                 None, None)
             valid = TimeRecordValidation.TimeRecordValidation()
             validationMessage = valid.ValidateOnCreation(timeRecord)
             if not len(validationMessage) == 0:
                 errorMessage = ''
                 for i in validationMessage:
                     errorMessage = errorMessage + i + '\n'
                 messagebox.showerror('Error', errorMessage)
             else:
                 index = self.DaysCombo.current()
                 blTr.Create(timeRecord)
                 self.Cache.RefreshAllStaticData()
                 self.FillCombos()
                 if index == -1: index = 0
                 self.DaysCombo.current(index)
                 self.RefreshTimeRecords()
     self.Master.after(500, self.CheckForUpdatesFromController)
예제 #4
0
 def GetAll(self):
     self.Cursor.execute("SELECT * FROM tblTimeRecord")
     rows = self.Cursor.fetchall()
     TimeRecords = []
     for row in rows:
         timeRecord = TimeRecord.TimeRecord(row[0], row[1], row[2], row[3],
                                            row[4], row[5], row[6], row[7],
                                            row[8], row[9])
         TimeRecords.append(timeRecord)
     return TimeRecords
예제 #5
0
 def GetAllForDate(self, date):
     self.Cursor.execute(
         "SELECT * from tblTimeRecord where strftime('%d-%m-%Y',TRE_StartHour) = ?",
         (date, ))
     rows = self.Cursor.fetchall()
     TimeRecords = []
     for row in rows:
         timeRecord = TimeRecord.TimeRecord(row[0], row[1], row[2], row[3],
                                            row[4], row[5], row[6], row[7],
                                            row[8], row[9])
         TimeRecords.append(timeRecord)
     return TimeRecords