diff --git a/src/cg/cg7401.cpp b/src/cg/cg7401.cpp index 279c99cfb..9aef2a398 100644 --- a/src/cg/cg7401.cpp +++ b/src/cg/cg7401.cpp @@ -93,9 +93,10 @@ void TQuadro_IVA_mask::build_report_sheet() TToken_string d(80); const char quadro = source_file()[3]; TSheet_field & sf = sfield(F_REPORTS); + TQuadro_IVA_app & app = (TQuadro_IVA_app &)main_app(); sf.destroy(); - ((TQuadro_IVA_app &) main_app()).load_sheet(sf); + app.load_sheet(sf); __stop.load("STOP"); const int items = sf.items(); @@ -158,13 +159,14 @@ bool TQuadro_IVA_mask::on_field_event(TOperable_field& o, TField_event e, long j { const int ditta_attiva = main_app().get_firm(); int codditta = get_int(F_FIRM); + TQuadro_IVA_app & app = (TQuadro_IVA_app &)main_app(); - if (codditta != ditta_attiva) + if (app.has_data() && dirty() && codditta != ditta_attiva) { if (yesno_box("Devo salvare i dati")) - ((TQuadro_IVA_app &)main_app()).save_data(*this); - main_app().set_firm(codditta); - ((TQuadro_IVA_app &)main_app()).load_data(*this); + app.save_data(*this); + app.set_firm(codditta); + app.load_data(*this); reset_dirty(); } } @@ -173,11 +175,15 @@ bool TQuadro_IVA_mask::on_field_event(TOperable_field& o, TField_event e, long j if (e == fe_button) { int codditta = get_int(F_FIRM); + TQuadro_IVA_app & app = (TQuadro_IVA_app &)main_app(); - ((TQuadro_IVA_app &)main_app()).save_data(*this); - main_app().set_firm(codditta); - ((TQuadro_IVA_app &)main_app()).load_data(*this); - reset_dirty(); + if (app.has_data()) + { + app.save_data(*this); + app.set_firm(codditta); + app.load_data(*this); + reset_dirty(); + } } break; default: @@ -411,10 +417,11 @@ void TQuadro_IVA_app::main_loop() _mask = new TQuadro_IVA_mask(_name); if (_mask->exist(F_FIRM)) _mask->set(F_FIRM, prefix().get_codditta()); - load_data(*_mask); + if (has_data()) + load_data(*_mask); while ((k = _mask->run()) != K_QUIT) print(); - if (_mask->dirty() && yesno_box("Devo salvare i dati")) + if (has_data() && _mask->dirty() && yesno_box("Devo salvare i dati")) save_data(*_mask); set_firm(oldditta); } diff --git a/src/cg/cg7401.h b/src/cg/cg7401.h index 36a1d953d..a5d892e5c 100644 --- a/src/cg/cg7401.h +++ b/src/cg/cg7401.h @@ -86,6 +86,7 @@ protected: virtual char last_quadro_report() const { return 'a';} public: + virtual bool has_data() const { return false; } virtual void load_data(TQuadro_IVA_mask & m) {}; virtual void save_data(TQuadro_IVA_mask & m) {}; virtual TQuadro_IVA_recordset * app_recordset(const char* use, const int year, const char repid) pure; diff --git a/src/cg/cg7a00.cpp b/src/cg/cg7a00.cpp index 4eaa95038..32e27e2cc 100644 --- a/src/cg/cg7a00.cpp +++ b/src/cg/cg7a00.cpp @@ -103,6 +103,7 @@ void TQuadro_VL_recordset::load(const char repid) } } + /* TISAM_recordset * recset = app().mask()->get_recset(REP_QUADRO); recset->set_var("#ANNO", format("%d", year())); @@ -139,6 +140,7 @@ void TQuadro_VL_recordset::load(const char repid) break; } } + */ const TRectype & lia = cache().get("%LIA", format("%04d", year())); const bool credito_compensabile = (lia.get("S9") == "CM"); @@ -180,6 +182,7 @@ void TQuadro_VL_recordset::load(const char repid) else credito_utilizzato_iva = risultato -iva_credeb; add_value("VL27.1", credito_utilizzato_iva); + ivadetr += credito_utilizzato_iva; if (month < 10) { add_value("VL22.1", credito_utilizzato_iva); @@ -287,6 +290,7 @@ class TQuadro_VL_app : public TQuadro_IVA_app { protected: + virtual bool has_data() const override { return true; } virtual void load_sheet(TSheet_field & sf); public: @@ -301,7 +305,7 @@ public: void TQuadro_VL_app::load_sheet(TSheet_field & sf) { - TToken_string & row1 = sf.row(sf.items()); row1.add("|1|Quadro VJ - VJ1 - VJ19|cg7800b"); +// TToken_string & row1 = sf.row(sf.items()); row1.add("|1|Quadro VJ - VJ1 - VJ19|cg7800b"); } void TQuadro_VL_app::load_data(TQuadro_IVA_mask & m)