Files correlati : at9.exe at9300a.msk Ricompilazione Demo : [ ] Commento : aggiunto programma di aggiornamento dati da estrazione git-svn-id: svn://10.65.10.50/trunk@11660 c028cbd2-c16b-5b4b-a496-9718f37d4682
230 lines
6.5 KiB
C++
Executable File
230 lines
6.5 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <filetext.h>
|
|
#include <form.h>
|
|
#include <mask.h>
|
|
#include <progind.h>
|
|
#include <relation.h>
|
|
#include <tabutil.h>
|
|
#include <printer.h>
|
|
#include <recarray.h>
|
|
#include <utility.h>
|
|
|
|
#include "at9.h"
|
|
#include "at9300a.h"
|
|
|
|
#include "soggetti.h"
|
|
#include "donaz.h"
|
|
#include "contsan.h"
|
|
#include "idoneita.h"
|
|
#include "benem.h"
|
|
#include "storico.h"
|
|
|
|
class TProv2com: public TSkeleton_application
|
|
{
|
|
TMask* _msk;
|
|
TRelation* _rel;
|
|
TRelation* _reltmp;
|
|
TConfig* _configfile;
|
|
TIsamtempfile* _filesog;
|
|
TIsamtempfile* _filedon;
|
|
TIsamtempfile* _filecon;
|
|
TIsamtempfile* _fileido;
|
|
TIsamtempfile* _fileben;
|
|
TIsamtempfile* _filesto;
|
|
TLocalisamfile* _soggetti;
|
|
|
|
protected:
|
|
virtual bool create(void);
|
|
virtual void main_loop();
|
|
virtual bool destroy(void) ;
|
|
void agg_anagrafica(const TRectype& recsog);
|
|
void transfer();
|
|
|
|
public:
|
|
const TMask& msk() const { return *_msk; }
|
|
TProv2com() {}
|
|
virtual ~TProv2com() {}
|
|
};
|
|
|
|
// restituisce un riferimento all' applicazione
|
|
inline TProv2com& app() { return (TProv2com&) main_app();}
|
|
|
|
// creazione dell'applicazione
|
|
bool TProv2com::create()
|
|
{
|
|
_msk = new TMask("at9300a");
|
|
_configfile = new TConfig("at9300a.ini");
|
|
_soggetti = new TLocalisamfile(LF_SOGGETTI);
|
|
return TSkeleton_application::create();
|
|
}
|
|
|
|
// distruzione dell'applicazione
|
|
bool TProv2com::destroy()
|
|
{
|
|
delete _soggetti;
|
|
delete _configfile;
|
|
delete _msk;
|
|
return TSkeleton_application::destroy();
|
|
}
|
|
|
|
// carica la maschera
|
|
void TProv2com::main_loop()
|
|
{
|
|
_msk->set(F_PERCORSO,_configfile->get("PERCORSO", "ARCHIVIO"));
|
|
KEY key = _msk->run();
|
|
if (key == K_ENTER)
|
|
{
|
|
transfer();
|
|
_configfile->set("PERCORSO", _msk->get(F_PERCORSO), "ARCHIVIO");
|
|
TDate oggi(TODAY);
|
|
_configfile->set("DATA", oggi, "ARCHIVIO");
|
|
}
|
|
}
|
|
|
|
// trasferimento dati da file CT su programma avis
|
|
void TProv2com::transfer()
|
|
{
|
|
bool anagrafica = _msk->get_bool(F_ANAGRAFICA);
|
|
const bool donazioni = _msk->get_bool(F_DONAZIONI);
|
|
const bool controlli = _msk->get_bool(F_CONTROLLI);
|
|
const bool benemerenze = _msk->get_bool(F_BENEMERENZE);
|
|
const bool storico = _msk->get_bool(F_STORICO);
|
|
TString80 percorso = _msk->get(F_PERCORSO);
|
|
percorso.insert("%");
|
|
TString80 nomesog = percorso;
|
|
nomesog << "SOGGETTI";
|
|
TString80 nomedon = percorso;
|
|
nomedon << "DONAZ";
|
|
TString80 nomecon = percorso;
|
|
nomecon << "CONTSAN";
|
|
TString80 nomeido = percorso;
|
|
nomeido << "IDONEITA";
|
|
TString80 nomeben = percorso;
|
|
nomeben << "BENEM";
|
|
TString80 nomesto = percorso;
|
|
nomesto << "STORICO";
|
|
|
|
_filesog = new TIsamtempfile(LF_SOGGETTI, (const char *) nomesog, FALSE);
|
|
_filecon = new TIsamtempfile(LF_CONTSAN, (const char*) nomecon, FALSE);
|
|
_filedon = new TIsamtempfile(LF_DONAZ, (const char* ) nomedon, FALSE);
|
|
_fileido = new TIsamtempfile(LF_IDONEITA, (const char*) nomeido, FALSE);
|
|
_fileben = new TIsamtempfile(LF_BENEM, (const char*) nomeben, FALSE);
|
|
_filesto = new TIsamtempfile(LF_STORICO, (const char*) nomesto, FALSE);
|
|
_rel = new TRelation(LF_SOGGETTI);
|
|
if (donazioni)
|
|
{
|
|
_rel->add(LF_DONAZ, "CODICE==CODICE");
|
|
}
|
|
if (controlli)
|
|
{
|
|
_rel->add(LF_CONTSAN, "CODICE==CODICE");
|
|
_rel->add(LF_IDONEITA, "CODICE==CODICE");
|
|
}
|
|
if (benemerenze)
|
|
_rel->add(LF_BENEM, "CODICE==CODICE");
|
|
if (storico)
|
|
_rel->add(LF_STORICO, "CODICE==CODICE");
|
|
|
|
_reltmp = new TRelation(LF_SOGGETTI);
|
|
//_reltmp->add(LF_DONAZ, "CODICE==CODICE");
|
|
//_reltmp->add(LF_CONTSAN, "CODICE==CODICE");
|
|
//_reltmp->add(LF_IDONEITA, "CODICE==CODICE");
|
|
//_reltmp->add(LF_BENEM, "CODICE==CODICE");
|
|
//_reltmp->add(LF_STORICO, "CODICE==CODICE");
|
|
|
|
_reltmp->replace(_filesog);
|
|
|
|
anagrafica = (anagrafica || donazioni || controlli || benemerenze || storico);
|
|
TCursor cursore(_reltmp);
|
|
long records = cursore.items();
|
|
TProgind pi(records,"Aggiornamento archivi", TRUE, TRUE);
|
|
pi.setstatus(1);
|
|
for (cursore = 0; cursore.pos() < records; ++(cursore))
|
|
{
|
|
const long codsog = cursore.curr().get_long(SOG_CODICE);
|
|
pi.addstatus(1);
|
|
if (pi.iscancelled()) break;
|
|
if (anagrafica)
|
|
agg_anagrafica(cursore.curr());
|
|
if (donazioni)
|
|
{
|
|
bool continua = TRUE;
|
|
while (continua)
|
|
{
|
|
const long codice = cursore.curr(LF_DONAZ).get_long(DON_CODICE);
|
|
if (codice == codsog)
|
|
//filedon.write(cursore.curr(LF_DONAZ));
|
|
continua = cursore.next_match(LF_DONAZ, "CODICE");
|
|
}
|
|
}
|
|
if (controlli)
|
|
{
|
|
bool continua = TRUE;
|
|
while (continua)
|
|
{
|
|
const long codice = cursore.curr(LF_CONTSAN).get_long(CON_CODICE);
|
|
if (codice == codsog)
|
|
//filecon.write(cursore.curr(LF_CONTSAN));
|
|
continua = cursore.next_match(LF_CONTSAN, "CODICE");
|
|
}
|
|
continua = TRUE;
|
|
while (continua)
|
|
{
|
|
const long codice = cursore.curr(LF_IDONEITA).get_long(IDO_CODICE);
|
|
if (codice == codsog)
|
|
//fileido.write(cursore.curr(LF_IDONEITA));
|
|
continua = cursore.next_match(LF_IDONEITA, "CODICE");
|
|
}
|
|
}
|
|
if (benemerenze)
|
|
{
|
|
bool continua = TRUE;
|
|
while (continua)
|
|
{
|
|
const long codice = cursore.curr(LF_BENEM).get_long(BEN_CODICE);
|
|
if (codice == codsog)
|
|
//fileben.write(cursore.curr(LF_BENEM));
|
|
continua = cursore.next_match(LF_BENEM, "CODICE");
|
|
}
|
|
}
|
|
if (storico)
|
|
{
|
|
bool continua = TRUE;
|
|
while (continua)
|
|
{
|
|
const long codice = cursore.curr(LF_STORICO).get_long(STO_CODICE);
|
|
if (codice == codsog)
|
|
//filesto.write(cursore.curr(LF_STORICO));
|
|
continua = cursore.next_match(LF_STORICO, "CODICE");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void TProv2com::agg_anagrafica(const TRectype& recsog)
|
|
{
|
|
const TString80 cognome = recsog.get(SOG_COGNOME);
|
|
const TString80 nome = recsog.get(SOG_NOME);
|
|
const TDate datanasc = recsog.get_date(SOG_DATANASC);
|
|
_soggetti->setkey(3);
|
|
TRectype& rec = _rel->curr();
|
|
rec.zero();
|
|
rec.put(SOG_COGNOME, cognome);
|
|
rec.put(SOG_NOME, nome);
|
|
rec.put(SOG_DATANASC, datanasc);
|
|
if (_soggetti->read(rec)==NOERR)
|
|
{
|
|
TString80 cog = rec.get(SOG_COGNOME);
|
|
TString80 nom = rec.get(SOG_NOME);
|
|
int a = 1;
|
|
a++;
|
|
}
|
|
}
|
|
|
|
int at9300(int argc, char* argv[])
|
|
{
|
|
TProv2com a;
|
|
a.run(argc, argv, "Aggiornamento archivi da estrazione");
|
|
return 0;
|
|
}
|