5fcae22382
Files correlati : Ricompilazione Demo : [ ] Commento : tolto controllo inutile stringa.ok() git-svn-id: svn://10.65.10.50/trunk@9233 c028cbd2-c16b-5b4b-a496-9718f37d4682
235 lines
6.1 KiB
C++
Executable File
235 lines
6.1 KiB
C++
Executable File
#include <form.h>
|
||
#include <mask.h>
|
||
#include <printapp.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 TStampaMedici : public TPrintapp
|
||
{
|
||
TRelation* _rel;
|
||
TMask* _msk;
|
||
TMed_form* _form_eti;
|
||
int _cur1, _cur2;
|
||
TParagraph_string _cognome_nome, _dencom, _indirizzo;
|
||
TDate _data_stampa;
|
||
ts _tipostampa;
|
||
int _etlarghezza, _etcolonne;
|
||
|
||
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();
|
||
TStampaMedici() : _data_stampa(TODAY), _indirizzo("",25), _dencom("",25), _cognome_nome("",40) {}
|
||
};
|
||
|
||
HIDDEN inline TStampaMedici& app() { return (TStampaMedici&) main_app(); }
|
||
|
||
TCursor* TMed_form::cursor() const { return app().current_cursor(); }
|
||
|
||
TRelation* TMed_form::relation() const { return cursor()->relation(); }
|
||
|
||
void TStampaMedici::set_page(int file, int cnt)
|
||
{
|
||
// costruzione etichette
|
||
switch (_tipostampa)
|
||
{
|
||
case etichette:
|
||
{
|
||
TPrint_section& corpo = _form_eti->get_body();
|
||
for (int r=1;r<=_etcolonne;r++)
|
||
{
|
||
if (current_cursor()->pos()<current_cursor()->items())
|
||
{
|
||
force_setpage(TRUE);
|
||
corpo.update();
|
||
for (word i = 0; i < corpo.height(); i++)
|
||
{
|
||
TPrintrow& riga = corpo.row(i);
|
||
TString256 riga1 = riga.row();
|
||
riga1.cut(_etlarghezza);
|
||
int colonna = ((r-1)*_etlarghezza);
|
||
TString16 formato;
|
||
formato << '@' << colonna << "g";
|
||
riga1.insert(formato,0);
|
||
set_row(i+1,riga1);
|
||
}
|
||
if (r < _etcolonne)
|
||
++(*current_cursor());
|
||
}
|
||
}
|
||
}
|
||
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 TStampaMedici::preprocess_page(int file, int counter)
|
||
{
|
||
if (_tipostampa==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 << " - ";
|
||
localita << current_cursor()->curr(LF_COMUNI).get(COM_DENCOM);
|
||
_dencom = localita;
|
||
_indirizzo = current_cursor()->curr(LF_MEDICI).get(MED_INDIRIZZO);
|
||
}
|
||
if (_tipostampa==etichette)
|
||
if (printer().rows_left() < _form_eti->get_body().height())
|
||
printer().formfeed();
|
||
return TRUE;
|
||
}
|
||
|
||
bool TStampaMedici::set_print(int)
|
||
{
|
||
_tipostampa = undefined;
|
||
KEY tasto;
|
||
tasto = _msk->run();
|
||
switch (tasto)
|
||
{
|
||
case F_ELENCO:
|
||
_tipostampa = elenco;
|
||
break;
|
||
case F_ETICHETTE:
|
||
_tipostampa = etichette;
|
||
break;
|
||
}
|
||
if (_tipostampa != 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 TStampaMedici::crea_intestazione()
|
||
{
|
||
reset_header();
|
||
if (_tipostampa == 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 TStampaMedici::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");
|
||
TConfig config(CONFIG_STUDIO);
|
||
TString16 etformato = config.get("EtFormato");
|
||
_etlarghezza = config.get_int("EtLarghezza");
|
||
_etcolonne = config.get_int("EtColonne");
|
||
return TRUE;
|
||
}
|
||
|
||
bool TStampaMedici::user_destroy()
|
||
{
|
||
delete _form_eti;
|
||
delete _msk;
|
||
delete _rel;
|
||
return TRUE;
|
||
}
|
||
|
||
int at6100(int argc, char* argv[])
|
||
{
|
||
TStampaMedici a;
|
||
a.run(argc, argv, "Stampa Tabella Medici");
|
||
return 0;
|
||
}
|