void Priorities::slotInsertOrUpdateRecords(void) { QList<QVariant> list; QSqlQuery stored; if (m_rad == RecordActionDatabase::ardInsert){ list.append(dictionaryDialog->ui->lineEditItem->text()); list.append((int)dictionaryDialog->ui->checkBoxActual->isChecked()); list.append((int)(dictionaryDialog->ui->comboBoxIcon->currentIndex())); stored = execStored(currentDatabase(), "InsertPriorityType", storageHashTable(list)); stored.finish(); } else if (m_rad == RecordActionDatabase::ardUpdate){ unsigned i(0); unsigned m_code = m_selectionModel->currentIndex().sibling(m_selectionModel->currentIndex().row(), i).data(Qt::DisplayRole).toUInt(); list.append(m_code); list.append(dictionaryDialog->ui->lineEditItem->text()); list.append((int)(dictionaryDialog->ui->checkBoxActual->isChecked())); list.append((int)(dictionaryDialog->ui->comboBoxIcon->currentIndex())); stored = execStored(currentDatabase(), "UpdatePriorityType", storageHashTable(list)); stored.finish(); } slotRefreshRecords(); clearEditDialog(dictionaryDialog); m_selectedItem = false; }
void CTaskType::slotFindTask(const QString &text) { QList<QVariant> list; QSqlQuery stored; #ifndef QT_NO_CURSOR QApplication::setOverrideCursor(QCursor(QPixmap("data/picture/additionally/wait.png"))); #endif list.append((int)actualRecords); list.append(text); stored.setForwardOnly(true); stored = execStored(currentDatabase(), "FindTaskType", storageHashTable(list)); bool empty(false); while (stored.next()){ empty = true; } stored = execStored(currentDatabase(), "FindTaskType", storageHashTable(list)); if (empty) { fillTaskModel(stored); } #ifndef QT_NO_CURSOR QApplication::restoreOverrideCursor(); #endif stored.finish(); }
void Priorities::slotRefreshRecords() { QList<QVariant> list; QSqlQuery stored; #ifndef QT_NO_CURSOR QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); #endif list.append(!actualRecords); stored = execStored(currentDatabase(), "ReadAllPriorityType", storageHashTable(list)); fillingModel(stored); m_model->setHeaderData(1, Qt::Horizontal, QObject::tr("Наименование")); m_model->setHeaderData(6, Qt::Horizontal, QObject::tr("Иконка")); for (int i = 0; i != m_model->columnCount(); ++i){ if (i == 1 || i == 6) { continue; } else { treeView->setColumnHidden(i, true); } } #ifndef QT_NO_CURSOR QApplication::restoreOverrideCursor(); #endif stored.finish(); }
void CCustomer::slotFillPartner(const QModelIndex &index) { QList<QVariant> list; QSqlQuery stored; if (index.sibling(index.row(), 3).data().toString() == nullptr && root->index() != index){ #ifndef QT_NO_CURSOR QApplication::setOverrideCursor(QCursor(QPixmap("data/picture/additionally/wait.png"))); #endif list.append((int)index.sibling(index.row(), 1).data().toInt()); stored.setForwardOnly(true); stored = execStored(currentDatabase(), "ReadOneCustomer", storageHashTable(list)); fillPartnerModel(stored); #ifndef QT_NO_CURSOR QApplication::restoreOverrideCursor(); #endif stored.finish(); } else { modelPartner->removeRows(0, modelPartner->rowCount(QModelIndex()), QModelIndex()); textEditPartnerComment->clear(); } }
void CTaskType::slotDeleteRecords(void) { QList<QVariant> list; QSqlQuery stored; if (currentDatabase().isOpen()) { int code = modelSelectionTask->currentIndex().sibling(modelSelectionTask->currentIndex().row(), 0).data().toUInt(); if (!modelSelectionTask->selection().isEmpty()) { CMessage answer(this, "Удаление", "Подтверждаете удаление?"); QPushButton *_delete = answer.addButton(QString("Удалить"), QMessageBox::ActionRole); QPushButton *cancel = answer.addButton(QString("Отмена"), QMessageBox::ActionRole); answer.exec(); if (answer.clickedButton() == _delete){ list.append((int)code); stored.setForwardOnly(true); stored = execStored(currentDatabase(), "DeleteTaskType", storageHashTable(list)); stored.finish(); slotRefreshRecords(); // refresh } else if (answer.clickedButton() == cancel){ treeCppsst->clearSelection(); answer.reject(); } } else CCommunicate::showing(QString("Не удается выполнить, запись не выбрана")); } else CCommunicate::showing(QString("Не удается выполнить, база данных не доступна")); }
void Positions::slotSelectRecords(bool actual) { QList<QVariant> list; QSqlQuery stored; #ifndef QT_NO_CURSOR QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); #endif list.append((int)actual); stored = execStored(currentDatabase(), "ReadAllPosition", storageHashTable(list)); fillingModel(stored); m_model->setHeaderData(1, Qt::Horizontal, QObject::tr("Наименование")); for (int i = 0; i != m_model->columnCount(); ++i) { if (i == 1) { continue; } else { treeView->setColumnHidden(i, true); } } #ifndef QT_NO_CURSOR QApplication::restoreOverrideCursor(); #endif stored.finish(); actual ? ui->m_lblViewState->setText(QString(tr("Отображаются записи: <b><u>Актуальные</u></b>"))) : ui->m_lblViewState->setText(QString(tr("Отображаются записи: <b><u>Все</u></b>"))); m_selectedItem = false; actualRecords = !actualRecords; }
void Positions::slotPushSelectRecordData(void) { QList<QVariant> list; QSqlQuery stored; QString userName; if (m_rad == RecordActionDatabase::ardInsert) { dictionaryDialog->ui->labelUserD->setText(currentUser()); dictionaryDialog->ui->labelDateD->setText(QString(tr("Не определено")).trimmed()); } else if (m_rad == RecordActionDatabase::ardUpdate) { unsigned i(1); QString m_item = m_selectionModel->currentIndex().sibling(m_selectionModel->currentIndex().row(), i).data(Qt::DisplayRole).toString(); dictionaryDialog->setWindowTitle(QString(dictionaryDialog->windowTitle() + " запись - [ %1 ]").arg(m_item)); dictionaryDialog->ui->lineEditItem->setText(QString(m_item).trimmed()); unsigned c(2); unsigned m_check = m_selectionModel->currentIndex().sibling(m_selectionModel->currentIndex().row(), c).data(Qt::DisplayRole).toUInt(); dictionaryDialog->ui->checkBoxActual->setChecked((bool)m_check); unsigned u(3); unsigned m_muser = m_selectionModel->currentIndex().sibling(m_selectionModel->currentIndex().row(), u).data(Qt::DisplayRole).toUInt(); list.append(m_muser); stored = execStored(currentDatabase(), "ReadCurrentUser", storageHashTable(list)); while (stored.next()) { userName = stored.record().field("opt_name_first").value().toString(); } dictionaryDialog->ui->labelUserD->setText(userName); stored.finish(); unsigned d(4); QString m_mdate = m_selectionModel->currentIndex().sibling(m_selectionModel->currentIndex().row(), d).data(Qt::DisplayRole).toString(); dictionaryDialog->ui->labelDateD->setText(m_mdate); } }
bool CTaskType::fillListSelectedRecord(QList<QString> ¶m) { QList<QVariant> list; QSqlQuery stored; if (act == Action::Add) { param.append(QString("%1").arg(-1)); param.append("Нет данных"); param.append("Нет данных"); } else if (act == Action::Edit) { const int code = modelSelectionTask->currentIndex().sibling(modelSelectionTask->currentIndex().row(), 0).data().toUInt(); list.append(code); stored.setForwardOnly(true); stored = execStored(currentDatabase(), "ReadOneTaskType", storageHashTable(list)); bool empty(false); while (stored.next()){ empty = true; } stored = execStored(currentDatabase(), "ReadOneTaskType", storageHashTable(list)); if (empty) { while (stored.next()) { const QString name = stored.value(stored.record().indexOf("tt_name")).toString(); const bool actual = stored.value(stored.record().indexOf("tt_actual")).toBool(); const QString user = stored.value(stored.record().indexOf("tt_muser")).toString(); const QString date = stored.value(stored.record().indexOf("tt_mdate")).toDateTime().toString("yyyy-MM-dd hh:mm:ss"); param.append(name); param.append(QString("%1").arg(-1)); param.append(QVariant(actual).toString()); param.append(user); param.append(date); } } else { CCommunicate::showing(QString("Не удается выполнить, документ либо его элемент был удален другим пользователем")); return false; } stored.finish(); } return true; }
void CCustomer::slotFillGroup(const QModelIndex &index) { QList<QVariant> list; QSqlQuery stored; #ifndef QT_NO_CURSOR QApplication::setOverrideCursor(QCursor(QPixmap("data/picture/additionally/wait.png"))); #endif if (modelFaces->hasChildren(index)){ modelFaces->removeRows(0, modelFaces->rowCount(index), index); } list.append((int)GROUP_TYPE_CUSTOMER); list.append((int)actualRecords); list.append((int)SKIP); // parameter skip stored.setForwardOnly(true); stored = execStored(currentDatabase(), "ReadAllReferenceGroups", storageHashTable(list)); fillFacesModel(index, stored); if (root->index() != index){ if(list.size() > 0) list.clear(); list.append((int)actualRecords); list.append((int)index.sibling(index.row(), 1).data(Qt::DisplayRole).toInt()); list.append(QVariant::Invalid); list.append(QVariant::Invalid); list.append(QVariant::Invalid); list.append(QVariant::Invalid); stored.setForwardOnly(true); stored = execStored(currentDatabase(), "ReadAllCustomers", storageHashTable(list)); fillFacesModel(index, stored); } #ifndef QT_NO_CURSOR QApplication::restoreOverrideCursor(); #endif stored.finish(); }
void CTaskType::slotInsertOrUpdateRecords(const QList<QString> ¶m) { QList<QVariant> list; QSqlQuery stored; int code = modelSelectionTask->currentIndex().sibling(modelSelectionTask->currentIndex().row(), 0).data().toUInt(); list.append(code); list.append(param.at(0)); list.append(QVariant(param.at(2)).toBool()); if (act == Action::Add) { list.removeAt(0); stored = execStored(currentDatabase(), "InsertTaskType", storageHashTable(list)); } else if (act == Action::Edit) { stored = execStored(currentDatabase(), "UpdateTaskType", storageHashTable(list)); } stored.finish(); slotRefreshRecords(); CDictionaryCore::clearEditDialog(cppsstDialog); }
void Priorities::slotDeleteRecords(void) { QList<QVariant> list; QSqlQuery stored; QString m_name; unsigned i(0); unsigned m_code = m_selectionModel->currentIndex().sibling(m_selectionModel->currentIndex().row(), i).data(Qt::DisplayRole).toUInt(); if (m_selectionModel->currentIndex().column() != 1){ m_name = m_selectionModel->currentIndex().sibling(m_selectionModel->currentIndex().row(), 1).data(Qt::DisplayRole).toString(); } else { m_name = m_selectionModel->currentIndex().data(Qt::DisplayRole).toString(); } if (m_selectionModel->isSelected(m_selectionModel->currentIndex())){ QMessageBox answer; answer.setText(QString(tr("Подтверждаете удаление <b>%1</b>?").arg(m_name))); answer.setWindowTitle(QString(tr("Удаление"))); answer.setIcon(QMessageBox::Question); QPushButton *m_delete = answer.addButton(QString(tr("Удалить")), QMessageBox::ActionRole); QPushButton *m_cancel = answer.addButton(QString(tr("Отмена")), QMessageBox::ActionRole); answer.exec(); if (answer.clickedButton() == m_delete){ list.append(m_code); stored = execStored(currentDatabase(), "DeletePriorityType", storageHashTable(list)); stored.finish(); slotRefreshRecords(); } else if (answer.clickedButton() == m_cancel){ treeView->clearSelection(); answer.reject(); } } else { Communicate::showing(QString("Не удается удалить,\n запись не выбрана"), 3000); } m_selectedItem = false; }
void CTaskType::slotFillTask() { QList<QVariant> list; QSqlQuery stored; #ifndef QT_NO_CURSOR QApplication::setOverrideCursor(QCursor(QPixmap("data/picture/additionally/wait.png"))); #endif if (modelTask->rowCount() > 0){ modelTask->removeRows(0, modelTask->rowCount()); } list.append((int)actualRecords); stored.setForwardOnly(true); stored = execStored(currentDatabase(), "ReadAllTaskType", storageHashTable(list)); fillTaskModel(stored); #ifndef QT_NO_CURSOR QApplication::restoreOverrideCursor(); #endif stored.finish(); }