bd2e5486f7
git-svn-id: svn://10.65.10.50/trunk@2516 c028cbd2-c16b-5b4b-a496-9718f37d4682
1499 lines
40 KiB
C++
Executable File
1499 lines
40 KiB
C++
Executable File
// Ricezione dati da sistema
|
|
|
|
#include <mask.h>
|
|
#include <printapp.h>
|
|
#include <relation.h>
|
|
#include <tabutil.h>
|
|
#include <utility.h>
|
|
#include <config.h>
|
|
#include <urldefid.h>
|
|
#include <mailbox.h>
|
|
#include <execp.h>
|
|
#include <prefix.h>
|
|
#include <scanner.h>
|
|
#include <lffiles.h>
|
|
#include <progind.h>
|
|
#include <nditte.h>
|
|
#include <mov.h>
|
|
#include <rmov.h>
|
|
#include <rmoviva.h>
|
|
#include <pconti.h>
|
|
#include <comuni.h>
|
|
#include <clifo.h>
|
|
#include <rcausali.h>
|
|
#include <causali.h>
|
|
#include <occas.h>
|
|
|
|
#include "cglib04.h"
|
|
#include "cglib.h"
|
|
#include "cg2103.h"
|
|
|
|
#include "cg6600.h"
|
|
|
|
class TRic_tab : public TApplication
|
|
{
|
|
|
|
TTable* _tab_tra;
|
|
TLocalisamfile* _caus,*_rcaus,*_clifo,*_pcon,*_mov,*_rmov,*_rmoviva,*_saldi,*_occas;
|
|
TIsamtempfile* _tcaus,*_trcaus,*_tclifo,*_tpcon,*_tmov,*_trmov,*_triva,*_toccas;
|
|
TTable* _reg;
|
|
TTransfer_file _tras_file;
|
|
TArray _aggiorna;
|
|
char _scelta, _ric_auto;
|
|
TSaldo_agg _sld;
|
|
TProgind* _prog;
|
|
|
|
int _numinv,_nultras,_annoes,_g,_c;
|
|
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,_tmpoccas;
|
|
|
|
public:
|
|
TString _titolo;
|
|
|
|
virtual bool create();
|
|
virtual bool destroy();
|
|
virtual bool menu(MENU_TAG m);
|
|
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);
|
|
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 occasionali(const TString& ocfpi);
|
|
|
|
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";
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
_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;
|
|
}
|
|
|
|
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();
|
|
|
|
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 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;
|
|
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);
|
|
}
|
|
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_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(const TString& ocfpi)
|
|
{
|
|
TString chiave;
|
|
long prog = 1;
|
|
bool esiste = FALSE;
|
|
|
|
TString nocfpi = _tmov->get("TOCFP");
|
|
nocfpi.trim();
|
|
|
|
if (nocfpi.empty())
|
|
{
|
|
_occas->setkey(1);
|
|
_occas->zero();
|
|
_occas->put("CFPI", "RIC9999999999999");
|
|
_occas->read();
|
|
_occas->prev();
|
|
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);
|
|
}
|
|
else
|
|
chiave = format("%3s%13ld", (const char*) "RIC", prog);
|
|
|
|
esiste = FALSE;
|
|
}
|
|
else
|
|
{
|
|
_occas->setkey(1);
|
|
_occas->zero();
|
|
_occas->put("CFPI", nocfpi);
|
|
_occas->read();
|
|
|
|
esiste = TRUE;
|
|
}
|
|
|
|
_toccas->setkey(1);
|
|
_toccas->zero();
|
|
_toccas->put(OCC_CFPI, ocfpi);
|
|
_toccas->read();
|
|
|
|
_occas->curr() = _toccas->curr();
|
|
|
|
if (esiste)
|
|
_occas->rewrite();
|
|
else
|
|
_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);
|
|
|
|
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->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);
|
|
}
|
|
}
|
|
|
|
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 ("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();
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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(*argv[2],p3);
|
|
main_app.run(argc, argv,main_app._titolo);
|
|
return TRUE;
|
|
}
|