Patch level : 12.0 574

Files correlati     : bs
Commento            :
- Sistemati errori in importazione UM
- Sistemato errore con codartalt == codart

git-svn-id: svn://10.65.10.50/branches/R_10_00@24495 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
mtollari 2018-05-24 08:20:58 +00:00
parent 73cb530d74
commit a678a66b50

View File

@ -495,55 +495,91 @@ void TSknet_sync::sync_anamag()
TISAM_recordset art(query);
sync_table(art, "tieArticoli", fields);
// Controllo se esistono varianti e le aggiungo
query.cut(0) << "SELECT * FROM tieArtVarianti where origine=" << their_origin();
TODBC_recordset odbc(query);
odbc.connect(_dsn, _usr, _psw);
// Apro codcorr per aggiungere i codici dei clienti
TLocalisamfile ccor(LF_CODCORR);
TRectype rccor(LF_CODCORR);
for (bool go = odbc.move_first(); go; go = odbc.move_next())
// Sincronizzo le unità di misura
{
// Lavoro sul file ISAM, più veloce
// Azzero
ccor.first(); // Useless??
rccor.zero();
bool add = true;
int riga = 1;
rccor.put(CODCORR_CODART, odbc.get("CodPadre").as_string());
rccor.put(CODCORR_NRIGA, riga);
if (ccor.read(rccor, _isequal) == NOERR)
query.cut(0) << "SELECT * from tieArticoli where Origine=" << their_origin();
TODBC_recordset odbcunit(query);
odbcunit.connect(_dsn, _usr, _psw);
for (bool go = odbcunit.move_first(); go; go = odbcunit.move_next())
{
while (add && rccor.get(CODCORR_CODART) == odbc.get("CodPadre").as_string())
// Umart
TLocalisamfile umart(LF_UMART);
TRectype rumart(LF_UMART);
const TString& codpadre = odbcunit.get("CodPadre").as_string();
rumart.put("CODART", codpadre);
rumart.put("NRIGA", 1);
rumart.put("UM", "PZ");
rumart.put("FC", UNO);
if (rumart.rewrite_write(umart) != NOERR)
{
riga = rccor.get_int(CODCORR_NRIGA);
add = rccor.get(CODCORR_CODARTALT) != odbc.get("CodArticolo").as_string();
rccor.next(ccor);
// Eror!
bool tolla = true;
TString msg = "Errata importazione UM per l'articolo ";
msg << codpadre;
_log->log(1, msg);
}
}
if (add)
{
rccor.zero();
rccor.put(CODCORR_CODART, odbc.get("CodPadre").as_string());
rccor.put(CODCORR_NRIGA, riga++);
rccor.put(CODCORR_CODARTALT, odbc.get("CodArticolo").as_string());
rccor.put(CODCORR_UM, ini_get_string(CONFIG_DITTA, "BS", "SKCodUmsDef"));
ccor.write(rccor);
}
}
// Umart
TLocalisamfile umart(LF_UMART);
TRectype rumart(LF_UMART);
rumart.put("CODART", odbc.get("CodPadre").as_string());
rumart.put("NRIGA", 1);
rumart.put("UM", "PZ");
rumart.put("FC", UNO);
if (rumart.rewrite_write(umart) != NOERR)
{
// Eror!
bool tolla = true;
// Controllo se esistono varianti e le aggiungo
query.cut(0) << "SELECT * FROM tieArtVarianti where origine=" << their_origin();
TODBC_recordset odbc(query);
odbc.connect(_dsn, _usr, _psw);
// Apro codcorr per aggiungere i codici dei clienti
TLocalisamfile ccor(LF_CODCORR);
TRectype rccor(LF_CODCORR);
// Il primo giro svuoto CODCORR dagli articoli inseriti (sono stati importati tantissimi articoli con CODART == CODARTALT, così facendo pulisco)
for (bool go = odbc.move_first(); go; go = odbc.move_next())
{
ccor.first(); // Useless??
rccor.zero();
const TString& codpadre = odbc.get("CodPadre").as_string();
rccor.put(CODCORR_CODART, codpadre);
rccor.put(CODCORR_NRIGA, 1);
if (ccor.read(rccor, _isequal) == NOERR)
{
while (rccor.get(CODCORR_CODART) == codpadre)
{
rccor.remove(ccor);
rccor.next(ccor);
}
}
}
for (bool go = odbc.move_first(); go; go = odbc.move_next())
{
// Lavoro sul file ISAM, più veloce
// Azzero
ccor.first(); // Useless??
rccor.zero();
bool add = false;
int riga = 1;
const TString& codpadre = odbc.get("CodPadre").as_string();
const TString& codarticolo = odbc.get("CodArticolo").as_string();
rccor.put(CODCORR_CODART, codpadre);
rccor.put(CODCORR_NRIGA, riga);
if (codpadre != codarticolo && ccor.read(rccor, _isequal) == NOERR)
{
add = true;
while (add && rccor.get(CODCORR_CODART) == codpadre)
{
riga = rccor.get_int(CODCORR_NRIGA);
add = rccor.get(CODCORR_CODARTALT) != codarticolo;
rccor.next(ccor);
}
}
if (add)
{
rccor.zero();
rccor.put(CODCORR_CODART, codpadre);
rccor.put(CODCORR_NRIGA, riga++);
rccor.put(CODCORR_CODARTALT, codarticolo);
rccor.put(CODCORR_UM, ini_get_string(CONFIG_DITTA, "BS", "SKCodUmsDef"));
ccor.write(rccor);
}
}
}
// Conai
@ -553,7 +589,8 @@ void TSknet_sync::sync_anamag()
TLocalisamfile art(LF_ANAMAG);
TRectype rart(LF_ANAMAG);
query.cut(0) << "SELECT * FROM tieArtCONAI where origine=" << their_origin();
odbc.exec(query);
TODBC_recordset odbc(query);
odbc.connect(_dsn, _usr, _psw);
for (bool go = odbc.move_first(); go; go = odbc.move_next())
{
art.first(); // Useless??
@ -995,7 +1032,7 @@ void TSknet_sync::load_clifo(const char tipocf)
cfv.put(CFV_ADDBOLLI, tipocf == 'C');
// Non ho capito se alla fine mi passa qua i dati o nel campo NOTE
cfv.put(CFV_ASSFIS, tipocf == 'C' ? odbc.get("Cli_CodIva").as_string() : odbc.get("For_CodIva").as_string());
cfv.put(CFV_ASSFIS, cache().get("%SKI", tipocf == 'C' ? odbc.get("Cli_CodIva").as_string() : odbc.get("For_CodIva").as_string(), "S6"));
// Parso il campo Note
TToken_string note(odbc.get("Note").as_string());