Patch level : 10.0
Files correlati : lv1 Ricompilazione Demo : [ ] Commento : Corretta gestione transazioni di stampa e filtro sullo stato documenti git-svn-id: svn://10.65.10.50/trunk@19832 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
97a79e484e
commit
c6ed5a8d50
123
lv/lv1100.cpp
123
lv/lv1100.cpp
@ -4,9 +4,12 @@
|
||||
#include <relation.h>
|
||||
#include <reprint.h>
|
||||
|
||||
#include <doc.h>
|
||||
|
||||
#include "lv1100a.h"
|
||||
#include "../ve/velib.h"
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TStampaBuoni_mask
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TStampaBuoni_mask: public TAutomask
|
||||
{
|
||||
@ -18,10 +21,12 @@ public:
|
||||
|
||||
TStampaBuoni_mask::TStampaBuoni_mask() : TAutomask("lv1100a")
|
||||
{
|
||||
// Riutilizza astutamente il titolo dell'applicazione per la maschera
|
||||
const TApplication& app = main_app();
|
||||
TConfig configlv(CONFIG_DITTA, "lv");
|
||||
const TString& title = app.title();
|
||||
set_caption(title);
|
||||
|
||||
TConfig configlv(CONFIG_DITTA, "lv");
|
||||
const char tipobuoni = app.argc() > 2 ? toupper(app.argv(2)[0]) : 'C';
|
||||
switch (tipobuoni)
|
||||
{
|
||||
@ -42,33 +47,41 @@ TStampaBuoni_mask::TStampaBuoni_mask() : TAutomask("lv1100a")
|
||||
}
|
||||
|
||||
bool TStampaBuoni_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
{ return true; }
|
||||
|
||||
class TStampaBuoni_app: public TSkeleton_application
|
||||
{
|
||||
protected:
|
||||
virtual void main_loop();
|
||||
void elabora(const TMask& mask, const char action) const;
|
||||
};
|
||||
///////////////////////////////////////////////////////////
|
||||
// TStampaBuoni_set
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TStampaBuoni_set : public TISAM_recordset
|
||||
{
|
||||
protected:
|
||||
static bool status_filter(const TRelation* rel);
|
||||
virtual void set_custom_filter(TCursor& cursor) const;
|
||||
|
||||
public:
|
||||
TStampaBuoni_set(const TMask& mask);
|
||||
};
|
||||
|
||||
// Accetta solo i documenti stampabili in definitivo
|
||||
bool TStampaBuoni_set::status_filter(const TRelation* rel)
|
||||
{
|
||||
const TRectype& doc = rel->curr();
|
||||
const char stato_attuale = doc.get_char(DOC_STATO);
|
||||
if (stato_attuale <= ' ')
|
||||
return true;
|
||||
|
||||
const TTipo_documento& tipo = cached_tipodoc(doc.get(DOC_TIPODOC));
|
||||
if (stato_attuale == tipo.stato_finale_stampa())
|
||||
return false;
|
||||
|
||||
const TString& stati_stampa = tipo.stati_iniziali_stampa();
|
||||
return stati_stampa.blank() || stati_stampa.find(stato_attuale) >= 0;
|
||||
}
|
||||
|
||||
void TStampaBuoni_set::set_custom_filter(TCursor& cursor) const
|
||||
{
|
||||
if (cursor.items() > 0)
|
||||
{
|
||||
cursor = 0L;
|
||||
const TString4 tipodoc = cursor.curr().get(DOC_TIPODOC);
|
||||
}
|
||||
cursor.set_filterfunction(status_filter);
|
||||
}
|
||||
|
||||
TStampaBuoni_set::TStampaBuoni_set(const TMask& mask) : TISAM_recordset("USE DOC")
|
||||
@ -93,45 +106,59 @@ TStampaBuoni_set::TStampaBuoni_set(const TMask& mask) : TISAM_recordset("USE DOC
|
||||
set_var("#CODITI_TO", TVariant(mask.get(F_CODITI_TO)));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TStampaBuoni_app
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TStampaBuoni_app: public TSkeleton_application
|
||||
{
|
||||
protected:
|
||||
virtual void main_loop();
|
||||
void elabora(const TMask& mask, const char action) const;
|
||||
};
|
||||
|
||||
void TStampaBuoni_app::elabora(const TMask& mask, const char action) const
|
||||
{
|
||||
TStampaBuoni_set buoni(mask);
|
||||
|
||||
TCursor* c = buoni.cursor();
|
||||
TCursor_sheet sht(c, " |NDOC|DATADOC|4->S0[1,25]|CODCF|20->RAGSOC", TR("Selezione Documenti"),
|
||||
HR("@1|Numero\nDoc.@7|Data\nDoc.@10|Stato@25|Cliente|Ragione Sociale@50"));
|
||||
|
||||
TCursor_sheet sht(c, " |NDOC|DATADOC|4->S0[1,25]|G1:CODITI|CODCF|20->RAGSOC", TR("Selezione Documenti"),
|
||||
HR("@1|Numero\nDoc.@7|Data\nDoc.@10|Stato@25|Itinerario|Cliente|Ragione Sociale@50"));
|
||||
sht.check(-1);
|
||||
if (sht.run() && sht.one_checked())
|
||||
{
|
||||
const TDate data_from = mask.get_date(F_DATA_FROM);
|
||||
TString80 chiavedoc = "D|";
|
||||
chiavedoc << data_from.year() << "|" << mask.get(F_CODNUM) << "|";
|
||||
TFilename tmp;
|
||||
tmp.temp("", "ini");
|
||||
|
||||
TFilename tmp; tmp.temp("", "ini");
|
||||
ofstream outf(tmp);
|
||||
|
||||
outf << "[Transaction]" << endl;
|
||||
outf << "Action=" << action << endl;
|
||||
outf << "Mode=D" << endl;
|
||||
outf << "[33]" << endl;
|
||||
// Ensure that the ofstream is well closed before ve1 call
|
||||
if (tmp.full()) // dummy test
|
||||
{
|
||||
const TDate data_from = mask.get_date(F_DATA_FROM);
|
||||
const TString& cod_num = mask.get(F_CODNUM);
|
||||
TString16 chiavedoc; // Parte della chiave comune a tutti i documenti
|
||||
chiavedoc << "D|" << data_from.year() << "|" << cod_num << "|";
|
||||
|
||||
long nx=0;
|
||||
ofstream outf(tmp);
|
||||
outf << "[Transaction]" << endl; // Transaction header
|
||||
outf << "Action=" << action << endl; // 'P'rint or 'A'nteprint
|
||||
outf << "Mode=D" << endl; // Definitive (always?)
|
||||
outf << endl;
|
||||
outf << "[33]" << endl; // Transaction body
|
||||
long nx = 0; // Document counter
|
||||
FOR_EACH_CHECKED_ROW(sht, i, row)
|
||||
{
|
||||
outf << "Doc(" << (nx++) << ")=";
|
||||
outf << chiavedoc << row->get(1) << endl;
|
||||
}
|
||||
}
|
||||
|
||||
const long items = sht.items();
|
||||
for (long i = 0L; i<items; i++)
|
||||
if (sht.checked(i))
|
||||
{
|
||||
outf << "Doc(" << (nx++) << ")=";
|
||||
outf << chiavedoc << sht.row(i).get_long(1) << endl;
|
||||
}
|
||||
outf.close();
|
||||
|
||||
TFilename appname = "ve1 -2 -i";
|
||||
appname << tmp;
|
||||
TExternal_app app(appname);
|
||||
app.run();
|
||||
tmp.fremove();
|
||||
if (tmp.exist())
|
||||
{
|
||||
TString cmdline; cmdline << "ve1 -2 -i" << tmp;
|
||||
TExternal_app app(cmdline);
|
||||
app.run();
|
||||
tmp.fremove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,9 +171,9 @@ void TStampaBuoni_app::main_loop()
|
||||
const KEY k = m.run();
|
||||
switch (k)
|
||||
{
|
||||
case K_ENTER: elabora(m, 'P'); break;
|
||||
case 'A': elabora(m, 'A'); break;
|
||||
default: running = false; break;
|
||||
case K_ENTER: elabora(m, 'P'); break; // 'P'rint
|
||||
case 'A': elabora(m, 'A'); break; // 'A'nteprint
|
||||
default: running = false; break; // quit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user