Exemplo n.º 1
0
class AddMaterial(QtWidgets.QDialog):
    def __init__(self):
        super(AddMaterial, self).__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)

        self.ui.comboBox.addItem("Да")
        self.ui.comboBox.addItem("Нет")
        self.ui.comboBox_2.addItem("Да")
        self.ui.comboBox_2.addItem("Нет")

        self.ui.buttonBox.accepted.connect(self.add)
        self.ui.buttonBox.rejected.connect(self.close)

        self.bd = Orm()

    def add(self):
        name = self.ui.lineEdit.text()
        company = self.ui.lineEdit_2.text()
        store = self.ui.lineEdit_3.text()
        supplier = self.ui.lineEdit_4.text()
        if "Да" == self.ui.comboBox.currentText():
            reckoning = True
        else:
            reckoning = False
        if "Да" == self.ui.comboBox_2.currentText():
            ndc = True
        else:
            ndc = False
        count = self.ui.spinBox.value()
        measure = self.ui.lineEdit_5.text()
        price = self.ui.doubleSpinBox.value()
        self.bd.addmater(name, company, store, supplier, reckoning, ndc, count,
                         measure, price)
        self.close()
Exemplo n.º 2
0
 def __init__(self, root, id=None, state=None):
     super().__init__(root)
     self.ui = Ui_Dialog()
     self.ui.setupUi(self)
     self.ui.tableWidget.setSelectionBehavior(QAbstractItemView.SelectRows)
     self.ui.pushButton_2.clicked.connect(self.add)
     self.ui.pushButton.clicked.connect(self.delfac)
     self.setWindowModality(Qt.ApplicationModal)
     self.bd = Orm()
     self.state = state
     self.id = id
     if id:
         if self.state == 1:
             data = self.bd.allfac(self.id)
         elif self.state == 2:
             res = self.bd.getres(self.id)
             fio = res.name + " " + res.family[0] + ". " + res.patronymic[
                 0] + '.'
             data = self.bd.resfacil(fio)
         elif self.state == 3:
             cons = self.bd.getcons(self.id)
             data = self.bd.consfacil(cons.facility)
         # self.id = id
         # data = self.bd.allfac(self.id)
     self.now(data)
     self.idfac = False
Exemplo n.º 3
0
 def __init__(self):
     super().__init__()
     self.ui = Ui_MainWindow()
     self.ui.setupUi(self)
     self.ui.tableWidget.setSelectionBehavior(QAbstractItemView.SelectRows)
     self.state = 1
     self.ui.pushButton.clicked.connect(self.addfac)
     self.ui.pushButton_2.clicked.connect(self.addmat)
     self.ui.pushButton_3.clicked.connect(self.delmat)
     self.ui.pushButton_4.clicked.connect(self.search)
     self.ui.pushButton_5.hide()
     self.ui.pushButton_5.clicked.connect(self.tomain)
     self.ui.pushButton_6.clicked.connect(self.update)  # Материалы
     self.ui.pushButton_7.clicked.connect(
         self.constructionObject)  # обьекты
     self.ui.pushButton_8.clicked.connect(
         self.responsible)  # Ответсстевенные
     self.ui.pushButton_9.clicked.connect(
         self.addres)  # добавить сотрудника
     self.ui.pushButton_10.clicked.connect(self.addcon)  # добавить обьект
     self.ui.pushButton_9.hide()  # добавить сотрудника
     self.ui.pushButton_10.hide()  # добавить обьект
     self.bd = Orm()
     self.now(self.bd.allmat(), self.state)
     self.id = False
