campo-sirio/ba/ba6200.cpp

287 lines
6.9 KiB
C++
Executable File

#include <mask.h>
#include <printapp.h>
#include <relation.h>
#include <tabutil.h>
#include <utility.h>
#include <sort.h>
#include <lffiles.h>
#include <comuni.h>
#include "ba6.h"
#include "ba6200.h"
const MAXSTR = 128;
static char __tmp [MAXSTR];
static TFixed_string tmp (__tmp, MAXSTR);
class BA6200_application : public TPrintapp
{
TRelation* _rel;
TMask* _msk;
TLocalisamfile* _comuni;
TParagraph_string * _descr_comune;
int _cur1, _cur2;
TString _provcom_msk, _com, _dencom, _provcom, _capcom;
TString _codistat;
int _uffiidd1, _uffiidd2, _uffiidd3, _uffiva1, _uffiva2, _uffiva3;
int _uffreg, _uffconc, _uffcserv, _uffesprov, _uffescom, _terrmon;
real _alqici;
TDate _data_stampa;
protected:
virtual void user_create() ;
virtual void user_destroy();
virtual bool set_print(int m);
virtual bool preprocess_page (int,int);
public:
void crea_intestazione();
void setta_righe_descr(TParagraph_string*);
BA6200_application();
};
bool BA6200_application::preprocess_page(int file, int counter)
{
reset_print();
if (counter)
return TRUE;
if (file == LF_COMUNI)
{
_provcom = current_cursor()->curr(LF_COMUNI).get(COM_PROVCOM);
if ((_provcom == _provcom_msk) || (_provcom_msk == ""))
{
_com = current_cursor()->curr(LF_COMUNI).get(COM_COM);
_dencom = current_cursor()->curr(LF_COMUNI).get(COM_DENCOM);
*_descr_comune = (const char*) _dencom;
_capcom = current_cursor()->curr(LF_COMUNI).get(COM_CAPCOM);
_codistat = current_cursor()->curr(LF_COMUNI).get(COM_CODISTAT);
_uffiidd1 = current_cursor()->curr(LF_COMUNI).get_int(COM_UFFIIDD1);
_uffiidd2 = current_cursor()->curr(LF_COMUNI).get_int(COM_UFFIIDD2);
_uffiidd3 = current_cursor()->curr(LF_COMUNI).get_int(COM_UFFIIDD3);
_uffiva1 = current_cursor()->curr(LF_COMUNI).get_int(COM_UFFIVA1);
_uffiva2 = current_cursor()->curr(LF_COMUNI).get_int(COM_UFFIVA2);
_uffiva3 = current_cursor()->curr(LF_COMUNI).get_int(COM_UFFIVA3);
_uffreg = current_cursor()->curr(LF_COMUNI).get_int(COM_UFFREG);
_uffconc = current_cursor()->curr(LF_COMUNI).get_int(COM_UFFCONC);
_uffcserv = current_cursor()->curr(LF_COMUNI).get_int(COM_UFFCSERV);
_uffesprov = current_cursor()->curr(LF_COMUNI).get_int(COM_UFFESPROV);
_uffescom = current_cursor()->curr(LF_COMUNI).get_int(COM_UFFESCOM);
_alqici = current_cursor()->curr(LF_COMUNI).get_real(COM_ALIQICI);
_terrmon = current_cursor()->curr(LF_COMUNI).get_int(COM_TERRMON);
setta_righe_descr(_descr_comune);
set_row (1,"@0g%4s", (const char*) _com);
set_row (1,"@33g%5s", (const char*) _provcom);
set_row (1,"@39g%5s", (const char*) _capcom);
set_row (1,"@46g%6s", (const char*) _codistat);
set_row (1,"@54g%r", &_alqici);
if (_terrmon != 0)
set_row (1,"@63g%d", _terrmon);
if (_uffiidd1 != 0)
set_row (1,"@72g%03d", _uffiidd1);
if (_uffiidd2 != 0)
set_row (1,"@76g%03d", _uffiidd2);
if (_uffiidd3 != 0)
set_row (1,"@80g%03d", _uffiidd3);
if (_uffiva1 != 0)
set_row (1,"@85g%03d", _uffiva1);
if (_uffiva2 != 0)
set_row (1,"@89g%03d", _uffiva2);
if (_uffiva3 != 0)
set_row (1,"@93g%03d", _uffiva3);
if (_uffreg != 0)
set_row (1,"@98g%03d", _uffreg);
if (_uffconc != 0)
set_row (1,"@104g%03d", _uffconc);
if (_uffcserv != 0)
set_row (1,"@110g%03d", _uffcserv);
if (_uffesprov != 0)
set_row (1,"@115g%03d", _uffesprov);
if (_uffescom != 0)
set_row (1,"@119g%03d", _uffescom);
return TRUE;
}
else
return FALSE;
}
return TRUE;
}
void BA6200_application::setta_righe_descr(TParagraph_string* str)
{
const char* r;
int i = 1;
while ((r = str->get()) != NULL)
{
set_row (i,"@7g%s", r);
i++;
}
}
BA6200_application::BA6200_application()
{
}
bool BA6200_application::set_print(int)
{
KEY tasto;
TLocalisamfile* fl;
TString statoini,statofine,codiceini,codicefine,denomini,denomfine;
tasto = _msk->run();
if (tasto == K_ENTER)
{
_data_stampa = _msk->get (F_DATA);
int scelta = _msk->get_int (F_SCELTA);
_provcom_msk = _msk->get (F_PROVCOM);
if (scelta == 1)
{
statoini = _msk->get(F_STATOINI);
codiceini = _msk->get(F_CODICEINI);
statofine = _msk->get(F_STATOFINE);
codicefine = _msk->get(F_CODICEFINE);
reset_files(); //resetta l'albero di stampa
add_file(LF_COMUNI);
select_cursor(_cur1);
fl = current_cursor()->file(LF_COMUNI);
TRectype da (fl->curr());
TRectype a (fl->curr());
da.zero();
a.zero();
da.put(COM_STATO,statoini);
da.put(COM_COM ,codiceini);
a.put(COM_STATO,statofine);
a.put(COM_COM ,codicefine);
current_cursor()->setregion(&da, &a);
}
else
if (scelta == 2)
{
denomini = _msk->get(F_NOMEINI);
denomfine = _msk->get(F_NOMEFINE);
select_cursor(_cur2);
reset_files();
add_file(LF_COMUNI);
fl = current_cursor()->file(LF_COMUNI);
TRectype da (fl->curr());
TRectype a (fl->curr());
da.zero();
a.zero();
da.put(COM_DENCOM, denomini);
a.put (COM_DENCOM, denomfine);
current_cursor()->setregion(&da, &a);
}
//set_print_zero();
crea_intestazione();
return TRUE;
}
else
return FALSE;
}
void BA6200_application::crea_intestazione()
{
TString sep(132);
TString data_stampa;
reset_header();
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 COMUNI@91gSTUDIO@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@7gDenominazione@33gProv.@40gCap@45gCd.Istat@54gAl.ICI@61gMont.@67gUff.@74gII.DD.@87gI.V.A.@97gRegi.@103gConc.@109gServ.@115gEsatt.");
set_header (6,"@0g------@7g-------------------------@33g-----@39g-----");
set_header (6,"@45g--------@54g------@61g-----@72g-----------");
set_header (6,"@85g------------@97g-----@103g-----@109g-----@115g-------");
}
void BA6200_application::user_create()
{
_rel = new TRelation (LF_COMUNI);
_cur1 = add_cursor(new TCursor(_rel,"",1));
_cur2 = add_cursor(new TCursor(_rel,"",2));
_comuni = new TLocalisamfile (LF_COMUNI);
_descr_comune = new TParagraph_string ("",25);
_msk = new TMask("ba6200a");
}
void BA6200_application::user_destroy()
{
delete _msk;
delete _rel;
delete _comuni;
delete _descr_comune;
}
int ba6200(int argc, char* argv[])
{
BA6200_application a;
a.run(argc, argv, "Stampa Comuni");
return 0;
}