89794b4b98
Files correlati : lv2.exe lv3.exe lv4.exe ve0.exe ve1.exe ve5.exe ve6.exe Ricompilazione Demo : [ ] Commento : Se il documento ha una causale di lavanderia il magazzino collegato non viene piu' lo prende dalla causale quindi) Programma per aggiornare i documenti da numero a numero sulle lavanderie (lv4 -3 ) non a menu ma per manutenzioni Per ilaria e roberto ( verificare che negli altri casi prenda il magazzino cllegato dal documento) git-svn-id: svn://10.65.10.50/trunk@20150 c028cbd2-c16b-5b4b-a496-9718f37d4682
154 lines
4.1 KiB
C++
Executable File
154 lines
4.1 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <doc.h>
|
|
#include <mask.h>
|
|
#include <postman.h>
|
|
#include <progind.h>
|
|
#include <relation.h>
|
|
|
|
#include "lv4400a.h"
|
|
#include "lvlib.h"
|
|
#include "..\ve\velib.h"
|
|
|
|
class TRewrite_docs_mask : public TMask
|
|
{
|
|
public:
|
|
TRewrite_docs_mask() : TMask("lv4400a") { }
|
|
virtual ~TRewrite_docs_mask() { }
|
|
};
|
|
|
|
|
|
class TRewrite_docs_change : public TSkeleton_application
|
|
{
|
|
|
|
protected: // TSkeleton_application
|
|
virtual void main_loop();
|
|
virtual bool create();
|
|
void update_mag(TDocumento & doc);
|
|
|
|
public:
|
|
TRewrite_docs_change() { }
|
|
virtual ~TRewrite_docs_change() { }
|
|
};
|
|
|
|
bool TRewrite_docs_change::create()
|
|
{
|
|
open_files(LF_TABCOM, LF_TAB, LF_CLIFO, LF_OCCAS, LF_INDSP, LF_CFVEN, LF_DOC, LF_RIGHEDOC,
|
|
LF_ANAMAG, LF_MOVMAG, LF_RMOVMAG, LF_CONDV, LF_SVRIEP, LF_AGENTI, LF_PERCPROV, LF_CESS,
|
|
LF_CAUSALI, LF_RCAUSALI, 0);
|
|
return TSkeleton_application::create();
|
|
}
|
|
|
|
void TRewrite_docs_change::update_mag(TDocumento & doc)
|
|
{
|
|
const int rows = doc.physical_rows();
|
|
|
|
for (int r = 1; r <= rows; r++)
|
|
{
|
|
TRiga_documento & row = doc[r];
|
|
TString4 causale = row.get(RDOC_CODAGG1);
|
|
|
|
if (causale.full())
|
|
{
|
|
/* TString4 codmag(doc.clifor().vendite().get(CFV_CODMAG));
|
|
TString4 coddep(doc.clifor().vendite().get(CFV_CODDEP));
|
|
TString4 codmagcoll(codmag);
|
|
TString4 coddepcoll(coddep); */
|
|
|
|
const TCausale_lavanderie cau(causale);
|
|
const TCausale_magazzino rit = cau.causale_ritiro();
|
|
const TCausale_magazzino con = cau.causale_consegna();
|
|
|
|
TString8 magazzino;
|
|
TString8 magazzinoc;
|
|
|
|
if(rit.get("S10").full())
|
|
magazzino = rit.get("S10").mid(0,5);
|
|
else
|
|
magazzino << ini_get_string(CONFIG_DITTA, "lv", "CODMAG") << ini_get_string(CONFIG_DITTA, "lv", "CODMAGN");
|
|
|
|
if(con.get("S10").full())
|
|
magazzinoc = con.get("S10").mid(0,5);
|
|
else
|
|
magazzinoc << ini_get_string(CONFIG_DITTA, "lv", "CODMAG") << ini_get_string(CONFIG_DITTA, "lv", "CODMAGC");
|
|
|
|
row.put(RDOC_CODMAG, magazzino);
|
|
row.put(RDOC_CODMAGC, magazzinoc);
|
|
}
|
|
}
|
|
}
|
|
|
|
void TRewrite_docs_change::main_loop()
|
|
{
|
|
TRewrite_docs_mask m;
|
|
while (m.run() == K_ENTER)
|
|
{
|
|
TRelation rel(LF_DOC);
|
|
m.autosave(rel);
|
|
// const bool update_mags = m.get_bool(F_UPDATEMAG);
|
|
const bool update_mags = false;
|
|
|
|
TRectype recini(rel.curr());
|
|
TRectype recfin(rel.curr());
|
|
|
|
recini.put(DOC_NDOC, m.get(F_DANUMERO));
|
|
recfin.put(DOC_NDOC, m.get(F_ANUMERO));
|
|
const TString4 stato = m.get(F_STATO);
|
|
|
|
TString filter;
|
|
|
|
if (stato.full())
|
|
filter << DOC_STATO << "==\"" << stato << "\"";
|
|
|
|
TCursor cur(&rel, filter, 1, &recini, &recfin);
|
|
const long total = cur.items();
|
|
if (total > 0)
|
|
{
|
|
TString msg = "Confermare l'aggiornamento di ";
|
|
msg.add_plural(total, "documento");
|
|
if (yesno_box(msg))
|
|
|
|
{
|
|
TProgind pi(total, "Elaborazione in corso...", TRUE, TRUE, 60);
|
|
TDocumento* doc = new TDocumento;
|
|
rel.lfile().set_curr(doc);
|
|
cur.freeze();
|
|
for (cur = 0; cur.pos() < total && !pi.iscancelled(); ++cur)
|
|
{
|
|
pi.addstatus(1);
|
|
if (update_mags)
|
|
update_mag(*doc);
|
|
doc->rewrite();
|
|
|
|
// Invia anche la transazione se necessario
|
|
/* if (::can_dispatch_transaction(*doc)) // da riimplementare
|
|
{
|
|
TFilename tmpname; tmpname.temp();
|
|
{ // Parentesi strategiche
|
|
TConfig ini(tmpname, "Transaction");
|
|
ini.set("Action", "MODIFY");
|
|
ini.set("Firm", get_firm());
|
|
ini.set("Mode", "A");
|
|
TString8 paradoc; paradoc.format("%d", LF_DOC);
|
|
ini.set_paragraph(paradoc);
|
|
ini.set(DOC_PROVV, doc->get(DOC_PROVV));
|
|
ini.set(DOC_ANNO, doc->get(DOC_ANNO));
|
|
ini.set(DOC_CODNUM, doc->get(DOC_CODNUM));
|
|
ini.set(DOC_NDOC, doc->get(DOC_NDOC));
|
|
}
|
|
::dispatch_transaction(*doc, tmpname);
|
|
::remove(tmpname);
|
|
} */
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
int lv4400(int argc, char* argv[])
|
|
{
|
|
TRewrite_docs_change a;
|
|
a.run(argc, argv, "Aggiornamento documenti");
|
|
return 0;
|
|
}
|
|
|