Exemplo n.º 4
0
    def __init__(self, id):
        self.id = id
        super(AddFacility, self).__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.bd = Orm()
        resens = self.bd.allresname()
        for res in resens:
            self.ui.comboBox.addItem(res)
        cons = self.bd.allconname()
        for con in cons:
            self.ui.comboBox_2.addItem(con)
        self.measure = self.bd.getmatwes(self.id)

        self.ui.comboBox_3.addItem("Да")
        self.ui.comboBox_3.addItem("Нет")
        self.ui.comboBox_4.addItem("Да")
        self.ui.comboBox_4.addItem("Нет")
        mer = "Ед. изм. " + str(self.measure)
        self.ui.label_6.setText(mer)

        self.ui.buttonBox.accepted.connect(self.add)
        self.ui.buttonBox.rejected.connect(self.close)

        self.bd = Orm()
Exemplo n.º 5
0
class InputDialog(QtWidgets.QDialog):
    def __init__(self, root, state):
        super().__init__(root)
        self.win = root
        self.state = state
        label = QtWidgets.QLabel('Введите название')
        self.edit = QtWidgets.QLineEdit()
        button = QtWidgets.QPushButton('Найти')
        button.clicked.connect(self.push)
        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(label)
        layout.addWidget(self.edit)
        layout.addWidget(button)
        self.setLayout(layout)
        self.bd = Orm()

    def push(self):
        if self.edit.text():
            if self.state == 1:
                r = self.bd.search_mater(self.edit.text())
            elif self.state == 2:
                r = self.bd.search_res(self.edit.text())
            elif self.state == 3:
                r = self.bd.search_cons(self.edit.text())
            if r:
                self.win.now(r, self.state)
                self.close()
            else:
                msg = QMessageBox()
                msg.setWindowTitle("Ошибка")
                msg.setText("Не найдено ")
                msg.addButton('Ок', QMessageBox.RejectRole)
                msg.exec()
Exemplo n.º 6
0
    def __init__(self):
        super(AddConstructionObject, self).__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.ui.buttonBox.accepted.connect(self.add)
        self.ui.buttonBox.rejected.connect(self.close)

        self.bd = Orm()
Exemplo n.º 7
0
    def __init__(self):
        super(AddResponsible, self).__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.ui.buttonBox.accepted.connect(self.add)
        self.ui.buttonBox.rejected.connect(self.close)

        self.bd = Orm()
Exemplo n.º 8
0
 def __init__(self, root):
     super().__init__(root)
     self.win = root
     label = QtWidgets.QLabel('Введите название')
     self.edit = QtWidgets.QLineEdit()
     button = QtWidgets.QPushButton('Найти')
     button.clicked.connect(self.push)
     layout = QtWidgets.QVBoxLayout()
     layout.addWidget(label)
     layout.addWidget(self.edit)
     layout.addWidget(button)
     self.setLayout(layout)
     self.bd = Orm()
Exemplo n.º 9
0
 def __init__(self, id=None):
     super(AddPass, self).__init__()
     self.ui = Ui_Dialog()
     self.ui.setupUi(self)
     self.ui.buttonBox.accepted.connect(self.add)
     self.ui.buttonBox.rejected.connect(self.close)
     self.bd = Orm()
     self.id = id
     if self.id:
         data = self.bd.get_change(self.id)
         self.ui.lineEdit_1.setText(str(data[0][1]))
         self.ui.lineEdit_2.setText(str(data[0][2]))
         self.ui.lineEdit_3.setText(str(data[0][3]))
Exemplo n.º 10
0
    def __init__(self):
        super(AddMaterial, self).__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)

        self.ui.comboBox.addItem("Да")
        self.ui.comboBox.addItem("Нет")
        self.ui.comboBox_2.addItem("Да")
        self.ui.comboBox_2.addItem("Нет")

        self.ui.buttonBox.accepted.connect(self.add)
        self.ui.buttonBox.rejected.connect(self.close)

        self.bd = Orm()
