3070c2a72c
git-svn-id: svn://10.65.10.50/branches/R_10_00@22850 c028cbd2-c16b-5b4b-a496-9718f37d4682
166 lines
4.0 KiB
C++
Executable File
166 lines
4.0 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <automask.h>
|
|
#include <defmask.h>
|
|
#include <isam.h>
|
|
#include <recset.h>
|
|
#include <reprint.h>
|
|
#include <utility.h>
|
|
|
|
#include <mov.h>
|
|
|
|
#include "ct0100a.h"
|
|
|
|
////////////////////////////////////////////////////////
|
|
// MASCHERA
|
|
////////////////////////////////////////////////////////
|
|
class TPrint_CUP_mask : public TAutomask
|
|
{
|
|
protected:
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
public:
|
|
TPrint_CUP_mask();
|
|
};
|
|
|
|
TPrint_CUP_mask::TPrint_CUP_mask() : TAutomask("ct0100a")
|
|
{
|
|
}
|
|
|
|
bool TPrint_CUP_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
{
|
|
switch(o.dlg())
|
|
{
|
|
case DLG_PRINT:
|
|
if (e == fe_button)
|
|
{
|
|
main_app().print();
|
|
return false;
|
|
}
|
|
break;
|
|
case DLG_PREVIEW:
|
|
if (e == fe_button)
|
|
{
|
|
main_app().preview();
|
|
return false;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////
|
|
// REPORT
|
|
////////////////////////////////////////////////////////
|
|
//i report in questione (sono 8) hanno la query inside..
|
|
//..e non necessitano di altro che i FIELD #... dei campi della maschera per avere i valori..
|
|
//..delle set_var interne
|
|
class TPrint_CUP_report : public TReport
|
|
{
|
|
protected:
|
|
virtual bool use_mask() { return false; } //questo ci vuole perchè la maschera ha un nome != dai report
|
|
public:
|
|
TPrint_CUP_report() {}
|
|
};
|
|
|
|
|
|
////////////////////////////////////////////////////////
|
|
// APPLICAZIONE
|
|
////////////////////////////////////////////////////////
|
|
class TPrint_CUP : public TSkeleton_application
|
|
{
|
|
TPrint_CUP_mask* _mask;
|
|
|
|
protected:
|
|
virtual void print();
|
|
virtual void preview();
|
|
virtual void print_or_preview(const bool stampa);
|
|
|
|
public:
|
|
virtual void main_loop();
|
|
|
|
};
|
|
|
|
//fantastico metodo per gestire stampa o anteprima
|
|
void TPrint_CUP::print_or_preview(const bool stampa)
|
|
{
|
|
if (_mask->check_fields())
|
|
{
|
|
//crea il nome del report da usare in base alle scelte di stampa (radiobuttons)
|
|
//schema dei reports classe ct0100xx:
|
|
//M1 = movimenti per cup-cig M2 = movimenti per clifo
|
|
//D1 = documenti // D2 = documenti //
|
|
//E1 = effetti // E2 = effetti //
|
|
//R1 = rilevazione // R2 = rilevazione //
|
|
const TString& tipo_archivio = _mask->get(F_ARCHIVI);
|
|
const TString& tipo_ordinamento = _mask->get(F_ORDINAMENTO);
|
|
TString rep_name = "ct0100";
|
|
rep_name << tipo_archivio << tipo_ordinamento;
|
|
|
|
TPrint_CUP_report rep;
|
|
rep.load(rep_name);
|
|
|
|
rep.mask2report(*_mask); //setta i valori della maschera sul report
|
|
|
|
//solo per la ricerca in RMOV
|
|
if (tipo_archivio == "M")
|
|
{
|
|
long from_nreg = 0L;
|
|
long to_nreg = 0L;
|
|
|
|
const TDate dataini = _mask->get_date(F_DADATA);
|
|
const TDate datafine = _mask->get_date(F_ADATA);
|
|
if (dataini.ok() || datafine.ok())
|
|
{
|
|
TLocalisamfile mov(LF_MOV);
|
|
mov.setkey(2);
|
|
mov.put(MOV_DATAREG, dataini);
|
|
for (int err = mov.read(_isgteq); err == NOERR; err = mov.read(_isnext))
|
|
{
|
|
const TDate date = mov.get(MOV_DATAREG);
|
|
if (date < dataini)
|
|
continue; // Should never happen
|
|
if (datafine.ok() && date > datafine)
|
|
break;
|
|
const long nreg = mov.get_long(MOV_NUMREG);
|
|
if (nreg < from_nreg || from_nreg <= 0)
|
|
from_nreg = nreg;
|
|
if (nreg > to_nreg)
|
|
to_nreg = nreg;
|
|
}
|
|
}
|
|
rep.recordset()->set_var("#DANUMREG", from_nreg);
|
|
rep.recordset()->set_var("#ANUMREG", to_nreg);
|
|
} //if (tipo_archivio == "M")...
|
|
|
|
TReport_book book;
|
|
book.add(rep);
|
|
book.print_or_preview();
|
|
}
|
|
}
|
|
|
|
void TPrint_CUP::print()
|
|
{
|
|
print_or_preview(true);
|
|
}
|
|
|
|
void TPrint_CUP::preview()
|
|
{
|
|
print_or_preview(false);
|
|
}
|
|
|
|
void TPrint_CUP::main_loop()
|
|
{
|
|
_mask = new TPrint_CUP_mask;
|
|
_mask->run();
|
|
delete _mask;
|
|
_mask = NULL;
|
|
}
|
|
|
|
int ct0100(int argc, char* argv[])
|
|
{
|
|
TPrint_CUP a;
|
|
a.run(argc, argv, TR("Stampa tracciabilità CUP"));
|
|
return 0;
|
|
} |