Patch level : 12.0
Files correlati : Commento : Rifatta query O01C git-svn-id: svn://10.65.10.50/branches/R_10_00@23938 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
df6e74ca09
commit
ccaf3f2549
@ -331,7 +331,7 @@ TString TCampass_app::esporta(const TString& DSN, const TString& usr, const TStr
|
||||
endExport(a01);
|
||||
|
||||
logFile << getTime() << " - Fine esportazione A01!\n";
|
||||
}
|
||||
}
|
||||
|
||||
if(m->get_bool(B_IMPORT))
|
||||
{
|
||||
@ -485,6 +485,7 @@ bool TCampass_app::a01a(const TString id) const
|
||||
|
||||
bool TCampass_app::o01a(const TString id) const
|
||||
{
|
||||
long totalItems = 0;
|
||||
TODBC_recordset sqlset("", true);
|
||||
// Controllo la connessione
|
||||
if (!sqlset.connect(DSN, usr, psw))
|
||||
@ -530,7 +531,6 @@ bool TCampass_app::o01a(const TString id) const
|
||||
filtroFiltro.put("PROVV", rowRDoc.get("DAPROVV"));
|
||||
filtroFiltro.put("NDOC", rowRDoc.get("DANDOC"));
|
||||
TCursor curFiltro(&rdoc, "", 1, &filtroFiltro, &filtroFiltro);
|
||||
|
||||
bool trovato = false;
|
||||
for(curFiltro = 0; curFiltro.pos() < curFiltro.items() && !trovato;)
|
||||
{
|
||||
@ -538,7 +538,7 @@ bool TCampass_app::o01a(const TString id) const
|
||||
if(!trovato) ++curFiltro;
|
||||
}
|
||||
if(curFiltro.items() <= 0 || !trovato || curFiltro.curr().get_bool("RIGAEVASA")) continue;
|
||||
|
||||
totalItems++;
|
||||
// Dichiaro la stringa
|
||||
TString sqlQuery;
|
||||
|
||||
@ -582,57 +582,60 @@ bool TCampass_app::o01a(const TString id) const
|
||||
|
||||
bool TCampass_app::o01c(const TString id) const
|
||||
{
|
||||
long totalItems = 0;
|
||||
TODBC_recordset sqlset("", true);
|
||||
// Controllo la connessione
|
||||
if (!sqlset.connect(DSN, usr, psw))
|
||||
return false;
|
||||
|
||||
TRelation rdist(LF_RDIST),rdoc(LF_RIGHEDOC), filtro(LF_RIGHEDOC);
|
||||
TRelation rdoc(LF_RIGHEDOC), filtro(LF_RIGHEDOC), rdist(LF_RDIST);
|
||||
int items;
|
||||
for(int year = TDate(TODAY).year() - 2; year <= TDate(TODAY).year(); year++)
|
||||
TString msg("Esportazione tabella "); msg << "O01C";
|
||||
TRectype frdoc(rdoc.curr());
|
||||
frdoc.put("CODNUM", "ORP1");
|
||||
TCursor crdoc(&rdoc, "", 1, &frdoc, &frdoc);
|
||||
items = crdoc.items();
|
||||
TProgress_monitor p(items, msg);
|
||||
for(crdoc = 0; crdoc.pos() < items; ++crdoc)
|
||||
{
|
||||
TString msg("Esportazione tabella "); msg << "O01C Anno: " << year;
|
||||
// I long non danno errori in creazione
|
||||
TString campoQuery = "USE RDIST\n";
|
||||
campoQuery << "SELECT (113.TIPO=\"A\")&&(34.RIGAEVASA!=\"X\")\n";
|
||||
campoQuery << "JOIN RDOC KEY 5 INTO CODART==CODDIST ANNO==" << year << " CODNUM=='ORP1'\n";
|
||||
//campoQuery << "BY 113.CODDIST";
|
||||
// Aggiorno il Progress Monitor
|
||||
if (!p.add_status())
|
||||
break;
|
||||
|
||||
TISAM_recordset curDist(campoQuery);
|
||||
items = curDist.items();
|
||||
|
||||
TProgress_monitor p(items, msg);
|
||||
|
||||
for (bool ok = curDist.move_first(); ok && !p.is_cancelled(); ok = curDist.move_next())
|
||||
TRectype rowRDoc = crdoc.curr();
|
||||
if(rowRDoc.get_bool("RIGAEVASA")) continue;
|
||||
if(rowRDoc.get("DACODNUM") == "ORC" || rowRDoc.get("DACODNUM") == "PRC")
|
||||
{
|
||||
// Aggiorno il Progress Monitor
|
||||
if (!p.add_status())
|
||||
break;
|
||||
|
||||
if(curDist.get("34.RIGAEVASA").as_bool())
|
||||
bool tolla = true;
|
||||
|
||||
// Vado a prendere la riga di riferimento
|
||||
// Adesso creo il cursore del filtro
|
||||
TRectype filtroFiltro(filtro.curr());
|
||||
if(curDist.get("34.DACODNUM").as_string() == "ORC" || curDist.get("34.DACODNUM").as_string() == "PRC")
|
||||
filtroFiltro.put("CODNUM", rowRDoc.get("DACODNUM"));
|
||||
filtroFiltro.put("ANNO", rowRDoc.get("DAANNO"));
|
||||
filtroFiltro.put("PROVV", rowRDoc.get("DAPROVV"));
|
||||
filtroFiltro.put("NDOC", rowRDoc.get("DANDOC"));
|
||||
|
||||
TCursor curFiltro(&rdoc, "", 1, &filtroFiltro, &filtroFiltro);
|
||||
bool trovato = false;
|
||||
for (curFiltro = 0; curFiltro.pos() < curFiltro.items() && !trovato; ++curFiltro)
|
||||
{
|
||||
filtroFiltro.put("CODNUM", curDist.get("34.DACODNUM").as_string());
|
||||
filtroFiltro.put("ANNO", curDist.get("34.DAANNO").as_string());
|
||||
filtroFiltro.put("PROVV", curDist.get("34.DAPROVV").as_string());
|
||||
filtroFiltro.put("NDOC", curDist.get("34.DANDOC").as_string());
|
||||
|
||||
TCursor curFiltro(&rdoc, "", 1, &filtroFiltro, &filtroFiltro);
|
||||
if(curFiltro.items() > 1)
|
||||
bool tolla2 = true;
|
||||
for (curFiltro = 0; curFiltro.pos() < curFiltro.items() && !p.is_cancelled(); ++curFiltro)
|
||||
TRectype rowFiltro = curFiltro.curr();
|
||||
if(rowFiltro.get_bool("RIGAEVASA")) continue;
|
||||
trovato |= rowFiltro.get_int("IDRIGA") == rowRDoc.get_int("DAIDRIGA");
|
||||
}
|
||||
if(trovato)
|
||||
{
|
||||
totalItems++;
|
||||
// Adesso creo il cursore di RDIST
|
||||
TRectype frdist(rdist.curr());
|
||||
frdist.put("CODDIST", rowRDoc.get("CODART"));
|
||||
TCursor cRdist(&rdist, "", 1, &frdist, &frdist);
|
||||
for (cRdist = 0; cRdist.pos() < cRdist.items(); ++cRdist)
|
||||
{
|
||||
// Filtro aggiuntivo
|
||||
if(curFiltro.curr().get_int("IDRIGA") != curDist.get("34.DAIDRIGA").as_int() || curFiltro.curr().get_bool("RIGAEVASA")) continue;
|
||||
TRectype rowDist = cRdist.curr();
|
||||
if(rowDist.get_char("TIPO") != 'A') continue;
|
||||
TString sqlQuery;
|
||||
sqlQuery << "INSERT INTO O01C ( IKRUNIMP, CStr, CPRD, CARTFIL, CUDM, QIMP, QBASE, XTCALC, NSEQ )";
|
||||
sqlQuery << "VALUES('" << id << "','DBS','" << zeroFill(curDist.get("34.NDOC").as_string()) << ".";
|
||||
sqlQuery << curDist.get("34.IDRIGA").as_string() << "','" << curDist.get("113.CODCOMP").as_string() << "','";
|
||||
sqlQuery << curDist.get("113.UM").as_string() << "','" << curDist.get("113.EXPR").as_string() << "','1','0','" << curDist.get("113.NRIG").as_string() << "');";
|
||||
sqlQuery << "VALUES('" << id << "','DBS','" << zeroFill(rowRDoc.get("NDOC")) << ".";
|
||||
sqlQuery << rowRDoc.get("IDRIGA") << "','" << rowDist.get("CODCOMP") << "','";
|
||||
sqlQuery << rowDist.get("UM") << "','" << rowDist.get("EXPR") << "','1','0','" << rowDist.get("NRIG") << "');";
|
||||
if(sqlset.exec(sqlQuery) != 1)
|
||||
{
|
||||
message_box(sqlQuery);
|
||||
|
Loading…
x
Reference in New Issue
Block a user