Exemplo n.º 11
0
 def __init__(self, parent=None):
     super().__init__(parent)
     self.ui = Ui_MainWindow()
     self.ui.setupUi(self)
     self.ui.tableWidget.setSelectionBehavior(
         QTableView.SelectionBehavior.SelectRows)
     self.ui.pushButton_1.clicked.connect(self.add_log)
     self.ui.pushButton_2.clicked.connect(self.del_log)
     self.ui.pushButton_3.clicked.connect(self.search)
     self.ui.pushButton_4.clicked.connect(self.to_main)
     self.ui.pushButton_5.clicked.connect(self.change_data)
     self.ui.pushButton_4.hide()
     self.id = False
     self.bd = Orm()
     self.now(self.bd.all_log())
Exemplo n.º 12
0
class AddConstructionObject(QtWidgets.QDialog):
    def __init__(self):
        super(AddConstructionObject, self).__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.ui.buttonBox.accepted.connect(self.add)
        self.ui.buttonBox.rejected.connect(self.close)

        self.bd = Orm()

    def add(self):
        facility = self.ui.lineEdit.text()  # объект
        address = self.ui.lineEdit_2.text()  # адрес
        contract = self.ui.lineEdit_3.text()  # договор

        self.bd.addcon(facility, address, contract)
        self.close()
Exemplo n.º 13
0
class AddPass(QtWidgets.QDialog):
    def __init__(self, id=None):
        super(AddPass, self).__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.ui.buttonBox.accepted.connect(self.add)
        self.ui.buttonBox.rejected.connect(self.close)
        self.bd = Orm()
        self.id = id
        if self.id:
            data = self.bd.get_change(self.id)
            self.ui.lineEdit_1.setText(str(data[0][1]))
            self.ui.lineEdit_2.setText(str(data[0][2]))
            self.ui.lineEdit_3.setText(str(data[0][3]))

    def add(self):
        name = self.ui.lineEdit_1.text()
        login = self.ui.lineEdit_2.text()
        password = self.ui.lineEdit_3.text()
        if self.id:
            self.bd.del_log(self.id)
            self.bd.changelog(self.id, name, login, password)
        else:
            self.bd.add_log(name, login, password)
        self.close()
Exemplo n.º 14
0
class AddResponsible(QtWidgets.QDialog):
    def __init__(self):
        super(AddResponsible, self).__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.ui.buttonBox.accepted.connect(self.add)
        self.ui.buttonBox.rejected.connect(self.close)

        self.bd = Orm()

    def add(self):
        name = self.ui.lineEdit.text()  # имя
        family = self.ui.lineEdit_2.text()  # фамилия
        patronymic =self.ui.lineEdit_3.text()  # отчество
        position = self.ui.lineEdit_4.text() # должность

        self.bd.addres(name, family, patronymic, position)
        self.close()
Exemplo n.º 15
0
 def __init__(self, parent=None):
     super().__init__(parent)
     if not AdminPassword.chek_db():
         label = QtWidgets.QLabel('Укажите пароль для доступа')
         self.chekAdmin = False
     else:
         label = QtWidgets.QLabel('Введите пароль')
         self.chekAdmin = True
         self.adb = AdminPassword()
     self.edit = QtWidgets.QLineEdit()
     button = QtWidgets.QPushButton('Ок')
     button.clicked.connect(self.push)
     layout = QtWidgets.QVBoxLayout()
     layout.addWidget(label)
     layout.addWidget(self.edit)
     layout.addWidget(button)
     self.setLayout(layout)
     self.bd = Orm()
Exemplo n.º 16
0
class AddFacility(QtWidgets.QDialog):
    def __init__(self, id):
        self.id = id
        super(AddFacility, self).__init__()
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.bd = Orm()
        resens = self.bd.allresname()
        for res in resens:
            self.ui.comboBox.addItem(res)
        cons = self.bd.allconname()
        for con in cons:
            self.ui.comboBox_2.addItem(con)
        self.measure = self.bd.getmatwes(self.id)

        self.ui.comboBox_3.addItem("Да")
        self.ui.comboBox_3.addItem("Нет")
        self.ui.comboBox_4.addItem("Да")
        self.ui.comboBox_4.addItem("Нет")
        mer = "Ед. изм. " + str(self.measure)
        self.ui.label_6.setText(mer)

        self.ui.buttonBox.accepted.connect(self.add)
        self.ui.buttonBox.rejected.connect(self.close)

        self.bd = Orm()

    def add(self):
        owner = self.id
        name = self.ui.comboBox.currentText()
        facility = self.ui.comboBox_2.currentText()
        if "Да" == self.ui.comboBox_3.currentText():
            reckoning = True
        else:
            reckoning = False
        if "Да" == self.ui.comboBox_4.currentText():
            waybills = True
        else:
            waybills = False
        count = self.ui.spinBox.value()
        measure = self.bd.getmatwes(self.id)

        self.bd.addfacil(owner, name, facility, reckoning, waybills, count,
                         measure)
        self.close()
