diff --git a/cg/cg7300.cpp b/cg/cg7300.cpp index 2b904dc25..333b7a82b 100755 --- a/cg/cg7300.cpp +++ b/cg/cg7300.cpp @@ -71,32 +71,24 @@ bool TInvioS_mask::on_field_event(TOperable_field& o, TField_event e, long jolly class TInvioS : public TSkeleton_application { TCursor* _cur; - TInvioS_mask* _msk; + TInvioS_mask* _msk; TInvioS_file* _trasfile; - long _nrecords, _nrecsfattvend, _nrecsfattacqu, _nrecsmocontab; - int _nfiles; - long _nrecsdettaglio; - TString16 _descrdettaglio; + TConfig* _configfile; TDate _dataini, _datafin; - bool _totale, _finemov; protected: virtual bool create(void); virtual bool destroy(void); virtual void main_loop() ; void invio_sispac(); - long i_sispac_clifor(const bool invio = TRUE); + long i_sispac_clifor(const char* tipocf, const bool invio = TRUE); long i_sispac_movcont(const bool invio = TRUE); long i_sispac_moviva(const bool invio = TRUE); + public: - int get_nfiles() {return _nfiles;}; - long get_nrecords() {return _nrecords;}; - long get_nrecsdettaglio() {return _nrecsdettaglio;}; - TString16& get_descrdettaglio() {return _descrdettaglio;}; - const bool totale() {return _totale;}; - const bool finemov() {return _finemov;}; TInvioS_file* apri_file(const char* nome); void chiudi_file(TInvioS_file* trasfile); + TConfig& config() {return *_configfile;}; TInvioS() {} ; virtual ~TInvioS() {} ; }; @@ -126,16 +118,12 @@ void TInvioS_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, TS } else if (code == "_CODPAG") { - TFilename configname = "cg7300a.ini"; - TConfig configfile(configname); - valore = configfile.get(str, "PAGAMENTI"); + valore = app().config().get(str, "PAGAMENTI"); } else if (code == "_OPZIONI") { TString in(s.get()); - TFilename configname = "cg7300a.ini"; - TConfig configfile(configname); - valore = configfile.get(in, "OPZIONI"); + valore = app().config().get(in, "OPZIONI"); } else if (code == "_IMPORTO") { @@ -206,7 +194,6 @@ TInvioS_file* TInvioS::apri_file(const char* nome) filename.ext("txt"); if (filename.exist()) remove(filename); - TInvioS_file* trasfile = new TInvioS_file(filename); trasfile->open(filename,'w'); trasfile->force_record_separator(); @@ -223,13 +210,16 @@ long TInvioS::i_sispac_movcont(const bool invio) { TRectype da(LF_MOV); TRectype a(LF_MOV); - da.put(MOV_DATAREG, _dataini); - a.put(MOV_DATAREG, _datafin); + TDate dataini = _msk->get_date(F_DATAINI); + TDate datafin = _msk->get_date(F_DATAFIN); + if (dataini.ok()) + da.put(MOV_DATAREG, dataini); + if (datafin.ok()) + a.put(MOV_DATAREG, datafin); TRelation rel(LF_MOV); rel.add(LF_RMOV, "NUMREG==NUMREG", 1); rel.add(LF_CLIFO, "TIPOCF==TIPO|CODCF==CODCF", 1); TCursor cur(&rel, "", 2, &da, &a); - const long cur_items = cur.items(); if (cur_items != 0) { @@ -303,14 +293,21 @@ long TInvioS::i_sispac_moviva(const bool invio) return 0; } -long TInvioS::i_sispac_clifor(const bool invio) +long TInvioS::i_sispac_clifor(const char* tipocf, const bool invio) { - TInvioS_file* trasfile = apri_file("clifor.txt"); + TString80 nomefile = "FILE"; + nomefile << tipocf; + TInvioS_file* trasfilecf = apri_file(_configfile->get(nomefile, "OPZIONI")); TRelation rel(LF_CLIFO); rel.add(LF_COMUNI, "STATO==STATOCF|COM==COMCF", 1); rel.add(LF_ANAGFIS,"CODANAGR==CODANAGPER", 1); rel.add(LF_ANAG,"TIPOA==TIPOPERS|CODANAGR==CODANAGPER", 1); + TString80 filtro; + filtro = "20->TIPOCF == \""; + filtro << tipocf; + filtro << "\""; TCursor cur(&rel); + cur.setfilter(filtro, TRUE); const long cur_items = cur.items(); if (cur_items != 0 && invio) { @@ -319,80 +316,60 @@ long TInvioS::i_sispac_clifor(const bool invio) for (cur = 0; cur.pos() < cur_items; ++(cur)) { TRecord_text rec; - const char tipocf = cur.curr().get_char(CLI_TIPOCF); - if (tipocf == 'C') - rec.set_type("C"); - else - rec.set_type("F"); - trasfile->autoload(rec, cur); - trasfile->write(rec); + rec.set_type(tipocf); + trasfilecf->autoload(rec, cur); + trasfilecf->write(rec); } } - chiudi_file(trasfile); - return cur_items+cur_items; + chiudi_file(trasfilecf); + return 0; } //metodone globale che chiama, come un menu, i vari sottometodi in base alle scelte sulla maschera void TInvioS::invio_sispac() { - //prende i parametri dal file di configurazione dell'applicazione - TFilename configname = "cg7300a.ini"; - TConfig configfile(configname); - - //prepara il file su cui scrivere, ovvero il _trasfile - TFilename filename = _msk->get(F_DESTINAZIONE); - filename.add(configfile.get("FILEMOVIM", "OPZIONI")); - if (fexist(filename)) - remove(filename); - - _trasfile = new TInvioS_file(filename); - _trasfile->open(filename,'w'); - if (_msk->get_bool(F_CLIFOR)) - i_sispac_clifor(); + { + i_sispac_clifor("C"); + i_sispac_clifor("F"); + } if (_msk->get_bool(F_MOVCONT)) { + TString80 filename = _configfile->get("FILEM", "OPZIONI"); + _trasfile = apri_file(filename); i_sispac_movcont(); i_sispac_moviva(); + chiudi_file(_trasfile); } - _trasfile->close(); - delete _trasfile; - _trasfile = NULL; } bool TInvioS::create() { _msk = new TInvioS_mask(); - _trasfile = NULL; + TFilename configname = "cg7300a.ini"; + configname.custom_path(); + _configfile = new TConfig(configname); return TSkeleton_application::create(); } bool TInvioS::destroy() { - if (_trasfile) - delete _trasfile; - delete _msk; - + delete _configfile; + delete _msk; return TSkeleton_application::destroy(); } void TInvioS::main_loop() { - TFilename configname = "cg7300a.ini"; - configname.custom_path(); - TConfig configfile(configname); - _msk->set(F_NUMEROINVIO, configfile.get_int("NUMEROINVIO","OPZIONI")+1); - _msk->set(F_DATAINI, configfile.get("DATA","OPZIONI")); - _msk->set(F_DESTINAZIONE, configfile.get("PERCORSO","OPZIONI")); - + _msk->set(F_NUMEROINVIO, _configfile->get_int("NUMEROINVIO","OPZIONI")+1); + _msk->set(F_DATAINI, _configfile->get("DATA","OPZIONI")); + _msk->set(F_DESTINAZIONE, _configfile->get("PERCORSO","OPZIONI")); while (_msk->run() != K_QUIT) { - _totale = false; - _finemov = false; - configfile.set("NUMEROINVIO", _msk->get(F_NUMEROINVIO),"OPZIONI"); - configfile.set("DATA", _msk->get_date(F_DATAFIN),"OPZIONI"); - configfile.set("PERCORSO", _msk->get(F_DESTINAZIONE),"OPZIONI"); - configfile.set_paragraph("CAUSALI"); + _configfile->set("NUMEROINVIO", _msk->get(F_NUMEROINVIO),"OPZIONI"); + _configfile->set("DATA", _msk->get_date(F_DATAFIN),"OPZIONI"); + _configfile->set("PERCORSO", _msk->get(F_DESTINAZIONE),"OPZIONI"); + _configfile->set_paragraph("PAGAMENTI"); _dataini = _msk->get_date(F_DATAINI); _datafin = _msk->get_date(F_DATAFIN); const char tipoinvio = _msk->get(F_TIPOINVIO)[0]; diff --git a/cg/cg7300a.ini b/cg/cg7300a.ini index c75a83d9b..d8b1fa2b6 100755 --- a/cg/cg7300a.ini +++ b/cg/cg7300a.ini @@ -1,7 +1,8 @@ [OPZIONI] DATA = -FILECLIFO = clifo.txt -FILEMOVIM = movim.txt +FILEC = cli.txt +FILEF = for.txt +FILEM = mov.txt NUMEROINVIO = PERCORSO = c:\temp\ diff --git a/cg/cg7300a.uml b/cg/cg7300a.uml index ebed8fdfd..b397f0fbf 100755 --- a/cg/cg7300a.uml +++ b/cg/cg7300a.uml @@ -23,58 +23,46 @@ BEGIN FLAGS "D" END -GROUPBOX DLG_NULL 76 6 +GROUPBOX DLG_NULL 76 4 BEGIN PROMPT 2 4 "Dati da inviare" END BOOLEAN F_CLIFOR BEGIN - PROMPT 3 7 "Clienti/Fornitori" + PROMPT 3 5 "Clienti/Fornitori" END BOOLEAN F_MOVCONT BEGIN - PROMPT 3 8 "Movimenti" + PROMPT 3 6 "Movimenti" MESSAGE TRUE,ENABLE F_DATAFIN END LISTBOX F_TIPOINVIO 20 BEGIN - PROMPT 2 10 "Invio a " + PROMPT 2 8 "Invio a " ITEM "S|Sispac/Cosmo" END STRING F_DESTINAZIONE 20 BEGIN - PROMPT 2 11 "Destinazione " + PROMPT 2 9 "Destinazione " END NUMBER F_NUMEROINVIO 2 BEGIN - PROMPT 2 12 "Numero invio " + PROMPT 2 10 "Numero invio " END DATE F_DATAINI BEGIN - PROMPT 20 12 "Data iniz. " + PROMPT 20 10 "Data iniz. " END DATE F_DATAFIN BEGIN - PROMPT 44 12 "Data fin. " -END - -BUTTON F_RIPRISTINA 20 -BEGIN - PROMPT 2 14 "Annulla invio" - MESSAGE SHOW,F_DATARIPRISTINO|ENABLE,F_DATARIPRISTINO -END - -DATE F_DATARIPRISTINO -BEGIN - PROMPT 25 14 "Annulla invio fino al " - FLAGS "HD" + PROMPT 44 10 "Data fin. " END BUTTON DLG_OK 9 2