示例#1
0
 def add_pc(self):
     session = data.Session()
     try:
         reg_pc_window = pc.RegisterPC(session)
         if reg_pc_window.exec_() == QDialog.Accepted:
             session.commit()
             QMessageBox.information(self, 'Notificação',
                                     'Computador adicionado com sucesso')
             QApplication.setOverrideCursor(Qt.WaitCursor)
             self.employee_table.fill_table()
             self.pcs_table.update_table_content()
             QApplication.restoreOverrideCursor()
     except exc.IntegrityError as errmsg:
         print(errmsg)
         session.rollback()
         msg = QMessageBox()
         msg.setIcon(QMessageBox.Critical)
         msg.setText("Erro crítico no banco de dados")
         msg.setWindowTitle("Erro crítico")
         msg.setDetailedText(errmsg)
         msg.setStandardButtons(QMessageBox.Ok)
         msg.buttonClicked.connect(sys.exit)
     else:
         print('Tudo com sucesso')
     finally:
         session.close()
示例#2
0
 def excel(self):
     filename = QFileDialog.getSaveFileName(self,
                                            'Salvar arquivo excel',
                                            filter='*.xlsx')
     if not filename[1]:
         return
     else:
         filename = filename[0]
     session = data.Session()
     try:
         QApplication.setOverrideCursor(Qt.WaitCursor)
         excel.run(filename, session)
     except PermissionError:
         QApplication.restoreOverrideCursor()
         QMessageBox.warning(
             self, 'A prevenção',
             'Fechar {}\n e tente novamente'.format(filename))
     except OSError:
         QApplication.restoreOverrideCursor()
         QMessageBox.warning(self, 'Erro!', 'Tente um caminho diferente')
     else:
         QApplication.restoreOverrideCursor()
         QMessageBox.information(self, 'Notificação',
                                 'Gerada: {}'.format(filename))
     finally:
         session.close()
示例#3
0
 def add_pc(self):
     session = data.Session()
     try:
         reg_pc_window = pc.RegisterPC(session)
         if reg_pc_window.exec_() == QDialog.Accepted:
             session.commit()
             QMessageBox.information(self, 'Уведомление',
                                     'Компьютер успешно добавлен')
             QApplication.setOverrideCursor(Qt.WaitCursor)
             self.employee_table.fill_table()
             self.pcs_table.update_table_content()
             QApplication.restoreOverrideCursor()
     except exc.IntegrityError as errmsg:
         print(errmsg)
         session.rollback()
         msg = QMessageBox()
         msg.setIcon(QMessageBox.Critical)
         msg.setText("Критическая ошибка базы данных")
         msg.setWindowTitle("Критическая ошибка")
         msg.setDetailedText(errmsg)
         msg.setStandardButtons(QMessageBox.Ok)
         msg.buttonClicked.connect(sys.exit)
     else:
         print('Все успешно')
     finally:
         session.close()
示例#4
0
 def excel(self):
     filename = QFileDialog.getSaveFileName(self,
                                            'Сохрание excel файла',
                                            filter='*.xlsx')
     if not filename[1]:
         return
     else:
         filename = filename[0]
     session = data.Session()
     try:
         QApplication.setOverrideCursor(Qt.WaitCursor)
         excel.run(filename, session)
     except PermissionError:
         QApplication.restoreOverrideCursor()
         QMessageBox.warning(
             self, 'Предупреждение',
             'Закройте {}\n' + 'и попробуйте еще раз'.format(filename))
     except OSError:
         QApplication.restoreOverrideCursor()
         QMessageBox.warning(self, 'Ошибка!', 'Попробуйте другой путь')
     else:
         QApplication.restoreOverrideCursor()
         QMessageBox.information(self, 'Уведомление',
                                 'Сгенерирован: {}'.format(filename))
     finally:
         session.close()
示例#5
0
 def display_data(self):
     session = data.Session()
     try:
         self.employee_table = employees.EmployeeTable(session, self)
         self.pcs_table = pcs.PcsTable(session, self)
         tab_widget = QTabWidget()
         tab_widget.addTab(self.employee_table, "Funcionários")
         tab_widget.addTab(self.pcs_table, "Computadores")
         self.setCentralWidget(tab_widget)
     except exc.IntegrityError as errmsg:
         print(errmsg)
         session.rollback()
         session.close()
         msg = QMessageBox()
         msg.setIcon(QMessageBox.Critical)
         msg.setText("Erro crítico no banco de dados")
         msg.setWindowTitle("Erro crítico")
         msg.setDetailedText(errmsg)
         msg.setStandardButtons(QMessageBox.Ok)
         msg.buttonClicked.connect(sys.exit)
示例#6
0
 def display_data(self):
     session = data.Session()
     try:
         self.employee_table = employees.EmployeeTable(session, self)
         self.pcs_table = pcs.PcsTable(session, self)
         tab_widget = QTabWidget()
         tab_widget.addTab(self.employee_table, "Сотрудники")
         tab_widget.addTab(self.pcs_table, "Компьютеры")
         self.setCentralWidget(tab_widget)
     except exc.IntegrityError as errmsg:
         print(errmsg)
         session.rollback()
         session.close()
         msg = QMessageBox()
         msg.setIcon(QMessageBox.Critical)
         msg.setText("Критическая ошибка базы данных")
         msg.setWindowTitle("Критическая ошибка")
         msg.setDetailedText(errmsg)
         msg.setStandardButtons(QMessageBox.Ok)
         msg.buttonClicked.connect(sys.exit)
示例#7
0
 def add_address(self):
     session = data.Session()
     try:
         address_window = address.ConfigureAddresses(session)
         if address_window.exec_() == QDialog.Accepted:
             session.commit()
             self.employee_table.set_filter_comboboxes()
             print("Zakommitili")
     except exc.IntegrityError as errmsg:
         print(errmsg)
         session.rollback()
         msg = QMessageBox()
         msg.setIcon(QMessageBox.Critical)
         msg.setText("Erro crítico no banco de dados")
         msg.setWindowTitle("Erro crítico")
         msg.setDetailedText(errmsg)
         msg.setStandardButtons(QMessageBox.Ok)
         msg.buttonClicked.connect(sys.exit)
     else:
         print('Tudo com sucesso')
     finally:
         session.close()
示例#8
0
 def add_address(self):
     session = data.Session()
     try:
         address_window = address.ConfigureAddresses(session)
         if address_window.exec_() == QDialog.Accepted:
             session.commit()
             self.employee_table.set_filter_comboboxes()
             print("Закоммитили")
     except exc.IntegrityError as errmsg:
         print(errmsg)
         session.rollback()
         msg = QMessageBox()
         msg.setIcon(QMessageBox.Critical)
         msg.setText("Критическая ошибка базы данных")
         msg.setWindowTitle("Критическая ошибка")
         msg.setDetailedText(errmsg)
         msg.setStandardButtons(QMessageBox.Ok)
         msg.buttonClicked.connect(sys.exit)
     else:
         print('Все успешно')
     finally:
         session.close()