Exemplo n.º 17
0
class MainWindow(QtWidgets.QMainWindow):
    def __init__(self):
        super().__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.tableWidget.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.state = 1
        self.ui.pushButton.clicked.connect(self.addfac)
        self.ui.pushButton_2.clicked.connect(self.addmat)
        self.ui.pushButton_3.clicked.connect(self.delmat)
        self.ui.pushButton_4.clicked.connect(self.search)
        self.ui.pushButton_5.hide()
        self.ui.pushButton_5.clicked.connect(self.tomain)
        self.ui.pushButton_6.clicked.connect(self.update)  # Материалы
        self.ui.pushButton_7.clicked.connect(
            self.constructionObject)  # обьекты
        self.ui.pushButton_8.clicked.connect(
            self.responsible)  # Ответсстевенные
        self.ui.pushButton_9.clicked.connect(
            self.addres)  # добавить сотрудника
        self.ui.pushButton_10.clicked.connect(self.addcon)  # добавить обьект
        self.ui.pushButton_9.hide()  # добавить сотрудника
        self.ui.pushButton_10.hide()  # добавить обьект
        self.bd = Orm()
        self.now(self.bd.allmat(), self.state)
        self.id = False

    def update(self):
        self.state = 1
        self.now(self.bd.allmat(), 1)
        self.ui.pushButton.show()
        self.ui.pushButton_2.show()
        self.ui.pushButton_4.show()
        self.ui.pushButton_6.show()
        self.ui.pushButton_9.hide()
        self.ui.pushButton_5.hide()
        self.ui.pushButton_10.hide()

    def now(self, data, state):
        if data:
            self.ui.tableWidget.setEnabled(True)
            self.ui.pushButton_3.setEnabled(True)
            self.ui.pushButton_4.setEnabled(True)
            # ряды и столбцы
            self.ui.tableWidget.setRowCount(len(data))
            self.ui.tableWidget.setColumnCount(len(data[0]))
            if state == 1:
                self.ui.tableWidget.setHorizontalHeaderLabels(
                    ('Номер', 'Название материала', 'Фирма', 'Магазин',
                     'Поставщик', 'Наличие счета', 'Наличие НДС', 'Количество',
                     'Общее количество', 'Ед.изм', 'Цена за ед.Грн',
                     'Общая цена.Грн'))
            elif state == 2:
                self.ui.tableWidget.setHorizontalHeaderLabels(
                    ('Номер', 'Имя', 'Фамилия', 'Отчество', 'Должность'))
            elif state == 3:
                self.ui.tableWidget.setHorizontalHeaderLabels(
                    ('Номер', 'Объект', 'Адрес', 'Договор'))

            row = 0
            for tup in data:
                col = 0

                for item in tup:
                    cellinfo = QTableWidgetItem(str(item))
                    cellinfo.setFlags(QtCore.Qt.ItemIsSelectable
                                      | QtCore.Qt.ItemIsEnabled)
                    self.ui.tableWidget.setItem(row, col, cellinfo)
                    # self.ui.tableWidget.horizontalHeader().setSectionResizeMode(col , QHeaderView.Stretch)

                    col += 1

                row += 1
                self.ui.tableWidget.resizeColumnsToContents()
                self.ui.tableWidget.horizontalHeader().setSectionResizeMode(
                    col - 1, QHeaderView.Stretch)
        else:
            self.ui.tableWidget.clear()
            self.ui.tableWidget.setEnabled(False)
            self.ui.pushButton_3.setEnabled(False)
            self.ui.pushButton_4.setEnabled(False)

    def addmat(self):
        self.dualog = AddMaterial()
        self.dualog.exec()
        self.now(self.bd.allmat(), self.state)

    def addfac(self):
        if not self.id:
            self.now(self.bd.allmat(), self.state)
            msg = QMessageBox()
            msg.setWindowTitle("Ошибка")
            msg.setText("Вы не выбрали не один договор")
            msg.addButton('Ок', QMessageBox.RejectRole)
            msg.exec()

        else:
            # print(self.id)
            self.now(self.bd.allmat(), self.state)
            self.dualog2 = AddFacility(self.id)
            self.dualog2.exec()
            self.now(self.bd.allmat(), self.state)

    def delmat(self):  # проблема с индексами после удаления
        state = self.state
        if state == 1:
            if not self.id:
                self.now(self.bd.allmat(), state)
                msg = QMessageBox()
                msg.setWindowTitle("Ошибка")
                msg.setText("Вы не выбрали не одну запись")
                msg.addButton('Ок', QMessageBox.RejectRole)
                msg.exec()
            else:
                self.bd.delmat(self.id)
                self.now(self.bd.allmat(), state)
                self.id = False
        elif state == 2:
            if not self.id:
                self.now(self.bd.allres(), state)
                msg = QMessageBox()
                msg.setWindowTitle("Ошибка")
                msg.setText("Вы не выбрали не одну запись")
                msg.addButton('Ок', QMessageBox.RejectRole)
                msg.exec()
            else:
                # print(self.id)
                self.bd.delres(self.id)
                self.now(self.bd.allres(), state)
                self.id = False
        elif state == 3:
            if not self.id:
                self.now(self.bd.allcon(), state)
                msg = QMessageBox()
                msg.setWindowTitle("Ошибка")
                msg.setText("Вы не выбрали не одну запись")
                msg.addButton('Ок', QMessageBox.RejectRole)
                msg.exec()
            else:
                # print(self.id)
                self.bd.delcon(self.id)
                self.now(self.bd.allcon(), state)
                self.id = False

    @pyqtSlot(QModelIndex)
    def on_tableWidget_clicked(
            self, index: QModelIndex):  # получение индекса строки при нажатие
        self.id = int(self.ui.tableWidget.item(index.row(), 0).text())

    @pyqtSlot(QModelIndex)
    def on_tableWidget_doubleClicked(
            self, index: QModelIndex):  # получение списка обьектов
        r = int(self.ui.tableWidget.item(index.row(), 0).text())
        if self.state == 1:
            data = self.bd.allfac(r)
        elif self.state == 2:
            res = self.bd.getres(r)
            fio = res.name + " " + res.family[0] + ". " + res.patronymic[
                0] + '.'
            data = self.bd.resfacil(fio)

        elif self.state == 3:
            cons = self.bd.getcons(r)
            data = self.bd.consfacil(cons.facility)
        if not data:
            msg = QMessageBox()
            msg.setWindowTitle("Ошибка")
            msg.setText("Нет записей")
            msg.addButton('Ок', QMessageBox.RejectRole)
            msg.exec()

        else:
            self.twow = TwoWindow(self, r, self.state)
            self.twow.show()

    def search(self):
        self.ui.pushButton_4.hide()
        self.ui.pushButton_5.show()
        self.search = InputDialog(self, self.state)
        self.search.exec()

    def tomain(self):
        self.ui.pushButton_5.hide()
        if self.state == 1:
            self.update()
        elif self.state == 2:
            self.responsible()
        elif self.state == 3:
            self.constructionObject()

    def responsible(self):
        self.state = 2
        self.id = False
        self.now(self.bd.allres(), self.state)
        self.ui.pushButton.hide()
        self.ui.pushButton_2.hide()
        self.ui.pushButton_5.hide()
        self.ui.pushButton_4.show()
        self.ui.pushButton_6.show()
        self.ui.pushButton_9.show()
        self.ui.pushButton_10.hide()

    def addres(self):
        self.dualog3 = AddResponsible()
        self.dualog3.exec()
        self.now(self.bd.allres(), self.state)

    def constructionObject(self):
        self.state = 3
        self.id = False
        self.now(self.bd.allcon(), self.state)
        self.ui.pushButton.hide()
        self.ui.pushButton_2.hide()
        self.ui.pushButton_9.hide()
        self.ui.pushButton_5.hide()
        self.ui.pushButton_10.show()
        self.ui.pushButton_4.show()
        self.ui.pushButton_6.show()

    def addcon(self):
        self.dualog4 = AddConstructionObject()
        self.dualog4.exec()
        self.now(self.bd.allcon(), self.state)
