diff --git a/argento/MainWindow.cpp b/argento/MainWindow.cpp index b04ebf2..fdc5ac8 100644 --- a/argento/MainWindow.cpp +++ b/argento/MainWindow.cpp @@ -38,7 +38,8 @@ MainWindow::~MainWindow() { void MainWindow::on_buttonCerca_clicked() { if (!db.open()) connectDatabase(); - query.prepare("SELECT id, nome, cognome FROM socio WHERE cognome LIKE :cognome"); + query.prepare("SELECT id, nome, cognome FROM socio WHERE LOWER(nome) LIKE LOWER(:nome) AND LOWER(cognome) LIKE LOWER(:cognome)"); + query.bindValue( ":nome", QString("%%1%").arg(lineNome->text()) ); query.bindValue( ":cognome", QString("%%1%").arg(lineCognome->text()) ); if ( ! query.exec() ) { qDebug() << query.lastQuery(); return; } @@ -59,7 +60,8 @@ void MainWindow::on_buttonNuovo_clicked() { /* TODO -- please implement me thank void MainWindow::on_tableSoci_clicked(const QModelIndex& index) { if (index.isValid()) { - int id = index.data().toInt(); /* retrieve id socio */ + /* extracts id socio from first column of table view */ + int id = index.model()->data(index.siblingAtColumn(0)).toInt(); if (id != 0) { /* if click is not on other fields than id... */ EditWindow* w = new EditWindow(id, this); w->show();