Пример #1
0
class MainInquiryUser(QWidget):
    def __init__(self, windows):
        QWidget.__init__(self)
        self.windows = windows
        self.__component__()

    def __component__(self):
        self.__pushButton__()
        self.__table__()
        self.__layout__()

    def __pushButton__(self):
        def btnCloseClick():
            idx = self.windows.tab.currentIndex()
            self.windows.tab.removeTab(idx)
            self.windows.currentTabs.pop(idx)
        self.btnClose = BtnTabClose('닫기\n(Ctrl+W)', btnCloseClick)

        def btnExcelClick():
            dig = QFileDialog()
            filePath = dig.getSaveFileName(caption='엑셀로 내보내기', filter='*.xlsx')[0]
            if filePath != '':
                df = self.windows.connUser.dataFrameUser()
                del df['비밀번호']
                del df['재직상태']
                del df['접근권한']
                del df['가입승인여부']
                df.to_excel(filePath, sheet_name='화재안전팀 부서원 현황(일반)', index=False)
                DialogMassage(f'저장되었습니다.\n\n○ 파일 경로 : {filePath}')
        self.btnExcel = BtnTool('엑셀로 저장\n(Ctrl+E)', btnExcelClick)

        def btnRefreshClick():
            self.windows.RefreshInquiryUser()
        self.btnRefresh = BtnTool('새로고침\n(F5)', btnRefreshClick)

    def __table__(self):
        self.tbl = TableInquiryUser(self)

    def __layout__(self):
        layoutBtn = QHBoxLayout()
        layoutBtn.addWidget(self.btnClose)
        layoutBtn.addWidget(self.btnExcel)
        layoutBtn.addWidget(self.btnRefresh)
        layoutBtn.addWidget(LblNull(), 10)
        layout = QVBoxLayout()
        layout.addLayout(layoutBtn)
        layout.addWidget(self.tbl)
        self.setLayout(layout)

    def keyPressEvent(self, QKeyEvent):
        if Qt.ControlModifier:
            if QKeyEvent.key() == Qt.Key_E:
                self.btnExcel.click()
            elif QKeyEvent.key() == Qt.Key_W:
                self.btnClose.click()
        elif QKeyEvent.key() == Qt.Key_F5:
            self.btnRefresh.click()
Пример #2
0
class MainAdminInfo(QDialog):
    def __init__(self, windows):
        QDialog.__init__(self)
        self.windows = windows
        self.__component__()

    def __component__(self):
        self.__button__()
        self.__table__()
        self.__layout__()

    def __button__(self):
        def btnCloseClick():
            idx = self.windows.tab.currentIndex()
            self.windows.tab.removeTab(idx)
            self.windows.currentTabs.pop(idx)
        self.btnClose = BtnTabClose('닫기\n(Ctrl+W)', btnCloseClick)

        def btnRefreshClick():
            self.windows.RefreshAdminInfo()
        self.btnRefresh = BtnTool('새로고침\n(F5)', btnRefreshClick, shortcut='F5')

        def btnNewClick():
            DialogNewInfo(self.windows)
        self.btnNew = BtnTool('새 알림\n(Ctrl+N)', btnNewClick, shortcut='Ctrl+N')

    def __table__(self):
        self.tbl = TableAdminInfo(self)

    def __layout__(self):
        layoutBtn = QHBoxLayout()
        layoutBtn.addWidget(self.btnClose)
        layoutBtn.addWidget(self.btnNew)
        layoutBtn.addWidget(LblNull(), 10)
        layout = QVBoxLayout()
        layout.addLayout(layoutBtn)
        layout.addWidget(self.tbl)
        self.setLayout(layout)

    def keyPressEvent(self, QKeyEvent):
        if Qt.ControlModifier:
            if QKeyEvent.key() == Qt.Key_W:
                self.btnClose.click()
            elif QKeyEvent.key() == Qt.Key_N:
                self.btnClose.click()
        elif QKeyEvent.key() == Qt.Key_F5:
            self.btnRefresh.click()