Exemplo n.º 18
0
class TwoWindow(QtWidgets.QDialog):
    def __init__(self, root, id=None, state=None):
        super().__init__(root)
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        self.ui.tableWidget.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.ui.pushButton_2.clicked.connect(self.add)
        self.ui.pushButton.clicked.connect(self.delfac)
        self.setWindowModality(Qt.ApplicationModal)
        self.bd = Orm()
        self.state = state
        self.id = id
        if id:
            if self.state == 1:
                data = self.bd.allfac(self.id)
            elif self.state == 2:
                res = self.bd.getres(self.id)
                fio = res.name + " " + res.family[0] + ". " + res.patronymic[
                    0] + '.'
                data = self.bd.resfacil(fio)
            elif self.state == 3:
                cons = self.bd.getcons(self.id)
                data = self.bd.consfacil(cons.facility)
            # self.id = id
            # data = self.bd.allfac(self.id)
        self.now(data)
        self.idfac = False

    def now(self, data):
        if data:
            self.ui.tableWidget.setEnabled(True)
            self.ui.pushButton.setEnabled(True)
            # ряды и столбцы
            self.ui.tableWidget.setRowCount(len(data))
            self.ui.tableWidget.setColumnCount(len(data[0]))

            self.ui.tableWidget.setHorizontalHeaderLabels(
                ('Id', 'Имя(кто взял материалы)', 'объект', 'Наличие счета',
                 'Наличие накладных', 'Количество', 'Ед.изм'))
            row = 0
            for tup in data:
                col = 0

                for item in tup:
                    cellinfo = QTableWidgetItem(str(item))
                    cellinfo.setFlags(QtCore.Qt.ItemIsSelectable
                                      | QtCore.Qt.ItemIsEnabled)
                    self.ui.tableWidget.setItem(row, col, cellinfo)
                    col += 1

                row += 1
            self.ui.tableWidget.resizeColumnsToContents()
            self.ui.tableWidget.horizontalHeader().setSectionResizeMode(
                col - 1, QHeaderView.Stretch)
        else:
            self.ui.tableWidget.clear()
            self.ui.tableWidget.setEnabled(False)
            self.ui.pushButton.setEnabled(False)

    def add(self):
        self.dualog = AddFacility(self.id)
        self.dualog.exec()
        self.now(self.bd.allfac(self.id))

    @pyqtSlot(QModelIndex)
    def on_tableWidget_clicked(
            self, index: QModelIndex):  # получение индекса строки при нажатие
        self.idfac = int(self.ui.tableWidget.item(index.row(), 0).text())

    def delfac(self):
        if not self.idfac:
            self.now(self.bd.allfac(self.id))
            msg = QMessageBox()
            msg.setWindowTitle("Ошибка")
            msg.setText("Вы не выбрали не один объект")
            msg.addButton('Ок', QMessageBox.RejectRole)
            msg.exec()
        else:
            # print(self.idfac)
            self.bd.delfac(self.idfac)
            self.now(self.bd.allfac(self.id))
