Patch level : at

Files correlati     :
Ricompilazione Demo : [ ]
Commento            : rsa


git-svn-id: svn://10.65.10.50/trunk@10597 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
cris 2002-10-31 13:50:41 +00:00
parent b62db47008
commit 0befe56d1f
8 changed files with 646 additions and 1382 deletions

View File

@ -4,7 +4,7 @@
#include "at8.h" #include "at8.h"
#define usage "Error - usage : %s -{0|1|2|3|4|5|6|7}" #define usage "Error - usage : %s -{0|1|2|3|4|5|6|7|8}"
int main(int argc,char** argv) int main(int argc,char** argv)
@ -30,6 +30,8 @@ int main(int argc,char** argv)
rt = at8700(argc,argv) ; break; rt = at8700(argc,argv) ; break;
case 7: case 7:
rt = at8800(argc,argv) ; break; rt = at8800(argc,argv) ; break;
case 8:
rt = at8900(argc,argv) ; break;
default: default:
error_box(usage, argv[0]) ; break; error_box(usage, argv[0]) ; break;
} }

View File

@ -9,6 +9,7 @@ int at8500(int argc, char* argv[]);
int at8600(int argc, char* argv[]); int at8600(int argc, char* argv[]);
int at8700(int argc, char* argv[]); int at8700(int argc, char* argv[]);
int at8800(int argc, char* argv[]); int at8800(int argc, char* argv[]);
int at8900(int argc, char* argv[]);
#endif // __AT8_H #endif // __AT8_H

View File

@ -1,800 +1,126 @@
#include <applicat.h> #include <applicat.h>
#include <execp.h>
#include <mask.h>
#include <msksheet.h>
#include <mailbox.h>
#include <prefix.h>
#include <progind.h>
#include <recarray.h> #include <recarray.h>
#include <relation.h> #include <relation.h>
#include <tabutil.h> #include <tabutil.h>
#include <urldefid.h> #include <utility.h>
#include <validate.h>
#include <lffiles.h>
#include "at8.h"
// nomi campi maschera
#include "at8600a.h"
#include "atlib.h" #include "atlib.h"
// nomi dei campi #include "at5.h"
#include "soggetti.h" #include "soggetti.h"
#include "donaz.h" #include "donaz.h"
#include "contsan.h" #include "contsan.h"
#include "idoneita.h" #include "idoneita.h"
#include "rconvoc.h"
#define ALIAS_CTD 700 class TRiordinaSog : public TApplication
{
class TCorreggiDC : public TApplication
{
TMask* _msk;
TRelation* _rel;
TLocalisamfile* _soggetti; TLocalisamfile* _soggetti;
TLocalisamfile* _donaz; TLocalisamfile* _donaz;
TLocalisamfile* _contsan; TLocalisamfile* _contsan;
TLocalisamfile* _idoneita; TLocalisamfile* _idoneita;
TLocalisamfile* _rconvoc;
TRecord_array* _sdonazioni; TRecord_array* _sdonazioni;
TRecord_array* _scontrolli; TRecord_array* _scontrolli;
TRecord_array* _sidoneita; TRecord_array* _sidoneita;
TDate _datadon, _ndatadon;
TString16 _tipodon, _luogodon, _ntipodon, _nluogodon;
// parametri di sezione
int _intsi_f1, _intsi_f2, _intsi_m, _intaf_m, _etadonne;
int _numdon1, _numdon2;
TString16 _catini1, _catfin1, _catini2, _catfin2, _motivoid;
bool _sttess2, _dataisc, _nomessage, _autoid;
protected: protected:
virtual bool create(); virtual bool create();
virtual bool destroy(); virtual bool destroy();
virtual bool menu(MENU_TAG m);
virtual TMask& get_mask() { return *_msk; }
virtual TRelation* get_relation() const { return _rel; }
int read(TSheet_field& s);
bool modifica(TSheet_field& s);
bool elimina(TSheet_field& s);
public: public:
TCorreggiDC() {} TRiordinaSog() {}
virtual ~TRiordinaSog() {}
}; };
HIDDEN inline TCorreggiDC& app() { return (TCorreggiDC&) main_app(); } bool TRiordinaSog::create()
bool TCorreggiDC::create()
{ {
TApplication::create(); TApplication::create();
_msk = new TMask("at8600a");
_rel = new TRelation(LF_SOGGETTI); if (argc() < 3)
_rel->add("CTD", "CODTAB==CATDON",1,0,ALIAS_CTD); return error_box("Specificare il codice del soggetto");
_donaz = new TLocalisamfile(LF_DONAZ); long codsog = atol(argv(2));
_contsan = new TLocalisamfile(LF_CONTSAN); _soggetti = new TLocalisamfile(LF_SOGGETTI);
_idoneita = new TLocalisamfile(LF_IDONEITA); _donaz = new TLocalisamfile(LF_DONAZ);
_rconvoc = new TLocalisamfile(LF_RCONVOC); _contsan = new TLocalisamfile(LF_CONTSAN);
_idoneita = new TLocalisamfile(LF_IDONEITA);
_sdonazioni = new TRecord_array(LF_DONAZ,DON_PROGDON); _sdonazioni = new TRecord_array(LF_DONAZ,DON_PROGDON);
_scontrolli = new TRecord_array(LF_CONTSAN,CON_PROGCON); _scontrolli = new TRecord_array(LF_CONTSAN,CON_PROGCON);
_sidoneita = new TRecord_array(LF_IDONEITA,IDO_PROGIDO); _sidoneita = new TRecord_array(LF_IDONEITA,IDO_PROGIDO);
TConfig config(CONFIG_STUDIO); TConfig config(CONFIG_STUDIO);
_numdon1 = config.get_int("NumDon1"); const int numdon1 = config.get_int("NumDon1");
_numdon2 = config.get_int("NumDon2"); const int numdon2 = config.get_int("NumDon2");
_catini1 = config.get("CatIni1"); TString16 catini1 = config.get("CatIni1");
_catfin1 = config.get("CatFin1"); TString16 catfin1 = config.get("CatFin1");
_catini2 = config.get("CatIni2"); TString16 catini2 = config.get("CatIni2");
_catfin2 = config.get("CatFin2"); TString16 catfin2 = config.get("CatFin2");
_sttess2 = config.get_bool("StTess2"); const bool sttess2 = config.get_bool("StTess2");
_dataisc = config.get_bool("DataIsc"); const bool dataisc = config.get_bool("DataIsc");
_nomessage = config.get_bool("NoMessage"); const int etadonne = config.get_int("EtaDonne");
_etadonne = config.get_int("EtaDonne"); const int intsi_f1 = config.get_int("IntSI_F1");
_intsi_f1 = config.get_int("IntSI_F1"); const int intsi_f2 = config.get_int("IntSI_F2");
_intsi_f2 = config.get_int("IntSI_F2"); const int intsi_m = config.get_int("IntSI_M");
_intsi_m = config.get_int("IntSI_M"); const int intaf_m = config.get_int("IntAF_M");
_intaf_m = config.get_int("IntAF_M"); TRectype soggetto(LF_SOGGETTI);
dispatch_e_menu(BAR_ITEM(1)); _soggetti->put(SOG_CODICE, codsog);
return TRUE; if (_soggetti->read() == NOERR)
} {
TRectype& sog = _soggetti->curr();
TRectype* key = new TRectype(LF_DONAZ);
key->put(DON_CODICE, codsog);
int err = _sdonazioni->read(key);
if (err == NOERR)
{
calcola_donazioni_lib(sog, _sdonazioni);
_sdonazioni->rewrite();
_soggetti->rewrite();
}
TString16 catdon = sog.get(SOG_CATDON);
const int totdon = sog.get_int(SOG_TOTDON);
const TRectype& ctd = cache().get("CTD", catdon);
const bool dimissione = ctd.get_bool("B0");
if (dimissione)
{
const TString16 catcoll = ctd.get("S6");
if (catcoll.not_empty())
{
sog.put(SOG_CATDON, catcoll);
catdon = catcoll;
}
}
if ((catdon == catini1 || catini1.empty()) && (totdon==numdon1) && catfin1.not_empty())
sog.put(SOG_CATDON, catfin1);
if ((catdon == catini2 || catini2.empty()) && (totdon>=numdon2) && catfin2.not_empty() && (!sttess2 || dimissione))
sog.put(SOG_CATDON, catfin2);
TDate dataiscsog = sog.get_date(SOG_DATAISC);
if (!dataiscsog.ok() && dataisc)
{
if (!sog.get_date(SOG_DATAPRISI) == NULLDATE)
sog.put(SOG_DATAISC,sog.get(SOG_DATAPRISI));
else
{
const TRectype& riga = _sdonazioni->row(1);
sog.put(SOG_DATAISC,riga.get(DON_DATADON));
}
}
_soggetti->rewrite();
}
stop_run();
return TRUE;
}
bool TCorreggiDC::destroy() bool TRiordinaSog::destroy()
{ {
delete _sidoneita; delete _sidoneita;
delete _scontrolli; delete _scontrolli;
delete _sdonazioni; delete _sdonazioni;
delete _rconvoc; delete _idoneita;
delete _idoneita; delete _contsan;
delete _contsan; delete _donaz;
delete _donaz; delete _soggetti;
delete _rel; return TApplication::destroy();
delete _msk;
return TApplication::destroy();
} }
bool TCorreggiDC::menu(MENU_TAG m) int at5400(int argc, char* argv[])
{ {
TMask& msk = get_mask(); TRiordinaSog a;
msk.field(F_MODIFICA).disable(); a.run(argc, argv, "Riordina donazioni soggetto");
msk.field(F_ELIMINA).disable(); return 0;
msk.field(F_MODIFICA).hide();
msk.field(F_ELIMINA).hide();
KEY tasto = K_ENTER;
TSheet_field& s = (TSheet_field&)msk.field(F_SOGGETTI);
while (tasto != K_QUIT)
{
tasto = msk.run();
if (tasto == F_VISUALIZZA)
{
_datadon = msk.get_date(F_DATADON);
_tipodon = msk.get(F_TIPODON);
_luogodon = msk.get(F_LUOGODON);
int totale = TCorreggiDC::read(s);
if (totale > 0)
{
msk.set(F_TOTALE, totale);
msk.disable(F_VISUALIZZA);
msk.hide(F_VISUALIZZA);
msk.enable(F_MODIFICA);
msk.enable(F_ELIMINA);
msk.show(F_MODIFICA);
msk.show(F_ELIMINA);
}
else
error_box("ATTENZIONE! Non ci sono donazioni inserite con le caratteristiche richieste");
}
if (tasto == F_MODIFICA)
{
_ndatadon = msk.get_date(F_NDATADON);
_ntipodon = msk.get(F_NTIPODON);
_nluogodon = msk.get(F_NLUOGODON);
if (_ndatadon.ok() || !_ntipodon.blank() || !_nluogodon.blank())
{
if (yesno_box("Confermare la modifica dei dati della donazione?"))
TCorreggiDC::modifica(s);
}
else
error_box("Inserire almeno un dato da modificare");
}
if (tasto == F_ELIMINA)
{
if (yesno_box("Confermare l'eliminazione delle donazioni inserite?"))
TCorreggiDC::elimina(s);
}
if (tasto == F_MODIFICA || tasto == F_ELIMINA)
{
msk.reset();
msk.field(F_MODIFICA).disable();
msk.field(F_ELIMINA).disable();
msk.field(F_MODIFICA).hide();
msk.field(F_ELIMINA).hide();
msk.enable(F_VISUALIZZA);
msk.show(F_VISUALIZZA);
}
}
return FALSE;
}
bool TCorreggiDC::elimina(TSheet_field& s)
{
TMask& m = s.mask();
int items = s.items();
TProgind *pi;
pi = new TProgind(items,"Eliminazione donazioni", FALSE, TRUE, 10);
pi->setstatus(1);
TLocalisamfile& sog = get_relation()->lfile();
TLocalisamfile rconv(LF_RCONVOC);
for (int rigasog=1; rigasog<=s.items(); rigasog++)
{
pi->addstatus(1);
TToken_string& row = s.row(rigasog-1);
const long codsog = row.get_long(0);
if (codsog != 0)
{
sog.setkey(1);
sog.zero();
sog.put(SOG_CODICE, codsog);
int err = sog.read();
if (err == NOERR)
{
bool deleted = FALSE;
TRectype* key = new TRectype(LF_DONAZ);
key->put(DON_CODICE, row.get(0));
err = _sdonazioni->read(key);
if (err == NOERR)
{
int r=_sdonazioni->rows();
while (r>=1 && !deleted)
{
const TRectype& riga = _sdonazioni->row(r);
const TDate d = riga.get(DON_DATADON);
if (_datadon==d)
{
_sdonazioni->destroy_row(r,TRUE);
deleted=TRUE;
r=0;
}
r--;
}
}
if (deleted)
{
err = _sdonazioni->write(TRUE);
calcola_donazioni_lib(sog.curr(),_sdonazioni);
// aggiorno data e utente ultimo aggiornamento
const TDate oggi(TODAY);
sog.put(SOG_DATAULTAGG,oggi);
sog.put(SOG_UTENULTAGG,user());
if (err == NOERR)
sog.rewrite();
else
{
error_box("Errore %d durante la scrittura della riga %d", err, rigasog);
break;
}
}
}
}
}
delete pi;
return TRUE;
}
bool TCorreggiDC::modifica(TSheet_field& s)
{
s.destroy();
TLocalisamfile donaz(LF_DONAZ);
TLocalisamfile soggetti(LF_SOGGETTI);
soggetti.setkey(1);
donaz.setkey(4);
donaz.zero();
donaz.put(DON_DATADON, _datadon);
if (_tipodon.not_empty())
{
donaz.put(DON_TIPODON, _tipodon);
if (_luogodon.not_empty())
donaz.put(DON_LUOGODON, _luogodon);
}
TString16 luogodon, tipodon;
TDate datadon;
bool leggi = TRUE;
const TRectype r(donaz.curr());
donaz.read(_isgteq) ;
while (!donaz.eof() && (donaz.curr() == r))
{
luogodon = donaz.get(DON_LUOGODON);
tipodon = donaz.get(DON_TIPODON);
datadon = donaz.get(DON_DATADON);
if (_luogodon != luogodon || _tipodon != tipodon || _datadon != datadon) break;
if (_tipodon.empty())
{
if (luogodon == _luogodon)
leggi = TRUE;
else
leggi = FALSE;
}
else
{
if (_luogodon.empty())
{
if (luogodon.empty())
leggi = TRUE;
else
leggi = FALSE;
}
else
leggi = TRUE;
}
if (leggi)
{
if (!_nluogodon.blank())
{
donaz.put(DON_LUOGODON, _nluogodon);
donaz.rewrite();
}
}
donaz.zero();
donaz.put(DON_DATADON, _datadon);
if (_tipodon.not_empty())
{
donaz.put(DON_TIPODON, _tipodon);
if (_luogodon.not_empty())
donaz.put(DON_LUOGODON, _luogodon);
}
donaz.read(_isgteq);
}
return TRUE;
}
int TCorreggiDC::read(TSheet_field& s)
{
s.destroy();
TLocalisamfile donaz(LF_DONAZ);
TLocalisamfile soggetti(LF_SOGGETTI);
soggetti.setkey(1);
donaz.setkey(4);
donaz.zero();
donaz.put(DON_DATADON, _datadon);
if (_tipodon.not_empty())
{
donaz.put(DON_TIPODON, _tipodon);
if (_luogodon.not_empty())
donaz.put(DON_LUOGODON, _luogodon);
}
TString16 luogodon;
bool leggi = TRUE;
const TRectype r(donaz.curr());
int items = 0;
for(donaz.read(_isgteq); !donaz.eof(); donaz.next())
{
if (donaz.curr() != r) break;
if (_tipodon.empty())
{
luogodon = donaz.get(DON_LUOGODON);
if (luogodon == _luogodon)
leggi = TRUE;
else
leggi = FALSE;
}
else
if (_luogodon.empty())
{
luogodon = donaz.get(DON_LUOGODON);
if (luogodon.empty())
leggi = TRUE;
else
leggi = FALSE;
}
else
leggi = TRUE;
if (leggi)
{
TToken_string& row = s.row(items);
row.add(donaz.get(DON_CODICE));
soggetti.zero();
soggetti.put(SOG_CODICE,donaz.get(DON_CODICE));
int err = soggetti.read();
if (err == NOERR)
{
row.add(soggetti.get(SOG_COGNOME));
row.add(soggetti.get(SOG_NOME));
row.add(soggetti.get(SOG_TESSAVIS));
}
else
{
row.add("");
row.add("");
row.add("");
}
row.add(donaz.get(DON_TIPODON));
row.add("");
row.add(donaz.get(DON_ETICHETTA));
row.add(donaz.get(DON_PRIMADON));
row.add(""); // data donazione se diversa
if (err == NOERR)
{
row.add(soggetti.get(SOG_DATANASC));
row.add(soggetti.get(SOG_CODSEZ));
row.add(soggetti.get(SOG_CODSOT));
row.add(soggetti.get(SOG_CATDON));
row.add(soggetti.get(SOG_INTSI));
}
items++;
}
}
return items;
} }
/*
int TCorreggiDC::modifica(TSheet_field& s)
{
TMask& m = s.mask();
m.disable(-1);
int items = s.items();
TProgind *pi;
pi = new TProgind(items,"Registrazione donazioni e controlli", FALSE, TRUE, 10);
pi->setstatus(1);
TLocalisamfile& sog = get_relation()->lfile();
TLocalisamfile rconv(LF_RCONVOC);
for (int rigasog=1; rigasog<=s.items(); rigasog++)
{
pi->addstatus(1);
TToken_string& row = s.row(rigasog-1);
const long codsog = row.get_long(0);
if (codsog != 0)
{
sog.setkey(1);
sog.zero();
sog.put(SOG_CODICE, codsog);
int err = sog.read();
if (err == NOERR)
{
TDate datadonazione = row.get(8);
if (!datadonazione.ok())
datadonazione = _datadon;
TString16 tipocon = row.get(5);
if (tipocon.blank())
tipocon = m.get(F_TIPOCON);
if (tipocon.not_empty())
{
TRectype* recc = new TRectype(LF_CONTSAN);
recc->put(CON_CODICE, row.get(0));
recc->put(CON_DATACON, datadonazione);
recc->put(CON_TIPOCON, tipocon);
if (modstato_tcs(tipocon) == 'I')
{
recc->put(CON_IDON1,sog.get(SOG_IDON1));
recc->put(CON_IDON2,sog.get(SOG_IDON2));
recc->put(CON_IDON3,sog.get(SOG_IDON3));
recc->put(CON_IDON4,sog.get(SOG_IDON4));
recc->put(CON_INTSI,sog.get(SOG_INTSI));
recc->put(CON_INTAF,sog.get(SOG_INTAF));
}
bool insert = FALSE;
bool exist = FALSE;
TRectype* keyc = new TRectype(LF_CONTSAN);
keyc->put(CON_CODICE, row.get(0));
int err = _scontrolli->read(keyc);
if (err == NOERR)
{
int r=_scontrolli->rows();
while (r>=1 && !insert && !exist)
{
const TRectype& riga = _scontrolli->row(r);
const TDate d = riga.get(CON_DATACON);
if (datadonazione==d) // esiste già un controllo in questa data
{
exist=TRUE;
r=0;
}
else
if (datadonazione > d)
{
recc->put(CON_PROGCON,r+1);
_scontrolli->insert_row(recc);
insert=TRUE;
}
r--;
}
if (!exist && !insert)
{
recc->put(CON_PROGCON,1);
_scontrolli->insert_row(recc);
}
}
else
if (err == _iseof || err == _isemptyfile)
{
recc->put(CON_PROGCON,1);
_scontrolli->insert_row(recc);
}
if (!exist)
{
_scontrolli->write(TRUE);
TRectype* keyc = new TRectype(LF_IDONEITA);
keyc->put(IDO_CODICE, row.get(0));
int err = _sidoneita->read(keyc);
con_reord(sog.curr(),_scontrolli,_sidoneita);
}
}
TRectype* rec = new TRectype(LF_DONAZ);
rec->put(DON_CODICE, row.get(0));
rec->put(DON_ETICHETTA, row.get(6));
rec->put(DON_PRIMADON, row.get(7));
rec->put(DON_CODSEZ,sog.get(SOG_CODSEZ));
rec->put(DON_CODSOT,sog.get(SOG_CODSOT));
bool modified = FALSE;
bool found = FALSE;
TString16 tipodon = row.get(4);
if (tipodon.blank())
tipodon = _tipodon;
TRectype* key = new TRectype(LF_DONAZ);
key->put(DON_CODICE, row.get(0));
err = _sdonazioni->read(key);
if (err == NOERR)
{
int r = _sdonazioni->rows();
while (r>0 && !found)
{
const TRectype& riga = _sdonazioni->row(r);
const TDate d = riga.get(DON_DATADON);
if ((datadonazione==d) && (riga.get(DON_TIPODON)== tipodon) && (riga.get(DON_LUOGODON)==_luogodon)) // ho trovato la donazione da modificare
{
found=TRUE;
}
r--;
}
}
if (found)
{
r++;
TRectype& riga = _sdonazioni->row(r);
if (riga.get(DON_DATADON).blank())
datadonazione = _ndatadon;
if (riga.get(DON_TIPODON).blank())
tipodon=_ntipodon;
if (riga.get(DON_LUOGODON).blank())
luogodon=_nluogodon;
riga.put(DON_DATADON, datadonazione);
riga.put(DON_LUOGODON, luogodon);
riga.put(DON_TIPODON, tipodon);
err= _sdonazioni.rewrite();
// controllo se è idoneo
bool ctrlsi = FALSE; //devo controllare se è idoneo SI
bool ctrlaf = FALSE; //devo controllare se è idoneo AF
bool id_si = FALSE; // il soggetto è idoneo per si?
bool id_af = FALSE; // il soggetto è idoneo per af?
char modstato = ' ';
TString16 stato = sog.get(SOG_STATO); // stato attuale
TString16 statosi = sog.get(SOG_STATOSI); // stato attuale SI
TString16 statoaf = sog.get(SOG_STATOAF); // stato attuale AF
TString16 id1 = sog.get(SOG_IDON1); // idon. 1
TString16 id2 = sog.get(SOG_IDON2); // idon. 2
TString16 id3 = sog.get(SOG_IDON3); // idon. 3
TString16 id4 = sog.get(SOG_IDON4); // idon. 4
int intsi = sog.get_int(SOG_INTSI); // intervallo per SI
int intaf = sog.get_int(SOG_INTAF); // intervallo per AF
//id_si = ((is_idon(id1,id2,id3,id4,IDON_SI) || (statosi == "ID")) && intsi != 0); // il soggetto è idoneo SI
//id_af = ((is_idon(id1,id2,id3,id4,IDON_AF) || (statoaf == "ID")) && intaf != 0); // il soggetto è idoneo AF
id_si = ((statosi == "ID") && (intsi != 0)); // il soggetto è idoneo SI
id_af = ((statoaf == "ID") && (intaf != 0)); // il soggetto è idoneo AF
int totdon = sog.get_int(SOG_TOTDON);
TDate dataultdon = sog.get_date(SOG_DATAULTDON);
sog.put(SOG_TOTDON,totdon+1);
if (datadonazione > dataultdon)
{
sog.put(SOG_DATAULTDON,datadonazione);
sog.put(SOG_TIPOULTDON,tipodon);
}
if (is_donaz(tipodon,IDON_SI))
{
ctrlsi = TRUE;
totdon = sog.get_int(SOG_TOTDONSI);
sog.put(SOG_TOTDONSI,totdon+1);
dataultdon = sog.get_date(SOG_DATAULTSI);
if (datadonazione>dataultdon)
sog.put(SOG_DATAULTSI,datadonazione);
}
if (is_donaz(tipodon,IDON_AF))
{
ctrlaf = TRUE;
totdon = sog.get_int(SOG_TOTDONAF);
sog.put(SOG_TOTDONAF,totdon+1);
dataultdon = sog.get_date(SOG_DATAULTAF);
if (datadonazione>dataultdon)
sog.put(SOG_DATAULTAF,datadonazione);
}
dataultdon = sog.get_date(SOG_DATAULTDON); // data ultima donazione
const TString16 tipoultdon(sog.get(SOG_TIPOULTDON)); // tipo ultima donazione
TDate datasi(NULLDATE); // data prossima si calcolata
TDate dataaf(NULLDATE); // data prossima af calcolata
TDate dataultsi(NULLDATE); // data ultima donazione si
modstato = modstato_tcs(stato);
// il soggetto è idoneo per il tipo di donazione ?
if ((ctrlsi) && (!id_si) && (_autoid) && (modstato!='B'))
{
TRectype* key = new TRectype(LF_IDONEITA);
long codice = sog.get_long(SOG_CODICE);
key->put(IDO_CODICE, codice);
int err = _sidoneita->read(key);
int progido = _sidoneita->rows()+1;
TRectype& recido = _idoneita->curr();
recido.zero();
recido.put(IDO_CODICE, codice);
recido.put(IDO_PROGIDO, progido);
recido.put(IDO_DATAIDO, datadonazione);
recido.put(IDO_IDO_SOS, "ID");
recido.put(IDO_TIPOIDO, "SI");
TString80 resp = user();
resp << " - HA DONATO OGGI";
recido.put(IDO_RESPONSAB, resp);
recido.put(IDO_MOTIVO, _motivoid);
recido.put(IDO_INTERVALLO, sog.get(SOG_INTSI));
if (sog.get_int(SOG_INTSI) == 0)
{
const TString16 sesso = sog.get(SOG_SESSO);
if (sesso == "2")
{
TDate datanasc = sog.get_date(SOG_DATANASC);
int eta = datadonazione.year() - datanasc.year();
if(eta <= _etadonne)
recido.put(IDO_INTERVALLO, _intsi_f1);
else
recido.put(IDO_INTERVALLO, _intsi_f2);
}
else
recido.put(IDO_INTERVALLO, _intsi_m);
}
_sidoneita->add_row(recido);
_sidoneita->rewrite();
TRectype* keyc = new TRectype(LF_CONTSAN);
keyc->put(CON_CODICE, codice);
err = _scontrolli->read(keyc);
con_reord(sog.curr(),_scontrolli,_sidoneita);
sog.rewrite();
stato = sog.get(SOG_STATO); // stato attuale
modstato = modstato_tcs(stato);
}
if ((ctrlaf) && (!id_af) && (_autoid) && (modstato!='B'))
{
TRectype* key = new TRectype(LF_IDONEITA);
long codice = sog.get_long(SOG_CODICE);
key->put(IDO_CODICE, codice);
int err = _sidoneita->read(key);
int progido = _sidoneita->rows()+1;
TRectype& recido = _idoneita->curr();
recido.zero();
recido.put(IDO_CODICE, codice);
recido.put(IDO_PROGIDO, progido);
recido.put(IDO_DATAIDO, datadonazione);
recido.put(IDO_IDO_SOS, "ID");
recido.put(IDO_TIPOIDO, "AF");
TString80 resp = user();
resp << " - HA DONATO OGGI";
recido.put(IDO_RESPONSAB, resp);
recido.put(IDO_MOTIVO, _motivoid);
recido.put(IDO_INTERVALLO, sog.get(SOG_INTAF));
if (sog.get_int(SOG_INTAF) == 0)
recido.put(IDO_INTERVALLO, _intaf_m);
_sidoneita->add_row(recido);
_sidoneita->rewrite();
TRectype* keyc = new TRectype(LF_CONTSAN);
keyc->put(CON_CODICE, codice);
err = _scontrolli->read(keyc);
con_reord(sog.curr(),_scontrolli,_sidoneita);
sog.rewrite();
stato = sog.get(SOG_STATO); // stato attuale
modstato = modstato_tcs(stato);
}
sog.get(SOG_STATO); // stato attuale
statosi = sog.get(SOG_STATOSI); // stato attuale SI
statoaf = sog.get(SOG_STATOAF); // stato attuale AF
id1 = sog.get(SOG_IDON1); // idon. 1
id2 = sog.get(SOG_IDON2); // idon. 2
id3 = sog.get(SOG_IDON3); // idon. 3
id4 = sog.get(SOG_IDON4); // idon. 4
intsi = sog.get_int(SOG_INTSI); // intervallo per SI
intaf = sog.get_int(SOG_INTAF); // intervallo per AF
modstato = modstato_tcs(stato);
if (modstato == 'I' || modstato == 'F') // il soggetto è idoneo
{
//id_si = (is_idon(id1,id2,id3,id4,IDON_SI) && intsi != 0); // il soggetto è idoneo SI
//id_af = (is_idon(id1,id2,id3,id4,IDON_AF) && intaf != 0); // il soggetto è idoneo AF
id_si = ((statosi == "ID") && (intsi != 0)); // il soggetto è idoneo SI
id_af = ((statoaf == "ID") && (intaf != 0)); // il soggetto è idoneo AF
if (dataultdon.ok()) // se ha fatto almeno una donazione
{
if (is_donaz(tipoultdon,IDON_SI)) // se l'ultima donazione è una SI
{
if (id_si)
{
datasi=dataultdon;
datasi+=intsi;
}
if (id_af)
{
dataaf=dataultdon;
dataaf+=intaf;
}
}
if (is_donaz(tipoultdon,IDON_AF)) // se l'ultima donazione è una AF
{
dataultsi = sog.get_date(SOG_DATAULTSI);
if (id_si)
{
if (intaf != 0)
{
datasi=dataultdon;
datasi+=intaf;
}
else
{
datasi=dataultdon;
datasi+=intsi;
}
if (dataultsi.ok())
dataultsi+=intsi;
if (dataultsi > datasi)
datasi = dataultsi;
}
if (id_af)
{
dataaf=dataultdon;
dataaf+=intaf;
}
}
}
else
{
if (id_si)
datasi=sog.get_date(SOG_DATAULTID);
if (id_af)
dataaf=sog.get_date(SOG_DATAULTID);
}
}
sog.put(SOG_DATAPROSSI,datasi);
sog.put(SOG_DATAPROSAF,dataaf);
// se la data prossima SI è superiore all'ultima convocazione
// va cancellata, anche dall'archivio convocazioni
TDate dataprossi = sog.get_date(SOG_DATAPROSSI);
TDate dataconv = sog.get_date(SOG_DATACONV);
if (dataprossi >= dataconv)
{
rconv.setkey(2);
rconv.zero();
rconv.put(RCV_DATACONV, dataconv);
rconv.put(RCV_CODICE, codsog);
int err = rconv.read();
if (err == NOERR)
{
rconv.put(RCV_ANNULLATO,TRUE);
rconv.rewrite();
}
sog.put(SOG_DATACONV, NULLDATE);
sog.put(SOG_DATAULTSOL, NULLDATE);
const int zeroconv = 0;
sog.put(SOG_NUMCONV, zeroconv);
}
// controllo la sua categoria
// se dimesso diventa della categoria collegata
// se non c'e' la categoria collegata ???
TTable ctd("CTD");
TString16 catdon = sog.get(SOG_CATDON);
ctd.put("CODTAB",catdon);
if (ctd.read() == NOERR)
{
bool dimissione = ctd.get_bool("B0");
if (dimissione)
{
sog.put(SOG_CATDON,ctd.get("S6"));
if (ctd.get("S6").not_empty())
catdon = ctd.get("S6");
sog.put(SOG_DATADIM,NULLDATE);
}
if ((catdon == _catini1 || _catini1.empty()) && (totdon+1>=_numdon1) && _catfin1.not_empty())
sog.put(SOG_CATDON, _catfin1);
if ((catdon == _catini2 || _catini2.empty()) && (totdon+1>=_numdon2) && _catfin2.not_empty() && (!_sttess2 || dimissione))
sog.put(SOG_CATDON, _catfin2);
}
TDate dataisc = sog.get_date(SOG_DATAISC);
if (dataisc.ok() && _dataisc)
{
if (sog.get_date(SOG_DATAPRISI).ok())
sog.put(SOG_DATAISC,sog.get(SOG_DATAPRISI));
else
{
const TRectype& riga = _sdonazioni->row(1);
sog.put(SOG_DATAISC,riga.get(DON_DATADON));
}
}
// aggiorno data e utente ultimo aggiornamento
const TDate oggi(TODAY);
sog.put(SOG_DATAULTAGG,oggi);
sog.put(SOG_UTENULTAGG,user());
if (err == NOERR)
sog.rewrite();
else
{
error_box("Errore %d durante la scrittura della riga %d", err, rigasog);
break;
}
}
}
}
}
delete pi;
return NOERR;
}
*/
int at8600(int argc, char* argv[])
{
TCorreggiDC a;
a.run(argc, argv, "Correzione errato giornaliero donazioni");
return 0;
}

View File

@ -1,58 +0,0 @@
// correzione errato inseriemtno giornaliero donazioni
// dati dell'inserimento da correggere
#define F_DATADON 201
#define F_TIPODON 202
#define F_LUOGODON 203
#define F_DESC_TIPODON 204
#define F_DESC_LUOGODON 205
// dati nuovi
#define F_NDATADON 206
#define F_NTIPODON 207
#define F_NLUOGODON 208
#define F_DESC_NTIPODON 209
#define F_DESC_NLUOGODON 210
// operazioni possibili
#define F_VISUALIZZA 211
#define F_MODIFICA 212
#define F_ELIMINA 213
#define F_TOTALE 214
// spreadsheet
#define F_SOGGETTI 215
// pagina soggetti
#define F_S_CODICE 101
#define F_S_COGNOME 102
#define F_S_NOME 103
#define F_S_TESSAVIS 104
#define F_S_TIPODON 105
#define F_S_TIPOCON 106
#define F_S_ETICHETTA 107
#define F_S_PRIMADON 108
#define F_S_DATADON 109
#define F_S_DATANASC 110
#define F_S_CODSEZ 111
#define F_S_CODSOT 112
#define F_S_CATDON 113
#define F_S_INTSI 114
#define F_S_DENSEZ 151
#define F_S_DENSOT 152
#define F_S_DESC_TIPOCON 153
//#define F_S_DESC_CATDON 154
#define F_S_IDON1 155
#define F_S_IDON2 156
#define F_S_IDON3 157
#define F_S_IDON4 158
//#define F_S_INTSI 159
#define F_S_INTAF 160
#define F_S_PROSSTIPO 161
#define F_S_PROSSDATA 162
#define F_S_DESC_IDON1 163
#define F_S_DESC_IDON2 164
#define F_S_DESC_IDON3 165
#define F_S_DESC_IDON4 166
#define F_S_DESC_PROSSTIPO 167

View File

@ -1,552 +0,0 @@
#include "at8600a.h"
TOOLBAR "" 0 20 0 2
BUTTON F_VISUALIZZA 10 2
BEGIN
PROMPT -14 -11 "~Visualizza"
MESSAGE EXIT,F_VISUALIZZA
END
BUTTON F_MODIFICA 10 2
BEGIN
PROMPT -24 -11 "~Modifica"
MESSAGE EXIT,F_MODIFICA
END
BUTTON F_ELIMINA 10 2
BEGIN
PROMPT -34 -11 "~Elimina"
MESSAGE EXIT,F_ELIMINA
END
BUTTON DLG_QUIT 10 2
BEGIN
PROMPT -44 -11 "~Fine"
MESSAGE EXIT,K_QUIT
PICTURE BMP_QUIT
PICTURE BMP_QUITDN
END
ENDPAGE
PAGE "Correzione errato giornaliero donazioni" -1 -1 78 20
GROUPBOX DLG_NULL 77 5
BEGIN
PROMPT 1 0 "Dati dell'inserimento errato"
FLAGS "R"
END
DATE F_DATADON
BEGIN
PROMPT 2 1 "Data donazione "
CHECKTYPE REQUIRED
HELP "Data donazione"
END
STRING F_TIPODON 2
BEGIN
PROMPT 2 2 "Tipo donazione "
FLAGS "U"
USE TDN
INPUT CODTAB F_TIPODON
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@30" S0
OUTPUT F_TIPODON CODTAB
OUTPUT F_DESC_TIPODON S0
CHECKTYPE NORMAL
WARNING "Codice non presente"
HELP "Tipo donazione"
END
STRING F_LUOGODON 4
BEGIN
PROMPT 2 3 "Punto prelievo "
FLAGS "U"
USE LDN
INPUT CODTAB F_LUOGODON
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@50" S0
OUTPUT F_LUOGODON CODTAB
OUTPUT F_DESC_LUOGODON S0
CHECKTYPE NORMAL
WARNING "Codice non presente"
HELP "Punto di prelievo"
END
STRING F_DESC_TIPODON 30
BEGIN
PROMPT 26 2 ""
FLAGS "D"
END
STRING F_DESC_LUOGODON 50
BEGIN
PROMPT 26 3 ""
FLAGS "D"
END
NUMBER F_TOTALE 8
BEGIN
PROMPT 50 1 "Totale soggetti "
FLAGS "D"
END
GROUPBOX DLG_NULL 77 5
BEGIN
PROMPT 1 5 "Dati corretti"
FLAGS "R"
END
DATE F_NDATADON
BEGIN
PROMPT 2 6 "Data donazione "
HELP "Data donazione"
//GROUP 1
FLAGS "D"
END
STRING F_NTIPODON 2
BEGIN
PROMPT 2 7 "Tipo donazione "
FLAGS "U"
USE TDN
INPUT CODTAB F_NTIPODON
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@30" S0
OUTPUT F_NTIPODON CODTAB
OUTPUT F_DESC_NTIPODON S0
CHECKTYPE NORMAL
WARNING "Codice non presente"
HELP "Tipo donazione"
//GROUP 1
FLAGS "D"
END
STRING F_NLUOGODON 4
BEGIN
PROMPT 2 8 "Punto prelievo "
FLAGS "U"
USE LDN
INPUT CODTAB F_NLUOGODON
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@50" S0
OUTPUT F_NLUOGODON CODTAB
OUTPUT F_DESC_NLUOGODON S0
CHECKTYPE NORMAL
WARNING "Codice non presente"
HELP "Punto di prelievo"
GROUP 1
END
STRING F_DESC_NTIPODON 30
BEGIN
PROMPT 26 7 ""
FLAGS "D"
GROUP 1
END
STRING F_DESC_NLUOGODON 50
BEGIN
PROMPT 26 8 ""
FLAGS "D"
GROUP 1
END
SPREADSHEET F_SOGGETTI
BEGIN
PROMPT 2 10 "Soggetti"
ITEM "Codice@8"
ITEM "Cognome@25"
ITEM "Nome@25"
ITEM "Tessera"
ITEM "Don."
ITEM "Con."
ITEM "Et. sacca"
ITEM "1ø"
ITEM "Data don."
ITEM "Nato il@10"
ITEM "Sez."
ITEM "Sot."
ITEM "Cat."
ITEM "Int.SI"
END
ENDPAGE
ENDMASK
PAGE "Soggetto " -1 -1 78 20
GROUPBOX DLG_NULL 77 6
BEGIN
PROMPT 1 0 "Soggetto donatore"
FLAGS "R"
END
NUMBER F_S_CODICE 8
BEGIN
PROMPT 2 1 "Codice "
FLAGS "RG"
USE LF_SOGGETTI KEY 1
INPUT CODICE F_S_CODICE
DISPLAY "Codice@8" CODICE
DISPLAY "Cognome@25" COGNOME
DISPLAY "Nome@25" NOME
DISPLAY "Nato il@10" DATANASC
DISPLAY "Sez." CODSEZ
DISPLAY "Sot." CODSOT
DISPLAY "C." CATDON
DISPLAY "Tessera" TESSAVIS
DISPLAY "Gr.AB0" GRUPPOAB0
DISPLAY "Rh " RHANTID
DISPLAY "Int.SI" INTSI
OUTPUT F_S_CODICE CODICE
OUTPUT F_S_COGNOME COGNOME
OUTPUT F_S_NOME NOME
OUTPUT F_S_DATANASC DATANASC
OUTPUT F_S_CODSEZ CODSEZ
OUTPUT F_S_CODSOT CODSOT
OUTPUT F_S_CATDON CATDON
OUTPUT F_S_TESSAVIS TESSAVIS
OUTPUT F_S_INTSI INTSI
// CHECKTYPE NORMAL
ADD RUN at0 -0
END
STRING F_S_COGNOME 25
BEGIN
PROMPT 2 2 "Cognome e nome "
USE LF_SOGGETTI KEY 2
INPUT COGNOME F_S_COGNOME
INPUT NOME F_S_NOME
INPUT DATANASC F_S_DATANASC
DISPLAY "Cognome@25" COGNOME
DISPLAY "Nome@25" NOME
DISPLAY "Nato il@10" DATANASC
DISPLAY "Codice@8" CODICE
DISPLAY "Sez." CODSEZ
DISPLAY "Sot." CODSOT
DISPLAY "C." CATDON
DISPLAY "Tessera" TESSAVIS
DISPLAY "Gr.AB0" GRUPPOAB0
DISPLAY "Rh " RHANTID
DISPLAY "Int.SI" INTSI
OUTPUT F_S_CODICE CODICE
OUTPUT F_S_COGNOME COGNOME
OUTPUT F_S_NOME NOME
OUTPUT F_S_DATANASC DATANASC
OUTPUT F_S_CODSEZ CODSEZ
OUTPUT F_S_CODSOT CODSOT
OUTPUT F_S_CATDON CATDON
OUTPUT F_S_TESSAVIS TESSAVIS
OUTPUT F_S_INTSI INTSI
HELP "Cognome del soggetto"
// CHECKTYPE NORMAL
ADD RUN at0 -0
END
STRING F_S_NOME 25
BEGIN
PROMPT 46 2 ""
COPY ALL F_S_COGNOME
HELP "Nome del soggetto"
// CHECKTYPE NORMAL
ADD RUN at0 -0
END
STRING F_S_TESSAVIS 6
BEGIN
PROMPT 33 3 "Tessera AVIS "
USE LF_SOGGETTI KEY 4
INPUT TESSAVIS F_S_TESSAVIS
DISPLAY "Tessera" TESSAVIS
DISPLAY "Cognome@25" COGNOME
DISPLAY "Nome@25" NOME
DISPLAY "Nato il@10" DATANASC
DISPLAY "Codice@8" CODICE
DISPLAY "Sez." CODSEZ
DISPLAY "Sot." CODSOT
DISPLAY "C." CATDON
DISPLAY "Gr.AB0" GRUPPOAB0
DISPLAY "Rh " RHANTID
DISPLAY "Int.SI" INTSI
OUTPUT F_S_CODICE CODICE
OUTPUT F_S_COGNOME COGNOME
OUTPUT F_S_NOME NOME
OUTPUT F_S_DATANASC DATANASC
OUTPUT F_S_CODSEZ CODSEZ
OUTPUT F_S_CODSOT CODSOT
OUTPUT F_S_CATDON CATDON
OUTPUT F_S_TESSAVIS TESSAVIS
OUTPUT F_S_INTSI INTSI
HELP "Cognome del soggetto"
// CHECKTYPE NORMAL
ADD RUN at0 -0
END
STRING F_S_TIPODON 2
BEGIN
PROMPT 2 16 "Tipo donazione "
FLAGS "U"
USE TDN
INPUT CODTAB F_S_TIPODON
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@30" S0
OUTPUT F_S_TIPODON CODTAB
//OUTPUT F_S_DESC_TIPODON S0
CHECKTYPE NORMAL
WARNING "Codice non presente"
HELP "Tipo donazione (se diverso da dati fissi)"
END
GROUPBOX DLG_NULL 77 9
BEGIN
PROMPT 1 6 "Dati del controllo sanitario effettuato"
END
STRING F_S_TIPOCON 2
BEGIN
PROMPT 2 7 "Tipo controllo "
FLAGS "U"
USE TCS SELECT S6=="N"
INPUT CODTAB F_S_TIPOCON
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@30" S0
OUTPUT F_S_TIPOCON CODTAB
OUTPUT F_S_DESC_TIPOCON S0
WARNING "Codice non presente"
HELP "Tipo/Esito controllo sanitario"
END
GROUPBOX DLG_NULL 77 3
BEGIN
PROMPT 1 15 "Dati complementari della donazione"
END
NUMBER F_S_ETICHETTA 9
BEGIN
PROMPT 30 16 "Etichetta sacca "
END
BOOLEAN F_S_PRIMADON
BEGIN
PROMPT 60 16 "Prima donazione"
END
DATE F_S_DATADON
BEGIN
PROMPT 2 16 "Data don. "
END
DATE F_S_DATANASC
BEGIN
PROMPT 2 3 "Nato il "
FLAGS "D"
END
STRING F_S_CODSEZ 2
BEGIN
PROMPT 2 4 "Sez./Sottog. "
FLAGS "D"
END
STRING F_S_DENSEZ 25 23
BEGIN
PROMPT 20 4 ""
FLAGS "D"
END
STRING F_S_CODSOT 2
BEGIN
PROMPT 46 4 ""
FLAGS "D"
USE LF_SEZIONI
INPUT CODSEZ F_S_CODSEZ
INPUT CODSOT F_S_CODSOT
OUTPUT F_S_DENSEZ DENSEZ
OUTPUT F_S_DENSOT DENSOT
CHECKTYPE NORMAL
END
STRING F_S_DENSOT 25 23
BEGIN
PROMPT 49 4 ""
FLAGS "D"
END
STRING F_S_CATDON 2
BEGIN
PROMPT 60 3 "Categoria "
FLAGS "D"
// USE CTD
// INPUT CODTAB F_S_CATDON
// OUTPUT F_S_DESC_CATDON S0
// CHECKTYPE NORMAL
END
NUMBER F_S_INTSI 3 0
BEGIN
PROMPT 40 12 "Sangue intero "
END
STRING F_S_DESC_TIPOCON 25
BEGIN
PROMPT 23 7 ""
FLAGS "D"
END
//STRING F_S_DESC_CATDON 25 15
//BEGIN
// PROMPT 61 3 ""
// FLAGS "D"
//END
TEXT DLG_NULL
BEGIN
PROMPT 2 8 "Se idoneita': tipi donazione ammessi"
END
STRING F_S_IDON1 2
BEGIN
PROMPT 40 8 ""
FLAGS "U"
USE IDO
INPUT CODTAB F_S_IDON1
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@40" S0
OUTPUT F_S_IDON1 CODTAB
OUTPUT F_S_DESC_IDON1 S0
CHECKTYPE NORMAL
WARNING "Codice non presente"
HELP "Idoneita' alla donazione"
END
STRING F_S_IDON2 2
BEGIN
PROMPT 40 9 ""
FLAGS "U"
USE IDO
INPUT CODTAB F_S_IDON2
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@40" S0
OUTPUT F_S_IDON2 CODTAB
OUTPUT F_S_DESC_IDON2 S0
CHECKTYPE NORMAL
WARNING "Codice non presente"
HELP "Idoneita' alla donazione"
END
STRING F_S_IDON3 2
BEGIN
PROMPT 40 10 ""
FLAGS "U"
USE IDO
INPUT CODTAB F_S_IDON3
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@40" S0
OUTPUT F_S_IDON3 CODTAB
OUTPUT F_S_DESC_IDON3 S0
CHECKTYPE NORMAL
WARNING "Codice non presente"
HELP "Idoneita' alla donazione"
END
STRING F_S_IDON4 2
BEGIN
PROMPT 40 11 ""
FLAGS "U"
USE IDO
INPUT CODTAB F_S_IDON4
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@40" S0
OUTPUT F_S_IDON4 CODTAB
OUTPUT F_S_DESC_IDON4 S0
CHECKTYPE NORMAL
WARNING "Codice non presente"
HELP "Idoneita' alla donazione"
END
TEXT DLG_NULL
BEGIN
PROMPT 2 12 " intervalli"
END
//NUMBER F_S_INTSI 3 0
//BEGIN
// PROMPT 29 12 "Sangue intero "
// FLAGS "U"
//END
NUMBER F_S_INTAF 3 0
BEGIN
PROMPT 59 12 "Aferesi "
FLAGS "U"
END
STRING F_S_PROSSTIPO 2
BEGIN
PROMPT 2 13 "Prossimo tipo "
FLAGS "U"
USE TCS
INPUT CODTAB F_S_PROSSTIPO
DISPLAY "Codice" CODTAB
DISPLAY "Descrizione@40" S0
OUTPUT F_S_PROSSTIPO CODTAB
OUTPUT F_S_DESC_PROSSTIPO S0
CHECKTYPE NORMAL
WARNING "Codice non presente"
HELP "Tipo/Esito controllo sanitario"
END
DATE F_S_PROSSDATA
BEGIN
PROMPT 55 13 "Data "
FLAGS "D"
HELP "Data controllo"
END
STRING F_S_DESC_IDON1 25
BEGIN
PROMPT 45 8 ""
FLAGS "D"
END
STRING F_S_DESC_IDON2 25
BEGIN
PROMPT 45 9 ""
FLAGS "D"
END
STRING F_S_DESC_IDON3 25
BEGIN
PROMPT 45 10 ""
FLAGS "D"
END
STRING F_S_DESC_IDON4 25
BEGIN
PROMPT 45 11 ""
FLAGS "D"
END
STRING F_S_DESC_PROSSTIPO 25
BEGIN
PROMPT 23 13 ""
END
BUTTON DLG_OK 9 2
BEGIN
PROMPT -13 -1 ""
END
BUTTON DLG_CANCEL 9 2
BEGIN
PROMPT -23 -1 ""
END
ENDPAGE
ENDMASK

506
at/at8900.cpp Executable file
View File

@ -0,0 +1,506 @@
#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 "at8900a.h"
#include "atlib.h"
#include "contsan.h"
#include "donaz.h"
#include "idoneita.h"
#include "soggetti.h"
#include "convoc.h"
#include "rconvoc.h"
#include "storico.h"
#define ATFILENAME "aggiorna.txt"
////////////////////////////////////////////////////////
// Classe TCtpr2at_file customizzata dalla TFile_text //
////////////////////////////////////////////////////////
class TCtpr2at_file: public TFile_text
{
protected:
virtual void preformat_field(const TFieldref&field,TString &str,TRelation& rel,const TString &tipo_tr);
public:
virtual int autosave(TRelation& rel, const TRecord_text& rec);
TCtpr2at_file(const TString& file_name, const TString& config_name);
virtual ~TCtpr2at_file() { }
};
TCtpr2at_file::TCtpr2at_file(const TString& file_name, const TString& config_name)
: TFile_text(file_name, config_name)
{
}
int TCtpr2at_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();
if (valore[0] == '@') //se trovo il carattere @ -> azzero il campo
valore.cut(0);
switch(tipo_campo) //in base al tipo di campo formatta i valori seguendo le specifiche del tracciato
{
case _datefld: //tipo data...
{
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;
case _realfld: //tipi numerici
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;
}
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;
}
/////////////////////////////////////////////////////
// Classe TCtpr2at: applicazione principale //
/////////////////////////////////////////////////////
class TCtpr2at: public TSkeleton_application
{
TMask* _msk;
TCtpr2at_file* _trasfile;
int _numdon1, _numdon2;
TString16 _catini1, _catfin1, _catini2, _catfin2;
bool _sttess2, _dataisc;
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);
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);
void calcola_categoria(TRectype& recsog);
bool print_header();
void print_line(const TString& rigastampa);
void print_footer();
void new_sogg(TRectype& sogg, const TRecord_text& curr);
public:
const TMask& msk() const { return *_msk; }
TCtpr2at() {}
virtual ~TCtpr2at() {}
};
// restituisce un riferimento all' applicazione
inline TCtpr2at& app() { return (TCtpr2at&) main_app();}
// creazione dell'applicazione
bool TCtpr2at::create()
{
open_files(LF_SOGGETTI, LF_DONAZ, LF_CONTSAN, LF_IDONEITA, LF_CONVOC, LF_RCONVOC, LF_STORICO, 0);
_msk = new TMask("at8900a");
_msk->set(F_FILENAME,ATFILENAME);
_trasfile = NULL;
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");
return TSkeleton_application::create();
}
// distruzione dell'applicazione
bool TCtpr2at::destroy()
{
delete _msk;
return TSkeleton_application::destroy();
}
// carica la maschera
void TCtpr2at::main_loop()
{
KEY key = K_ENTER;
while (key != K_QUIT)
{
key = _msk->run();
if (key == K_ENTER)
transfer();
}
}
bool TCtpr2at::test_donation(TRectype& recsog, const char* tipo, const TDate& datadon, const TString& luogodon)
{
//ricostruisce le donazioni del soggetto in esame
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)
{
const TRectype& lastdon = donazioni[r];
if (lastdon.get_date(DON_DATADON) >= datadon)
return FALSE;
}
//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));
rec->put(DON_PROGDON,r+1);
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);
if (r == 0) //puó essere una prima donazione...
rec->put(DON_PRIMADON,"X");
donazioni.insert_row(rec);
donazioni.write(TRUE);
calcola_donazioni_lib(recsog, &donazioni); // questo metodo sistema tutto!!!
calcola_categoria(recsog);
// aggiorno data e utente ultimo aggiornamento
const TDate oggi(TODAY);
recsog.put(SOG_DATAULTAGG,oggi);
recsog.put(SOG_UTENULTAGG,"SIT");
return TRUE;
}
void TCtpr2at::calcola_categoria(TRectype& recsog)
{
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;
}
}
}
bool TCtpr2at::test_inter(TRectype& recsog, const char* tipo, const TDate& datadon, int inter)
{
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);
TString16 stato = recsog.get(SOG_STATO);
if (modstato_tcs(stato) != 'S' && stato.not_empty())
return FALSE;
if (tipo == "SI")
stato = recsog.get(SOG_STATOSI);
else
stato = recsog.get(SOG_STATOAF);
if (modstato_tcs(stato) != 'S' && stato.not_empty())
return FALSE;
const int r = idoneita.last_row(); //se trova una data idoneita >= di quella in esame, quest'ultima viene ignorata
if (r > 0)
{
const TRectype& lastido = idoneita[r];
if (lastido.get_date(IDO_DATAIDO) >= datadon)
return FALSE;
}
TRectype* rec = new TRectype(LF_IDONEITA);
rec->put(IDO_CODICE, recsog.get(SOG_CODICE));
rec->put(IDO_PROGIDO, r+1);
rec->put(IDO_DATAIDO, datadon);
rec->put(IDO_TIPOIDO, stricmp(tipo, "SI") != 0 ? "AF" : "SI"); // Il mondo è bello perchè c'é l'AVIS (tutte le donaz. non SI sono AF! mah?!)
rec->put(IDO_IDO_SOS, "ID");
rec->put(IDO_INTERVALLO, inter);
// aggiunto da cristina il 18/09/2002 altrimenti non so che quella riga é stata aggiunta da CT
rec->put(IDO_RESPONSAB, "TRASF. DA SIT");
idoneita.add_row(rec);
idoneita.write();
con_reord(recsog, &controlli, &idoneita);
// aggiorno data e utente ultimo aggiornamento (Cristina 18/09/2002)
const TDate oggi(TODAY);
recsog.put(SOG_DATAULTAGG,oggi);
recsog.put(SOG_UTENULTAGG,"SIT");
return TRUE;
}
bool TCtpr2at::print_header()
{
if (printer().open())
{
TDate oggi(TODAY);
TPrintrow row;
TString256 rigastampa;
rigastampa = "TRASFERIMENTO DATI DA CETRAPLUS";
rigastampa.center_just(132);
row.put(rigastampa);
row.put("@>", 1);
row.put("Pag. @#", 115);
printer().setheaderline(2, row);
rigastampa = "";
rigastampa.fill('-',132);
row.reset();
row.put(rigastampa);
printer().setheaderline(3, row);
return TRUE;
}
else
return error_box("Errore in apertura stampante.");
}
void TCtpr2at::print_line(const TString& rigastampa)
{
TPrintrow row;
row.put((const char*) rigastampa);
printer().print(row);
}
void TCtpr2at::print_footer()
{
printer().formfeed();
printer().close();
}
void TCtpr2at::new_sogg(TRectype& sogg, const TRecord_text& curr)
{
TLocalisamfile soggetti(LF_SOGGETTI);
soggetti.last();
long codice = soggetti.get_long(SOG_CODICE);
sogg.put(SOG_CODICE, codice+1);
sogg.put(SOG_CATDON, "NU");
}
// trasferimento dati da file CT su programma avis
void TCtpr2at::transfer()
{
if (print_header())
{
TFilename ctprini = "ctpr2at.ini";
_trasfile = new TCtpr2at_file(_msk->get(F_FILENAME), ctprini);
inizializza_file();
const long dimension = fsize(_msk->get(F_FILENAME));
TProgind pi(dimension,"Acquisizione in corso...");
TRelation rel(LF_SOGGETTI);
rel.lfile().setkey(2);
TRectype& sogg = rel.curr();
TString256 rigastampa;
TString80 cognome, nome, datanasc, str;
TString8 tipodon_at, luogodon_at;
char tipoacc, tipodon;
TDate dataacc;
bool update;
TRecord_text curr;
bool cancelled = FALSE;
while ((_trasfile->read(curr) == NOERR) && (!cancelled))
{
pi.setstatus(_trasfile->read_file()->tellg());
// cerco il donatore con cognome, nome e data nascita
cognome = curr.get(1);
str = cognome.left(7);
if (str != "COGNOME")
{
sogg.put(SOG_COGNOME, cognome);
nome = curr.get(2);
sogg.put(SOG_NOME, nome);
datanasc = curr.get(4);
sogg.put(SOG_DATANASC, datanasc);
if (rel.read(_isequal) != NOERR)
{
// segnalo l'errore
rigastampa.format("Inserito soggetto %s %s %s", (const char*) cognome, (const char*) nome, (const char*) datanasc);
print_line(rigastampa);
// nuovo donatore
sogg.zero();
sogg.put(SOG_COGNOME, cognome);
sogg.put(SOG_NOME, nome);
sogg.put(SOG_DATANASC, datanasc);
new_sogg(sogg, curr);
}
//esegue l'effettivo passaggio dati basandosi sulla formattazione del file .ini
_trasfile->autosave(rel, curr);
update = FALSE;
tipoacc = curr.get(25)[0];
str = curr.get(24);
dataacc = TDate(str);
// se l'accesso è una donazione
if (tipoacc == 'D')
{
tipodon = curr.get(27)[0];
switch (tipodon)
{
case '1':
tipodon_at = "SI"; break;
case '2':
tipodon_at = "PL"; break;
case '3':
tipodon_at = "PT"; break;
default:
tipodon_at = ""; break;
}
str = curr.get(26);
if (str.left(2) == "52")
luogodon_at = "0001";
else
{
if (sogg.get(SOG_CODSEZ) == "13")
luogodon_at = "1301";
else
luogodon_at = "0000";
}
if (tipodon_at.not_empty())
update |= test_donation(sogg, tipodon_at, dataacc, luogodon_at);
if (update)
{
rel.rewrite();
rigastampa.format("Inserita donazione del %s a %s %s %s", (const char*) dataacc.string(), (const char*) cognome, (const char*) nome, (const char*) datanasc);
print_line(rigastampa);
}
}
// aggiungere le visite e i controlli
}
cancelled = pi.iscancelled();
}
_trasfile->close();
print_footer();
if (cancelled)
message_box("Operazione annullata: il trasferimento non è stato completato");
else
message_box("Operazione terminata");
}
else
error_box("Errore in apertura stampante.");
}
//inizializza il file di testo su cui emettere i dati
void TCtpr2at::inizializza_file()
{
TFilename filect = _msk->get(F_FILENAME); //aggiungere lettura automatica nomi file
_trasfile->open(filect,'r');
}
// handler per gestire la conferma dell'annullamento dei dati inseriti
// nella maschera
bool TCtpr2at::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;
}
void TCtpr2at_file::preformat_field(const TFieldref&field,TString &str,TRelation& rel,const TString &tipo_tr)
{
TString tmp;
TString80 fieldname = field.name();
if (fieldname == "SESSO")
{
const char sesso = str[0];
if (sesso == 'M')
str = "1";
else if (sesso == 'F')
str = "2";
else str = " ";
}
else if ((fieldname == "CODCF") || (fieldname == "TESSSSN"))
{
tmp = rel.curr(field.file()).get(fieldname);
if (tmp.not_empty())
str.cut(0);
}
}
int at8900(int argc, char* argv[])
{
TCtpr2at a;
a.run(argc, argv, "Acquisizione dati da SIT Parma");
return 0;
}

4
at/at8900a.h Executable file
View File

@ -0,0 +1,4 @@
// acquisizione dati da CT Parma
// definizione campi per maschera di selezione
#define F_FILENAME 102 // nome del file da cui scaricare i dati

35
at/at8900a.uml Executable file
View File

@ -0,0 +1,35 @@
#include "at8900a.h"
TOOLBAR "" 0 20 0 2
BUTTON DLG_OK 9 2
BEGIN
PROMPT -12 -11 ""
END
BUTTON DLG_QUIT 9 2
BEGIN
PROMPT -22 -11 ""
END
ENDPAGE
PAGE "Acquisizione dati da SIT Parma" -1 -1 78 20
GROUPBOX DLG_NULL 77 9
BEGIN
PROMPT 1 1 "Selezioni per il trasferimento"
END
STRING F_FILENAME 52
BEGIN
PROMPT 2 2 "Nome file "
CHECKTYPE REQUIRED
VALIDATE FILENAME_FUNC
FLAGS "A"
HELP "Nome del file da cui caricare i dati"
WARNING "E' necessario specificare un nome di file"
END
ENDPAGE
ENDMASK