Пример #3
0
class MainDatabase(QWidget):
    def __init__(self, windows):
        QWidget.__init__(self)
        self.windows = windows
        self.__component__()

    def __component__(self):
        self.__comboBox__()
        self.__pushButton__()
        self.__table__()
        self.__label__()
        self.__layout__()

    def __comboBox__(self):
        def cbxYearChange(text):
            self.windows.DB_YEAR = text
            self.windows.RefreshAdminDB()
        self.cbxYear = CbxYears(returnMainList(), self.windows.DB_YEAR)
        self.cbxYear.currentTextChanged.connect(cbxYearChange)

    def __pushButton__(self):
        def btnCloseClick():
            idx = self.windows.tab.currentIndex()
            self.windows.tab.removeTab(idx)
            self.windows.currentTabs.pop(idx)
        self.btnClose = BtnTabClose('닫기\n(Ctrl+W)', btnCloseClick)

        nextYear = f'{int(self.cbxYear.currentText())+1}'
        self.btnCreate = BtnCreateNewDB(f'{nextYear}년 생성\n(Ctrl+N)', shortcut='Ctrl+N', windows=self.windows)

        def btnExcelClick():
            currentYear = self.cbxYear.currentText()
            dig = QFileDialog(self)
            filePath = dig.getSaveFileName(caption="엑셀로 내보내기", directory='', filter='*.xlsx')[0]
            if filePath != '':
                with ExcelWriter(filePath) as writer:
                    dataFrame = self.tblUser.dataFrame
                    dataFrame.to_excel(writer, sheet_name=f"화재팀-DB 현황({currentYear}-부서원)", index=False)
                    dataFrame = self.tblBusiness.dataFrame
                    dataFrame.to_excel(writer, sheet_name=f"화재팀-DB 현황({currentYear}-사업)", index=False)
                writer.close()
                DialogMassage('엑셀로 내보내기가 완료되었습니다.')
        self.btnExcel = BtnTool('엑셀로 저장\n(Ctrl+E)', btnExcelClick, shortcut='Ctrl+E')

        def btnRefreshClick():
            self.windows.RefreshAdminDB()
        self.btnRefresh = BtnTool('새로고침\n(F5)', btnRefreshClick)

    def __table__(self):
        self.tblUser = TableDBUser(self.windows.DB_YEAR, self)
        self.tblBusiness = TableDBBusiness(self.windows.DB_YEAR, self)

    def __label__(self):
        self.cntTotalUser = len(self.tblUser.dataFrame['적용상태_부서원'].tolist())
        self.cntAcceptUser = self.tblUser.dataFrame['적용상태_부서원'].tolist().count('적용')
        self.lblUser = LblTitle(f'○ 적용상태 / 총 부서원 수 : {self.cntAcceptUser}명 / {self.cntTotalUser}명')
        self.cntTotalBusiness = len(self.tblBusiness.dataFrame['적용상태_사업'].tolist())
        self.cntAcceptBusiness = self.tblBusiness.dataFrame['적용상태_사업'].tolist().count('적용')
        self.lblBusiness = LblTitle(f'○ 적용상태 / 총 사업 수 : {self.cntAcceptBusiness}건 / {self.cntTotalBusiness}건')

    def __layout__(self):
        layoutBtn = QHBoxLayout()
        layoutBtn.addWidget(self.cbxYear)
        layoutBtn.addWidget(self.btnClose)
        layoutBtn.addWidget(self.btnCreate)
        layoutBtn.addWidget(self.btnExcel)
        layoutBtn.addWidget(self.btnRefresh)
        layoutBtn.addWidget(LblNull(), 10)
        layoutTblUser = QVBoxLayout()
        layoutTblUser.addWidget(self.lblUser)
        layoutTblUser.addWidget(self.tblUser)
        layoutTblBusiness = QVBoxLayout()
        layoutTblBusiness.addWidget(self.lblBusiness)
        layoutTblBusiness.addWidget(self.tblBusiness)
        layoutTbl = QHBoxLayout()
        layoutTbl.addLayout(layoutTblUser)
        layoutTbl.addLayout(layoutTblBusiness)
        layoutTbl.addWidget(LblNull(), 10)
        layout = QVBoxLayout()
        layout.addLayout(layoutBtn)
        layout.addLayout(layoutTbl)
        self.setLayout(layout)

    def keyPressEvent(self, QKeyEvent):
        if Qt.ControlModifier:
            if QKeyEvent.key() == Qt.Key_N:
                self.btnCreate.click()
            elif QKeyEvent.key() == Qt.Key_E:
                self.btnExcel.click()
            elif QKeyEvent.key() == Qt.Key_W:
                self.btnClose.click()
        elif Qt.Key_F5:
            self.btnRefresh.click()
