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);
|
endExport(a01);
|
||||||
|
|
||||||
logFile << getTime() << " - Fine esportazione A01!\n";
|
logFile << getTime() << " - Fine esportazione A01!\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m->get_bool(B_IMPORT))
|
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
|
bool TCampass_app::o01a(const TString id) const
|
||||||
{
|
{
|
||||||
|
long totalItems = 0;
|
||||||
TODBC_recordset sqlset("", true);
|
TODBC_recordset sqlset("", true);
|
||||||
// Controllo la connessione
|
// Controllo la connessione
|
||||||
if (!sqlset.connect(DSN, usr, psw))
|
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("PROVV", rowRDoc.get("DAPROVV"));
|
||||||
filtroFiltro.put("NDOC", rowRDoc.get("DANDOC"));
|
filtroFiltro.put("NDOC", rowRDoc.get("DANDOC"));
|
||||||
TCursor curFiltro(&rdoc, "", 1, &filtroFiltro, &filtroFiltro);
|
TCursor curFiltro(&rdoc, "", 1, &filtroFiltro, &filtroFiltro);
|
||||||
|
|
||||||
bool trovato = false;
|
bool trovato = false;
|
||||||
for(curFiltro = 0; curFiltro.pos() < curFiltro.items() && !trovato;)
|
for(curFiltro = 0; curFiltro.pos() < curFiltro.items() && !trovato;)
|
||||||
{
|
{
|
||||||
@ -538,7 +538,7 @@ bool TCampass_app::o01a(const TString id) const
|
|||||||
if(!trovato) ++curFiltro;
|
if(!trovato) ++curFiltro;
|
||||||
}
|
}
|
||||||
if(curFiltro.items() <= 0 || !trovato || curFiltro.curr().get_bool("RIGAEVASA")) continue;
|
if(curFiltro.items() <= 0 || !trovato || curFiltro.curr().get_bool("RIGAEVASA")) continue;
|
||||||
|
totalItems++;
|
||||||
// Dichiaro la stringa
|
// Dichiaro la stringa
|
||||||
TString sqlQuery;
|
TString sqlQuery;
|
||||||
|
|
||||||
@ -582,57 +582,60 @@ bool TCampass_app::o01a(const TString id) const
|
|||||||
|
|
||||||
bool TCampass_app::o01c(const TString id) const
|
bool TCampass_app::o01c(const TString id) const
|
||||||
{
|
{
|
||||||
|
long totalItems = 0;
|
||||||
TODBC_recordset sqlset("", true);
|
TODBC_recordset sqlset("", true);
|
||||||
// Controllo la connessione
|
// Controllo la connessione
|
||||||
if (!sqlset.connect(DSN, usr, psw))
|
if (!sqlset.connect(DSN, usr, psw))
|
||||||
return false;
|
return false;
|
||||||
|
TRelation rdoc(LF_RIGHEDOC), filtro(LF_RIGHEDOC), rdist(LF_RDIST);
|
||||||
TRelation rdist(LF_RDIST),rdoc(LF_RIGHEDOC), filtro(LF_RIGHEDOC);
|
|
||||||
int items;
|
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;
|
// Aggiorno il Progress Monitor
|
||||||
// I long non danno errori in creazione
|
if (!p.add_status())
|
||||||
TString campoQuery = "USE RDIST\n";
|
break;
|
||||||
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";
|
|
||||||
|
|
||||||
TISAM_recordset curDist(campoQuery);
|
TRectype rowRDoc = crdoc.curr();
|
||||||
items = curDist.items();
|
if(rowRDoc.get_bool("RIGAEVASA")) continue;
|
||||||
|
if(rowRDoc.get("DACODNUM") == "ORC" || rowRDoc.get("DACODNUM") == "PRC")
|
||||||
TProgress_monitor p(items, msg);
|
|
||||||
|
|
||||||
for (bool ok = curDist.move_first(); ok && !p.is_cancelled(); ok = curDist.move_next())
|
|
||||||
{
|
{
|
||||||
// Aggiorno il Progress Monitor
|
// Adesso creo il cursore del filtro
|
||||||
if (!p.add_status())
|
|
||||||
break;
|
|
||||||
|
|
||||||
if(curDist.get("34.RIGAEVASA").as_bool())
|
|
||||||
bool tolla = true;
|
|
||||||
|
|
||||||
// Vado a prendere la riga di riferimento
|
|
||||||
TRectype filtroFiltro(filtro.curr());
|
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());
|
TRectype rowFiltro = curFiltro.curr();
|
||||||
filtroFiltro.put("ANNO", curDist.get("34.DAANNO").as_string());
|
if(rowFiltro.get_bool("RIGAEVASA")) continue;
|
||||||
filtroFiltro.put("PROVV", curDist.get("34.DAPROVV").as_string());
|
trovato |= rowFiltro.get_int("IDRIGA") == rowRDoc.get_int("DAIDRIGA");
|
||||||
filtroFiltro.put("NDOC", curDist.get("34.DANDOC").as_string());
|
}
|
||||||
|
if(trovato)
|
||||||
TCursor curFiltro(&rdoc, "", 1, &filtroFiltro, &filtroFiltro);
|
{
|
||||||
if(curFiltro.items() > 1)
|
totalItems++;
|
||||||
bool tolla2 = true;
|
// Adesso creo il cursore di RDIST
|
||||||
for (curFiltro = 0; curFiltro.pos() < curFiltro.items() && !p.is_cancelled(); ++curFiltro)
|
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
|
TRectype rowDist = cRdist.curr();
|
||||||
if(curFiltro.curr().get_int("IDRIGA") != curDist.get("34.DAIDRIGA").as_int() || curFiltro.curr().get_bool("RIGAEVASA")) continue;
|
if(rowDist.get_char("TIPO") != 'A') continue;
|
||||||
TString sqlQuery;
|
TString sqlQuery;
|
||||||
sqlQuery << "INSERT INTO O01C ( IKRUNIMP, CStr, CPRD, CARTFIL, CUDM, QIMP, QBASE, XTCALC, NSEQ )";
|
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 << "VALUES('" << id << "','DBS','" << zeroFill(rowRDoc.get("NDOC")) << ".";
|
||||||
sqlQuery << curDist.get("34.IDRIGA").as_string() << "','" << curDist.get("113.CODCOMP").as_string() << "','";
|
sqlQuery << rowRDoc.get("IDRIGA") << "','" << rowDist.get("CODCOMP") << "','";
|
||||||
sqlQuery << curDist.get("113.UM").as_string() << "','" << curDist.get("113.EXPR").as_string() << "','1','0','" << curDist.get("113.NRIG").as_string() << "');";
|
sqlQuery << rowDist.get("UM") << "','" << rowDist.get("EXPR") << "','1','0','" << rowDist.get("NRIG") << "');";
|
||||||
if(sqlset.exec(sqlQuery) != 1)
|
if(sqlset.exec(sqlQuery) != 1)
|
||||||
{
|
{
|
||||||
message_box(sqlQuery);
|
message_box(sqlQuery);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user