From a0eeb84de2370fb900484c51e675dc9f49d83150 Mon Sep 17 00:00:00 2001 From: giomba Date: Sat, 31 Oct 2020 22:45:29 +0100 Subject: [PATCH] aggiunto filtro per anno sui rinnovi iscrizione soci --- argento/RenewalTab.cpp | 20 +++++++++++++++++++- argento/RenewalTab.ui | 6 +----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/argento/RenewalTab.cpp b/argento/RenewalTab.cpp index 4fb8546..fd87da9 100644 --- a/argento/RenewalTab.cpp +++ b/argento/RenewalTab.cpp @@ -8,10 +8,28 @@ RenewalTab::RenewalTab(QWidget *parent) : ui->setupUi(this); ui->table->setModel(&model); + + QSqlQuery query; + QSqlRecord record; + + { + query.prepare("SELECT DISTINCT(YEAR(anno)) AS anno FROM iscrizione UNION SELECT YEAR(CURRENT_DATE()) AS anno UNION SELECT YEAR(CURRENT_DATE()) + 1 AS anno;"); + if (! query.exec()) status(Ui::ERROR, query.lastError().text()); + record = query.record(); + while (query.next()) { + const int anno = query.value(record.indexOf("anno")).toInt(); + ui->renewalYear->addItem(QString::number(anno), anno); + } + } + + } void RenewalTab::refresh() { - query.prepare("SELECT YEAR(i.anno) AS anno, s.cognome, s.nome FROM iscrizione AS i INNER JOIN socio AS s ON s.id = i.socio ORDER BY s.cognome;"); + const int anno = ui->renewalYear->currentData().toInt(); + + query.prepare("SELECT YEAR(i.anno) AS anno, s.cognome, s.nome FROM iscrizione AS i INNER JOIN socio AS s ON s.id = i.socio WHERE YEAR(i.anno) = :anno ORDER BY s.cognome"); + query.bindValue(":anno", anno); if (! query.exec()) { status(Ui::ERROR, model.lastError().text()); diff --git a/argento/RenewalTab.ui b/argento/RenewalTab.ui index 76bfac7..98ccef5 100644 --- a/argento/RenewalTab.ui +++ b/argento/RenewalTab.ui @@ -34,11 +34,7 @@ - - - false - - +