diff --git a/pe/pe0400.cpp b/pe/pe0400.cpp index 46fa54828..270db2571 100755 --- a/pe/pe0400.cpp +++ b/pe/pe0400.cpp @@ -566,9 +566,13 @@ bool TGestione_preventivo_msk::pe_new_revision_handler(TMask_field& f, KEY k) if (k == K_SPACE) { TGestione_preventivo_msk& mask = (TGestione_preventivo_msk&)f.mask(); - TDocumento & d = mask.doc(); + TDocumento& d = mask.doc(); + + if (d.bloccato()) + return f.error_box(TR("Documento bloccato: non e' possibile farne una nuova revisione")); + TDocumento backup(d); - const TTipo_documento & td = cached_tipodoc(d.get(DOC_TIPODOC)); + const TTipo_documento& td = d.tipo(); const char stato_iniziale = d.stato(); d.put(DOC_STATO, td.stato_bloccato()); @@ -584,11 +588,15 @@ bool TGestione_preventivo_msk::pe_new_revision_handler(TMask_field& f, KEY k) ok = d.write() == NOERR; if (ok) { + /* Trucco demenziale che non aggiorna bene ne' la TMask ne' la TRelation_application mask.doc2mask(false); mask.load_checks(); mask.mask2doc(); const int err = app().get_relation()->lfile().read(mask.doc()); app().get_relation()->save_status(); + */ + mask.enable(DLG_NEXTREC); // Mi assicuro che sia cceso il bottone Avanti + mask.stop_run(K_NEXT); // Passo al documento successivo appena creato } } else @@ -867,13 +875,13 @@ bool TGestione_preventivo_msk::pe_k_handler(TMask_field& f, KEY k) { TMask& row_mask = f.mask(); TSheet_field * sh = row_mask.get_sheet(); - const bool last_level = row_mask.field(FR_JOLLY3).enabled(); if (sh == NULL) return true; - TGestione_preventivo_msk & mask = (TGestione_preventivo_msk &) sh->mask(); + TGestione_preventivo_msk& mask = (TGestione_preventivo_msk&)sh->mask(); + const bool last_level = row_mask.field(FR_JOLLY3).enabled(); if (last_level) { if ((k == K_TAB && f.focusdirty()) || k == K_F8) @@ -1008,7 +1016,9 @@ bool TGestione_preventivo_msk::new_revision(const char* codnum, long& ndoc) cons const long divisore = fattore.integer(); const long newndoc = ndoc + 1; - if (((newndoc / divisore) - (ndoc / divisore)) != 0) + // Obfuscated C contest: forse bastava scrivere questo + // if (newndoc/divisore != ndoc/divisore) + if (((newndoc / divisore) - (ndoc / divisore)) != 0) return false; else { @@ -1188,21 +1198,18 @@ int TGestione_preventivo_app::read(TMask& m) //ridefinisco il metodo init_insert_mode della TMotore_application void TGestione_preventivo_app::init_insert_mode(TMask &m) { - TGestione_preventivo_msk & mask = (TGestione_preventivo_msk&) m; - - mask.disable(F_REVISION); - + m.disable(F_REVISION); + m.enable(F_LOAD_COSTS); return TMotore_application::init_insert_mode(m); } void TGestione_preventivo_app::init_modify_mode(TMask &m) { - TGestione_preventivo_msk & mask = (TGestione_preventivo_msk&) m; - TDocumento& d = mask.doc(); - const TCodice_numerazione& num = cached_numerazione(d.get(DOC_CODNUM)); - - mask.enable(F_REVISION, num.revision_len() > 0); - + TGestione_preventivo_msk& mask = (TGestione_preventivo_msk&) m; + const TDocumento& d = mask.doc(); + const TCodice_numerazione& num = d.codice_numerazione(); + mask.enable(F_REVISION, !d.bloccato() && num.revision_len() > 0); + mask.enable(F_LOAD_COSTS, !d.bloccato()); return TMotore_application::init_modify_mode(m); }