Exemplo n.º 19
0
class MainWindow(QMainWindow):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.tableWidget.setSelectionBehavior(
            QTableView.SelectionBehavior.SelectRows)
        self.ui.pushButton_1.clicked.connect(self.add_log)
        self.ui.pushButton_2.clicked.connect(self.del_log)
        self.ui.pushButton_3.clicked.connect(self.search)
        self.ui.pushButton_4.clicked.connect(self.to_main)
        self.ui.pushButton_5.clicked.connect(self.change_data)
        self.ui.pushButton_4.hide()
        self.id = False
        self.bd = Orm()
        self.now(self.bd.all_log())

    def now(self, data):
        if data:
            self.ui.tableWidget.setEnabled(True)
            self.ui.pushButton_3.setEnabled(True)
            self.ui.pushButton_4.setEnabled(True)
            # ряды и столбцы
            self.ui.tableWidget.setRowCount(len(data))
            self.ui.tableWidget.setColumnCount(len(data[0]))
            self.ui.tableWidget.setHorizontalHeaderLabels((
                'Id',
                'Название приложения',
                'Логин',
                'Пароль',
            ))
            row = 0
            for tup in data:
                col = 0

                for item in tup:
                    cellinfo = QTableWidgetItem(str(item))
                    cellinfo.setFlags(QtCore.Qt.ItemFlags.ItemIsSelectable
                                      | QtCore.Qt.ItemFlags.ItemIsEnabled)
                    self.ui.tableWidget.setItem(row, col, cellinfo)

                    col += 1

                row += 1
                self.ui.tableWidget.resizeColumnsToContents()
                # self.ui.tableWidget.horizontalHeader().setSectionResizeMode(col - 1, QHeaderView.stretchSectionCount)
                self.ui.tableWidget.horizontalHeader().setStretchLastSection(
                    True)

        else:
            self.ui.tableWidget.clear()
            self.ui.tableWidget.setEnabled(False)
            self.ui.pushButton_3.setEnabled(False)
            self.ui.pushButton_4.setEnabled(False)

    def add_log(self):

        self.dualog = AddPass()
        self.dualog.exec()
        self.now(self.bd.all_log())

    def change_data(self):
        if not self.id:
            self.now(self.bd.all_log())
            msg = QMessageBox()
            msg.setWindowTitle("Ошибка")
            msg.setText("Вы не выбрали не одну запись")
            msg.addButton('Ок', QMessageBox.ButtonRole.RejectRole)
            msg.exec()
        else:
            self.dualog = AddPass(self.id)
            self.dualog.exec()
            self.now(self.bd.all_log())
            self.id = False

    def del_log(self):
        if not self.id:
            self.now(self.bd.all_log())
            msg = QMessageBox()
            msg.setWindowTitle("Ошибка")
            msg.setText("Вы не выбрали не одну запись")
            msg.addButton('Ок', QMessageBox.ButtonRole.RejectRole)
            msg.exec()
        else:
            self.bd.del_log(self.id)
            self.now(self.bd.all_log())
            self.id = False

    @pyqtSlot(QModelIndex)
    def on_tableWidget_clicked(
            self, index: QModelIndex):  # получение индекса строки при нажатие
        self.id = int(self.ui.tableWidget.item(index.row(), 0).text())

    @pyqtSlot(QModelIndex)
    def on_tableWidget_doubleClicked(
            self, index: QModelIndex):  # получение списка обьектов
        r = self.ui.tableWidget.item(index.row(), index.column()).text()
        clipboard.setText(r)

    def search(self):
        self.ui.pushButton_3.hide()
        self.ui.pushButton_4.show()
        self.search_dialog = InputDialog(self)
        self.search_dialog.exec()

    def to_main(self):
        self.ui.pushButton_4.hide()
        self.ui.pushButton_3.show()
        self.now(self.bd.all_log())