def query(self): startDate = self.ui.dateStart.date() endDate = self.ui.dateEnd.date() start = f'{startDate.year():04d}-{startDate.month():02d}-{startDate.day():02d}' end = f'{endDate.year():04d}-{endDate.month():02d}-{endDate.day():02d}' if datetime.strptime(start, "%Y-%m-%d") > datetime.strptime( end, "%Y-%m-%d"): dialog = MessageDialog("錯誤訊息", "查詢時間區間設定錯誤,請查核後重試") dialog.exec() else: schedules = self.SQLHelper.getScheduleDetailByDateInterval( start, end) result = [] for schedule in schedules: scheduleStatus = self.ShiftHelper.getShiftStatus( schedule[4], schedule[1], schedule[8], schedule[9]) scheduleCheckIn = '' scheduleCheckOut = '' if not schedule[8] is None: scheduleCheckIn = schedule[8] if not schedule[9] is None: scheduleCheckOut = schedule[9] result.append([ schedule[0], f'{schedule[2]:03d}', schedule[3], schedule[1], schedule[5], schedule[7], scheduleCheckIn, scheduleCheckOut, scheduleStatus ]) self.ui.loadingList(result)
def comfirmClicked(self): startTime = self.ui.timeStart.time() endTime = self.ui.timeEnd.time() name = self.ui.nameLineEdit.text() start = f'{startTime.hour():02d}:{startTime.minute():02d}:{startTime.second():02d}' end = f'{endTime.hour():02d}:{endTime.minute():02d}:{endTime.second():02d}' hour = self.ui.hourLineEdit.text() payHour = self.ui.payHourLineEdit.text() if name == '' or hour == '' or payHour == '': dialog = MessageDialog("錯誤訊息", "請確認表單內容填寫完整") dialog.exec() else: if self.shiftId is None: dialog = MessageDialog("提示訊息", "請確認是否新增該筆班別資料") if dialog.exec(): self.SQLHelper.newShift(name, start, end, float(hour), float(payHour)) self.accept() else: dialog = MessageDialog("提示訊息", "請確認是否修改該筆班別資料") if dialog.exec(): self.SQLHelper.updateShiftById(self.shiftId, name, start, end, float(hour), float(payHour)) self.accept()
def comfirmClicked(self): staff = self.SQLHelper.getStaffById(self.staffNum)[0] if self.ui.stuNumLineEdit.text() == staff[1]: self.accept() else: self.hide() dialog = MessageDialog("錯誤提示", "操作人員驗證錯誤,請重試") dialog.exec() self.reject()
def comfirmClicked(self): password = self.ui.passwordLineEdit.text() hashPassword = HMACSHA256Helper.HMACSHA256Hash(password) sysPassword = self.SQLHelper.getPWD() if hashPassword == sysPassword: self.SQLHelper.close() self.accept() else: self.hide() dialog = MessageDialog("錯誤提示", "管理員密碼錯誤,請重試") dialog.exec() self.reject()
def reloadTodaySchedules(self, updatePeriod): now = datetime.now() todayPeriod = self.SQLHelper.getPeriodByDate(now.strftime("%Y-%m-%d")) if len(todayPeriod) != 0: todayPeriod = todayPeriod[0] if todayPeriod[0] == updatePeriod[0]: dialog = MessageDialog("提示訊息", "請問是否重新載入今日所有已執行及未執行之班表") if dialog.exec(): self.SQLHelper.delScheduleByDate(now.strftime("%Y-%m-%d")) arrangements = self.SQLHelper.getArrangementByPeriodAndWeek( todayPeriod[0], now.weekday()) self.SQLHelper.newSchedules(now.strftime("%Y-%m-%d"), arrangements)
def deleteClicked(self): if len(self.ui.listArea.selectedItems()) == 0: dialog = MessageDialog("錯誤訊息", "請先選擇項目後再進行相關操作") dialog.exec() else: dialog = MessageDialog("提示訊息", "請確認是否刪除該項實習室資料及其關聯的所有班表資訊") if dialog.exec(): roomId = self.ui.listArea.selectedItems()[0].data( 0, Qt.UserRole) self.SQLHelper.delRoomById(roomId) self.loadingRoom()
def deleteClicked(self): if len(self.ui.listArea.selectedItems()) == 0: dialog = MessageDialog("錯誤訊息", "請先選擇項目後再進行相關操作") dialog.exec() else: dialog = MessageDialog("提示訊息", "請確認是否刪除該筆排班資料") if dialog.exec(): arrangementId = self.ui.listArea.selectedItems()[0].data( 0, Qt.UserRole) self.SQLHelper.delArrangementById(arrangementId) self.loadingArrangement()
def deleteClicked(self): if len(self.ui.listArea.selectedItems()) == 0: dialog = MessageDialog("錯誤訊息", "請先選擇項目後再進行相關操作") dialog.exec() else: dialog = MessageDialog("提示訊息", "請確認是否刪除該筆排班資料") if dialog.exec(): scheduleId = self.ui.listArea.selectedItems()[0].data( 0, Qt.UserRole) self.SQLHelper.delScheduleById(scheduleId) self.loadingTodaySchedule()
def deleteClicked(self): if len(self.ui.listArea.selectedItems())==0: dialog = MessageDialog("錯誤訊息", "請先選擇項目後再進行相關操作") dialog.exec() else: dialog = MessageDialog("提示訊息", "刪除工讀生將一併刪除其紀錄資料及其班表資料,請再次確認") if dialog.exec(): staffId = self.ui.listArea.selectedItems()[0].data(0, Qt.UserRole) self.SQLHelper.delStaffById(staffId) self.loadingStaff()
def deleteClicked(self): if len(self.ui.listArea.selectedItems())==0: dialog = MessageDialog("錯誤訊息", "請先選擇項目後再進行相關操作") dialog.exec() else: dialog = MessageDialog("提示訊息", "請確認是否刪除該筆假日資料") if dialog.exec(): periodId = self.ui.listArea.selectedItems()[0].data(0, Qt.UserRole) self.SQLHelper.delPeriodById(periodId) self.loadingVacation()
def comfirmClicked(self): password = self.ui.passwordLineEdit.text() checkPassword = self.ui.checkPasswordLineEdit.text() if password != checkPassword: self.hide() dialog = MessageDialog("錯誤提示", "兩次密碼輸入不相同,請重試") dialog.exec() self.reject() else: hashPassword = HMACSHA256Helper.HMACSHA256Hash(password) self.SQLHelper.updatePWD(hashPassword) self.hide() dialog = MessageDialog("提示訊息", "密碼修改成功") dialog.exec() self.accept()
def editClicked(self): if len(self.ui.listArea.selectedItems()) == 0: dialog = MessageDialog("錯誤訊息", "請先選擇項目後再進行相關操作") dialog.exec() else: periodId = self.ui.listArea.selectedItems()[0].data(0, Qt.UserRole) dialog = EditVacationCellDialog(periodId) if dialog.exec(): self.loadingVacation()
def editClicked(self): if len(self.ui.listArea.selectedItems()) == 0: dialog = MessageDialog("錯誤訊息", "請先選擇項目後再進行相關操作") dialog.exec() else: roomId = self.ui.listArea.selectedItems()[0].data(0, Qt.UserRole) dialog = EditRoomCellDialog(roomId) if dialog.exec(): self.loadingRoom()
def clearCheckOutClicked(self): if len(self.ui.listArea.selectedItems()) != 0: schedule = self.SQLHelper.getScheduleDetailWithShiftById( self.ui.listArea.selectedItems()[0].data(0, Qt.UserRole))[0] dialog = MessageDialog("提示訊息", "請確認是否清除簽退紀錄") if dialog.exec(): self.SQLHelper.updateScheduleCheckOutNullById(schedule[0]) self.query() else: dialog = MessageDialog("錯誤訊息", "請先選擇項目後再執行操作") dialog.exec()
def comfirmClicked(self): startDate = self.ui.dateStart.date() endDate = self.ui.dateEnd.date() name = self.ui.nameLineEdit.text().strip() start = f'{startDate.year():04d}-{startDate.month():02d}-{startDate.day():02d}' end = f'{endDate.year():04d}-{endDate.month():02d}-{endDate.day():02d}' if name == '': dialog = MessageDialog("錯誤訊息", "請確認表單內容填寫完整") dialog.exec() else: if self.periodId is None: dialog = MessageDialog("提示訊息", "請確認是否新增該筆假日項目") if dialog.exec(): self.SQLHelper.newPeriodVacation(name, start, end) self.accept() else: dialog = MessageDialog("提示訊息", "請確認是否修改該筆假日項目") if dialog.exec(): self.SQLHelper.updatePeriodById(self.periodId, name, start, end) self.accept()
def editClicked(self): if len(self.ui.listArea.selectedItems()) == 0: dialog = MessageDialog("錯誤訊息", "請先選擇項目後再進行相關操作") dialog.exec() else: scheduleId = self.ui.listArea.selectedItems()[0].data( 0, Qt.UserRole) dialog = EditTodayScheduleCellDialog(scheduleId) if dialog.exec(): self.loadingTodaySchedule()
def editLateClicked(self): if len(self.ui.listArea.selectedItems()) != 0: schedule = self.SQLHelper.getScheduleDetailWithShiftById( self.ui.listArea.selectedItems()[0].data(0, Qt.UserRole))[0] dialog = MessageDialog("提示訊息", "請確認是否將該筆資料設為遲到") if dialog.exec(): lateCheckIn = datetime.strptime(f'{schedule[1]} {schedule[6]}', "%Y-%m-%d %H:%M:%S") self.SQLHelper.updateScheduleCheckInById( lateCheckIn.strftime("%Y-%m-%d %H:%M:%S"), schedule[0]) self.query() else: dialog = MessageDialog("錯誤訊息", "請先選擇項目後再執行操作") dialog.exec()
def comfirmClicked(self): shiftId = self.ui.shiftSelection.currentData(Qt.UserRole) roomId = self.ui.roomSelection.currentData(Qt.UserRole) staffId = self.ui.staffSelection.currentData(Qt.UserRole) date = datetime.now().strftime("%Y-%m-%d") if self.scheduleId is None: dialog = MessageDialog("提示訊息", "請確認是否新增該筆排班資料") if dialog.exec(): self.SQLHelper.newSchedule(date, staffId, shiftId, roomId) self.accept() else: dialog = MessageDialog("提示訊息", "請確認是否修改該筆排班資料") if dialog.exec(): self.SQLHelper.updateScheduleById(staffId, shiftId, roomId, self.scheduleId) self.accept()
def comfirmClicked(self): week = self.ui.weekSelection.currentData(Qt.UserRole) shiftId = self.ui.shiftSelection.currentData(Qt.UserRole) roomId = self.ui.roomSelection.currentData(Qt.UserRole) periodId = self.ui.periodSelection.currentData(Qt.UserRole) staffId = self.ui.staffSelection.currentData(Qt.UserRole) if self.arrangementId is None: dialog = MessageDialog("提示訊息", "請確認是否新增該筆排班資料") if dialog.exec(): self.SQLHelper.newArrangement(staffId, week, shiftId, roomId, periodId) self.accept() else: dialog = MessageDialog("提示訊息", "請確認是否修改該筆排班資料") if dialog.exec(): self.SQLHelper.updateArrangementById(self.arrangementId, staffId, week, shiftId, roomId, periodId) self.accept()
def comfirmClicked(self): staffNum = self.ui.staffNumLineEdit.text() stuNum = self.ui.stuNumLineEdit.text() name = self.ui.nameLineEdit.text() if staffNum == '' or stuNum == '' or name == '': dialog = MessageDialog("錯誤訊息", "請確認表單資料填寫完整") dialog.exec() else: staffNum = int(staffNum) if self.staffId is None: staffs = self.SQLHelper.getStaffById(staffNum) if len(staffs) != 0: dialog = MessageDialog("錯誤訊息", f'已有工讀生編號{staffNum}號的工讀生,請查核後重試') dialog.exec() else: dialog = MessageDialog("提示訊息", "請確認是否新增工讀生") if dialog.exec(): self.SQLHelper.newStaff(staffNum, stuNum, name) self.accept() else: dialog = MessageDialog("提示訊息", "請確認是否修改工讀生") if dialog.exec(): self.SQLHelper.updateStaffById(staffNum, stuNum, name) self.accept()
def editExcusedClicked(self): if len(self.ui.listArea.selectedItems()) != 0: schedule = self.SQLHelper.getScheduleDetailWithShiftById( self.ui.listArea.selectedItems()[0].data(0, Qt.UserRole))[0] dialog = MessageDialog("提示訊息", "請確認是否將該筆資料設為早退") if dialog.exec(): if schedule[12] is None: dialog = MessageDialog("錯誤訊息", "無法設定無簽到記錄之項目,請先設定簽到記錄") dialog.exec() else: excusedCheckOut = datetime.strptime( f'{schedule[1]} {schedule[7]}', "%Y-%m-%d %H:%M:%S") - timedelta(seconds=1) self.SQLHelper.updateScheduleCheckOutById( excusedCheckOut.strftime("%Y-%m-%d %H:%M:%S"), schedule[0]) self.query() else: dialog = MessageDialog("錯誤訊息", "請先選擇項目後再執行操作") dialog.exec()
def editOnTimeCheckOutClicked(self): if len(self.ui.listArea.selectedItems()) != 0: scheduleId = self.ui.listArea.selectedItems()[0].data( 0, Qt.UserRole) schedule = self.SQLHelper.getScheduleDetailWithShiftById( scheduleId)[0] if schedule[12] is None: dialog = MessageDialog("錯誤訊息", "無法設定無簽到記錄之項目,請先設定簽到記錄") dialog.exec() else: dialog = MessageDialog("提示訊息", "請確認是否將該筆資料之簽退時間設定為準時") if dialog.exec(): onTimeCheckIn = datetime.strptime( f'{schedule[1]} {schedule[6]}', "%Y-%m-%d %H:%M:%S") onTimeCheckOut = datetime.strptime( f'{schedule[1]} {schedule[7]}', "%Y-%m-%d %H:%M:%S") if onTimeCheckIn > onTimeCheckOut: onTimeCheckOut += timedelta(days=1) self.SQLHelper.updateScheduleCheckOutById( onTimeCheckOut.strftime("%Y-%m-%d %H:%M:%S"), schedule[0]) self.query() else: dialog = MessageDialog("錯誤訊息", "請先選擇項目後再執行操作") dialog.exec()
def comfirmClicked(self): name = self.ui.nameLineEdit.text() if name == '': dialog = MessageDialog("錯誤訊息", "請確認表單內容填寫完整") dialog.exec() else: if self.roomId is None: dialog = MessageDialog("提示訊息", "請確認是否新增該筆實習室資料") if dialog.exec(): if self.isDuplicatedRoom(name): dialog = MessageDialog("錯誤訊息", "實習室名稱重複,請確認後重試") dialog.exec() else: self.SQLHelper.newRoom(name) self.SQLHelper.close() self.accept() else: dialog = MessageDialog("提示訊息", "請確認是否修改該筆實習室資料") if dialog.exec(): if self.isDuplicatedRoom(name): dialog = MessageDialog("錯誤訊息", "實習室名稱重複,請確認後重試") dialog.exec() else: self.SQLHelper.updateRoomById(self.roomId, name) self.SQLHelper.close() self.accept()