164 lines
3.8 KiB
C++
164 lines
3.8 KiB
C++
|
#include <applicat.h>
|
|||
|
#include <automask.h>
|
|||
|
#include <config.h>
|
|||
|
#include <defmask.h>
|
|||
|
#include <recset.h>
|
|||
|
#include <reprint.h>
|
|||
|
|
|||
|
#include "ve3500a.h"
|
|||
|
|
|||
|
////////////////////////////////////////////////////////
|
|||
|
// MASCHERA
|
|||
|
////////////////////////////////////////////////////////
|
|||
|
class TPrint_condven_mask : public TAutomask
|
|||
|
{
|
|||
|
protected:
|
|||
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|||
|
public:
|
|||
|
TPrint_condven_mask();
|
|||
|
};
|
|||
|
|
|||
|
TPrint_condven_mask::TPrint_condven_mask() : TAutomask("ve3500a")
|
|||
|
{
|
|||
|
//legge il parametro con cui <20> stato chiamato il programma ('C'ontratti,'L'istini,'O'fferte..
|
|||
|
//..ed in base a questo setta il valore del campo F_TIPO sulla maschera che fa apparire/scomparire..
|
|||
|
//..campi
|
|||
|
const char* tipo = main_app().argv(2);
|
|||
|
set(F_TIPO, tipo);
|
|||
|
if (tipo[0] == 'L')
|
|||
|
{
|
|||
|
//il costruttore abilita/disabilita i campi delle categorie di vendita in base alla configurazione
|
|||
|
const bool gesliscv = ini_get_bool(CONFIG_DITTA, "ve", "GESLISCV");
|
|||
|
enable(F_L_CATVEN, gesliscv);
|
|||
|
enable(F_L_DESVEN, gesliscv);
|
|||
|
//attenzione!!! il campo CATVEN <20> in chiave 1! per disabilitarlo ci vuole questo trucco!
|
|||
|
if (!gesliscv)
|
|||
|
efield(F_L_CATVEN).reset_key(1);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
bool TPrint_condven_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 3, per Contratti, Listini, Offerte) 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_condven_report : public TReport
|
|||
|
{
|
|||
|
protected:
|
|||
|
virtual bool use_mask() { return false; } //questo ci vuole perch<63> la maschera ha un nome != dai report
|
|||
|
public:
|
|||
|
TPrint_condven_report() {}
|
|||
|
};
|
|||
|
|
|||
|
|
|||
|
////////////////////////////////////////////////////////
|
|||
|
// APPLICAZIONE
|
|||
|
////////////////////////////////////////////////////////
|
|||
|
class TPrint_condven : public TSkeleton_application
|
|||
|
{
|
|||
|
TPrint_condven_mask* _mask;
|
|||
|
|
|||
|
protected:
|
|||
|
virtual bool create();
|
|||
|
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_condven::print_or_preview(const bool stampa)
|
|||
|
{
|
|||
|
if (_mask->check_fields())
|
|||
|
{
|
|||
|
TString rep_name;
|
|||
|
const char tipo = _mask->get(F_TIPO)[0];
|
|||
|
switch (tipo)
|
|||
|
{
|
|||
|
case 'C': rep_name = "ve3500c.rep"; break;
|
|||
|
case 'L': rep_name = "ve3500l.rep"; break;
|
|||
|
case 'O': rep_name = "ve3500o.rep"; break;
|
|||
|
default: break;
|
|||
|
}
|
|||
|
|
|||
|
TPrint_condven_report rep;
|
|||
|
rep.load(rep_name);
|
|||
|
|
|||
|
rep.mask2report(*_mask); //setta i valori della maschera sul report
|
|||
|
|
|||
|
TReport_book book;
|
|||
|
book.add(rep);
|
|||
|
book.print_or_preview();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void TPrint_condven::print()
|
|||
|
{
|
|||
|
print_or_preview(true);
|
|||
|
}
|
|||
|
|
|||
|
void TPrint_condven::preview()
|
|||
|
{
|
|||
|
print_or_preview(false);
|
|||
|
}
|
|||
|
|
|||
|
void TPrint_condven::main_loop()
|
|||
|
{
|
|||
|
_mask = new TPrint_condven_mask;
|
|||
|
_mask->run();
|
|||
|
delete _mask;
|
|||
|
_mask = NULL;
|
|||
|
}
|
|||
|
|
|||
|
bool TPrint_condven::create()
|
|||
|
{
|
|||
|
//controlla che solo il producer AGA possa usare questo programma
|
|||
|
const int oem = ini_get_int(CONFIG_OEM, "MAIN", "OEM", -1);
|
|||
|
if (oem != 0)
|
|||
|
{
|
|||
|
error_box(TR("Programma non autorizzato!"));
|
|||
|
return false;
|
|||
|
|
|||
|
//se non paghi ti stronco!!!
|
|||
|
const TDate oggi(TODAY);
|
|||
|
if (oggi >= 20091120)
|
|||
|
return false;
|
|||
|
}
|
|||
|
return TSkeleton_application::create();
|
|||
|
}
|
|||
|
|
|||
|
int ve3500(int argc, char* argv[])
|
|||
|
{
|
|||
|
TPrint_condven a;
|
|||
|
a.run(argc, argv, TR("Stampa condizioni di vendita"));
|
|||
|
return 0;
|
|||
|
}
|