diff --git a/cg/cg5100.cpp b/cg/cg5100.cpp index bf24f493b..823cfc36c 100755 --- a/cg/cg5100.cpp +++ b/cg/cg5100.cpp @@ -1,16 +1,20 @@ #include #include #include -#include +#include +#include +#include +#include #include "cg5100a.h" class TParametri_ditta : public TConfig_application { - bool _change_pcon; - TString16 _val; + // bool _change_pcon; + // TString16 _val; TArray _atts; void swap_file(int logicnum, bool tocom); + void load_file(int logicnum); void check_registers(int year); public: @@ -20,14 +24,13 @@ public: const char* oldv, const char* newv); virtual bool user_create(); - virtual bool user_destroy(); TParametri_ditta() : TConfig_application(CONFIG_DITTA) {} virtual ~TParametri_ditta() {} }; bool TParametri_ditta::user_create() { - _change_pcon = FALSE; + // _change_pcon = FALSE; TLocalisamfile attiv(LF_ATTIV); attiv.zero(); @@ -126,17 +129,23 @@ void TParametri_ditta::swap_file(int logicnum, bool tocom) } } -bool TParametri_ditta::user_destroy() +void TParametri_ditta::load_file(int logicnum) { - if (_change_pcon) - { - swap_file(LF_PCON, _val[0] == 'X'); - swap_file(LF_CAUSALI, _val[0] == 'X'); - swap_file(LF_RCAUSALI, _val[0] == 'X'); - } - return TRUE; + TDir dir; + + dir.get(logicnum); + + TSystemisamfile f(logicnum); + TFilename lf; + + if (dir.eox() > 0L) + f.build(10L); + lf.format("%sstd/lf%04d.txt", __ptprf, logicnum); + if (fexist(lf)) + f.load(lf, '|', '\0', '\n', TRUE, TRUE); } + bool TParametri_ditta::preprocess_config (TMask& mask, TConfig& config) { // these are disabled in normal applications @@ -144,16 +153,11 @@ bool TParametri_ditta::preprocess_config (TMask& mask, TConfig& config) const bool movempty = mov.empty(); mask.enable(CHK_ANCFCM, movempty); mask.enable(CHK_PCTCCM, movempty); - disable_menu_item(M_FILE_NEW); - disable_menu_item(M_FILE_REVERT); return TRUE; } bool TParametri_ditta::postprocess_config(TMask& mask, TConfig& config) { - enable_menu_item(M_FILE_NEW); - enable_menu_item(M_FILE_REVERT); - check_registers(mask.get_int(FLD_ANLIIV)); if (mask.get_bool(CHK_GELIDI)) { @@ -197,8 +201,25 @@ bool TParametri_ditta::postprocess_config_changed(const char* par, const char* v { if (yesno_box("Confermi il cambiamento del piano conti/causali")) { - _change_pcon = TRUE; - _val = newv; + // _change_pcon = TRUE; + // _val = newv; + swap_file(LF_PCON, *newv == 'X'); + swap_file(LF_CAUSALI, *newv == 'X'); + swap_file(LF_RCAUSALI, *newv == 'X'); + const long firm = get_firm(); + prefix().set("COM"); + set_firm(firm); + if (*newv == 'X') + { + TDir d; + d.get(LF_PCON, _nolock, _comdir); + if (d.eod() == 0 && yesno_box("Vuoi caricare gli archivi standard ?")) + { + load_file(LF_PCON); + load_file(LF_CAUSALI); + load_file(LF_RCAUSALI); + } + } } else return FALSE;