check for already renewed subscriptions

This commit is contained in:
giomba 2020-09-21 18:02:40 +02:00
parent 1dba4a7a83
commit db55f17afa
1 changed files with 13 additions and 2 deletions

View File

@ -7,8 +7,6 @@ EditWindow::EditWindow(int idSocio, QWidget* parent) :
{
ui->setupUi(this);
QSqlQuery query;
model = new QSqlRelationalTableModel(this);
model->setTable("socio");
model->setFilter(QString("socio.id = %1").arg(idSocio));
@ -52,6 +50,19 @@ EditWindow::EditWindow(int idSocio, QWidget* parent) :
mapper->addMapping(ui->linePin, model->fieldIndex("pin"));
mapper->toFirst();
QSqlQuery query;
query.prepare("SELECT COUNT(*) AS count FROM iscrizione WHERE socio = :socio AND YEAR(anno) = :anno");
query.bindValue(":socio", idSocio);
query.bindValue(":anno", QDate::currentDate().year());
if (! (query.exec() && query.next())) {
status(Ui::ERROR, "can not get iscrizione");
} else {
int count = query.value(query.record().indexOf("count")).toInt();
if (count != 0) {
ui->buttonRinnova->setEnabled(false);
}
}
}
void EditWindow::on_buttonSalva_clicked() {