fe341219bc
Files correlati : VE7.EXE Ricompilazione Demo : [ ] Commento : Corretto erroracci git-svn-id: svn://10.65.10.50/trunk@14592 c028cbd2-c16b-5b4b-a496-9718f37d4682
346 lines
8.3 KiB
C++
Executable File
346 lines
8.3 KiB
C++
Executable File
#include "ve7700.h"
|
|
|
|
#include <recarray.h>
|
|
#include <tabutil.h>
|
|
#include <utility.h>
|
|
|
|
#include <..\mg\anamag.h>
|
|
#include <..\mg\umart.h>
|
|
#include <clifo.h>
|
|
#include <comuni.h>
|
|
#include <doc.h>
|
|
#include <mov.h>
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TGalileo_clifo
|
|
///////////////////////////////////////////////////////////
|
|
|
|
int TGalileo_clifo::cancella_clifo(TLocalisamfile& clifo) const
|
|
{
|
|
return NOERR;
|
|
}
|
|
|
|
long TGalileo_clifo::get_next_key(const char tipocf) const
|
|
{
|
|
TLocalisamfile clifo(LF_CLIFO);
|
|
long codcf = 1L;
|
|
if (!clifo.empty())
|
|
{
|
|
if (tipocf == 'C')
|
|
{
|
|
clifo.put(CLI_TIPOCF, 'F');
|
|
clifo.read(_isgteq);
|
|
if (clifo.good())
|
|
clifo.prev();
|
|
clifo.setstatus(NOERR);
|
|
}
|
|
else
|
|
clifo.last();
|
|
if (clifo.good())
|
|
{
|
|
const char tipo = clifo.get(CLI_TIPOCF)[0];
|
|
if (tipocf == tipo)
|
|
codcf += clifo.get_long(CLI_CODCF);
|
|
}
|
|
}
|
|
return codcf;
|
|
}
|
|
|
|
long TGalileo_clifo::get_codcf(const char tipocf, const char* ricalt) const
|
|
{
|
|
TLocalisamfile clifo(LF_CLIFO);
|
|
long codcf = -1;
|
|
clifo.setkey(6);
|
|
clifo.put(CLI_TIPOCF, tipocf);
|
|
clifo.put(CLI_RICALT, ricalt);
|
|
if (clifo.read() == NOERR)
|
|
codcf = clifo.get_long(CLI_CODCF);
|
|
return codcf;
|
|
}
|
|
|
|
bool TGalileo_clifo::dump()
|
|
{
|
|
TConfig& ini = config();
|
|
TString_array lista_clifo;
|
|
ini.list_variables(lista_clifo, true, "CLIFO", true);
|
|
TToken_string lista_dump;
|
|
lista_dump.add(CLI_TIPOCF);
|
|
lista_dump.add(CLI_CODCF);
|
|
lista_dump.add(CLI_COMCF);
|
|
TString16 campo_dest, campo_orig;
|
|
FOR_EACH_ARRAY_ROW(lista_clifo,i,row)
|
|
{
|
|
row->get(0, campo_dest);
|
|
row->get(1, campo_orig);
|
|
if (!campo_orig.blank())
|
|
lista_dump.add(campo_dest);
|
|
}
|
|
TFilename path = _path;
|
|
path << "clifo.txt";
|
|
TSystemisamfile clifo(LF_CLIFO);
|
|
return (clifo.dump(path, lista_dump) == NOERR);
|
|
}
|
|
|
|
bool TGalileo_clifo::trasferisci()
|
|
{
|
|
TString query =
|
|
"SELECT CLFOCP, CONTCA, DSCOCP, DSULCP, INDICA, LOCACA, PROVCA, CAPOCA, "
|
|
"NAZICA, CISOCA, PIVACA, CDFICA, NTELCA, NFAXCA \n"
|
|
"FROM CGANA01J \n";
|
|
if (!_data.empty())
|
|
{
|
|
query << "WHERE DTMNCA >= ";
|
|
query << _data.date2ansi();
|
|
}
|
|
|
|
TRecordset& recset = create_recordset(query);
|
|
|
|
TString str;
|
|
|
|
TConfig& ini = config();
|
|
TString_array lista_clifo;
|
|
ini.list_variables(lista_clifo, true, "CLIFO", true);
|
|
TLocalisamfile clifo(LF_CLIFO);
|
|
TRectype& rec_clifo = clifo.curr();
|
|
|
|
TRecord_cache cache_comuni(LF_COMUNI, 2);
|
|
|
|
TGalileo_iterator pi(this);
|
|
while (++pi)
|
|
{
|
|
const TString& contca = get_str("CONTCA");
|
|
const char tipocf = get_str("CLFOCP")[0];
|
|
long codcf = get_codcf(tipocf, contca); // mi restiuisce il codice del clinete se esiste oppure -1 se da aggiungere
|
|
|
|
bool needs_creation = codcf <= 0;
|
|
bool good = true;
|
|
|
|
if (!needs_creation)
|
|
{
|
|
// il cliente/fornitore va aggiornato
|
|
rec_clifo.zero();
|
|
rec_clifo.put(CLI_TIPOCF, tipocf);
|
|
rec_clifo.put(CLI_CODCF, codcf);
|
|
good = clifo.read() == NOERR;
|
|
if (!good)
|
|
needs_creation = true;
|
|
}
|
|
|
|
if (needs_creation)
|
|
{
|
|
// il cliente/fornitore va inserito in campo
|
|
if (codcf <= 0)
|
|
codcf = get_next_key(tipocf);
|
|
rec_clifo.zero();
|
|
rec_clifo.put(CLI_TIPOCF, tipocf);
|
|
rec_clifo.put(CLI_CODCF, codcf);
|
|
good &= test_write(clifo);
|
|
}
|
|
|
|
if (good)
|
|
{
|
|
// aggiormento comune
|
|
TString80 dencom = get_str("LOCACA");
|
|
dencom.trim(); dencom.upper();
|
|
const TRectype& reccom = cache_comuni.get(dencom);
|
|
if (dencom == reccom.get(COM_DENCOM))
|
|
rec_clifo.put(CLI_COMCF, reccom.get(COM_COM));
|
|
else
|
|
{
|
|
rec_clifo.zero(CLI_COMCF);
|
|
rec_clifo.put(CLI_LOCCF, dencom);
|
|
|
|
log("");
|
|
str.format(FR("Cliente/Fornitore %c %ld: comune non trovato %s"), tipocf, codcf, (const char*)dencom);
|
|
log(str);
|
|
}
|
|
aggiorna_record(clifo, lista_clifo);
|
|
}
|
|
}
|
|
return write_enabled();
|
|
}
|
|
|
|
bool TGalileo_clifo::aggiorna_record(TLocalisamfile& file, const TString_array& lista_campi)
|
|
{
|
|
TRectype& rec = file.curr();
|
|
TString campo_dest, campo_orig, valore, str;
|
|
FOR_EACH_ARRAY_ROW(lista_campi,i,row)
|
|
{
|
|
row->get(0, campo_dest);
|
|
row->get(1, campo_orig);
|
|
if (!campo_orig.blank())
|
|
{
|
|
if (campo_orig[0] == '_')
|
|
{
|
|
TToken_string elabora(campo_orig.mid(1),',');
|
|
const TString& str = elabora.get();
|
|
if (str == "TAB") // formato _TAB, <tabella da leggere>,<valore CODTAB>, <campo da leggere>
|
|
{
|
|
const TString4 tab = elabora.get(); // tabella da leggere
|
|
const TString80 campo = elabora.get();
|
|
const TString16 codtab = get_str(campo);
|
|
const TString80 campotab = elabora.get();
|
|
valore = cache().get(tab, codtab, campotab);
|
|
}
|
|
else if (str == "FISSO")
|
|
valore = elabora.get(); // valore fisso indicato in configurazione
|
|
}
|
|
else
|
|
valore = get_str(campo_orig);
|
|
rec.put(campo_dest, valore);
|
|
}
|
|
}
|
|
return test_rewrite(file);
|
|
}
|
|
|
|
TGalileo_clifo::TGalileo_clifo()
|
|
{
|
|
}
|
|
|
|
TGalileo_clifo::~TGalileo_clifo()
|
|
{
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TGalileo_articoli
|
|
///////////////////////////////////////////////////////////
|
|
|
|
int TGalileo_articoli::cancella_articolo(TLocalisamfile& anamag) const
|
|
{
|
|
return NOERR;
|
|
}
|
|
|
|
bool TGalileo_articoli::dump()
|
|
{
|
|
TConfig& ini = config();
|
|
TString_array lista_anamag;
|
|
ini.list_variables(lista_anamag, true, "ANAMAG", true);
|
|
TToken_string lista_dump;
|
|
lista_dump.add(ANAMAG_CODART);
|
|
TString16 campo_dest, campo_orig;
|
|
FOR_EACH_ARRAY_ROW(lista_anamag,i,row)
|
|
{
|
|
row->get(0, campo_dest);
|
|
row->get(1, campo_orig);
|
|
if (!campo_orig.blank())
|
|
lista_dump.add(campo_dest);
|
|
}
|
|
TFilename path = _path;
|
|
path << "umart.txt";
|
|
TSystemisamfile anamag(LF_ANAMAG);
|
|
TSystemisamfile umart(LF_UMART);
|
|
int err = umart.dump(path);
|
|
if (err == NOERR)
|
|
{
|
|
path = _path;
|
|
path << "anamag.txt";
|
|
err = anamag.dump(path, lista_dump);
|
|
}
|
|
return (err == NOERR);
|
|
}
|
|
|
|
bool TGalileo_articoli::trasferisci()
|
|
{
|
|
TString query =
|
|
"SELECT RICOD, RDES1, RDES2, RDES3, RSUMS, RITIP \n"
|
|
"FROM BRISO00F, BTABE00F \n"
|
|
"WHERE (MID(TBDAT,9,1)=RITIP) AND (TBTIP='COD') AND (TBELE='RIS')";
|
|
if (!_data.empty())
|
|
{
|
|
query << "AND (RIDTX >= ";
|
|
query << _data.date2ansi() << ")";
|
|
}
|
|
|
|
TRecordset& recset = create_recordset(query);
|
|
|
|
TString str;
|
|
|
|
TConfig& ini = config();
|
|
TString_array lista_anamag, lista_umart;
|
|
ini.list_variables(lista_anamag, true, "ANAMAG", true);
|
|
ini.list_variables(lista_umart, true, "UMART", true);
|
|
TLocalisamfile anamag(LF_ANAMAG);
|
|
TLocalisamfile umart(LF_UMART);
|
|
TRectype& rec_anamag = anamag.curr();
|
|
TRectype& rec_umart = umart.curr();
|
|
|
|
TGalileo_iterator pi(this);
|
|
while (++pi)
|
|
{
|
|
const TString& codart = get_str("RICOD");
|
|
rec_anamag.zero();
|
|
rec_anamag.put(ANAMAG_CODART, codart);
|
|
bool good = anamag.read() == NOERR;
|
|
if (!good)
|
|
{
|
|
rec_anamag.zero();
|
|
rec_anamag.put(ANAMAG_CODART, codart);
|
|
good = test_write(anamag);
|
|
}
|
|
if (good)
|
|
{
|
|
aggiorna_record(anamag, lista_anamag);
|
|
rec_umart.zero();
|
|
rec_umart.put(UMART_CODART, codart);
|
|
rec_umart.put(UMART_NRIGA, 1);
|
|
bool good = umart.read() == NOERR;
|
|
if (!good)
|
|
{
|
|
rec_umart.zero();
|
|
rec_umart.put(UMART_CODART, codart);
|
|
rec_umart.put(UMART_NRIGA, 1);
|
|
good = (umart.write() == NOERR);
|
|
}
|
|
if (good)
|
|
{
|
|
rec_umart.put(UMART_UM, get_str("RSUMS"));
|
|
rec_umart.put(UMART_FC, 1);
|
|
umart.rewrite();
|
|
}
|
|
}
|
|
}
|
|
return write_enabled();
|
|
}
|
|
|
|
bool TGalileo_articoli::aggiorna_record(TLocalisamfile& file, const TString_array& lista_campi)
|
|
{
|
|
TRectype& rec = file.curr();
|
|
TString campo_dest, campo_orig, valore, str;
|
|
FOR_EACH_ARRAY_ROW(lista_campi,i,row)
|
|
{
|
|
row->get(0, campo_dest);
|
|
row->get(1, campo_orig);
|
|
if (!campo_orig.blank())
|
|
{
|
|
if (campo_orig[0] == '_')
|
|
{
|
|
TToken_string elabora(campo_orig.mid(1),',');
|
|
const TString& str = elabora.get();
|
|
if (str == "TAB") // formato _TAB, <tabella da leggere>,<valore CODTAB>, <campo da leggere>
|
|
{
|
|
const TString4 tab = elabora.get(); // tabella da leggere
|
|
const TString80 campo = elabora.get();
|
|
const TString16 codtab = get_str(campo);
|
|
const TString80 campotab = elabora.get();
|
|
valore = cache().get(tab, codtab, campotab);
|
|
}
|
|
else if (str == "FISSO")
|
|
valore = elabora.get(); // valore fisso indicato in configurazione
|
|
}
|
|
else
|
|
valore = get_str(campo_orig);
|
|
rec.put(campo_dest, valore);
|
|
}
|
|
}
|
|
return test_rewrite(file);
|
|
}
|
|
|
|
TGalileo_articoli::TGalileo_articoli()
|
|
{
|
|
}
|
|
|
|
TGalileo_articoli::~TGalileo_articoli()
|
|
{
|
|
}
|
|
|