class MainUserTime(QWidget):
    def __init__(self, windows):
        QWidget.__init__(self)
        self.setStyleSheet(styleGeneral)
        self.windows = windows
        self.account = windows.account
        self.year = windows.CURRENT_YEAR
        self.__connector__()
        self.__component__()
        self.btnToday.click()

    def __connector__(self):
        self.connDB = connDB(self.year)

    def __component__(self):
        self.__pushButton__()
        self.__table__()
        self.__scrollBar__()
        self.__layout__()

    def __pushButton__(self):
        def btnCloseClick():
            idx = self.windows.tab.currentIndex()
            self.windows.tab.removeTab(idx)
            self.windows.currentTabs.pop(idx)

        self.btnClose = BtnTabClose('닫기\n(Ctrl+W)', btnCloseClick)

        def btnSaveClick():
            cnt = 0
            for obj in self.tblTime.objects:
                if obj.editLog:
                    column = self.tblTime.horizontalHeaderItem(obj.col).text()
                    value = obj.data
                    number = self.tblTime.item(obj.row, 0).text()
                    option = self.tblTime.item(obj.row, 3).text()
                    self.connDB.updateUserTime(column, value, number, option,
                                               self.account)
                    obj.init = value
                    obj.editLog = False
                    cnt += 1
            if cnt:
                DialogMassage('저장되었습니다.')

        self.btnSave = BtnTool('저장\n(Ctrl+S)', btnSaveClick, shortcut='Ctrl+S')

        def btnTodayClick():
            today = datetime.today()
            today = today.strftime("%m/%d")
            for col, header in enumerate(self.tblTime.columns):
                if today in header:
                    self.tblTime.setCurrentCell(0, col)
                    break

        self.btnToday = BtnTool('오늘\n(Ctrl+T)',
                                btnTodayClick,
                                shortcut='Ctrl+T')

        def btnRefreshClick():
            self.windows.RefreshTimeUser()

        self.btnRefresh = BtnTool('새로고침\n(F5)', btnRefreshClick, shortcut='F5')

        def btnExcelClick():
            dig = QFileDialog()
            filePath = dig.getSaveFileName(caption='엑셀로 내보내기',
                                           filter='*.xlsx')[0]
            if filePath != '':
                df = self.connDB.dataFramePerUserTime(self.account)
                del df['적용상태_사업']
                del df['계정']
                del df['성명']
                del df['적용상태_부서원']
                df.to_excel(filePath,
                            sheet_name=f'{self.year}-{self.account}',
                            index=False)
                DialogMassage(f'저장되었습니다.\n\n○ 파일 경로 : {filePath}')

        self.btnExcel = BtnTool('엑셀로 저장\n(Ctrl+E)', btnExcelClick)

    def __table__(self):
        self.tblBusiness = TableTimeBusiness(self.account, self.year)
        self.tblTime = TableTimeUser(self.account, self.year, self)
        self.tblHeader = TableTimeHeader()
        self.tblHeader.setColumnWidth(0, self.tblBusiness.width)
        self.tblHeader.setFixedWidth(self.tblBusiness.width)
        self.tblHeader.setFixedHeight(self.tblHeader.rowHeight(0))
        self.tblTotal = TableTimeTotal(self.account, self.year,
                                       self.tblTime.columns[8:])
        self.tblTotal.setFixedHeight(self.tblHeader.rowHeight(0))

    def __scrollBar__(self):
        def verScrBusinessChange(value):
            self.verScrTime.setValue(value)

        self.verScrBusiness = self.tblBusiness.verticalScrollBar()
        self.verScrBusiness.valueChanged.connect(verScrBusinessChange)

        def verScrTimeChange(value):
            self.verScrBusiness.setValue(value)

        self.verScrTime = self.tblTime.verticalScrollBar()
        self.verScrTime.valueChanged.connect(verScrTimeChange)

        def horScrTimeChange(value):
            self.horScrTotal.setValue(value)

        self.horScrTime = self.tblTime.horizontalScrollBar()
        self.horScrTime.valueChanged.connect(horScrTimeChange)

        def horScrTotalChange(value):
            self.horScrTime.setValue(value)

        self.horScrTotal = self.tblTotal.horizontalScrollBar()
        self.horScrTotal.valueChanged.connect(horScrTotalChange)

    def __layout__(self):
        layoutBtn = QHBoxLayout()
        layoutBtn.addWidget(self.btnClose)
        layoutBtn.addWidget(self.btnSave)
        layoutBtn.addWidget(self.btnToday)
        layoutBtn.addWidget(self.btnRefresh)
        layoutBtn.addWidget(self.btnExcel)
        layoutBtn.addWidget(LblNull(), 10)
        layoutTop = QHBoxLayout()
        layoutTop.addWidget(self.tblHeader)
        layoutTop.addWidget(self.tblTotal)
        layoutBottom = QHBoxLayout()
        layoutBottom.addWidget(self.tblBusiness)
        layoutBottom.addWidget(self.tblTime)
        layoutTbl = QVBoxLayout()
        layoutTbl.addLayout(layoutTop)
        layoutTbl.addLayout(layoutBottom)
        layoutTbl.addWidget(self.horScrTime)
        layoutScr = QHBoxLayout()
        layoutScr.addLayout(layoutTbl)
        layoutScr.addWidget(self.verScrTime)
        layout = QVBoxLayout()
        layout.addLayout(layoutBtn)
        layout.addLayout(layoutScr)
        self.setLayout(layout)

    def changeTotalValue(self, _):
        ldtTime = self.sender()
        table = ldtTime.table
        values = []
        for row in range(self.tblTime.rowCount()):
            value = table.cellWidget(row, ldtTime.col).text()
            try:
                value = float(value)
            except:
                value = 0.0
            values.append(value)
        total = returnTranValue(sum(values))
        self.tblTotal.cellWidget(0, ldtTime.col - 8).setText(str(total))

    def keyPressEvent(self, QKeyEvent):
        if Qt.ControlModifier:
            if QKeyEvent.key() == Qt.Key_S:
                self.btnSave.click()
            elif QKeyEvent.key() == Qt.Key_T:
                self.btnToday.click()
            elif QKeyEvent.key() == Qt.Key_E:
                self.btnExcel.click()
            elif QKeyEvent.key() == Qt.Key_W:
                self.btnClose.click()
        elif QKeyEvent.key() == Qt.Key_F5:
            self.btnRefresh.click()
