check for already renewed subscriptions
This commit is contained in:
parent
1dba4a7a83
commit
db55f17afa
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue