2000-10-10 09:32:13 +00:00
|
|
|
|
#include <applicat.h>
|
|
|
|
|
#include <filetext.h>
|
|
|
|
|
#include <form.h>
|
|
|
|
|
#include <mask.h>
|
|
|
|
|
#include <relation.h>
|
|
|
|
|
#include <tabutil.h>
|
|
|
|
|
#include <printer.h>
|
|
|
|
|
#include <progind.h>
|
|
|
|
|
#include <recarray.h>
|
|
|
|
|
#include <utility.h>
|
|
|
|
|
|
|
|
|
|
#include "at8.h"
|
|
|
|
|
#include "at8800a.h"
|
2001-10-22 09:07:33 +00:00
|
|
|
|
#include "atlib.h"
|
|
|
|
|
|
|
|
|
|
#include "contsan.h"
|
2000-10-10 09:32:13 +00:00
|
|
|
|
#include "donaz.h"
|
2001-10-22 09:07:33 +00:00
|
|
|
|
#include "idoneita.h"
|
|
|
|
|
#include "soggetti.h"
|
2001-12-28 16:23:47 +00:00
|
|
|
|
#include "convoc.h"
|
|
|
|
|
#include "rconvoc.h"
|
|
|
|
|
#include "storico.h"
|
2001-10-22 09:07:33 +00:00
|
|
|
|
|
|
|
|
|
#define ATFILENAME "pippo.txt"
|
|
|
|
|
|
2002-01-24 12:01:02 +00:00
|
|
|
|
////////////////////////////////////////////////////////
|
2001-10-22 09:07:33 +00:00
|
|
|
|
// Classe TCtbo2at_file customizzata dalla TFile_text //
|
2002-01-24 12:01:02 +00:00
|
|
|
|
////////////////////////////////////////////////////////
|
2001-10-22 09:07:33 +00:00
|
|
|
|
|
|
|
|
|
class TCtbo2at_file: public TFile_text
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual void validate(TCursor& cur,TRecord_text &rec, TToken_string &val, TString& str);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual int autosave(TRelation& rel, const TRecord_text& rec);
|
|
|
|
|
|
|
|
|
|
TCtbo2at_file(const TString& file_name, const TString& config_name);
|
|
|
|
|
virtual ~TCtbo2at_file() { }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TCtbo2at_file::TCtbo2at_file(const TString& file_name, const TString& config_name)
|
|
|
|
|
: TFile_text(file_name, config_name)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TCtbo2at_file::autosave(TRelation& rel, const TRecord_text& rec)
|
|
|
|
|
{
|
|
|
|
|
const TString& type = rec.type();//prendo il tracciato record del tipo del record_text
|
|
|
|
|
TTracciato_record& tr = *t_rec(type);
|
|
|
|
|
|
|
|
|
|
TArray& a_tc = tr.tracciati_campo();
|
|
|
|
|
const int items = a_tc.items();
|
|
|
|
|
TString valore;
|
|
|
|
|
for (int i = 0; i < items; i++)
|
|
|
|
|
{
|
|
|
|
|
const TTracciato_campo& tc = tr.get(i);
|
|
|
|
|
TFieldref field(tc.field());
|
|
|
|
|
if (field.name().not_empty())
|
|
|
|
|
{
|
|
|
|
|
if (field.file()==0)
|
|
|
|
|
field.set_file(rel.lfile().num());
|
|
|
|
|
valore = rec.row(i);
|
|
|
|
|
// formatta il campo del file di testo secondo le specifiche del campo su file isam
|
|
|
|
|
preformat_field(field,valore,rel,tr.type());
|
|
|
|
|
const TRectype& rel_rec = rel.curr(field.file());
|
|
|
|
|
TFieldtypes tipo_campo = rel_rec.type(field.name());
|
|
|
|
|
bool vuoto = valore.blank();
|
2001-12-28 16:23:47 +00:00
|
|
|
|
if (valore[0] == '@') //se trovo il carattere @ -> azzero il campo
|
2002-01-02 16:15:22 +00:00
|
|
|
|
valore.cut(0);
|
2002-01-24 12:01:02 +00:00
|
|
|
|
switch(tipo_campo) //in base al tipo di campo formatta i valori seguendo le specifiche del tracciato
|
2001-10-22 09:07:33 +00:00
|
|
|
|
{
|
2002-01-24 12:01:02 +00:00
|
|
|
|
case _datefld: //tipo data...
|
2001-10-22 09:07:33 +00:00
|
|
|
|
{
|
|
|
|
|
if (real::is_null(valore))
|
|
|
|
|
{
|
|
|
|
|
valore.cut(0);
|
|
|
|
|
vuoto = TRUE;
|
|
|
|
|
}
|
|
|
|
|
TDate data(valore);
|
|
|
|
|
format_date(data, fpicture(tc), valore);//formatta la data secondo le specifiche del tracciato
|
|
|
|
|
}
|
|
|
|
|
break;
|
2002-01-24 12:01:02 +00:00
|
|
|
|
case _realfld: //tipi numerici
|
2001-10-22 09:07:33 +00:00
|
|
|
|
case _intfld:
|
|
|
|
|
case _longfld:
|
|
|
|
|
{
|
|
|
|
|
const real numero(valore);
|
|
|
|
|
vuoto = numero.is_zero();
|
|
|
|
|
|
|
|
|
|
valore = numero.string(fpicture(tc));//formatta il numero secondo le specifiche del tracciato
|
|
|
|
|
|
|
|
|
|
int length = flength(tc,rel_rec);
|
|
|
|
|
if (falign(tc) == 'L')
|
|
|
|
|
valore.left_just(length, ffiller(tc));
|
|
|
|
|
else
|
|
|
|
|
valore.right_just(length, ffiller(tc)); }
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
valore = format_field(tc, rel.lfile().num(), valore);//formatta il campo secondo le specifiche del record
|
|
|
|
|
break;
|
|
|
|
|
}
|
2000-10-10 09:32:13 +00:00
|
|
|
|
|
2001-10-22 09:07:33 +00:00
|
|
|
|
if (!vuoto && rel.exist(field.file()))
|
|
|
|
|
field.write(valore, rel);//faccio una write sulla relazione del fieldref
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int err = NOERR;
|
|
|
|
|
if (pre_writerel(rel,rec))
|
|
|
|
|
{
|
|
|
|
|
err= rel.write();
|
|
|
|
|
if (err == _isdupkey || err ==_isreinsert)
|
|
|
|
|
err = rel.rewrite();
|
|
|
|
|
}
|
|
|
|
|
return err;
|
|
|
|
|
}
|
2000-10-10 09:32:13 +00:00
|
|
|
|
|
2001-10-22 09:07:33 +00:00
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
|
// Classe TCtbo2at: applicazione principale //
|
|
|
|
|
/////////////////////////////////////////////////////
|
2000-10-10 09:32:13 +00:00
|
|
|
|
|
|
|
|
|
class TCtbo2at: public TSkeleton_application
|
|
|
|
|
{
|
2002-01-02 16:15:22 +00:00
|
|
|
|
TMask* _msk;
|
2000-10-10 09:32:13 +00:00
|
|
|
|
TCtbo2at_file* _trasfile;
|
2002-01-02 16:15:22 +00:00
|
|
|
|
int _numdon1, _numdon2;
|
|
|
|
|
TString16 _catini1, _catfin1, _catini2, _catfin2;
|
|
|
|
|
bool _sttess2, _dataisc;
|
2000-10-10 09:32:13 +00:00
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
virtual bool create(void);
|
|
|
|
|
virtual void main_loop();
|
|
|
|
|
virtual bool destroy(void) ;
|
|
|
|
|
void transfer(void);
|
|
|
|
|
void inizializza_file(void);
|
|
|
|
|
static bool annulla_handler(TMask_field& f, KEY k);
|
2002-01-02 16:15:22 +00:00
|
|
|
|
bool test_donation(TRectype& recsog, const char* tipo, const TDate& datadon, const TString& luogodon);
|
|
|
|
|
bool test_inter(TRectype& recsog, const char* tipo, const TDate& datadon, int inter);
|
2001-11-06 09:48:07 +00:00
|
|
|
|
void calcola_categoria(TRectype& recsog);
|
2000-10-10 09:32:13 +00:00
|
|
|
|
public:
|
|
|
|
|
const TMask& msk() const { return *_msk; }
|
|
|
|
|
TCtbo2at() {}
|
|
|
|
|
virtual ~TCtbo2at() {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// restituisce un riferimento all' applicazione
|
|
|
|
|
inline TCtbo2at& app() { return (TCtbo2at&) main_app();}
|
|
|
|
|
|
|
|
|
|
// creazione dell'applicazione
|
|
|
|
|
bool TCtbo2at::create()
|
2001-10-22 09:07:33 +00:00
|
|
|
|
{
|
2001-12-28 16:23:47 +00:00
|
|
|
|
open_files(LF_SOGGETTI, LF_DONAZ, LF_CONTSAN, LF_IDONEITA, LF_CONVOC, LF_RCONVOC, LF_STORICO, 0);
|
2000-10-10 09:32:13 +00:00
|
|
|
|
_msk = new TMask("at8800a");
|
|
|
|
|
_msk->set(F_FILENAME,ATFILENAME);
|
|
|
|
|
_trasfile = NULL;
|
2001-11-06 09:48:07 +00:00
|
|
|
|
TConfig config(CONFIG_STUDIO);
|
|
|
|
|
_numdon1 = config.get_int("NumDon1");
|
|
|
|
|
_numdon2 = config.get_int("NumDon2");
|
|
|
|
|
_catini1 = config.get("CatIni1");
|
|
|
|
|
_catfin1 = config.get("CatFin1");
|
|
|
|
|
_catini2 = config.get("CatIni2");
|
|
|
|
|
_catfin2 = config.get("CatFin2");
|
|
|
|
|
_sttess2 = config.get_bool("StTess2");
|
|
|
|
|
_dataisc = config.get_bool("DataIsc");
|
2000-10-10 09:32:13 +00:00
|
|
|
|
return TSkeleton_application::create();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// distruzione dell'applicazione
|
|
|
|
|
bool TCtbo2at::destroy()
|
|
|
|
|
{
|
|
|
|
|
delete _msk;
|
|
|
|
|
return TSkeleton_application::destroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// carica la maschera
|
|
|
|
|
void TCtbo2at::main_loop()
|
|
|
|
|
{
|
|
|
|
|
// Preimposta gli eventuali valori specificati sulla riga di comando
|
2002-01-02 16:15:22 +00:00
|
|
|
|
//error_box("Attenzione: manca la configurazione del trasferimento!");
|
2000-10-10 09:32:13 +00:00
|
|
|
|
KEY key = K_ENTER;
|
|
|
|
|
while (key != K_QUIT)
|
|
|
|
|
{
|
|
|
|
|
key = _msk->run();
|
|
|
|
|
if (key == K_ENTER)
|
|
|
|
|
transfer();
|
2001-10-22 09:07:33 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TCtbo2at::test_donation(TRectype& recsog, const char* tipo, const TDate& datadon, const TString& luogodon)
|
|
|
|
|
{
|
|
|
|
|
//ricostruisce le donazioni del soggetto in esame
|
2002-01-02 16:15:22 +00:00
|
|
|
|
TRectype* key = new TRectype(LF_DONAZ);
|
|
|
|
|
key->put(DON_CODICE, recsog.get(SOG_CODICE));
|
|
|
|
|
TRecord_array donazioni(LF_DONAZ,DON_PROGDON);
|
|
|
|
|
donazioni.read(key);
|
|
|
|
|
// verificare se ha fatto una donazione di tipo <tipo> con data successiva all'ultima donazione
|
|
|
|
|
const int r=donazioni.last_row();
|
|
|
|
|
if (r > 0)
|
|
|
|
|
{
|
2001-10-22 09:07:33 +00:00
|
|
|
|
const TRectype& lastdon = donazioni[r];
|
|
|
|
|
if (lastdon.get_date(DON_DATADON) >= datadon)
|
|
|
|
|
return FALSE;
|
2000-10-10 09:32:13 +00:00
|
|
|
|
}
|
2002-01-02 16:15:22 +00:00
|
|
|
|
|
|
|
|
|
//aggiunge la nuova donazione
|
|
|
|
|
// compila i dati della donazione in esame
|
|
|
|
|
TRectype* rec = new TRectype(LF_DONAZ);
|
|
|
|
|
rec->put(DON_CODICE, recsog.get(SOG_CODICE));
|
2001-10-22 09:07:33 +00:00
|
|
|
|
rec->put(DON_PROGDON,r+1);
|
2002-01-02 16:15:22 +00:00
|
|
|
|
rec->put(DON_DATADON, datadon);
|
|
|
|
|
rec->put(DON_TIPODON, tipo);
|
|
|
|
|
rec->put(DON_CODSEZ,recsog.get(SOG_CODSEZ));
|
|
|
|
|
rec->put(DON_CODSOT,recsog.get(SOG_CODSOT));
|
|
|
|
|
rec->put(DON_LUOGODON, luogodon);
|
2002-01-24 12:01:02 +00:00
|
|
|
|
if (r == 0) //pu<70> essere una prima donazione...
|
2002-01-02 16:15:22 +00:00
|
|
|
|
rec->put(DON_PRIMADON,"X");
|
2001-10-22 09:07:33 +00:00
|
|
|
|
|
2002-01-02 16:15:22 +00:00
|
|
|
|
donazioni.insert_row(rec);
|
|
|
|
|
donazioni.write(TRUE);
|
|
|
|
|
calcola_donazioni_lib(recsog, &donazioni); // questo metodo sistema tutto!!!
|
2001-11-06 09:48:07 +00:00
|
|
|
|
calcola_categoria(recsog);
|
|
|
|
|
// aggiorno data e utente ultimo aggiornamento
|
2003-12-03 09:36:05 +00:00
|
|
|
|
//const TDate oggi(TODAY);
|
|
|
|
|
//recsog.put(SOG_DATAULTAGG,oggi);
|
|
|
|
|
//recsog.put(SOG_UTENULTAGG,"WINSIT");
|
2002-01-02 16:15:22 +00:00
|
|
|
|
return TRUE;
|
2001-10-22 09:07:33 +00:00
|
|
|
|
}
|
2001-11-06 09:48:07 +00:00
|
|
|
|
|
|
|
|
|
void TCtbo2at::calcola_categoria(TRectype& recsog)
|
|
|
|
|
{
|
2002-01-02 16:15:22 +00:00
|
|
|
|
TTable ctd("CTD");
|
|
|
|
|
TString16 catdon = recsog.get(SOG_CATDON);
|
|
|
|
|
const int totdon = recsog.get_int(SOG_TOTDON);
|
|
|
|
|
ctd.put("CODTAB",catdon);
|
|
|
|
|
if (ctd.read() == NOERR)
|
|
|
|
|
{
|
|
|
|
|
bool dimissione = ctd.get_bool("B0");
|
|
|
|
|
if (dimissione)
|
|
|
|
|
{
|
|
|
|
|
const TString& cat_coll = ctd.get("S6");
|
|
|
|
|
if (cat_coll.not_empty())
|
|
|
|
|
{
|
|
|
|
|
catdon = cat_coll;
|
|
|
|
|
recsog.put(SOG_CATDON, catdon);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ((catdon == _catini1 || _catini1.empty()) && (totdon>=_numdon1) && _catfin1.not_empty())
|
|
|
|
|
{
|
|
|
|
|
recsog.put(SOG_CATDON, _catfin1);
|
|
|
|
|
catdon = _catfin1;
|
|
|
|
|
}
|
|
|
|
|
bool tstampata = recsog.get_bool(SOG_T_STAMPATA);
|
|
|
|
|
if ((catdon == _catini2 || _catini2.empty()) && (totdon>=_numdon2) && _catfin2.not_empty() && (!_sttess2 || tstampata))
|
|
|
|
|
{
|
|
|
|
|
recsog.put(SOG_CATDON, _catfin2);
|
|
|
|
|
catdon = _catfin2;
|
|
|
|
|
}
|
2001-11-06 09:48:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-10-22 09:07:33 +00:00
|
|
|
|
bool TCtbo2at::test_inter(TRectype& recsog, const char* tipo, const TDate& datadon, int inter)
|
2003-06-24 08:47:34 +00:00
|
|
|
|
{
|
|
|
|
|
const char* tipoido = stricmp(tipo, "SI") != 0 ? "AF" : "SI";
|
|
|
|
|
int intervallo = 0;
|
|
|
|
|
|
2002-01-02 16:15:22 +00:00
|
|
|
|
TRectype* key_cont = new TRectype(LF_CONTSAN);
|
|
|
|
|
key_cont->put(CON_CODICE, recsog.get(SOG_CODICE));
|
|
|
|
|
TRecord_array controlli(LF_CONTSAN,CON_PROGCON);
|
|
|
|
|
controlli.read(key_cont);
|
|
|
|
|
|
|
|
|
|
TRectype* key = new TRectype(LF_IDONEITA);
|
|
|
|
|
key->put(IDO_CODICE, recsog.get(SOG_CODICE));
|
|
|
|
|
TRecord_array idoneita(LF_IDONEITA,IDO_PROGIDO);
|
|
|
|
|
idoneita.read(key);
|
2003-06-24 08:47:34 +00:00
|
|
|
|
|
|
|
|
|
TString16 stato;
|
2003-08-08 13:24:47 +00:00
|
|
|
|
TDate datapross;
|
2004-03-08 09:25:48 +00:00
|
|
|
|
TDate datastato;
|
2003-06-24 08:47:34 +00:00
|
|
|
|
if (tipo == "SI")
|
|
|
|
|
{
|
2002-10-31 13:48:46 +00:00
|
|
|
|
stato = recsog.get(SOG_STATOSI);
|
2003-06-24 08:47:34 +00:00
|
|
|
|
intervallo = recsog.get_int(SOG_INTSI);
|
2003-08-08 13:24:47 +00:00
|
|
|
|
datapross = recsog.get_int(SOG_DATAPROSSI);
|
2004-03-08 09:25:48 +00:00
|
|
|
|
datastato = recsog.get_date(SOG_DATASI);
|
2003-06-24 08:47:34 +00:00
|
|
|
|
}
|
2002-10-31 13:48:46 +00:00
|
|
|
|
else
|
2003-06-24 08:47:34 +00:00
|
|
|
|
{
|
2002-10-31 13:48:46 +00:00
|
|
|
|
stato = recsog.get(SOG_STATOAF);
|
2003-06-24 08:47:34 +00:00
|
|
|
|
intervallo = recsog.get_int(SOG_INTAF);
|
2003-08-08 13:24:47 +00:00
|
|
|
|
datapross = recsog.get_int(SOG_DATAPROSAF);
|
2004-03-08 09:25:48 +00:00
|
|
|
|
datastato = recsog.get_date(SOG_DATAAF);
|
|
|
|
|
|
2003-06-24 08:47:34 +00:00
|
|
|
|
}
|
|
|
|
|
if (stato.empty())
|
2004-03-08 09:25:48 +00:00
|
|
|
|
{
|
2003-06-24 08:47:34 +00:00
|
|
|
|
stato = recsog.get(SOG_STATO);
|
2004-03-08 09:25:48 +00:00
|
|
|
|
datastato = recsog.get_date(SOG_DATASTATO);
|
|
|
|
|
}
|
2003-08-08 13:24:47 +00:00
|
|
|
|
if (modstato_tcs(stato) != 'S' && stato.not_empty() && intervallo == inter && !datapross.empty())
|
2002-10-31 13:48:46 +00:00
|
|
|
|
return FALSE;
|
2002-01-24 12:01:02 +00:00
|
|
|
|
const int r = idoneita.last_row(); //se trova una data idoneita >= di quella in esame, quest'ultima viene ignorata
|
|
|
|
|
if (r > 0)
|
2001-10-22 09:07:33 +00:00
|
|
|
|
{
|
2003-12-03 09:36:05 +00:00
|
|
|
|
const TRectype& lastido = idoneita[r];
|
|
|
|
|
const TString16 tipoultido = lastido.get(IDO_TIPOIDO);
|
|
|
|
|
const TString16 tipoidostr(tipoido);
|
2004-03-08 09:25:48 +00:00
|
|
|
|
if ((lastido.get_date(IDO_DATAIDO) >= datadon) && (tipoidostr == tipoultido) && (modstato_tcs(stato) != 'S'))
|
2001-10-22 09:07:33 +00:00
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2004-03-08 09:25:48 +00:00
|
|
|
|
TDate data;
|
|
|
|
|
if (datadon < datastato)
|
|
|
|
|
data = TODAY;
|
|
|
|
|
else
|
|
|
|
|
data = datadon;
|
2002-01-02 16:15:22 +00:00
|
|
|
|
|
|
|
|
|
TRectype* rec = new TRectype(LF_IDONEITA);
|
|
|
|
|
rec->put(IDO_CODICE, recsog.get(SOG_CODICE));
|
2003-08-08 13:24:47 +00:00
|
|
|
|
if (idoneita.rows() == 0)
|
|
|
|
|
rec->put(IDO_PROGIDO, 1);
|
|
|
|
|
else
|
|
|
|
|
rec->put(IDO_PROGIDO, r+1);
|
2004-03-08 09:25:48 +00:00
|
|
|
|
rec->put(IDO_DATAIDO, data);
|
2003-06-24 08:47:34 +00:00
|
|
|
|
rec->put(IDO_TIPOIDO, tipoido); // Il mondo <20> bello perch<63> c'<27> l'AVIS (tutte le donaz. non SI sono AF! mah?!)
|
2002-01-02 16:15:22 +00:00
|
|
|
|
rec->put(IDO_IDO_SOS, "ID");
|
|
|
|
|
rec->put(IDO_INTERVALLO, inter);
|
2002-10-31 13:48:46 +00:00
|
|
|
|
// aggiunto da cristina il 18/09/2002 altrimenti non so che quella riga <20> stata aggiunta da CT
|
|
|
|
|
rec->put(IDO_RESPONSAB, "TRASF. DA CT");
|
2002-01-02 16:15:22 +00:00
|
|
|
|
idoneita.add_row(rec);
|
|
|
|
|
idoneita.write();
|
|
|
|
|
|
|
|
|
|
con_reord(recsog, &controlli, &idoneita);
|
2003-06-24 08:47:34 +00:00
|
|
|
|
// verifico se occorre azzerare numero convocazioni e data ultima convocazione
|
|
|
|
|
TDate dataultdon = recsog.get(SOG_DATAULTDON);
|
2004-03-08 09:25:48 +00:00
|
|
|
|
if ((data - dataultdon) > 730)
|
2003-06-24 08:47:34 +00:00
|
|
|
|
{
|
|
|
|
|
recsog.put(SOG_DATACONV, NULLDATE);
|
|
|
|
|
recsog.put(SOG_NUMCONV, 0);
|
|
|
|
|
}
|
2002-10-31 13:48:46 +00:00
|
|
|
|
// aggiorno data e utente ultimo aggiornamento (Cristina 18/09/2002)
|
2003-12-03 09:36:05 +00:00
|
|
|
|
//const TDate oggi(TODAY);
|
|
|
|
|
//recsog.put(SOG_DATAULTAGG,oggi);
|
|
|
|
|
//recsog.put(SOG_UTENULTAGG,"WINSIT");
|
2002-01-02 16:15:22 +00:00
|
|
|
|
|
|
|
|
|
return TRUE;
|
2000-10-10 09:32:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// trasferimento dati da file CT su programma avis
|
|
|
|
|
void TCtbo2at::transfer()
|
|
|
|
|
{
|
|
|
|
|
TFilename ctboini = "ctbo2at.ini";
|
|
|
|
|
|
|
|
|
|
_trasfile = new TCtbo2at_file(_msk->get(F_FILENAME), ctboini);
|
|
|
|
|
inizializza_file();
|
2001-12-28 16:23:47 +00:00
|
|
|
|
const long dimension = fsize(_msk->get(F_FILENAME));
|
|
|
|
|
TProgind pi(dimension,"Acquisizione in corso...");
|
2000-10-10 09:32:13 +00:00
|
|
|
|
|
2001-10-22 09:07:33 +00:00
|
|
|
|
TRelation rel(LF_SOGGETTI);
|
2004-06-03 10:50:37 +00:00
|
|
|
|
TRectype& recsog = rel.curr();
|
2001-10-22 09:07:33 +00:00
|
|
|
|
|
2004-06-03 10:50:37 +00:00
|
|
|
|
TLocalisamfile& soggetti = rel.lfile();
|
|
|
|
|
rel.lfile().setkey(2);
|
|
|
|
|
|
|
|
|
|
TString80 str; // Stringa jolly di lavoro
|
2002-01-02 16:15:22 +00:00
|
|
|
|
TRecord_text curr;
|
2001-10-22 09:07:33 +00:00
|
|
|
|
while (_trasfile->read(curr) == NOERR)
|
2001-12-28 16:23:47 +00:00
|
|
|
|
{
|
2002-01-02 16:15:22 +00:00
|
|
|
|
pi.setstatus(_trasfile->read_file()->tellg());
|
2001-12-28 16:23:47 +00:00
|
|
|
|
//controlla se il donatore <20> AVIS oppure un cane sciolto o, peggio ancora, un adepto della
|
|
|
|
|
//concorrenza!!!(ovviamente si va a stringhe fisse e non a tabelle! roba da avis.....)
|
2004-06-03 10:50:37 +00:00
|
|
|
|
|
2002-01-02 16:15:22 +00:00
|
|
|
|
str = curr.get(31); //donatore della concorrenza -> lo salta
|
|
|
|
|
str.trim();
|
|
|
|
|
if (str == "ADVS")
|
|
|
|
|
continue;
|
|
|
|
|
if (str == "NOASS") //se il donatore <20> un cane sciolto -> va in sezione NI ed in categoria NI
|
|
|
|
|
{
|
|
|
|
|
curr.add("NI",0);
|
|
|
|
|
curr.add("@",1);
|
2004-06-03 10:50:37 +00:00
|
|
|
|
//sogg.put(SOG_CATDON,"NI");
|
2002-01-02 16:15:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-06-03 10:50:37 +00:00
|
|
|
|
//str = curr.get(2);
|
|
|
|
|
//sogg.put(SOG_CODICE, atol(str));
|
|
|
|
|
//if (rel.read(_isequal) != NOERR)
|
|
|
|
|
|
|
|
|
|
recsog.zero();
|
|
|
|
|
str = curr.get(3);
|
|
|
|
|
recsog.put(SOG_COGNOME, str);
|
|
|
|
|
str = curr.get(4);
|
|
|
|
|
recsog.put(SOG_NOME, str);
|
|
|
|
|
str = curr.get(5);
|
|
|
|
|
if (!str.blank())
|
|
|
|
|
{
|
|
|
|
|
recsog.put(SOG_DATANASC, str);
|
|
|
|
|
if (recsog.read(rel.lfile())!=NOERR)
|
|
|
|
|
{
|
|
|
|
|
recsog.zero();
|
|
|
|
|
|
|
|
|
|
str = curr.get(2);
|
|
|
|
|
recsog.put(SOG_CODICE, str);
|
|
|
|
|
str = curr.get(3);
|
|
|
|
|
recsog.put(SOG_COGNOME, str);
|
|
|
|
|
str = curr.get(4);
|
|
|
|
|
recsog.put(SOG_NOME, str);
|
|
|
|
|
str = curr.get(5);
|
|
|
|
|
recsog.write(rel.lfile());
|
|
|
|
|
}
|
|
|
|
|
//controlla se il donatore ha cambiato sezione spostandosi da Bologna in provincia;
|
|
|
|
|
//in questo caso gli deve cancellare il sottogruppo (veramente un procedimento da
|
|
|
|
|
//galera, ma se l'avis e winsit vogliono cos<6F>.....)
|
|
|
|
|
str = curr.get(0);
|
|
|
|
|
str.trim();
|
|
|
|
|
TString8 str1;
|
|
|
|
|
str1 = curr.get(1);
|
|
|
|
|
str1.trim();
|
|
|
|
|
if (str != recsog.get(SOG_CODSEZ) && str != "01" && str1 == "")
|
|
|
|
|
curr.add("@",1);
|
|
|
|
|
|
|
|
|
|
//esegue l'effettivo passaggio dati basandosi sulla formattazione del file .ini
|
|
|
|
|
_trasfile->autosave(rel, curr);
|
|
|
|
|
const TDate oggi(TODAY);
|
|
|
|
|
recsog.put(SOG_DATAULTAGG,oggi);
|
|
|
|
|
recsog.put(SOG_UTENULTAGG,"WINSIT");
|
|
|
|
|
rel.rewrite();
|
|
|
|
|
const char* tipo[] = { "SI", "PL", "PI", "PP" };
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
{
|
|
|
|
|
bool update = FALSE;
|
|
|
|
|
TDate datadon(TODAY);
|
|
|
|
|
str = curr.get(23+i);
|
|
|
|
|
if (!str.blank())
|
|
|
|
|
{
|
|
|
|
|
datadon = TDate(str);
|
|
|
|
|
str = curr.get(32);
|
|
|
|
|
str.trim();
|
|
|
|
|
//cambio codice del punto di prelievo per casi speciali (sarebbe necessaria una tabella,
|
|
|
|
|
//ma con l'AVIS <20> tempo sprecato....)
|
|
|
|
|
if (str == "UROM")
|
|
|
|
|
str = "013";
|
|
|
|
|
else if (str == "UROB")
|
|
|
|
|
str = "O.BE";
|
|
|
|
|
else if (str == "IMOLA")
|
|
|
|
|
str = "70";
|
|
|
|
|
else if (str.empty())
|
|
|
|
|
str = "70";
|
|
|
|
|
update |= test_donation(recsog, tipo[i], datadon, str);
|
|
|
|
|
}
|
|
|
|
|
str = curr.get(35);
|
|
|
|
|
TDate datainisos(NULLDATE);
|
|
|
|
|
if (!str.blank())
|
|
|
|
|
datainisos = TDate(str);
|
|
|
|
|
str = curr.get(36);
|
|
|
|
|
TDate datafinesos(NULLDATE);
|
|
|
|
|
if (!str.blank())
|
|
|
|
|
datafinesos = TDate(str);
|
|
|
|
|
str = curr.get(27+i);
|
|
|
|
|
if ((datainisos.empty()) || (datafinesos <= oggi))
|
|
|
|
|
if (!real::is_null(str))
|
|
|
|
|
update |= test_inter(recsog, tipo[i], datadon, atoi(str));
|
|
|
|
|
if (update)
|
|
|
|
|
{
|
|
|
|
|
calcola_categoria(recsog);
|
|
|
|
|
rel.rewrite();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-10-10 09:32:13 +00:00
|
|
|
|
}
|
|
|
|
|
_trasfile->close();
|
2002-01-02 16:15:22 +00:00
|
|
|
|
message_box("Operazione terminata");
|
2000-10-10 09:32:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//inizializza il file di testo su cui emettere i dati
|
|
|
|
|
void TCtbo2at::inizializza_file()
|
|
|
|
|
{
|
2002-01-02 16:15:22 +00:00
|
|
|
|
TFilename filect = _msk->get(F_FILENAME); //aggiungere lettura automatica nomi file
|
2000-10-10 09:32:13 +00:00
|
|
|
|
_trasfile->open(filect,'r');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// handler per gestire la conferma dell'annullamento dei dati inseriti
|
|
|
|
|
// nella maschera
|
|
|
|
|
bool TCtbo2at::annulla_handler(TMask_field& f, KEY k)
|
|
|
|
|
{
|
|
|
|
|
TMask &m = f.mask();
|
|
|
|
|
if (k == K_SPACE)
|
|
|
|
|
{
|
|
|
|
|
if (yesno_box("Vuoi veramente annullare i dati inseriti"))
|
|
|
|
|
m.reset();
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// gestione dei messaggi estesi nei campi
|
|
|
|
|
void TCtbo2at_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, TString& str)
|
|
|
|
|
{
|
|
|
|
|
const TString code(s.get(0));
|
|
|
|
|
TString valore;
|
2001-11-06 09:48:07 +00:00
|
|
|
|
if (code == "_UPPERCASE")
|
2000-10-10 09:32:13 +00:00
|
|
|
|
{
|
2002-01-02 16:15:22 +00:00
|
|
|
|
valore.upper();
|
2000-10-10 09:32:13 +00:00
|
|
|
|
}
|
|
|
|
|
else NFCHECK("Macro non definita: %s", (const char *)code);
|
|
|
|
|
str = valore;
|
2001-10-22 09:07:33 +00:00
|
|
|
|
}
|
2000-10-10 09:32:13 +00:00
|
|
|
|
|
|
|
|
|
int at8800(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
TCtbo2at a ;
|
|
|
|
|
a.run(argc, argv, "Acquisizione dati da CT Bologna");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|