class MainTotalPerUser(QWidget):
    def __init__(self, windows):
        QWidget.__init__(self)
        self.windows = windows
        self.__component__()

    def __component__(self):
        self.__comboBox__()
        self.__pushButton__()
        self.__variables__()
        self.__table__()
        self.__tab__()
        self.__layout__()

    def __comboBox__(self):
        years = listdir(setting.databaseMain)
        years = [year.replace('.db', '') for year in years]

        def cbxYearChange(text):
            self.windows.TOTAL_YEAR = text
            self.windows.RefreshTotalPerUser()

        self.cbxYear = CbxYears(years, self.windows.TOTAL_YEAR)
        self.cbxYear.currentTextChanged.connect(cbxYearChange)

    def __pushButton__(self):
        def btnCloseClick():
            idx = self.windows.tab.currentIndex()
            self.windows.tab.removeTab(idx)
            self.windows.currentTabs.pop(idx)

        self.btnClose = BtnTabClose('닫기\n(Ctrl+W)', btnCloseClick)

        def btnExcelClick():
            dig = QFileDialog()
            filePath = dig.getSaveFileName(caption='엑셀로 내보내기',
                                           filter='*.xlsx')[0]
            if filePath != '':
                with ExcelWriter(filePath) as writer:
                    for key in self.totalDict.keys():
                        df = self.totalDict[key]
                        df.to_excel(writer, sheet_name=key, index=False)
                writer.close()
                DialogMassage(f'저장되었습니다.\n\n○ 파일 경로 : {filePath}')

        self.btnExcel = BtnTool('엑셀로 저장\n(Ctrl+E)', btnExcelClick)

        def btnRefreshClick():
            self.windows.RefreshTotalPerUser()

        self.btnRefresh = BtnTool('새로고침\n(F5)', btnRefreshClick)

    def __variables__(self):
        self.columns = returnTotalPerUser(self.windows.TOTAL_YEAR, column=True)
        self.totalDict = returnTotalPerUser(self.windows.TOTAL_YEAR)

    def __table__(self):
        self.objectTable = []
        for userName in self.totalDict.keys():
            self.objectTable.append(TableTotalPerUser(self, userName))

    def __tab__(self):
        self.tab = QTabWidget()
        self.tab.addTab(self.objectTable[-1], self.objectTable[-1].userName)
        self.objectTable.pop()
        currentText = []
        for table in self.objectTable:
            currentText.append(table.userName)
            self.tab.addTab(table, table.userName)
        self.tab.setCurrentIndex(
            currentText.index(
                self.windows.connUser.returnName(self.windows.account)) + 1)

    def __layout__(self):
        layoutTop = QHBoxLayout()
        layoutTop.addWidget(self.cbxYear)
        layoutTop.addWidget(self.btnClose)
        layoutTop.addWidget(self.btnExcel)
        layoutTop.addWidget(self.btnRefresh)
        layoutTop.addWidget(LblNull(), 10)
        layout = QVBoxLayout()
        layout.addLayout(layoutTop)
        layout.addWidget(self.tab)
        self.setLayout(layout)

    def keyPressEvent(self, QKeyEvent):
        if Qt.ControlModifier:
            if QKeyEvent.key() == Qt.Key_E:
                self.btnExcel.click()
            elif QKeyEvent.key() == Qt.Key_W:
                self.btnClose.click()
        elif QKeyEvent.key() == Qt.Key_F5:
            self.btnRefresh.click()
