224 lines
5.5 KiB
C++
224 lines
5.5 KiB
C++
|
#include <form.h>
|
|||
|
#include <mask.h>
|
|||
|
#include <printapp.h>
|
|||
|
|
|||
|
#include "lf.h"
|
|||
|
#include "medici.h"
|
|||
|
#include <comuni.h>
|
|||
|
|
|||
|
#include "at6.h"
|
|||
|
#include "at6100a.h"
|
|||
|
|
|||
|
enum ts { undefined = 0, elenco = 1, etichette = 2 };
|
|||
|
|
|||
|
// definizione form per etichette
|
|||
|
class TMed_form : public TForm
|
|||
|
{
|
|||
|
public:
|
|||
|
|
|||
|
virtual TCursor* cursor() const;
|
|||
|
virtual TRelation* relation() const;
|
|||
|
TPrint_section& get_body() { return section('B'); } ;
|
|||
|
TMed_form(): TForm() {};
|
|||
|
TMed_form(const char* form, const char * code = "", int editlevel = 0, const char* desc = "")
|
|||
|
: TForm(form,code,editlevel,desc) {};
|
|||
|
virtual ~TMed_form() {};
|
|||
|
};
|
|||
|
|
|||
|
class TMedprint_application : public TPrintapp
|
|||
|
{
|
|||
|
TRelation* _rel;
|
|||
|
TMask* _msk;
|
|||
|
TMed_form* _form_eti;
|
|||
|
|
|||
|
int _cur1, _cur2;
|
|||
|
TParagraph_string _cognome_nome, _dencom, _indirizzo;
|
|||
|
TDate _data_stampa;
|
|||
|
ts _tipo_stampa;
|
|||
|
|
|||
|
protected:
|
|||
|
virtual bool user_create();
|
|||
|
virtual bool user_destroy();
|
|||
|
virtual bool set_print(int m);
|
|||
|
virtual void set_page(int file, int cnt);
|
|||
|
virtual bool preprocess_page (int file, int counter);
|
|||
|
|
|||
|
public:
|
|||
|
void crea_intestazione();
|
|||
|
TMedprint_application() : _data_stampa(TODAY), _indirizzo("",25), _dencom("",25), _cognome_nome("",40) {}
|
|||
|
};
|
|||
|
|
|||
|
HIDDEN inline TMedprint_application& app() { return (TMedprint_application&) main_app(); }
|
|||
|
|
|||
|
TCursor* TMed_form::cursor() const { return app().current_cursor(); }
|
|||
|
|
|||
|
TRelation* TMed_form::relation() const { return cursor()->relation(); }
|
|||
|
|
|||
|
void TMedprint_application::set_page(int file, int cnt)
|
|||
|
{
|
|||
|
// costruzione etichette
|
|||
|
switch (_tipo_stampa)
|
|||
|
{
|
|||
|
case etichette:
|
|||
|
{
|
|||
|
TPrint_section& corpo = _form_eti->get_body();
|
|||
|
corpo.reset();
|
|||
|
corpo.update();
|
|||
|
for (int i = 0; i < corpo.height(); i++)
|
|||
|
{
|
|||
|
TPrintrow& riga = corpo.row(i);
|
|||
|
set_row(i+1,riga);
|
|||
|
}
|
|||
|
force_setpage(TRUE);
|
|||
|
}
|
|||
|
break;
|
|||
|
case elenco:
|
|||
|
{
|
|||
|
set_row(1,"@0g@pn",FLD(LF_MEDICI,MED_CODMED,"######"));
|
|||
|
set_row(1,"@7g#a",&_cognome_nome);
|
|||
|
set_row(1,"@48g#a",&_indirizzo);
|
|||
|
set_row(1,"@74g#a",&_dencom);
|
|||
|
set_row(1,"@100g@S",FLD(LF_MEDICI,MED_TELAMB));
|
|||
|
set_row(1,"@116g@S",FLD(LF_MEDICI,MED_TELABI));
|
|||
|
}
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
bool TMedprint_application::preprocess_page(int file, int counter)
|
|||
|
{
|
|||
|
if (_tipo_stampa == elenco)
|
|||
|
{
|
|||
|
TString80 nome = current_cursor()->curr().get(MED_COGNOME);
|
|||
|
nome << " ";
|
|||
|
nome << current_cursor()->curr().get(MED_NOME);
|
|||
|
_cognome_nome = nome;
|
|||
|
TString256 localita = "";
|
|||
|
localita << current_cursor()->curr("LCP").get("S0");
|
|||
|
if (localita.not_empty() && localita.ok())
|
|||
|
localita << " - ";
|
|||
|
localita << current_cursor()->curr(LF_COMUNI).get(COM_DENCOM);
|
|||
|
_dencom = localita;
|
|||
|
_indirizzo = current_cursor()->curr(LF_MEDICI).get(MED_INDIRIZZO);
|
|||
|
}
|
|||
|
return TRUE;
|
|||
|
}
|
|||
|
|
|||
|
bool TMedprint_application::set_print(int)
|
|||
|
{
|
|||
|
_tipo_stampa = undefined;
|
|||
|
KEY tasto;
|
|||
|
tasto = _msk->run();
|
|||
|
switch (tasto)
|
|||
|
{
|
|||
|
case F_ELENCO:
|
|||
|
_tipo_stampa = elenco;
|
|||
|
break;
|
|||
|
case F_ETICHETTE:
|
|||
|
_tipo_stampa = etichette;
|
|||
|
break;
|
|||
|
}
|
|||
|
if (_tipo_stampa != undefined)
|
|||
|
{
|
|||
|
long codfr, codto;
|
|||
|
TString80 cogfr, cogto;
|
|||
|
const int sort = _msk->get_int(F_SORT);
|
|||
|
reset_files();
|
|||
|
add_file(LF_MEDICI);
|
|||
|
if (sort == 1)
|
|||
|
{
|
|||
|
codfr = _msk->get_long(F_CODFR);
|
|||
|
codto = _msk->get_long(F_CODTO);
|
|||
|
select_cursor(_cur1);
|
|||
|
TLocalisamfile& fl = current_cursor()->file(LF_MEDICI);
|
|||
|
TRectype da(fl.curr());
|
|||
|
TRectype a(fl.curr());
|
|||
|
da.zero();
|
|||
|
a.zero();
|
|||
|
da.put(MED_CODMED, codfr);
|
|||
|
a.put(MED_CODMED, codto);
|
|||
|
current_cursor()->setregion(da, a);
|
|||
|
}
|
|||
|
else
|
|||
|
if (sort == 2)
|
|||
|
{
|
|||
|
cogfr = _msk->get(F_COGFR);
|
|||
|
cogto = _msk->get(F_COGTO);
|
|||
|
select_cursor(_cur2);
|
|||
|
TLocalisamfile& fl = current_cursor()->file(LF_MEDICI);
|
|||
|
TRectype da(fl.curr());
|
|||
|
TRectype a(fl.curr());
|
|||
|
da.zero();
|
|||
|
a.zero();
|
|||
|
da.put(MED_COGNOME, cogfr);
|
|||
|
a.put (MED_COGNOME, cogto);
|
|||
|
current_cursor()->setregion(da, a);
|
|||
|
}
|
|||
|
reset_print();
|
|||
|
crea_intestazione();
|
|||
|
return TRUE;
|
|||
|
}
|
|||
|
else
|
|||
|
return FALSE;
|
|||
|
}
|
|||
|
|
|||
|
void TMedprint_application::crea_intestazione()
|
|||
|
{
|
|||
|
reset_header();
|
|||
|
|
|||
|
if (_tipo_stampa == elenco)
|
|||
|
{
|
|||
|
TString sep(132);
|
|||
|
TString16 data_stampa;
|
|||
|
sep.fill('-');
|
|||
|
set_header(1, (const char *) sep);
|
|||
|
sep = "";
|
|||
|
sep << "Pag. @#";
|
|||
|
sep.right_just(132);
|
|||
|
set_header(2,(const char*) sep);
|
|||
|
set_header(2,"@0gARCHIVIO MEDICI@104gDATA");
|
|||
|
data_stampa = _data_stampa.string();
|
|||
|
set_header(2,"@109g%10s", (const char*) data_stampa);
|
|||
|
sep = "";
|
|||
|
sep.fill('-');
|
|||
|
set_header(3, (const char *) sep);
|
|||
|
|
|||
|
set_header(5,"@0gCodice@7gCognome e nome@48gIndirizzo@74gLocalit<69>/Comune@100gTel. amb.@116gTel. abi.");
|
|||
|
set_header(6,"@0g------@7g----------------------------------------@48g-------------------------");
|
|||
|
set_header(6,"@74g-------------------------@100g---------------@116g---------------");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
bool TMedprint_application::user_create()
|
|||
|
{
|
|||
|
_rel = new TRelation(LF_MEDICI);
|
|||
|
_rel->add(LF_COMUNI, "COM==COM");
|
|||
|
_rel->add("LCP", "CODTAB==LOCALITA");
|
|||
|
|
|||
|
_cur1 = add_cursor(new TCursor(_rel, "", 1)); //cursore ordinamento per codice
|
|||
|
_cur2 = add_cursor(new TCursor(_rel, "", 2)); //cursore ordinamento per cognome e nome
|
|||
|
|
|||
|
_msk = new TMask("at6100a");
|
|||
|
|
|||
|
_form_eti = new TMed_form("AT_ETMED");
|
|||
|
return TRUE;
|
|||
|
}
|
|||
|
|
|||
|
bool TMedprint_application::user_destroy()
|
|||
|
{
|
|||
|
delete _msk;
|
|||
|
delete _rel;
|
|||
|
delete _form_eti;
|
|||
|
return TRUE;
|
|||
|
}
|
|||
|
|
|||
|
int at6100(int argc, char* argv[])
|
|||
|
{
|
|||
|
|
|||
|
TMedprint_application a;
|
|||
|
|
|||
|
a.run(argc, argv, "Stampa Medici");
|
|||
|
|
|||
|
return 0;
|
|||
|
}
|