Example #1
0
void MainWindow::on_clearAPPushButton_clicked()
{
    if (QMessageBox::No == QMessageBox::question(this, tr("Action Possibility Creator"),
                                    tr("Do you really want to clear Action Possibility Thresholds?"),
                                    QMessageBox::Yes | QMessageBox::No, QMessageBox::No))
            return;

    QSqlQuery Goalquery(db);

    Goalquery.clear();

    db.database().transaction();

      Goalquery.prepare("UPDATE ActionPossibilities SET likelihood = 0");
      if (!Goalquery.exec())
      {
          QMessageBox msgBox;
          msgBox.setIcon(QMessageBox::Critical);

          msgBox.setText("Cant update action possibilities table!");
          msgBox.exec();
          closeDownRequest = true;
          return;
      }

    db.database().commit();

    fillDisplayArea();
}
Example #2
0
bool DbRecepient::createDb()
{
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "recepient");
    db.setDatabaseName(":memory:");

    if( !db.database("recepient").open() )
        return false;

    QSqlQuery query(db);

    return query.exec( "CREATE TABLE recepient  "
                " (id INTEGER PRIMARY KEY, " // 0
                "  name INTEGER, "           // 1
                "  address INTEGER, "        // 2
                "  number TEXT, "            // 3
                "  status DEFAULT 1)"        // 4
                );
}