Пример #6
0
class MainAdminBusiness(QWidget):
    def __init__(self, windows):
        QWidget.__init__(self)
        self.windows = windows
        self.__component__()

    def __component__(self):
        self.__pushButton__()
        self.__table__()
        self.__label__()
        self.__layout__()

    def __pushButton__(self):
        def btnCloseClick():
            idx = self.windows.tab.currentIndex()
            self.windows.tab.removeTab(idx)
            self.windows.currentTabs.pop(idx)
        self.btnClose = BtnTabClose('닫기\n(Ctrl+W)', btnCloseClick)

        def btnInsertClick():
            DialogNewBusiness(self)
        self.btnInput = BtnTool('신규 입력\n(Ctrl+N)', btnInsertClick, shortcut='Ctrl+N')

        def btnSaveClick():
            saveValue = 0
            for obj in self.tbl.objects:
                if obj.editLog:
                    self.tbl.UpdateEditDate(obj.row, self.windows.connBusiness.updateBusiness(obj.header, obj.data, obj.number))
                    obj.init = obj.data
                    obj.editLog = False
                    saveValue += 1
            if saveValue:
                DialogMassage('저장되었습니다.')
                self.windows.RefreshAdminBusiness()
        self.btnSave = BtnTool('저장\n(Ctrl+S)', btnSaveClick, shortcut='Ctrl+S')

        def btnRefreshClick():
            self.windows.RefreshAdminBusiness()
        self.btnRefresh = BtnTool('새로고침\n(F5)', btnRefreshClick, shortcut='F5')

        def btnExcelClick():
            dig = QFileDialog(self)
            filePath = dig.getSaveFileName(caption="엑셀로 내보내기", directory='', filter='*.xlsx')[0]
            if filePath != '':
                dataFrame = self.tbl.dataFrame
                dataFrame.to_excel(filePath, sheet_name="화재안전팀 사업 현황", index=False)
                DialogMassage(f'저장되었습니다.\n\n○ 파일 경로 : {filePath}')
        self.btnExcel = BtnTool('엑셀로 저장\n(Ctrl+E)', btnExcelClick, shortcut='Ctrl+E')

    def __table__(self):
        self.tbl = TableAdminBusiness(self)

    def __label__(self):
        cnt = len(self.tbl.dataFrame)
        cnt = 0 if cnt < 0 else cnt
        self.lblCount = LblTitle(f"총 사업 수 : {cnt}건")

    def __layout__(self):
        layoutBtn = QHBoxLayout()
        layoutBtn.addWidget(self.btnClose)
        layoutBtn.addWidget(self.btnInput)
        layoutBtn.addWidget(self.btnSave)
        layoutBtn.addWidget(self.btnRefresh)
        layoutBtn.addWidget(self.btnExcel)
        layoutBtn.addWidget(LblNull(), 10)
        layout = QVBoxLayout()
        layout.addLayout(layoutBtn)
        layout.addWidget(self.lblCount)
        layout.addWidget(self.tbl)
        self.setLayout(layout)

    def keyPressEvent(self, QKeyEvent):
        if Qt.ControlModifier:
            if QKeyEvent.key() == Qt.Key_N:
                self.btnInput.click()
            elif QKeyEvent.key() == Qt.Key_S:
                self.btnSave.click()
            elif QKeyEvent.key() == Qt.Key_E:
                self.btnExcel.click()
            elif QKeyEvent.key() == Qt.Key_W:
                self.btnClose.click()
        elif QKeyEvent.key() == Qt.Key_F5:
            self.btnRefresh.click()