// Ricezione dati da sistema #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "cglib04.h" #include "cglib.h" #include "cg2103.h" #include "saldacon.h" #include "cg6600.h" class TRic_tab : public TApplication { TTable* _tab_tra; TLocalisamfile* _caus,*_rcaus,*_clifo,*_pcon,*_mov,*_rmov,*_rmoviva; TLocalisamfile* _saldi,*_occas,*_part,*_scad,*_pagsca; TIsamtempfile* _tcaus,*_trcaus,*_tclifo,*_tpcon,*_tmov,*_trmov,*_triva; TIsamtempfile* _toccas,*_tpart,*_tscad,*_tpagsca; TTable* _reg; TTransfer_file _tras_file; TArray _aggiorna; char _scelta, _ric_auto; TSaldo_agg _sld; TProgind* _prog; int _numinv,_nultras,_annoes,_g,_c,_nrig,_nrata; TString _trasf,_ragsoc_dittar,_sigle_file,_std,_key,_nomeid,_dittainv; long _dittaric,_numrec,_nreg,_s,_ndoc,_npiva,_nupiva; TDate _dataultras,_datareg,_dreg,_ddoc; TString _uselab,_record,_nrec_file,_creg,_ccau,_tdoc,_cod_com; bool _prima_volta,_nprot_att,_nprot_pas; long _protiva,_uprotiva,_nprotiva,_nuprotiva,_numreg,_numreg_p,_numreg_piva,_nuovareg; char _sez; real _importo,_totdoc; TString _tmpcaus,_tmprcaus,_tmpclifo,_tmpcon,_tmpmov,_tmprmov,_tmpriva; TString _tmpoccas,_tmppart,_tmpscad,_tmppagsca; public: TString _titolo; virtual bool create(); virtual bool destroy(); virtual bool menu(MENU_TAG m); virtual void on_config_change(); bool main_loop(); bool video(); bool leggi_trasfer(); bool controlli(); void ditta_ricevente(); bool controllo_pre_ricezione(); void leggi_record_controllo(); void apri_file_temp(); void chiudi_file_temp(); void setta_parametri_record(const TString& sigla,const TString& flag); void trasferimento(); void ricevi_causali(TString& key, char sigla); void cancella_righe_causali(TString& codcaus); void scrivi_righe_causali(TString& codcaus, char sigla); void ricevi_clifo(TString& key, char sigla); void ricevi_pcon(TString& key, char sigla); void conto(TRectype& pcon,char flag,bool esiste); void sottoconto(TRectype& pcon,char flag,bool esiste); void scrivi_pcon(TRectype& pcon,bool esiste); void ricevi_movPN(TString& key, char sigla); void scrivi_righePN(long numreg); void ricevi_movIVA(TString& key, char sigla); void scrivi_righeIVA(long numreg); void ricevi_movSC(TString& key,char sigla); long esiste_numreg(long nreg); void num_protocollo(); long controlli_primanota(); long ulnumprot_reg(int anno,TString& codreg); long ultima_registrazione(); void aggiorna_reg(int anno,TString& codreg,long ulnum); char ricerca_causale(TString& field); bool esiste_partita(TString& key); void rigaErata(char,int,int,long,int,TString&,int,int); void aggiorna_temp_scad(char,int,int,long,int,TString&,int,int,int,int); bool occasionali(TString& ocfpi); long nuovaregSC(long nreg); TRic_tab(char ric_tab_mov, char ric_auto = '\0'); }; HIDDEN TRic_tab& app() { return (TRic_tab &) main_app(); } TRic_tab::TRic_tab(char ric_tab_mov, char ric_auto) : _scelta(toupper(ric_tab_mov)), _ric_auto(toupper(ric_auto)) { if (_scelta == 'T') _titolo = "Ricezione tabelle"; if (_scelta == 'M') _titolo = "Ricezione movimenti"; } void TRic_tab::on_config_change() { TPartita::carica_allineamento(); // Necessario per utilizzare l'oggetto TPartita con un corretto allineamento } bool TRic_tab::create() { TApplication::create(); _tab_tra = new TTable ("%TRA"); _reg = new TTable ("REG"); if (_scelta == 'T') { _caus = new TLocalisamfile (LF_CAUSALI); _rcaus = new TLocalisamfile (LF_RCAUSALI); _clifo = new TLocalisamfile (LF_CLIFO); _pcon = new TLocalisamfile (LF_PCON); } else { _mov = new TLocalisamfile (LF_MOV); _rmov = new TLocalisamfile (LF_RMOV); _rmoviva = new TLocalisamfile (LF_RMOVIVA); _saldi = new TLocalisamfile (LF_SALDI); _occas = new TLocalisamfile (LF_OCCAS); _part = new TLocalisamfile (LF_PARTITE); _scad = new TLocalisamfile (LF_SCADENZE); _pagsca = new TLocalisamfile (LF_PAGSCA); } _numrec = 1; _prima_volta = TRUE; _aggiorna.destroy(); _numreg_p = 0; _numreg_piva = 0; _nreg = 0; _sld.reset(); dispatch_e_menu (BAR_ITEM(1)); return TRUE; } bool TRic_tab::destroy() { delete _tab_tra; delete _reg; if (_scelta == 'T') { delete _caus; delete _rcaus; delete _clifo; delete _pcon; } else { delete _mov; delete _rmov; delete _rmoviva; delete _saldi; delete _occas; delete _part; delete _scad; delete _pagsca; } return TApplication::destroy(); } void TRic_tab::leggi_record_controllo() { _tras_file.read_control_rec(); _record = _tras_file.record(); } bool TRic_tab::main_loop() { int posiz; _dittaric = get_firm(); if (_ric_auto == 'A') { leggi_trasfer(); if (_scelta == 'T') { apri_file_temp(); trasferimento(); posiz = _tras_file.num('Z'); //Ritorna la posizione della sigla all'interno dell'indice if (posiz >= 0) { setta_parametri_record(" ","C"); //message_box("Aggiornamento tabelle terminato: proseguire con controllo movimenti"); leggi_record_controllo(); TString str; str.spaces(60); _record.overwrite(str,241); _tras_file.write_control_rec(_record,1024); } else { chiudi_file_temp(); //message_box("Trasferimento interamente completato: proseguire per cancellare il file"); setta_parametri_record(" ","*"); //_tras_file.remove_all(); //setta_parametri_record(" "," "); } } else if (_scelta == 'M') { apri_file_temp(); trasferimento(); chiudi_file_temp(); //message_box("Trasferimento interamente completato: proseguire per cancellare il file"); setta_parametri_record(" ","*"); //_tras_file.remove_all(); //setta_parametri_record(" "," "); } } else { if (_scelta == 'T') { if (video()) { if (_std == "") if (!controllo_pre_ricezione()) return FALSE; apri_file_temp(); trasferimento(); posiz = _tras_file.num('Z'); //Ritorna la posizione della sigla all'interno dell'indice if (posiz >= 0) { setta_parametri_record(" ","C"); message_box("Aggiornamento tabelle terminato: proseguire con controllo movimenti"); leggi_record_controllo(); TString str; str.spaces(60); _record.overwrite(str,241); _tras_file.write_control_rec(_record,1024); } else { chiudi_file_temp(); message_box("Trasferimento interamente completato: proseguire per cancellare il file"); setta_parametri_record(" ","*"); _tras_file.remove_all(); setta_parametri_record(" "," "); } } } else if (_scelta == 'M') { if (video()) { apri_file_temp(); trasferimento(); chiudi_file_temp(); message_box("Trasferimento interamente completato: proseguire per cancellare il file"); setta_parametri_record(" ","*"); _tras_file.remove_all(); setta_parametri_record(" "," "); } } } return FALSE; } void TRic_tab::trasferimento() { char uselab; TString key = ""; int posiz,i; int last_tab; char sigla; TString message; uselab = (_tras_file.ult_file())[0]; posiz = _tras_file.num(uselab); //Ritorna la posizione della sigla all'interno dell'indice key = _tras_file.key(); key.trim(); leggi_record_controllo(); if (_scelta == 'T') last_tab = _tras_file.last_tab(); else if (_scelta == 'M') last_tab = _tras_file.last_mov(); for (i = posiz; i < last_tab;i++) { long numero = atol(_record.mid( ((i * 6) + 95),6)); if (numero == 0) continue; long nrec = ((_tras_file.nrec(i))+1); sigla = _tras_file.name(i)[0]; long cicli; switch (sigla) { case 'W': message = "Ricezione tabella causali in corso... Prego attendere."; cicli = _tcaus->items(); break; case 'A': message = "Ricezione anagrafica Clienti / Fornitori in corso... Prego attendere."; cicli = _tclifo->items(); break; case 'P': message = "Ricezione anagrafica Piano dei Conti in corso... Prego attendere."; cicli = _tpcon->items(); break; case 'Z': message = "Ricezione Movimenti di primanota in corso... Prego attendere."; cicli = _tmov->items(); break; case 'U': message = "Ricezione Movimenti iva in corso... Prego attendere."; cicli = _tmov->items(); break; case 'B': message = "Ricezione Movimenti saldaconto in corso... Prego attendere."; cicli = _tpart->items(); break; default: break; } _prog = new TProgind(cicli,message,FALSE); if (_scelta == 'T') { if (sigla == 'W') ricevi_causali(key,sigla); if (sigla == 'A') ricevi_clifo(key,sigla); if (sigla == 'P') ricevi_pcon(key,sigla); } else if (_scelta == 'M') { if (sigla == 'Z') { ricevi_movPN(key,sigla); _sld.registra(); } else if (sigla == 'U') ricevi_movIVA(key,sigla); else if (sigla == 'B') ricevi_movSC(key,sigla); } delete _prog; key = ""; //Altrimenti in caso di ripartenza mi ripristina sempre la situazione } } void TRic_tab::ricevi_causali(TString& key, char uselab) { TString str; char flag = _tras_file.flg_agg(uselab); _tcaus->setkey(1); if (key.empty()) _tcaus->first(); else { TString causale (key.mid(0,3)); _tcaus->zero(); _tcaus->put(CAU_CODCAUS, causale); _tcaus->read(); } for(; !_tcaus->eof(); _tcaus->next()) { _prog->addstatus(1); TString codcaus = _tcaus->get(CAU_CODCAUS); _caus->curr() = _tcaus->curr(); if (_caus->read() == NOERR) // Esiste la testata { if (flag == 'N') { leggi_record_controllo(); TString chiave; chiave.format("%3s",(const char*) codcaus); TString sigla (format("%c", uselab)); str = _record.overwrite(sigla,240); str = _record.overwrite(chiave,241); _tras_file.write_control_rec(str,1024); continue; } else if (flag == 'D') { TString descr = _tcaus->get(CAU_DESCR); _caus->put(CAU_DESCR, descr); _caus->rewrite(); } else if (flag == 'T') { scrivi_righe_causali(codcaus,uselab); _caus->zero(); _caus->curr() = _tcaus->curr(); _caus->rewrite(); } } else { scrivi_righe_causali(codcaus,uselab); _caus->zero(); _caus->curr() = _tcaus->curr(); _caus->write(); } leggi_record_controllo(); TString chiave; chiave.format("%3s",(const char*) codcaus); TString sigla (format("%c", uselab)); str = _record.overwrite(sigla,240); str = _record.overwrite(chiave,241); _tras_file.write_control_rec(str,1024); } } void TRic_tab::cancella_righe_causali(TString& codcaus) { _rcaus->setkey(1); _rcaus->zero(); _rcaus->put(RCA_CODCAUS, codcaus); TRectype rcau (LF_RCAUSALI); rcau = _rcaus->curr(); for (_rcaus->read(); !_rcaus->eof(); _rcaus->next()) { if (_rcaus->curr() > rcau) break; _rcaus->remove(); } } void TRic_tab::scrivi_righe_causali(TString& codcaus, char uselab) { TString str; cancella_righe_causali(codcaus); _trcaus->setkey(1); _trcaus->zero(); _trcaus->put(RCA_CODCAUS, codcaus); TRectype rcau (LF_RCAUSALI); rcau = _trcaus->curr(); for (_trcaus->read(); !_trcaus->eof(); _trcaus->next()) { if (_trcaus->curr() > rcau) break; _rcaus->curr() = _trcaus->curr(); _rcaus->write(); leggi_record_controllo(); TString chiave; chiave.format("%3s",(const char*) codcaus); TString sigla (format("%c", uselab)); str = _record.overwrite(sigla,240); str = _record.overwrite(chiave,241); _tras_file.write_control_rec(str,1024); } } void TRic_tab::ricevi_clifo(TString& key, char uselab) { TString str; char flag = _tras_file.flg_agg(uselab); _tclifo->setkey(1); if (key.empty()) _tclifo->first(); else { char tipo = (key.mid(0,1))[0]; long codice = atol(key.mid(1,6)); _tclifo->zero(); _tclifo->put(CLI_TIPOCF, tipo); _tclifo->put(CLI_CODCF, codice); _tclifo->read(); } for(; !_tclifo->eof(); _tclifo->next()) { _prog->addstatus(1); char tipocf = _tclifo->get_char(CLI_TIPOCF); long codcf = _tclifo->get_long(CLI_CODCF); _clifo->curr() = _tclifo->curr(); if (_clifo->read() == NOERR) // Esiste gia' il cliente { if (flag == 'N') { leggi_record_controllo(); TString chiave; chiave.format("%c%06ld", tipocf,codcf); TString sigla (format("%c", uselab)); str = _record.overwrite(sigla,240); str = _record.overwrite(chiave,241); _tras_file.write_control_rec(str,1024); continue; } else if (flag == 'D') { TString ragsoc = _tclifo->get(CLI_RAGSOC); TString ind = _tclifo->get(CLI_INDCF); TString civ = _tclifo->get(CLI_CIVCF); TString com = _tclifo->get(CLI_COMCF); TString cap = _tclifo->get(CLI_CAPCF); TString cofi = _tclifo->get(CLI_COFI); TString paiv = _tclifo->get(CLI_PAIV); TString ptel = _tclifo->get(CLI_PTEL); TString tel = _tclifo->get(CLI_TEL); _clifo->put(CLI_RAGSOC, ragsoc); _clifo->put(CLI_INDCF, ind); _clifo->put(CLI_CIVCF, civ); _clifo->put(CLI_COMCF, com); _clifo->put(CLI_CAPCF, cap); _clifo->put(CLI_COFI, cofi); _clifo->put(CLI_PAIV, paiv); _clifo->put(CLI_PTEL, ptel); _clifo->put(CLI_TEL, tel); _clifo->rewrite(); } else if (flag == 'T') { _clifo->zero(); _clifo->curr() = _tclifo->curr(); _clifo->rewrite(); } } else { _clifo->zero(); _clifo->curr() = _tclifo->curr(); _clifo->write(); } leggi_record_controllo(); TString chiave; chiave.format("%c%06ld", tipocf, codcf); TString sigla (format("%c", uselab)); str = _record.overwrite(sigla,240); str = _record.overwrite(chiave,241); _tras_file.write_control_rec(str,1024); } } void TRic_tab::ricevi_pcon(TString& key, char uselab) { TString str; bool esiste; TRectype pcon (LF_PCON); char flag = _tras_file.flg_agg(uselab); char f_IV = _tras_file.flg_agg_IV(uselab); _tpcon->setkey(1); if (key.empty()) _tpcon->first(); else { int gruppo = atoi(key.mid(0,3)); int conto = atoi(key.mid(3,3)); long sottoc = atol(key.mid(6,6)); _tpcon->zero(); _tpcon->put(PCN_GRUPPO, gruppo); if (conto != 0) _tpcon->put(PCN_CONTO, conto); if (sottoc != 0) _tpcon->put(PCN_SOTTOCONTO, sottoc); _tpcon->read(); } for(; !_tpcon->eof(); _tpcon->next()) { _prog->addstatus(1); int g = _tpcon->get_int (PCN_GRUPPO); int c = _tpcon->get_int (PCN_CONTO); long s = _tpcon->get_long(PCN_SOTTOCONTO); _pcon->curr() = _tpcon->curr(); if (_pcon->read() == NOERR) // Esiste gia' sul Piano dei Conti { esiste = TRUE; if (flag == 'N') { leggi_record_controllo(); TString chiave; chiave.format("%03d%03d%06ld", g, c, s); TString sigla (format("%c", uselab)); str = _record.overwrite(sigla,240); str = _record.overwrite(chiave,241); _tras_file.write_control_rec(str,1024); continue; } else if (flag == 'D') { TString descr = _tpcon->get(PCN_DESCR); _pcon->put(PCN_DESCR, descr); _pcon->rewrite(); } else if (flag == 'T') scrivi_pcon(pcon,esiste); } else // Non esiste sull'archivio effettivo { esiste = FALSE; scrivi_pcon(pcon,esiste); } TRecnotype rec; if (esiste) rec = _pcon->recno(); if (f_IV == 'T') { if (g != 0 && c == 0) conto(pcon,flag,esiste); if (g != 0 && c != 0 && s != 0) sottoconto(pcon,flag,esiste); } if (esiste) _pcon->readat(rec); if ( (flag == 'T' && esiste) || !esiste) _pcon->curr() = pcon; if (esiste) _pcon->rewrite(); else _pcon->write(); leggi_record_controllo(); TString chiave; chiave.format("%03d%03d%06ld", g, c, s); TString sigla (format("%c", uselab)); str = _record.overwrite(sigla,240); str = _record.overwrite(chiave,241); _tras_file.write_control_rec(str,1024); } } void TRic_tab::scrivi_pcon(TRectype& pcon,bool esiste) { int g = _tpcon->get_int (PCN_GRUPPO); int c = _tpcon->get_int (PCN_CONTO); long s = _tpcon->get_long(PCN_SOTTOCONTO); TString descr = _tpcon->get (PCN_DESCR); int indbil = _tpcon->get_int (PCN_INDBIL); char tmcf = _tpcon->get_char(PCN_TMCF); bool stsottbil = _tpcon->get_bool(PCN_STSOTTBIL); bool compens = _tpcon->get_bool(PCN_COMPENS); int tipospric = _tpcon->get_int (PCN_TIPOSPRIC); TString codcbl = _tpcon->get (PCN_CODCBL); bool stsottab = _tpcon->get_bool(PCN_STSOTTAB); char sezsaldi = _tpcon->get_char(PCN_SEZSALDI); bool sospeso = _tpcon->get_bool(PCN_SOSPESO); int ricser = _tpcon->get_int (PCN_RICSER); pcon.zero(); pcon.put(PCN_GRUPPO, g); if (c != 0) pcon.put(PCN_CONTO, c); if (s != 0) pcon.put(PCN_SOTTOCONTO, s); pcon.put(PCN_DESCR, descr); pcon.put(PCN_INDBIL, indbil); pcon.put(PCN_TMCF, tmcf); pcon.put(PCN_STSOTTBIL, stsottbil); pcon.put(PCN_COMPENS, compens); pcon.put(PCN_TIPOSPRIC, tipospric); pcon.put(PCN_CODCBL, codcbl); pcon.put(PCN_STSOTTAB, stsottab); pcon.put(PCN_SEZSALDI, sezsaldi); pcon.put(PCN_SOSPESO, sospeso); pcon.put(PCN_RICSER, ricser); } void TRic_tab::conto(TRectype& pcon,char flag,bool esiste) { int g = _tpcon->get_int(PCN_GRUPPO); int c = _tpcon->get_int(PCN_CONTO); TString sez = _tpcon->get (PCN_SEZIVD); TString let = _tpcon->get (PCN_LETTIVD); TString numr = _tpcon->get (PCN_NUMRIVD); int num = _tpcon->get_int(PCN_NUMIVD); if (sez.not_empty()) { if (!esiste || (esiste && flag == 'T') ) { pcon.put (PCN_SEZIVD, sez); pcon.put (PCN_LETTIVD, let); pcon.put (PCN_NUMRIVD, numr); pcon.put (PCN_NUMIVD, num); pcon.zero(PCN_SEZIVDOPP); pcon.zero(PCN_LETTIVDOPP); pcon.zero(PCN_NUMRIVDOPP); pcon.zero(PCN_NUMIVDOPP); _tras_file.annulla_classi(g,c,TRUE); } } else { if (esiste && flag == 'T') { pcon.put (PCN_SEZIVD, sez); pcon.put (PCN_LETTIVD, let); pcon.put (PCN_NUMRIVD, numr); pcon.put (PCN_NUMIVD, num); pcon.zero(PCN_SEZIVDOPP); pcon.zero(PCN_LETTIVDOPP); pcon.zero(PCN_NUMRIVDOPP); pcon.zero(PCN_NUMIVDOPP); _tras_file.annulla_classi(g,c,TRUE); } } } void TRic_tab::sottoconto(TRectype& pcon,char flag,bool esiste) { int g = _tpcon->get_int(PCN_GRUPPO); int c = _tpcon->get_int(PCN_CONTO); TString sez = _tpcon->get (PCN_SEZIVD); TString let = _tpcon->get (PCN_LETTIVD); TString numr = _tpcon->get (PCN_NUMRIVD); int num = _tpcon->get_int(PCN_NUMIVD); TString sezop = _tpcon->get (PCN_SEZIVDOPP); TString letop = _tpcon->get (PCN_LETTIVDOPP); TString numrop = _tpcon->get (PCN_NUMRIVDOPP); int numop = _tpcon->get_int(PCN_NUMIVDOPP); if (sez.not_empty()) { if (!esiste || (esiste && flag == 'T') ) { pcon.put(PCN_SEZIVD, sez); pcon.put(PCN_LETTIVD, let); pcon.put(PCN_NUMRIVD, numr); pcon.put(PCN_NUMIVD, num); pcon.put(PCN_SEZIVDOPP, sezop); pcon.put(PCN_LETTIVDOPP, letop); pcon.put(PCN_NUMRIVDOPP, numrop); pcon.put(PCN_NUMIVDOPP, numop); _tras_file.annulla_classi(g,c,FALSE); } } else { if (sezop.not_empty()) { if (!esiste || (esiste && flag == 'T') ) { pcon.put(PCN_SEZIVDOPP, sezop); pcon.put(PCN_LETTIVDOPP, letop); pcon.put(PCN_NUMRIVDOPP, numrop); pcon.put(PCN_NUMIVDOPP, numop); } } else { pcon.zero(PCN_SEZIVDOPP); pcon.zero(PCN_LETTIVDOPP); pcon.zero(PCN_NUMRIVDOPP); pcon.zero(PCN_NUMIVDOPP); } } } long TRic_tab::esiste_numreg(long numulreg) { TLocalisamfile mov (LF_MOV); do { numulreg++; mov.setkey(1); mov.zero(); mov.put(MOV_NUMREG, numulreg); } while (mov.read() == NOERR); return numulreg; } long TRic_tab::ultima_registrazione() { if (_nreg == 0) { TLocalisamfile mov (LF_MOV); mov.last(); return (mov.get_long(MOV_NUMREG)); } else return _nreg; } void TRic_tab::num_protocollo() { _protiva = _tmov->get_long(MOV_PROTIVA); _uprotiva = _tmov->get_long(MOV_UPROTIVA); if (_protiva == 0) _uprotiva = 0; _nprotiva = _protiva; _nuprotiva = _uprotiva; } long TRic_tab::ulnumprot_reg(int anno,TString& cr) { TRegistro rg (cr, anno); return rg.protocol(); } void TRic_tab::aggiorna_reg(int anno,TString& codreg,long ulnum) { TTable reg ("REG"); TString16 dep; if (real::is_natural(codreg)) dep.format("%04d%03s", anno,(const char*) codreg); else dep.format("%04d%-3s", anno,(const char*) codreg); reg.zero(); reg.put("CODTAB", (const char*) dep); if (reg.read() == NOERR) { if (_nprotiva > ulnum ) reg.put("I5", _nprotiva); if (_nuprotiva > ulnum ) reg.put("I5", _nuprotiva); reg.rewrite(); } } long TRic_tab::controlli_primanota() { TTable tpd ("%TPD"); bool corrisp = FALSE; TDate datareg; int anno; long ulnum = 0; TString16 tmp; TString tipodoc,codreg; char tipocf = _tmov->get_char(MOV_TIPO); int tiporeg; if (tipocf == 'C') tiporeg = 1; else if (tipocf == 'F') tiporeg = 2; codreg = _tmov->get(MOV_REG); tipodoc = _tmov->get(MOV_TIPODOC); datareg = _tmov->get_date(MOV_DATAREG); anno = datareg.year(); tpd.zero(); tpd.put("CODTAB", (const char*) tipodoc); if (tpd.read() == NOERR) corrisp = tpd.get_bool("B0"); if (codreg.not_empty() && !corrisp) { if ( ( (tiporeg == 1 && (_nprot_att || _protiva == 0) ) ) || ( (tiporeg == 2 && (_nprot_pas || _protiva == 0) ) ) ) { ulnum = ulnumprot_reg(anno,codreg); _nprotiva = ulnum + 1; if (_uprotiva != 0) _nuprotiva = (_nprotiva - ulnum) + _uprotiva; } } return ulnum; } char TRic_tab::ricerca_causale(TString& causale) { TLocalisamfile cau (LF_CAUSALI); char movap = ' '; if (real::is_natural(causale)) causale.format("%03s", (const char*) causale); else causale.format("%-3s", (const char*) causale); cau.setkey(1); cau.zero(); cau.put("CODCAUS", causale); if (cau.read() == NOERR) movap = cau.get_char("MOVAP"); return movap; } void TRic_tab::scrivi_righePN(long numreg) { TString str; _trmov->setkey(1); _trmov->zero(); _trmov->put(RMV_NUMREG, numreg); TRectype rmov (LF_RMOV); rmov = _trmov->curr(); for (_trmov->read(); !_trmov->eof(); _trmov->next()) { if (_trmov->curr() > rmov) break; int g = _trmov->get_int (RMV_GRUPPO); int c = _trmov->get_int (RMV_CONTO); long s = _trmov->get_long(RMV_SOTTOCONTO); char sez = _trmov->get_char(RMV_SEZIONE); real imp ( _trmov->get_real(RMV_IMPORTO) ); _trmov->put(RMV_NUMREG, _nreg); _rmov->curr() = _trmov->curr(); _rmov->write(); _sld.aggiorna(g,c,s,imp,sez); } } void TRic_tab::ricevi_movPN(TString& key, char uselab) { TString str; long numulreg; TRectype recmov (LF_MOV); char flag = _tras_file.flg_agg(uselab); _nprot_att = _tras_file.numprot_att(); _nprot_pas = _tras_file.numprot_pas(); _tmov->setkey(1); if (key.empty()) _tmov->first(); else { long numreg = atol(key.mid(0,7)); _tmov->zero(); _tmov->put(MOV_NUMREG, numreg); _tmov->read(); } for(; !_tmov->eof(); _tmov->next()) { _prog->addstatus(1); long nreg = _tmov->get_long(MOV_NUMREG); long nuova_reg = _tmov->get_long("TNUMREG" ); if (nuova_reg == 0) { numulreg = ultima_registrazione(); // reperisco il numero ultima registrazione _nreg = esiste_numreg(numulreg); } else _nreg = nuova_reg; TRecnotype rec = _tmov->recno(); // Salvo il nuovo numero di _tmov->put("TNUMREG", _nreg); // registrazione sul file di lavoro _tmov->rewrite(); _tmov->readat(rec); int annoes = _tmov->get_int(MOV_ANNOES); recmov = _tmov->curr(); _mov->setkey(1); _mov->zero(); _mov->put(MOV_NUMREG, _nreg); if (_mov->read() != NOERR) // Se non esiste la testata { num_protocollo(); // Riattribuzione numero di protocollo long ulnum = controlli_primanota(); recmov.put(MOV_NUMREG, _nreg); recmov.put(MOV_PROTIVA, _nprotiva); recmov.put(MOV_UPROTIVA, _nuprotiva); _mov->zero(); _mov->curr() = recmov; _mov->write(); TString codreg (_tmov->get (MOV_REG)); TString codcaus (_tmov->get (MOV_CODCAUS)); TDate datareg (_tmov->get_date(MOV_DATAREG)); int anno = datareg.year(); aggiorna_reg(anno,codreg,ulnum); // Aggiorna il registro _sld.set_anno_es(annoes); _sld.set_movprovv(FALSE); _sld.set_num_ulmov(_nreg); _sld.set_data_ulmov(datareg); char movap = ricerca_causale(codcaus); if (movap == 'A') _sld.set_tipo_saldo(apertura); else if (movap == 'C') _sld.set_tipo_saldo(chiusura); // if (movap == 'A') // Sostituire con la parte commentata sopra // _sld.set_movap(TRUE); scrivi_righePN(nreg); _sld.registra(); _sld.reset(); } leggi_record_controllo(); TString chiave; chiave.format("%07ld", nreg); TString sigla (format("%c", uselab)); str = _record.overwrite(sigla,240); str = _record.overwrite(chiave,241); _tras_file.write_control_rec(str,1024); } } bool TRic_tab::occasionali(TString& ocfpi) { TString chiave; long prog = 0; bool esiste = FALSE; bool ric = TRUE; TString ocfpitemp = ocfpi; if (ocfpi.mid(0,3) == "RIC") { // TString nocfpi = _tmov->get("TOCFP"); // nocfpi.trim(); // if (nocfpi.empty()) // { _occas->setkey(1); _occas->zero(); for (_occas->first(); !_occas->eof(); _occas->next()) { TString cfpi = _occas->get(OCC_CFPI); if (cfpi.mid(0,3) == "RIC") prog = atol(cfpi.mid(3,13)); } prog++; chiave = format("%3s%13ld", (const char*) "RIC", prog); esiste = FALSE; ocfpi = chiave; } else { _occas->setkey(1); _occas->zero(); _occas->put("CFPI", ocfpi); if (_occas->read() == NOERR) { TRecnotype rec = _occas->recno(); _occas->setkey(1); _occas->zero(); for (_occas->first(); !_occas->eof(); _occas->next()) { TString cfpi = _occas->get(OCC_CFPI); if (cfpi.mid(0,3) == "RIC") prog = atol(cfpi.mid(3,13)); } prog++; chiave = format("%3s%13ld", (const char*) "RIC", prog); ocfpi = chiave; _occas->readat(rec); } } // } // else // { // _occas->setkey(1); // _occas->zero(); // _occas->put("CFPI", nocfpi); // _occas->read(); // esiste = TRUE; // ocfpi = nocfpi; // } _toccas->setkey(1); _toccas->zero(); _toccas->put(OCC_CFPI, ocfpitemp); _toccas->read(); _occas->curr() = _toccas->curr(); if (esiste) _occas->rewrite(); else { _occas->put(OCC_CFPI, ocfpi); _occas->write(); } return TRUE; } void TRic_tab::scrivi_righeIVA(long numreg) { TString str; _triva->setkey(1); _triva->zero(); _triva->put(RMI_NUMREG, numreg); TRectype riva (LF_RMOVIVA); riva = _triva->curr(); for (_triva->read(); !_triva->eof(); _triva->next()) { if (_triva->curr() > riva) break; _triva->put(RMI_NUMREG, _nuovareg); _rmoviva->curr() = _triva->curr(); _rmoviva->write(); } } void TRic_tab::ricevi_movIVA(TString& key, char uselab) { TString str; TRectype recmov (LF_MOV); char flag = _tras_file.flg_agg(uselab); _tmov->setkey(1); if (key.empty()) _tmov->first(); else { long numreg = atol(key.mid(0,7)); _tmov->zero(); _tmov->put(MOV_NUMREG, numreg); _tmov->read(); } for(; !_tmov->eof(); _tmov->next()) { _prog->addstatus(1); long nreg = _tmov->get_long(MOV_NUMREG); TString codreg = _tmov->get(MOV_REG); TString codcau = _tmov->get(MOV_CODCAUS); if (codreg.empty() || codcau.empty()) continue; _nuovareg = _tmov->get_long("TNUMREG"); TString ocfpi = _tmov->get(MOV_OCFPI); if (ocfpi.not_empty()) occasionali(ocfpi); // TRecnotype rec = _tmov->recno(); // Salvo il nuovo numero di // _tmov->put("TOCFP", ocfpi); // registrazione sul file di lavoro // _tmov->rewrite(); // _tmov->readat(rec); TDate data74ter ( _tmov->get_date(MOV_DATA74TER) ); TString codval ( _tmov->get (MOV_CODVALI) ); long codcf = _tmov->get_long(MOV_CODCF); real totdoc ( _tmov->get_real(MOV_TOTDOC) ); real cambioi ( _tmov->get_real(MOV_CAMBIOI) ); real corrlire ( _tmov->get_real(MOV_CORRLIRE) ); real corrval ( _tmov->get_real(MOV_CORRVALUTA) ); int annoiva = _tmov->get_int (MOV_ANNOIVA); _mov->setkey(1); _mov->zero(); _mov->put(MOV_NUMREG, _nuovareg); if (_mov->read() == NOERR) // Se non esiste la testata { _mov->put(MOV_DATA74TER, data74ter); _mov->put(MOV_CODVALI, codval); _mov->put(MOV_CODCF, codcf); _mov->put(MOV_TOTDOC, totdoc); _mov->put(MOV_CAMBIOI, cambioi); _mov->put(MOV_CORRLIRE, corrlire); _mov->put(MOV_CORRVALUTA, corrval); _mov->put(MOV_ANNOIVA, annoiva); _mov->put(MOV_OCFPI, ocfpi); _mov->rewrite(); scrivi_righeIVA(nreg); } leggi_record_controllo(); TString chiave; chiave.format("%07ld", nreg); TString sigla (format("%c", uselab)); str = _record.overwrite(sigla,240); str = _record.overwrite(chiave,241); _tras_file.write_control_rec(str,1024); } } long TRic_tab::nuovaregSC(long nreg) { long nuovareg = 0; _tmov->zero(); _tmov->put(MOV_NUMREG, nreg); if (_tmov->read() == NOERR) nuovareg = _tmov->get_long("TNUMREG"); return nuovareg; } bool TRic_tab::esiste_partita(TString& key) { TLocalisamfile part (LF_PARTITE); char tipoc = key.mid(0,1)[0]; int gruppo = atoi(key.mid(1,3)); int conto = atoi(key.mid(4,3)); long sottoc = atol(key.mid(7,6)); int anno = atoi(key.mid(13,4)); TString npart = key.mid(17,7); int nriga = atoi(key.mid(24,4)); part.zero(); part.put(PART_TIPOCF, tipoc); part.put(PART_GRUPPO, gruppo); part.put(PART_CONTO, conto); part.put(PART_SOTTOCONTO, sottoc); part.put(PART_ANNO, anno); part.put(PART_NUMPART, npart); part.put(PART_NRIGA, nriga); if (part.read() == NOERR) return TRUE; return FALSE; } void TRic_tab::aggiorna_temp_scad(char tipocf,int gruppo,int conto,long codcf,int anno,TString& numpart, int nriga,int nrata,int nuova_riga,int nuova_rata) { TRecnotype rec = _tscad->recno(); TIsamtempfile& scad = *_tscad; scad.setkey(1); scad.zero(); scad.put(SCAD_TIPOCF, tipocf); scad.put(SCAD_GRUPPO, gruppo); scad.put(SCAD_CONTO, conto); scad.put(SCAD_SOTTOCONTO, codcf); scad.put(SCAD_ANNO, anno); scad.put(SCAD_NUMPART, numpart); scad.put(SCAD_NRIGA, nriga); scad.put(SCAD_NRATA, nrata); if (scad.read() == NOERR) { scad.put(SCAD_TNRIGA, nuova_riga); scad.put(SCAD_TNRATA, nuova_rata); scad.rewrite(); } _tscad->readat(rec); } void TRic_tab::rigaErata(char tipocf,int gruppo,int conto,long codcf,int anno, TString& numpart,int nriga, int nrata) { TRecnotype rec = _tscad->recno(); TIsamtempfile& scad = *_tscad; scad.setkey(1); scad.zero(); scad.put(SCAD_TIPOCF, tipocf); scad.put(SCAD_GRUPPO, gruppo); scad.put(SCAD_CONTO, conto); scad.put(SCAD_SOTTOCONTO, codcf); scad.put(SCAD_ANNO, anno); scad.put(SCAD_NUMPART, numpart); scad.put(SCAD_NRIGA, nriga); scad.put(SCAD_NRATA, nrata); if (scad.read() == NOERR) { _nrig = scad.get_int(SCAD_TNRIGA); _nrata = scad.get_int(SCAD_TNRATA); } _tscad->readat(rec); } void TRic_tab::ricevi_movSC(TString& key, char uselab) { TString str; TPartita* newgame = NULL; bool chiave = FALSE; _tpart->setkey(1); if (key.empty()) _tpart->first(); else { char tipoc = key.mid(0,1)[0]; int gruppo = atoi(key.mid(1,3)); int conto = atoi(key.mid(4,3)); long sottoc = atol(key.mid(7,6)); int anno = atoi(key.mid(13,4)); TString npart = key.mid(17,7); int nriga = atoi(key.mid(24,4)); _tpart->zero(); _tpart->put(PART_TIPOCF, tipoc); _tpart->put(PART_GRUPPO, gruppo); _tpart->put(PART_CONTO, conto); _tpart->put(PART_SOTTOCONTO, sottoc); _tpart->put(PART_ANNO, anno); _tpart->put(PART_NUMPART, npart); _tpart->put(PART_NRIGA, nriga); _tpart->read(); chiave = TRUE; } for(; !_tpart->eof(); _tpart->next()) { _prog->addstatus(1); if (chiave) if (esiste_partita(key)) continue; long nreg = _tpart->get_long(PART_NREG); _nuovareg = nuovaregSC(nreg); int anno = _tpart->get_int (PART_ANNO); TString numpart = _tpart->get (PART_NUMPART); char tipocf = _tpart->get_char(PART_TIPOCF); int gruppo = _tpart->get_int (PART_GRUPPO); int conto = _tpart->get_int (PART_CONTO); long codcf = _tpart->get_long(PART_SOTTOCONTO); int nriga = _tpart->get_int (PART_NRIGA); int tipomov = _tpart->get_int (PART_TIPOMOV); TBill clifo; clifo.set(gruppo, conto, codcf, tipocf); newgame = new TPartita(clifo, anno, numpart); newgame->allinea(); TRiga_partite& partita = newgame->new_row(); int nuova_riga = partita.get_int(PART_NRIGA); // put data on partita partita.put(PART_TIPOMOV, _tpart->get_int (PART_TIPOMOV)); partita.put(PART_TIPOPAG, _tpart->get_int (PART_TIPOPAG)); partita.put(PART_NREG, _nuovareg); partita.put(PART_NUMRIG, _tpart->get_int (PART_NUMRIG)); partita.put(PART_DATAREG, _tpart->get_date(PART_DATAREG)); partita.put(PART_DATADOC, _tpart->get_date(PART_DATADOC)); partita.put(PART_DATAPAG, _tpart->get_date(PART_DATAPAG)); partita.put(PART_NUMDOC, _tpart->get (PART_NUMDOC)); partita.put(PART_REG, _tpart->get (PART_REG)); partita.put(PART_PROTIVA, _tpart->get_long(PART_PROTIVA)); partita.put(PART_CODCAUS, _tpart->get (PART_CODCAUS)); partita.put(PART_SEZ, _tpart->get (PART_SEZ)); partita.put(PART_IMPORTO, _tpart->get_real(PART_IMPORTO)); partita.put(PART_IMPOSTA, _tpart->get_real(PART_IMPOSTA)); partita.put(PART_CODVAL, _tpart->get (PART_CODVAL)); partita.put(PART_CAMBIO, _tpart->get_real(PART_CAMBIO)); partita.put(PART_IMPORTOVAL, _tpart->get_real(PART_IMPORTOVAL)); partita.put(PART_DATACAM, _tpart->get_date(PART_DATACAM)); partita.put(PART_IMPTOTDOC, _tpart->get_real(PART_IMPTOTDOC)); partita.put(PART_IMPTOTVAL, _tpart->get_real(PART_IMPTOTVAL)); partita.put(PART_RITENUTE, _tpart->get_real(PART_RITENUTE)); partita.put(PART_SEZABB, _tpart->get (PART_SEZABB)); partita.put(PART_ABBUONI, _tpart->get_real(PART_ABBUONI)); partita.put(PART_SEZDIFCAM, _tpart->get (PART_SEZDIFCAM)); partita.put(PART_DIFFCAM, _tpart->get_real(PART_DIFFCAM)); partita.put(PART_GRUPPOCL, _tpart->get_int (PART_GRUPPOCL)); partita.put(PART_CONTOCL, _tpart->get_int (PART_CONTOCL)); if (tipomov == 1) { _tscad->zero(); _tscad->put(SCAD_TIPOCF, tipocf); if (gruppo != 0) _tscad->put(SCAD_GRUPPO, gruppo); if (conto != 0) _tscad->put(SCAD_CONTO, conto); if (codcf != 0) _tscad->put(SCAD_SOTTOCONTO, codcf); _tscad->put(SCAD_ANNO, anno); _tscad->put(SCAD_NUMPART, numpart); _tscad->put(SCAD_NRIGA, nriga); TRectype scad (_tscad->curr()); for (_tscad->read(_isgteq); !_tscad->eof(); _tscad->next()) { TString rec = scad.get(SCAD_NUMPART); TString file = _tscad->get(SCAD_NUMPART); if (_tscad->curr() != scad || file != rec) break; TRiga_scadenze& scadenza = partita.new_row(); scadenza.put(SCAD_CODPAG, _tscad->get (SCAD_CODPAG)); scadenza.put(SCAD_TIPOPAG, _tscad->get_int (SCAD_TIPOPAG)); scadenza.put(SCAD_ULTCLASS, _tscad->get (SCAD_ULTCLASS)); scadenza.put(SCAD_IMPORTO, _tscad->get_real(SCAD_IMPORTO)); scadenza.put(SCAD_IMPORTOVAL, _tscad->get_real(SCAD_IMPORTOVAL)); scadenza.put(SCAD_DATASCAD, _tscad->get_date(SCAD_DATASCAD)); int nrata = _tscad->get_int(SCAD_NRATA); int nuova_rata = scadenza.get_int(SCAD_NRATA); aggiorna_temp_scad(tipocf,gruppo,conto,codcf,anno,numpart,nriga,nrata,nuova_riga,nuova_rata); } } if (tipomov != 1) { _tpagsca->zero(); _tpagsca->put(PAGSCA_TIPOC, tipocf); if (gruppo != 0) _tpagsca->put(PAGSCA_GRUPPO, gruppo); if (conto != 0) _tpagsca->put(PAGSCA_CONTO, conto); if (codcf != 0) _tpagsca->put(PAGSCA_SOTTOCONTO, codcf); _tpagsca->put(PAGSCA_ANNO, anno); _tpagsca->put(PAGSCA_NUMPART, numpart); // _tpagsca->put(PAGSCA_NRIGA, nriga); TRectype pagsca (_tpagsca->curr()); for (_tpagsca->read(_isgteq); !_tpagsca->eof(); _tpagsca->next()) { int nrigp = _tpagsca->get_int(PAGSCA_NRIGP); TString rec = pagsca.get(PAGSCA_NUMPART); TString file = _tpagsca->get(PAGSCA_NUMPART); if (_tpagsca->curr() != pagsca || file != rec) break; if (nriga != nrigp) continue; int nrig = _tpagsca->get_int(PAGSCA_NRIGA); int nrata = _tpagsca->get_int(PAGSCA_NRATA); _nrig = nrig; _nrata = nrata; rigaErata(tipocf,gruppo,conto,codcf,anno,numpart,nrig,nrata); TRectype& pag = newgame->pagamento(_nrig,_nrata,nuova_riga); if (_nrig == 9999 && _nrata == 9999) pag.put(PAGSCA_ACCSAL, "A"); else { pag.put(PAGSCA_ACCSAL, _tpagsca->get (PAGSCA_ACCSAL)); pag.put(PAGSCA_PASSATT, _tpagsca->get (PAGSCA_PASSATT)); pag.put(PAGSCA_ABBUONI, _tpagsca->get_real(PAGSCA_ABBUONI)); pag.put(PAGSCA_DIFFCAM, _tpagsca->get_real(PAGSCA_DIFFCAM)); } pag.put(PAGSCA_IMPORTO, _tpagsca->get_real(PAGSCA_IMPORTO)); pag.put(PAGSCA_IMPORTOVAL, _tpagsca->get_real(PAGSCA_IMPORTOVAL)); pag.put(PAGSCA_RITENUTE, _tpagsca->get_real(PAGSCA_RITENUTE)); } } if (newgame != NULL) // Se non ho cancellato il numero partita ... { newgame->write(); // Salva nuova partita delete newgame; } leggi_record_controllo(); TString chiave; chiave.format("%c%03d%03d%06ld%04d%7s%04d", tipocf,gruppo,conto,codcf,anno,(const char*)numpart,nriga); TString sigla (format("%c", uselab)); str = _record.overwrite(sigla,240); str = _record.overwrite(chiave,241); _tras_file.write_control_rec(str,1024); } } bool TRic_tab::leggi_trasfer() { _nultras = 0; _trasf = _tras_file.path(_dittaric); _trasf << HEADER; _tras_file.open(_trasf); if (_tras_file.exist()) { if (_tras_file.read_control_rec()) { _nultras = _tras_file.nultras(); _dataultras = _tras_file.dataultras(); _sigle_file = _tras_file.sigle_file(); _nrec_file = _tras_file.nrec_file(); _uselab = _tras_file.ult_file(); _key = _tras_file.key(); _record = _tras_file.record(); } else return error_box("Rilevati gravi errori negli archivi:procedura interrotta"); } else return error_box("Al momento non presenti trasferimenti attivi sulla ditta selezionata"); return TRUE; } bool TRic_tab::video() { TConfig conf(CONFIG_DITTA); _std = conf.get("FlStTra"); if (!leggi_trasfer()) return FALSE; TMask* msk = new TMask("cg6600a"); KEY tasto; ditta_ricevente(); msk->set(F_CODDITTA, _dittaric); msk->set(F_RAGSOC, _ragsoc_dittar); msk->set(F_NULTRAS, _nultras); TString data1 = _dataultras.string(); msk->set(F_DATAULTRAS, data1); msk->set(F_STD, _std); msk->set(F_USELAB, _uselab); msk->set(F_STATO, _key); tasto = msk->run(); delete msk; if (tasto != K_ENTER) return FALSE; if (!prefix().exist(_dittaric)) return error_box("Rilevati gravi errori negli archivi: procedura interrotta"); if (!controlli()) return FALSE; return TRUE; } void TRic_tab::setta_parametri_record(const TString& sigla,const TString& flag) { TConfig conf (CONFIG_DITTA); conf.set("FlStTra", flag); leggi_record_controllo(); _record.overwrite(sigla,240); const int size = 1024; _tras_file.write_control_rec(_record, size); } bool TRic_tab::controllo_pre_ricezione() { TString flag; TString sigla = _sigle_file.mid(0,1); if (sigla == " ") { flag = "*"; setta_parametri_record(sigla,flag); fremove(_trasf); return FALSE; } if (sigla == "Z") { flag = "C"; setta_parametri_record(sigla,flag); return error_box("Aggiornamento tabelle terminato: proseguire con controllo movimenti"); } if (sigla != "Z") { flag = "T"; setta_parametri_record(sigla,flag); return TRUE; } return TRUE; } void TRic_tab::ditta_ricevente() { TLocalisamfile nditte (LF_NDITTE); nditte.setkey(1); nditte.zero(); nditte.put(NDT_CODDITTA, _dittaric); if (nditte.read() == NOERR) _ragsoc_dittar = nditte.get(NDT_RAGSOC); } bool TRic_tab::controlli() { if (_scelta == 'T') { if (_std == "C") return error_box("Aggiornamento tabelle gia' effettuato: richiamare Controllo movimenti"); if (_std == "M") return error_box("Aggiornamento tabelle gia' effettuato: richiamare Trasferimento movimenti"); if (_std == "*") { warning_box("Trasferimento interamente completato: proseguire per cancellare il file"); _tras_file.remove_all(); setta_parametri_record(" "," "); return FALSE; } if (_std != "" && _std != "T") return error_box("Rilevati gravi errori negli archivi: procedura interrotta"); if ( (_std == "" || _std == "T") && (_uselab == "Z" || _uselab == "U") ) return error_box("Rilevati gravi errori negli archivi: procedura interrotta"); } else if (_scelta == 'M') { if (_std == "" || _std == "T") return error_box("Aggiornamento tabelle NON EFFETTUATO: richiamare il programma relativo"); if (_std == "C") return error_box("Controllo movimenti non effettuato o rilevati errori gravi"); if (_std == "M" && (_uselab != "Z" && _uselab != "U" && _uselab != "B") ) return error_box("Rilevati GRAVI ERRORI negli archivi: procedura interrotta"); if (_std != "*" && _std != "M") error_box("Rilevati GRAVI ERRORI negli archivi: procedura interrotta"); if (_std == "*") { warning_box("Trasferimento interamente completato: proseguire per cancellare il file"); _tras_file.remove_all(); setta_parametri_record(" "," "); return FALSE; } } return TRUE; } void TRic_tab::apri_file_temp() { if (_scelta == 'T') { TString80 tmpcaus = "%"; tmpcaus << get_firm_dir(); tmpcaus << "\\" << TEMP_CAUS; _tmpcaus = tmpcaus.mid(1); _tmpcaus << ".dbf"; if(fexist(_tmpcaus)) _tcaus = new TIsamtempfile(LF_CAUSALI, tmpcaus, 0); TString80 tmprcaus = "%"; tmprcaus << get_firm_dir(); tmprcaus << "\\" << TEMP_RCAUS; _tmprcaus = tmprcaus.mid(1); _tmprcaus << ".dbf"; if (fexist(_tmprcaus)) _trcaus = new TIsamtempfile(LF_RCAUSALI, tmprcaus, 0); TString80 tmpclifo = "%"; tmpclifo << get_firm_dir(); tmpclifo << "\\" << TEMP_CLIFO; _tmpclifo = tmpclifo.mid(1); _tmpclifo << ".dbf"; if (fexist(_tmpclifo)) _tclifo = new TIsamtempfile(LF_CLIFO, tmpclifo, 0); TString80 tmppcon = "%"; tmppcon << get_firm_dir(); tmppcon << "\\" << TEMP_PCON; _tmpcon = tmppcon.mid(1); _tmpcon << ".dbf"; if (fexist(_tmpcon)) _tpcon = new TIsamtempfile(LF_PCON, tmppcon, 0); } else { TString80 tmpmov = "%"; tmpmov << get_firm_dir(); tmpmov << "\\" << TEMP_MOV; _tmpmov = tmpmov.mid(1); _tmpmov << ".dbf"; if (fexist(_tmpmov)) _tmov = new TIsamtempfile(LF_MOV, tmpmov, 0); TString80 tmprmov = "%"; tmprmov << get_firm_dir(); tmprmov << "\\" << TEMP_RMOV; _tmprmov = tmprmov.mid(1); _tmprmov << ".dbf"; if (fexist(_tmprmov)) _trmov = new TIsamtempfile(LF_RMOV, tmprmov, 0); TString80 tmpriva = "%"; tmpriva << get_firm_dir(); tmpriva << "\\" << TEMP_RMOVIVA; _tmpriva = tmpriva.mid(1); _tmpriva << ".dbf"; if (fexist(_tmpriva)) _triva = new TIsamtempfile(LF_RMOVIVA, tmpriva, 0); TString80 tmpoccas = "%"; tmpoccas << get_firm_dir(); tmpoccas << "\\" << TEMP_OCC; _tmpoccas = tmpoccas.mid(1); _tmpoccas << ".dbf"; if (fexist(_tmpoccas)) _toccas = new TIsamtempfile(LF_OCCAS, tmpoccas, 0); TString80 tmppart = "%"; tmppart << get_firm_dir(); tmppart << "\\" << TEMP_PART; _tmppart = tmppart.mid(1); _tmppart << ".dbf"; if (fexist(_tmppart)) _tpart = new TIsamtempfile(LF_PARTITE, tmppart, 0); TString80 tmpscad = "%"; tmpscad << get_firm_dir(); tmpscad << "\\" << TEMP_SCAD; _tmpscad = tmpscad.mid(1); _tmpscad << ".dbf"; if (fexist(_tmpscad)) _tscad = new TIsamtempfile(LF_SCADENZE, tmpscad, 0); TString80 tmppagsca = "%"; tmppagsca << get_firm_dir(); tmppagsca << "\\" << TEMP_PAGSCA; _tmppagsca = tmppagsca.mid(1); _tmppagsca << ".dbf"; if (fexist(_tmppagsca)) _tpagsca = new TIsamtempfile(LF_PAGSCA, tmppagsca, 0); } } void TRic_tab::chiudi_file_temp() { if (_scelta == 'T') { if (fexist(_tmpcaus)) delete _tcaus; if (fexist(_tmprcaus)) delete _trcaus; if (fexist(_tmpclifo)) delete _tclifo; if (fexist(_tmpcon)) delete _tpcon; } else { if (fexist(_tmpmov)) delete _tmov; if (fexist(_tmprmov)) delete _trmov; if (fexist(_tmpriva)) delete _triva; if (fexist(_tmpoccas)) delete _toccas; if (fexist(_tmppart)) delete _tpart; if (fexist(_tmpscad)) delete _tscad; if (fexist(_tmppagsca)) delete _tpagsca; } } bool TRic_tab::menu(MENU_TAG m) { if (m == BAR_ITEM(1)) return main_loop(); return FALSE; } int cg6600 (int argc, char* argv[]) { char p3 = '\0'; if (argc > 4) p3 = *argv[3]; TRic_tab* main_app=new TRic_tab(*argv[2],p3); main_app->run(argc, argv,main_app->_titolo); delete main_app; return TRUE; }