848151dff5
git-svn-id: svn://10.65.10.50/branches/R_10_00@23036 c028cbd2-c16b-5b4b-a496-9718f37d4682
1920 lines
54 KiB
C++
Executable File
1920 lines
54 KiB
C++
Executable File
// Ricezione dati da sistema
|
|
|
|
#include "cglib02.h"
|
|
#include "cglib04.h"
|
|
#include "cgsaldac.h"
|
|
|
|
#include "cg6600.h"
|
|
|
|
#include <applicat.h>
|
|
#include <mask.h>
|
|
#include <tabutil.h>
|
|
#include <progind.h>
|
|
|
|
#include <comuni.h>
|
|
#include <nditte.h>
|
|
#include <occas.h>
|
|
|
|
class TRic_tab : public TSkeleton_application
|
|
{
|
|
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;
|
|
TFilename _tmpcaus,_tmprcaus,_tmpclifo,_tmpcon,_tmpmov,_tmprmov,_tmpriva;
|
|
TFilename _tmpoccas,_tmppart,_tmpscad,_tmppagsca;
|
|
|
|
protected:
|
|
void genera_codice_occasionale(TString& ocfpi);
|
|
bool tmp_test_box(const char* fname) const;
|
|
|
|
public:
|
|
TString _titolo;
|
|
|
|
virtual bool create();
|
|
virtual bool destroy();
|
|
virtual void main_loop();
|
|
virtual bool check_autorization() const
|
|
{return FALSE;}
|
|
virtual void on_config_change();
|
|
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(const TString& codcaus);
|
|
void scrivi_righe_causali(const 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(const TString& key, char sigla);
|
|
void scrivi_righePN(long numreg);
|
|
void ricevi_movIVA(const TString& key, char sigla);
|
|
bool scrivi_righeIVA(long numreg);
|
|
void ricevi_movSC(TString& key,char sigla);
|
|
long esiste_numreg(long nreg);
|
|
void num_protocollo();
|
|
void controlli_primanota();
|
|
long ulnumprot_reg(int anno, const TString& codreg);
|
|
long ultima_registrazione();
|
|
void aggiorna_reg(int anno, const TString& codreg);
|
|
char ricerca_causale(const TString& codcaus) const;
|
|
bool esiste_partita(const TString& key) const;
|
|
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)),
|
|
_tcaus(NULL), _trcaus(NULL), _tclifo(NULL), _tpcon(NULL), _tmov(NULL), _trmov(NULL), _triva(NULL)
|
|
{
|
|
if (_scelta == 'T')
|
|
_titolo = TR("Ricezione tabelle");
|
|
|
|
if (_scelta == 'M')
|
|
_titolo = TR("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()
|
|
{
|
|
_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();
|
|
|
|
return TSkeleton_application::create();
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
void 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;
|
|
|
|
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(TR("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(TR("Trasferimento interamente completato: proseguire per cancellare il file"));
|
|
setta_parametri_record(" ","*");
|
|
_tras_file.remove_all();
|
|
setta_parametri_record(" "," ");
|
|
}
|
|
}
|
|
}
|
|
else
|
|
if (_scelta == 'M')
|
|
{
|
|
bool ok = video();
|
|
if (ok)
|
|
{
|
|
apri_file_temp();
|
|
|
|
trasferimento();
|
|
chiudi_file_temp();
|
|
message_box(TR("Trasferimento interamente completato: proseguire per cancellare il file"));
|
|
setta_parametri_record(" ","*");
|
|
_tras_file.remove_all();
|
|
setta_parametri_record(" "," ");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
bool TRic_tab::tmp_test_box(const char* fname) const
|
|
{
|
|
TFilename tmp = get_firm_dir();
|
|
tmp.add(fname);
|
|
tmp.ext("dbf");
|
|
const bool ok = tmp.exist();
|
|
if (!ok)
|
|
cantread_box(tmp);
|
|
return ok;
|
|
}
|
|
|
|
void TRic_tab::trasferimento()
|
|
{
|
|
int last_tab = 0;
|
|
char sigla = ' ';
|
|
TString message;
|
|
|
|
char uselab = _tras_file.ult_file()[0];
|
|
int posiz = _tras_file.num(uselab); //Ritorna la posizione della sigla all'interno dell'indice
|
|
TString 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 (int i = posiz; i < last_tab;i++)
|
|
{
|
|
const long numero = atol(_record.mid( ((i * 6) + 95),6));
|
|
if (numero <= 0) // Numero di records totali del tipo atteso
|
|
continue;
|
|
const long nrec = _tras_file.nrec(i)+1; // Numero di records presenti (< numero)
|
|
sigla = _tras_file.name(i)[0];
|
|
long cicli = 0;
|
|
|
|
switch (sigla)
|
|
{
|
|
case 'W':
|
|
if (_tcaus != NULL)
|
|
{
|
|
message = TR("Ricezione tabella causali");
|
|
cicli = _tcaus->items();
|
|
}
|
|
else
|
|
{
|
|
error_box(FR("Sono presenti %ld record causali non dichiarati nel record di controllo."), numero);
|
|
tmp_test_box(TEMP_CAUS);
|
|
}
|
|
break;
|
|
case 'A':
|
|
if (_tclifo != NULL)
|
|
{
|
|
message = TR("Ricezione anagrafica Clienti / Fornitori");
|
|
cicli = _tclifo->items();
|
|
}
|
|
else
|
|
{
|
|
error_box(FR("Sono presenti %ld record clienti/fornitori non dichiarati nel record di controllo"), numero);
|
|
tmp_test_box(TEMP_CLIFO);
|
|
}
|
|
break;
|
|
case 'P':
|
|
if (_tpcon != NULL)
|
|
{
|
|
message = TR("Ricezione anagrafica Piano dei Conti");
|
|
cicli = _tpcon->items();
|
|
}
|
|
else
|
|
{
|
|
error_box("Sono presenti %ld record piano dei conti non dichiarati nel record di controllo", numero);
|
|
tmp_test_box(TEMP_PCON);
|
|
}
|
|
break;
|
|
case 'Z':
|
|
message = TR("Ricezione Movimenti di primanota");
|
|
cicli = _tmov->items();
|
|
break;
|
|
case 'U':
|
|
message = TR("Ricezione Movimenti iva");
|
|
cicli = _tmov->items();
|
|
break;
|
|
case 'B':
|
|
message = TR("Ricezione Movimenti saldaconto");
|
|
cicli = _tpart->items();
|
|
break;
|
|
default: break;
|
|
}
|
|
|
|
if (cicli > 0)
|
|
{
|
|
_prog = new TProgind(cicli,message,FALSE);
|
|
|
|
if (_scelta == 'T')
|
|
{
|
|
switch(sigla)
|
|
{
|
|
case 'W': ricevi_causali(key,sigla); break;
|
|
case 'A': ricevi_clifo(key,sigla); break;
|
|
case 'P': ricevi_pcon(key,sigla); break;
|
|
default: break;
|
|
}
|
|
}
|
|
else
|
|
if (_scelta == 'M')
|
|
{
|
|
switch(sigla)
|
|
{
|
|
case 'Z': ricevi_movPN(key,sigla); _sld.registra(); break;
|
|
case 'U': ricevi_movIVA(key,sigla); break;
|
|
case 'B': ricevi_movSC(key,sigla); break;
|
|
default: break;
|
|
}
|
|
}
|
|
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);
|
|
|
|
const TString4 codcaus = _tcaus->get(CAU_CODCAUS);
|
|
|
|
_caus->curr() = _tcaus->curr();
|
|
|
|
if (_caus->read() == NOERR) // Esiste la testata
|
|
{
|
|
if (flag == 'N')
|
|
{
|
|
leggi_record_controllo();
|
|
TString16 chiave;
|
|
chiave.format("%3s",(const char*) codcaus);
|
|
TString16 sigla; sigla << 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();
|
|
TString16 chiave;
|
|
chiave.format("%3s", (const char*)codcaus);
|
|
TString16 sigla; sigla << uselab;
|
|
str = _record.overwrite(sigla,240);
|
|
str = _record.overwrite(chiave,241);
|
|
_tras_file.write_control_rec(str,1024);
|
|
}
|
|
}
|
|
|
|
void TRic_tab::cancella_righe_causali(const TString& codcaus)
|
|
{
|
|
_rcaus->setkey(1);
|
|
_rcaus->zero();
|
|
_rcaus->put(RCA_CODCAUS, codcaus);
|
|
for (_rcaus->read(); !_rcaus->eof(); _rcaus->next())
|
|
{
|
|
if (_rcaus->get(RCA_CODCAUS) != codcaus)
|
|
break;
|
|
_rcaus->remove();
|
|
}
|
|
}
|
|
|
|
void TRic_tab::scrivi_righe_causali(const TString& codcaus, char uselab)
|
|
{
|
|
TString str;
|
|
|
|
cancella_righe_causali(codcaus);
|
|
|
|
_trcaus->setkey(1);
|
|
_trcaus->zero();
|
|
_trcaus->put(RCA_CODCAUS, codcaus);
|
|
for (_trcaus->read(); !_trcaus->eof(); _trcaus->next())
|
|
{
|
|
if (_trcaus->get(RCA_CODCAUS) != codcaus)
|
|
break;
|
|
|
|
_rcaus->curr() = _trcaus->curr();
|
|
_rcaus->write();
|
|
|
|
leggi_record_controllo();
|
|
TString16 chiave;
|
|
chiave.format("%3s",(const char*) codcaus);
|
|
TString16 sigla; sigla << 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();
|
|
TString16 chiave;
|
|
chiave.format("%c%06ld", tipocf,codcf);
|
|
TString16 sigla; sigla << 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();
|
|
TString16 chiave;
|
|
chiave.format("%c%06ld", tipocf, codcf);
|
|
TString16 sigla; sigla << 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);
|
|
|
|
const int g = _tpcon->get_int (PCN_GRUPPO);
|
|
const int c = _tpcon->get_int (PCN_CONTO);
|
|
const 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();
|
|
TString16 chiave;
|
|
chiave.format("%03d%03d%06ld", g, c, s);
|
|
TString16 sigla; sigla << 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 (g != 0 && c != 0)
|
|
{
|
|
if (s == 0)
|
|
conto(pcon,flag,esiste);
|
|
else
|
|
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();
|
|
TString16 chiave;
|
|
chiave.format("%03d%03d%06ld", g, c, s);
|
|
TString16 sigla; sigla << 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);
|
|
TString ivacomp = _tpcon->get(PCN_IVACOMP);
|
|
|
|
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);
|
|
pcon.put(PCN_IVACOMP, ivacomp);
|
|
}
|
|
|
|
void TRic_tab::conto(TRectype& pcon,char flag,bool esiste)
|
|
{
|
|
const int g = _tpcon->get_int(PCN_GRUPPO);
|
|
const int c = _tpcon->get_int(PCN_CONTO);
|
|
|
|
TString8 sez = _tpcon->get (PCN_SEZIVD);
|
|
TString8 let = _tpcon->get (PCN_LETTIVD);
|
|
TString8 numr = _tpcon->get (PCN_NUMRIVD);
|
|
TString8 num = _tpcon->get(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);
|
|
TString num = _tpcon->get(PCN_NUMIVD);
|
|
TString sezop = _tpcon->get(PCN_SEZIVDOPP);
|
|
TString letop = _tpcon->get(PCN_LETTIVDOPP);
|
|
TString numrop = _tpcon->get(PCN_NUMRIVDOPP);
|
|
TString numop = _tpcon->get(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;
|
|
}
|
|
|
|
// Legge i numeri di protocollo dal movimento ricevuto
|
|
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, const TString& codreg)
|
|
{
|
|
TString16 dep;
|
|
if (real::is_natural(codreg))
|
|
dep.format("%04d%03s", anno, (const char*)codreg);
|
|
else
|
|
dep.format("%04d%-3s", anno, (const char*)codreg);
|
|
|
|
// Non usare le cache! Problemi di aggiornamento veloce
|
|
TTable& reg = *_reg;
|
|
|
|
int err = NOERR;
|
|
if (reg.get("CODTAB") != dep)
|
|
{
|
|
reg.put("CODTAB", dep);
|
|
err = reg.read();
|
|
}
|
|
long lastprot = err == NOERR ? reg.get_long("I5") : 0L;
|
|
return lastprot;
|
|
}
|
|
|
|
void TRic_tab::aggiorna_reg(int anno, const TString& codreg)
|
|
{
|
|
TString16 dep;
|
|
if (real::is_natural(codreg))
|
|
dep.format("%04d%03s", anno, (const char*)codreg);
|
|
else
|
|
dep.format("%04d%-3s", anno, (const char*)codreg);
|
|
|
|
TTable& reg = *_reg;
|
|
int err = NOERR;
|
|
if (reg.get("CODTAB") != dep)
|
|
{
|
|
reg.put("CODTAB", dep);
|
|
err = reg.read();
|
|
}
|
|
if (err == NOERR)
|
|
{
|
|
const long ulnum = reg.get_long("I5");
|
|
if (_nuprotiva > ulnum )
|
|
reg.put("I5", _nuprotiva);
|
|
else
|
|
{
|
|
if (_nprotiva > ulnum )
|
|
reg.put("I5", _nprotiva);
|
|
}
|
|
reg.rewrite();
|
|
}
|
|
}
|
|
|
|
void TRic_tab::controlli_primanota()
|
|
{
|
|
const char tipocf = _tmov->get_char(MOV_TIPO);
|
|
int tiporeg = 0;
|
|
if (tipocf == 'C')
|
|
tiporeg = 1;
|
|
else
|
|
if (tipocf == 'F')
|
|
tiporeg = 2;
|
|
|
|
const TString8 codreg = _tmov->get(MOV_REG);
|
|
const TString8 tipodoc = _tmov->get(MOV_TIPODOC);
|
|
|
|
const TDate datareg = _tmov->get_date(MOV_DATAREG);
|
|
const int anno = datareg.year();
|
|
|
|
const TRectype& tpd = cache().get("%TDP", tipodoc);
|
|
const bool corrisp = tpd.get_bool("B0");
|
|
|
|
if (codreg.not_empty() && !corrisp)
|
|
{
|
|
if ( ( (tiporeg == 1 && (_nprot_att || _protiva == 0) ) )
|
|
|| ( (tiporeg == 2 && (_nprot_pas || _protiva == 0) ) ) )
|
|
{
|
|
const long ulnum = ulnumprot_reg(anno, codreg);
|
|
_nprotiva = ulnum + 1;
|
|
if (_uprotiva != 0)
|
|
_nuprotiva = (_nprotiva - ulnum) + _uprotiva;
|
|
}
|
|
}
|
|
}
|
|
|
|
char TRic_tab::ricerca_causale(const TString& causale) const
|
|
{
|
|
/* Guy: mi pare una ca$$ata immane
|
|
if (real::is_natural(causale))
|
|
causale.format("%03s", (const char*) causale);
|
|
else
|
|
causale.format("%-3s", (const char*) causale);
|
|
*/
|
|
const TRectype& cau = cache().get(LF_CAUSALI, causale);
|
|
char movap = cau.get_char(CAU_MOVAP);
|
|
if (movap < ' ')
|
|
movap = ' ';
|
|
|
|
return movap;
|
|
}
|
|
|
|
void TRic_tab::scrivi_righePN(long numreg)
|
|
{
|
|
_trmov->setkey(1);
|
|
_trmov->zero();
|
|
_trmov->put(RMV_NUMREG, numreg);
|
|
for (_trmov->read(); !_trmov->eof(); _trmov->next())
|
|
{
|
|
if (_trmov->get_long(RMV_NUMREG) != numreg)
|
|
break;
|
|
|
|
_trmov->put(RMV_NUMREG, _mov->get(MOV_NUMREG)); // Aggiorna vero numero di registrazione
|
|
_trmov->put(RMV_ANNOES, _mov->get(MOV_ANNOES)); // Altrimenti e' casuale!
|
|
_rmov->curr() = _trmov->curr();
|
|
_rmov->write();
|
|
|
|
const int g = _trmov->get_int (RMV_GRUPPO);
|
|
const int c = _trmov->get_int (RMV_CONTO);
|
|
const long s = _trmov->get_long(RMV_SOTTOCONTO);
|
|
const char sez = _trmov->get_char(RMV_SEZIONE);
|
|
const real imp = _trmov->get(RMV_IMPORTO);
|
|
_sld.aggiorna(g,c,s,imp,sez);
|
|
}
|
|
}
|
|
|
|
// Ricezione Saldaconto da Sistema e PC: da file temporanei a file reali
|
|
void TRic_tab::ricevi_movPN(const TString& key, char uselab)
|
|
{
|
|
long numulreg = 0;
|
|
|
|
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");
|
|
bool provvis = _tmov->get_char(MOV_PROVVIS) > ' ';
|
|
|
|
if (nuova_reg == 0)
|
|
{
|
|
numulreg = ultima_registrazione(); // reperisco il numero ultima registrazione
|
|
_nreg = esiste_numreg(numulreg);
|
|
}
|
|
else
|
|
_nreg = nuova_reg;
|
|
|
|
const TRecnotype rec = _tmov->recno(); // Salvo il nuovo numero di
|
|
_tmov->put("TNUMREG", _nreg); // registrazione sul file di lavoro
|
|
_tmov->rewrite();
|
|
_tmov->readat(rec);
|
|
|
|
const int annoes = _tmov->get_int(MOV_ANNOES);
|
|
|
|
TRectype recmov = _tmov->curr();
|
|
_mov->setkey(1);
|
|
_mov->zero();
|
|
_mov->put(MOV_NUMREG, _nreg);
|
|
|
|
if (_mov->read() != NOERR) // Se non esiste la testata
|
|
{
|
|
num_protocollo(); // Legge i numeri di protocollo dal movimento ricevuto
|
|
controlli_primanota();
|
|
|
|
recmov.put(MOV_NUMREG, _nreg);
|
|
recmov.put(MOV_PROTIVA, _nprotiva);
|
|
recmov.put(MOV_UPROTIVA, _nuprotiva);
|
|
|
|
_mov->curr() = recmov;
|
|
_mov->write();
|
|
|
|
const TString4 codreg = _tmov->get(MOV_REG);
|
|
const TString4 codcaus= _tmov->get(MOV_CODCAUS);
|
|
const TDate datareg = _tmov->get(MOV_DATAREG);
|
|
const int annoiva = datareg.year();
|
|
|
|
aggiorna_reg(annoiva, codreg); // Aggiorna il registro
|
|
|
|
_sld.set_anno_es(annoes);
|
|
_sld.set_movprovv(provvis);
|
|
_sld.set_num_ulmov(_nreg);
|
|
_sld.set_data_ulmov(datareg);
|
|
|
|
const char movap = ricerca_causale(codcaus);
|
|
if (movap == 'A')
|
|
_sld.set_tipo_saldo(apertura);
|
|
else if (movap == 'C')
|
|
_sld.set_tipo_saldo(chiusura);
|
|
|
|
scrivi_righePN(nreg);
|
|
|
|
_sld.registra();
|
|
_sld.reset();
|
|
}
|
|
|
|
leggi_record_controllo();
|
|
TString8 chiave;
|
|
chiave.format("%07ld", nreg);
|
|
TString16 sigla; sigla << uselab;
|
|
TString str = _record.overwrite(sigla,240);
|
|
str = _record.overwrite(chiave,241);
|
|
_tras_file.write_control_rec(str,1024);
|
|
}
|
|
}
|
|
|
|
void TRic_tab::genera_codice_occasionale(TString& ocfpi)
|
|
{
|
|
long progr = 0;
|
|
_occas->setkey(1);
|
|
_occas->put(OCC_CFPI, "RIC~"); // Chiave sicuramente maggiore di "RIC"
|
|
|
|
bool found = false;
|
|
|
|
if (_occas->read(_isgteq) == NOERR)
|
|
{
|
|
while (_occas->read(_isprev) == NOERR)
|
|
{
|
|
const TString& cfpi = _occas->get(OCC_CFPI);
|
|
// Non lasciarti ingannare dai codici fiscali che cominciano per RIC
|
|
const int cmp = cfpi.compare("RIC ", 4);
|
|
if (cmp == 0)
|
|
{
|
|
found = true;
|
|
break;
|
|
}
|
|
if (cmp <= 0)
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
found = _occas->last() == NOERR;
|
|
|
|
if (found)
|
|
{
|
|
const TString& cfpi = _occas->get(OCC_CFPI);
|
|
if (cfpi.starts_with("RIC "))
|
|
progr = atol(cfpi.mid(4));
|
|
}
|
|
|
|
ocfpi.format("RIC%13ld", progr+1);
|
|
}
|
|
|
|
|
|
bool TRic_tab::occasionali(TString& ocfpi)
|
|
{
|
|
// Mi posiziono sui dati dell'occasionale temporaneo da trasferire
|
|
_toccas->setkey(1);
|
|
_toccas->zero();
|
|
_toccas->put(OCC_CFPI, ocfpi);
|
|
if (_toccas->read() != NOERR)
|
|
_toccas->zero();
|
|
|
|
bool rinumera = true;
|
|
if (ocfpi.len() == 11)
|
|
{
|
|
rinumera = !real::is_natural(ocfpi); // Rinumera se non e' una Partita IVA
|
|
} else
|
|
if (ocfpi.len() == 16)
|
|
{
|
|
const char* const test = "AAAAAANNANNANNNA";
|
|
int i;
|
|
for (i = 15; i >= 0; i--)
|
|
{
|
|
if (test[i] == 'A')
|
|
{
|
|
if (!isalpha(ocfpi[i]))
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
if (!isdigit(ocfpi[i]))
|
|
break;
|
|
}
|
|
}
|
|
rinumera = i >= 0; // Rinumera se non e' un codice fiscale
|
|
}
|
|
|
|
bool update = false; // Di default faccio la write invece della rewrite
|
|
if (rinumera)
|
|
{
|
|
genera_codice_occasionale(ocfpi);
|
|
}
|
|
else
|
|
{
|
|
_occas->put(OCC_CFPI, ocfpi);
|
|
update = _occas->read() == NOERR;
|
|
}
|
|
|
|
// Copio i dati dall'occasionale temporaneo se esistono
|
|
if (_toccas->curr().empty())
|
|
_occas->zero();
|
|
else
|
|
_occas->curr() = _toccas->curr();
|
|
_occas->put(OCC_CFPI, ocfpi);
|
|
int err = update ? _occas->rewrite() : _occas->write();
|
|
return err == NOERR;
|
|
}
|
|
|
|
bool TRic_tab::scrivi_righeIVA(long numreg)
|
|
{
|
|
if (_triva)
|
|
{
|
|
_triva->setkey(1);
|
|
_triva->zero();
|
|
_triva->put(RMI_NUMREG, numreg);
|
|
|
|
for (_triva->read(); !_triva->eof(); _triva->next())
|
|
{
|
|
if (_triva->get_long(RMI_NUMREG) != numreg)
|
|
break;
|
|
_triva->put(RMI_NUMREG, _nuovareg);
|
|
_rmoviva->curr() = _triva->curr();
|
|
_rmoviva->write();
|
|
}
|
|
}
|
|
else
|
|
return cantread_box(_tmpriva);
|
|
return true;
|
|
}
|
|
|
|
void TRic_tab::ricevi_movIVA(const TString& key, char uselab)
|
|
{
|
|
if (_triva == NULL)
|
|
{
|
|
cantread_box(_tmpriva);
|
|
return;
|
|
}
|
|
|
|
const 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);
|
|
|
|
const long nreg = _tmov->get_long(MOV_NUMREG);
|
|
const TString4 codreg = _tmov->get(MOV_REG);
|
|
const TString4 codcau = _tmov->get(MOV_CODCAUS);
|
|
|
|
if (codreg.empty() || codcau.empty())
|
|
continue;
|
|
|
|
_nuovareg = _tmov->get_long("TNUMREG");
|
|
|
|
TString16 ocfpi = _tmov->get(MOV_OCFPI);
|
|
if (ocfpi.full())
|
|
occasionali(ocfpi);
|
|
|
|
TDate data74ter ( _tmov->get_date(MOV_DATA74TER) );
|
|
TString4 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();
|
|
TString8 chiave; chiave.format("%07ld", nreg);
|
|
TString16 sigla; sigla << uselab;
|
|
TString 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(const TString& key) const
|
|
{
|
|
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));
|
|
TString8 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);
|
|
|
|
return part.read() == NOERR;
|
|
}
|
|
|
|
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)
|
|
{
|
|
const 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));
|
|
TString8 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;
|
|
|
|
const long nreg = _tpart->get_long(PART_NREG);
|
|
_nuovareg = nuovaregSC(nreg);
|
|
int anno = _tpart->get_int (PART_ANNO);
|
|
TString8 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_DESCR, _tpart->get (PART_DESCR));
|
|
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_RITSOC, _tpart->get_real(PART_RITSOC));
|
|
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);
|
|
|
|
const TRectype scad = _tscad->curr();
|
|
|
|
for (_tscad->read(_isgteq); !_tscad->eof(); _tscad->next())
|
|
{
|
|
const TString8 rec = scad.get(SCAD_NUMPART);
|
|
const TString8 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));
|
|
scadenza.put(SCAD_CODABIPR, _tscad->get(SCAD_CODABIPR));
|
|
scadenza.put(SCAD_CODCABPR, _tscad->get(SCAD_CODCABPR));
|
|
scadenza.put(SCAD_CODABI, _tscad->get(SCAD_CODABI));
|
|
scadenza.put(SCAD_CODCAB, _tscad->get(SCAD_CODCAB));
|
|
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));
|
|
pag.put(PAGSCA_RITSOC, _tpagsca->get_real(PAGSCA_RITSOC));
|
|
|
|
pag.put(PAGSCA_TIPOCC, _tpagsca->get(PAGSCA_TIPOCC));
|
|
pag.put(PAGSCA_GRUPPOC, _tpagsca->get(PAGSCA_GRUPPOC));
|
|
pag.put(PAGSCA_CONTOC, _tpagsca->get(PAGSCA_CONTOC));
|
|
pag.put(PAGSCA_SOTTOCONTC, _tpagsca->get(PAGSCA_SOTTOCONTC));
|
|
|
|
pag.put(PAGSCA_CODABI, _tpagsca->get(PAGSCA_CODABI));
|
|
pag.put(PAGSCA_CODCAB, _tpagsca->get(PAGSCA_CODCAB));
|
|
pag.put(PAGSCA_CODABIPR, _tpagsca->get(PAGSCA_CODABIPR));
|
|
pag.put(PAGSCA_CODCABPR, _tpagsca->get(PAGSCA_CODCABPR));
|
|
|
|
pag.put(PAGSCA_CODAG, _tpagsca->get(PAGSCA_CODAG));
|
|
}
|
|
}
|
|
|
|
if (newgame != NULL) // Se non ho cancellato il numero partita ...
|
|
{
|
|
newgame->write(); // Salva nuova partita
|
|
delete newgame;
|
|
}
|
|
|
|
leggi_record_controllo();
|
|
TString80 chiave;
|
|
chiave.format("%c%03d%03d%06ld%04d%7s%04d", tipocf,gruppo,conto,codcf,anno,(const char*)numpart,nriga);
|
|
TString16 sigla; sigla << 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(TR("Rilevati gravi errori negli archivi:procedura interrotta"));
|
|
}
|
|
else
|
|
return error_box(TR("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(TR("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);
|
|
::remove(_trasf);
|
|
return FALSE;
|
|
}
|
|
|
|
if (sigla == "Z")
|
|
{
|
|
flag = "C";
|
|
setta_parametri_record(sigla,flag);
|
|
return error_box(TR("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(TR("Aggiornamento tabelle gia' effettuato: richiamare Controllo movimenti"));
|
|
|
|
if (_std == "M")
|
|
return error_box(TR("Aggiornamento tabelle gia' effettuato: richiamare Trasferimento movimenti"));
|
|
|
|
if (_std == "*")
|
|
{
|
|
warning_box(TR("Trasferimento interamente completato: proseguire per cancellare il file"));
|
|
_tras_file.remove_all();
|
|
setta_parametri_record(" "," ");
|
|
return FALSE;
|
|
}
|
|
|
|
if (_std != "" && _std != "T")
|
|
return error_box(TR("Rilevati gravi errori negli archivi: procedura interrotta"));
|
|
|
|
if ( (_std == "" || _std == "T") && (_uselab == "Z" || _uselab == "U") )
|
|
return error_box(TR("Rilevati gravi errori negli archivi: procedura interrotta"));
|
|
}
|
|
else
|
|
if (_scelta == 'M')
|
|
{
|
|
if (_std == "" || _std == "T")
|
|
return error_box(TR("Aggiornamento tabelle NON EFFETTUATO: richiamare il programma relativo"));
|
|
|
|
if (_std == "C")
|
|
return error_box(TR("Controllo movimenti non effettuato o rilevati errori gravi"));
|
|
|
|
if (_std == "M" && (_uselab != "Z" && _uselab != "U" && _uselab != "B") )
|
|
return error_box(TR("Rilevati GRAVI ERRORI negli archivi: procedura interrotta"));
|
|
|
|
if (_std != "*" && _std != "M")
|
|
error_box(TR("Rilevati GRAVI ERRORI negli archivi: procedura interrotta"));
|
|
|
|
if (_std == "*")
|
|
{
|
|
warning_box(TR("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')
|
|
{
|
|
TFilename tmpcaus = "%";
|
|
tmpcaus << get_firm_dir();
|
|
tmpcaus << "\\" << TEMP_CAUS;
|
|
_tmpcaus = tmpcaus.mid(1);
|
|
_tmpcaus << ".dbf";
|
|
if(_tmpcaus.exist())
|
|
_tcaus = new TIsamtempfile(LF_CAUSALI, tmpcaus, 0);
|
|
TFilename tmprcaus = "%";
|
|
tmprcaus << get_firm_dir();
|
|
tmprcaus << "\\" << TEMP_RCAUS;
|
|
_tmprcaus = tmprcaus.mid(1);
|
|
_tmprcaus << ".dbf";
|
|
if (_tmprcaus.exist())
|
|
_trcaus = new TIsamtempfile(LF_RCAUSALI, tmprcaus, 0);
|
|
TFilename tmpclifo = "%";
|
|
tmpclifo << get_firm_dir();
|
|
tmpclifo << "\\" << TEMP_CLIFO;
|
|
_tmpclifo = tmpclifo.mid(1);
|
|
_tmpclifo << ".dbf";
|
|
if (_tmpclifo.exist())
|
|
_tclifo = new TIsamtempfile(LF_CLIFO, tmpclifo, 0);
|
|
TFilename tmppcon = "%";
|
|
tmppcon << get_firm_dir();
|
|
tmppcon << "\\" << TEMP_PCON;
|
|
_tmpcon = tmppcon.mid(1);
|
|
_tmpcon << ".dbf";
|
|
if (_tmpcon.exist())
|
|
_tpcon = new TIsamtempfile(LF_PCON, tmppcon, 0);
|
|
}
|
|
else
|
|
{
|
|
TFilename tmpmov = "%";
|
|
tmpmov << get_firm_dir();
|
|
tmpmov << "\\" << TEMP_MOV;
|
|
_tmpmov = tmpmov.mid(1);
|
|
_tmpmov << ".dbf";
|
|
if (_tmpmov.exist())
|
|
_tmov = new TIsamtempfile(LF_MOV, tmpmov, 0);
|
|
TFilename tmprmov = "%";
|
|
tmprmov << get_firm_dir();
|
|
tmprmov << "\\" << TEMP_RMOV;
|
|
_tmprmov = tmprmov.mid(1);
|
|
_tmprmov << ".dbf";
|
|
if (_tmprmov.exist())
|
|
_trmov = new TIsamtempfile(LF_RMOV, tmprmov, 0);
|
|
TFilename tmpriva = "%";
|
|
tmpriva << get_firm_dir();
|
|
tmpriva << "\\" << TEMP_RMOVIVA;
|
|
_tmpriva = tmpriva.mid(1);
|
|
_tmpriva << ".dbf";
|
|
if (_tmpriva.exist())
|
|
_triva = new TIsamtempfile(LF_RMOVIVA, tmpriva, 0);
|
|
TFilename tmpoccas = "%";
|
|
tmpoccas << get_firm_dir();
|
|
tmpoccas << "\\" << TEMP_OCC;
|
|
_tmpoccas = tmpoccas.mid(1);
|
|
_tmpoccas << ".dbf";
|
|
if (_tmpoccas.exist())
|
|
_toccas = new TIsamtempfile(LF_OCCAS, tmpoccas, 0);
|
|
TFilename tmppart = "%";
|
|
tmppart << get_firm_dir();
|
|
tmppart << "\\" << TEMP_PART;
|
|
_tmppart = tmppart.mid(1);
|
|
_tmppart << ".dbf";
|
|
if (_tmppart.exist())
|
|
_tpart = new TIsamtempfile(LF_PARTITE, tmppart, 0);
|
|
TFilename tmpscad = "%";
|
|
tmpscad << get_firm_dir();
|
|
tmpscad << "\\" << TEMP_SCAD;
|
|
_tmpscad = tmpscad.mid(1);
|
|
_tmpscad << ".dbf";
|
|
if (_tmpscad.exist())
|
|
_tscad = new TIsamtempfile(LF_SCADENZE, tmpscad, 0);
|
|
TFilename tmppagsca = "%";
|
|
tmppagsca << get_firm_dir();
|
|
tmppagsca << "\\" << TEMP_PAGSCA;
|
|
_tmppagsca = tmppagsca.mid(1);
|
|
_tmppagsca << ".dbf";
|
|
if (_tmppagsca.exist())
|
|
_tpagsca = new TIsamtempfile(LF_PAGSCA, tmppagsca, 0);
|
|
}
|
|
}
|
|
|
|
void TRic_tab::chiudi_file_temp()
|
|
{
|
|
if (_scelta == 'T')
|
|
{
|
|
if (_tmpcaus.exist())
|
|
delete _tcaus;
|
|
if (_tmprcaus.exist())
|
|
delete _trcaus;
|
|
if (_tmpclifo.exist())
|
|
delete _tclifo;
|
|
if (_tmpcon.exist())
|
|
delete _tpcon;
|
|
}
|
|
else
|
|
{
|
|
if (_tmpmov.exist())
|
|
delete _tmov;
|
|
if (_tmprmov.exist())
|
|
delete _trmov;
|
|
if (_tmpriva.exist())
|
|
delete _triva;
|
|
if (_tmpoccas.exist())
|
|
delete _toccas;
|
|
if (_tmppart.exist())
|
|
delete _tpart;
|
|
if (_tmpscad.exist())
|
|
delete _tscad;
|
|
if (_tmppagsca.exist())
|
|
delete _tpagsca;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|