diff --git a/src/li/li0400.cpp b/src/li/li0400.cpp index 9320ba75f..8f11ba303 100755 --- a/src/li/li0400.cpp +++ b/src/li/li0400.cpp @@ -48,17 +48,17 @@ bool TLetint_mask::on_field_event(TOperable_field& o, TField_event e, long jolly { case F_ANNO: if (e == fe_modify || e == fe_init || e == fe_close) - { - if (!is_registro(atoi(o.get()))) - return error_box(FR("Manca il registro dichiarazioni d'intento per l'anno %d"), atoi(o.get())); - } + { + if (!is_registro(atoi(o.get()))) + return error_box(FR("Manca il registro dichiarazioni d'intento per l'anno %d"), atoi(o.get())); + } case F_NUMPROT: if (e == fe_close && query_mode()) { const long numprot = get_long(F_NUMPROT); if (!keyforced && numprot > 1) { - const int anno = get_int(F_ANNO); + const int anno = get_int(F_ANNO); TLocalisamfile letint(LF_LETINT); letint.put(LETINT_ANNO, anno); letint.put(LETINT_NUMPROT, numprot - 1); @@ -68,13 +68,13 @@ bool TLetint_mask::on_field_event(TOperable_field& o, TField_event e, long jolly } break; - case F_DATAREG: + case F_DATAREG: if (e == fe_close && insert_mode()) { const long numprot = get_long(F_NUMPROT); if (numprot > 1) { - const int anno = get_int(F_ANNO); + const int anno = get_int(F_ANNO); TLocalisamfile letint(LF_LETINT); letint.put(LETINT_ANNO, anno); letint.put(LETINT_NUMPROT, numprot - 1); @@ -82,59 +82,47 @@ bool TLetint_mask::on_field_event(TOperable_field& o, TField_event e, long jolly { const TDate& old_data = letint.get_date(LETINT_DATAREG); if (get_date(F_DATAREG) < old_data) - return error_box(TR("La data di registrazione non puo' essere antecedente a %s"), (const char*) old_data.string()); + return error_box(TR("La data di registrazione non puo' essere antecedente a %s"), (const char*)old_data.string()); + } + else + { + TDate ultima = ultima_stampa(anno); + if (get_date(F_DATAREG) <= ultima) + return error_box(TR("La data di registrazione non puo' essere antecedente a %s"), (const char*)ultima.string()); } - else - { - TDate ultima = ultima_stampa(anno); - if (get_date(F_DATAREG) <= ultima) - return error_box(TR("La data di registrazione non puo' essere antecedente a %s"), (const char*)ultima.string()); - } } } - else - if (e == fe_modify) - { - } + else + if (e == fe_modify) + { + } break; + case F_TIPOOP: + // Controlli + if (e == fe_close) + { + const int tipo_op = get_int(F_TIPOOP); + const TDate data = get_date(F_DAL); - case F_DAL: - if(e != fe_modify) - break; - case F_TIPOOP: - // Controlli -/* if(!keyforced && insert_mode() && get_int(F_TIPOOP) == 3 && get_date(F_DAL) > TDate(01,03,2017)) - { - error_box(TR("Non puņ esistere una dichiarazione di intento di tipo \"A Periodo\"\ncon data posteriore al 01/03/2017!")); - disable(DLG_SAVEREC); - } - else - { - enable(DLG_SAVEREC); - } */ - // Abilitazione date - switch (get_int(F_TIPOOP)) - { - case 1: - disable(F_DAL); - disable(F_AL); - set(F_DAL, ""); - set(F_AL, ""); - break; - case 2: - enable(F_DAL); - disable(F_AL); - set(F_AL, ""); - break; - case 3: - enable(F_DAL); - enable(F_AL); - break; - } - break; - default: - break; - } + if (!keyforced && tipo_op == 3 && data > TDate(01, 03, 2017) && get(F_TIPOES).blank()) + return error_box(TR("Non puņ esistere una dichiarazione di intento di tipo \"Nel Periodo\"\ncon data posteriore al 01/03/2017!")); + } + else + if (e == fe_init || e == fe_modify) // Abilitazione date + { + const int tipo_op = get_int(F_TIPOOP); + + enable(F_DAL, tipo_op != 1); + enable(F_AL, tipo_op == 3); + if (e == fe_modify) + { + if (tipo_op == 1) + reset(F_DAL); + if (tipo_op != 3) + reset(F_DAL); + } + } + } return true; }