int main(int argc, char * argv[]) { testDoc(); return 0; }
void docItem::openItem(){ if (list.size() == 0){ ui.lineEdit_title->clear(); } else if (list.size() > 0){ QSqlQuery query(QString("select book_item.book, books.title, book_item.identifier " "from book_item,doc_item, books " "where doc_item.book_item = book_item.id and books.id = book_item.book " "and doc_item.id = \'%1\' ").arg(list.at(curr))); query.next(); ui.spinBox_id_book->setValue(query.value(0).toInt()); ui.lineEdit_title->setText(query.value(1).toString()); //ui.spinBox_coun->setValue(query.value(2).toInt()); ui.lineEdit_identifier->setText(query.value(2).toString()); } viewItems(); //test for deleting if (vid == 1){ QSqlQuery testRead(QString("select Count(card_read.id) " "from card_read, book_item " "where card_read.book_item = book_item.id and book_item.identifier = \'%1\'") .arg(ui.lineEdit_identifier->text())); testRead.next(); QSqlQuery testDoc(QString("select Count(doc_item.id) " "from doc_item, docs, book_item " "where doc_item.book_item = book_item.id and doc_item.doc = docs.id and docs.vid = 2 " "and book_item.identifier = \'%1\'") .arg(ui.lineEdit_identifier->text())); testDoc.next(); if (testRead.value(0).toInt() == 0 and testDoc.value(0).toInt() == 0){ ui.pushButton_del->setEnabled(true); } else if (testRead.value(0).toInt() > 0 or testDoc.value(0).toInt() > 0){ ui.pushButton_del->setEnabled(false); } } else if (vid == 2){ ui.pushButton_del->setEnabled(true); } // if (list.size() == 0){ ui.pushButton_toFirst->setEnabled(false); ui.pushButton_toLast->setEnabled(false); ui.pushButton_toNext->setEnabled(false); ui.pushButton_toPrev->setEnabled(false); } else if (list.size() > 0) { if (curr == 0){ ui.pushButton_toFirst->setEnabled(false); ui.pushButton_toPrev->setEnabled(false); } else { ui.pushButton_toFirst->setEnabled(true); ui.pushButton_toPrev->setEnabled(true); } if (curr == list.size() - 1){ ui.pushButton_toLast->setEnabled(false); ui.pushButton_toNext->setEnabled(false); } else { ui.pushButton_toLast->setEnabled(true); ui.pushButton_toNext->setEnabled(true); } } }