diff --git a/cg/cg0200.cpp b/cg/cg0200.cpp index 743db76d7..4d8bf41da 100755 --- a/cg/cg0200.cpp +++ b/cg/cg0200.cpp @@ -969,11 +969,37 @@ bool TClifo_application::effetti_notify(TSheet_field& pnae, int r, KEY key) if (key == K_INS) { TClifo_application& a = app(); - TRectype& cfven = a.get_relation()->curr(LF_CFVEN); - int mass_len = cfven.length(CFV_NONACCEFF); // Lunghezza campo - int mass_rig = mass_len / 11; // Numero di periodi ivi salvabili - return pnae.items() < mass_rig; // Non accettare righe che non si possono salvare + const TRectype& cfven = a.get_relation()->curr(LF_CFVEN); + const int mass_len = cfven.length(CFV_NONACCEFF); // Lunghezza campo + const int mass_rig = mass_len / 11; // Numero di periodi ivi salvabili + return pnae.items() < mass_rig; // Non accettare righe che non si possono salvare } + + if (key == K_ENTER) + { + // Controlla che i giorni superiori a 29 appartengano veramente al mese corrispondente + TToken_string& row = pnae.row(r); + bool dirty = false; + for (int i = 0; i <= 4; i += 2) + { + int gg; row.get(i, gg); + int mm; row.get(i+1, mm); + if (gg > 29) + { + TDate d(1, mm, 2000); // Scelgo un anno bisestile arbitrario + d.set_end_month(); + if (d.day() < gg) + { + gg = d.day(); + row.add(gg, i); + dirty = true; + } + } + } + if (dirty) + pnae.force_update(r); + } + return true; } @@ -1004,8 +1030,7 @@ bool TClifo_application::user_create() // initvar e arrmask TSheet_field& pnae = _msk->sfield(F_NONACCEFF); pnae.set_notify(effetti_notify); - TConfig config(CONFIG_STUDIO); - _savenew = !config.get_bool("Cg02SN"); + _savenew = !ini_get_bool(CONFIG_STUDIO, "cg", "Cg02SN"); return true; }