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)
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()
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)
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
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