Files correlati : Ricompilazione Demo : [ ] Commento :altri errori di compilazione non esistenti nella 16 bit git-svn-id: svn://10.65.10.50/trunk@11548 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			1600 lines
		
	
	
		
			45 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			1600 lines
		
	
	
		
			45 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <applicat.h>
 | 
						||
#include <filetext.h>
 | 
						||
#include <form.h>
 | 
						||
#include <mask.h>
 | 
						||
#include <relation.h>
 | 
						||
#include <tabutil.h>
 | 
						||
#include <printer.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"
 | 
						||
#include "comuni.h"
 | 
						||
#include "medici.h"
 | 
						||
 | 
						||
////////////////////////////////////////////////////////
 | 
						||
// Classe TCtpr2at_file customizzata dalla TFile_text //
 | 
						||
////////////////////////////////////////////////////////
 | 
						||
 | 
						||
/////////////////////////////////////////////////////
 | 
						||
// Classe TCtpr2at: applicazione principale        //
 | 
						||
/////////////////////////////////////////////////////
 | 
						||
 | 
						||
class TCtpr2at: public TSkeleton_application
 | 
						||
{
 | 
						||
  TMask*          _msk;
 | 
						||
	TRelation*   		_rel;
 | 
						||
	TRelation*			_relcom;
 | 
						||
  TLocalisamfile* _soggetti;
 | 
						||
	TLocalisamfile* _donaz;
 | 
						||
	TLocalisamfile* _contsan;
 | 
						||
	TLocalisamfile* _idoneita;
 | 
						||
	TRecord_array*	_sdonazioni; 
 | 
						||
	TRecord_array*	_scontrolli;
 | 
						||
	TRecord_array*	_sidoneita;
 | 
						||
	TAssoc_array*		_array_comuni;
 | 
						||
	TAssoc_array*		_array_donaz;
 | 
						||
  
 | 
						||
  int             _numdon1, _numdon2;
 | 
						||
  TString4        _catini1, _catfin1, _catini2, _catfin2;
 | 
						||
  bool            _sttess2, _dataisc;
 | 
						||
	TConfig* 				_configfile;
 | 
						||
	
 | 
						||
	TDate						_dataagg;
 | 
						||
	long						_progins;	                         
 | 
						||
	bool						_message;
 | 
						||
	TString80				_intestazione;
 | 
						||
  
 | 
						||
protected:
 | 
						||
  virtual bool create(void);
 | 
						||
  virtual void main_loop();
 | 
						||
  virtual bool destroy(void) ;
 | 
						||
  void transfer();
 | 
						||
	void transfer_file(const bool prima = TRUE);
 | 
						||
  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();
 | 
						||
	bool build_record(TAssoc_array& record, const TString& istruzione);  
 | 
						||
	bool update_record(TRectype& recsog, TAssoc_array& record);
 | 
						||
  bool soggetto(const TString& istruzione);
 | 
						||
  bool accesso(const TString& istruzione);
 | 
						||
  bool sacca(const TString& istruzione);
 | 
						||
  bool analisi(const TString& istruzione);
 | 
						||
  bool intervalli(const TString& istruzione);
 | 
						||
  bool esclusione(const TString& istruzione);
 | 
						||
  long get_next_key();
 | 
						||
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");
 | 
						||
	_rel = new TRelation(LF_SOGGETTI);
 | 
						||
	_relcom = new TRelation(LF_COMUNI);
 | 
						||
	_donaz = new TLocalisamfile(LF_DONAZ);
 | 
						||
	_contsan = new TLocalisamfile(LF_CONTSAN);
 | 
						||
	_idoneita = new TLocalisamfile(LF_IDONEITA);
 | 
						||
	_sdonazioni = new TRecord_array(LF_DONAZ,DON_PROGDON);
 | 
						||
	_scontrolli = new TRecord_array(LF_CONTSAN,CON_PROGCON);
 | 
						||
	_sidoneita = new TRecord_array(LF_IDONEITA,IDO_PROGIDO);
 | 
						||
	_array_comuni = new TAssoc_array();
 | 
						||
	_array_donaz = new TAssoc_array();
 | 
						||
  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");
 | 
						||
	_configfile = new TConfig("at8900a.ini");
 | 
						||
  _donaz->setkey(3);
 | 
						||
	_donaz->last();
 | 
						||
	_progins = _donaz->get_long(DON_PROGINS);
 | 
						||
	_donaz->setkey(1);
 | 
						||
	
 | 
						||
  return TSkeleton_application::create();
 | 
						||
}
 | 
						||
 | 
						||
// distruzione dell'applicazione
 | 
						||
bool TCtpr2at::destroy()
 | 
						||
{                      
 | 
						||
	delete _array_donaz;
 | 
						||
	delete _array_comuni;
 | 
						||
	delete _sidoneita;
 | 
						||
	delete _scontrolli;
 | 
						||
	delete _sdonazioni;
 | 
						||
	delete _idoneita;
 | 
						||
	delete _contsan;
 | 
						||
	delete _donaz;	
 | 
						||
	delete _rel;
 | 
						||
  delete _msk;
 | 
						||
  delete _configfile;
 | 
						||
  return TSkeleton_application::destroy();
 | 
						||
}
 | 
						||
 | 
						||
// carica la maschera 
 | 
						||
void TCtpr2at::main_loop()
 | 
						||
{                       
 | 
						||
	_intestazione = "";
 | 
						||
	_message = FALSE;
 | 
						||
  _msk->set(F_FILENAME,_configfile->get("PERCORSO", "ARCHIVIO"));
 | 
						||
  KEY key = _msk->run();
 | 
						||
  if (key == K_ENTER)
 | 
						||
  {
 | 
						||
    transfer();
 | 
						||
  	_configfile->set("PERCORSO", _msk->get(F_FILENAME), "ARCHIVIO");
 | 
						||
  }	
 | 
						||
}
 | 
						||
 | 
						||
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<70> 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)
 | 
						||
{ 
 | 
						||
 	TString256 stampa;
 | 
						||
  TTable ctd("CTD"); 
 | 
						||
  TString4 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())
 | 
						||
      { 
 | 
						||
      	stampa = "Il soggetto <20> dimesso, non effettuato cambio di categoria ";
 | 
						||
      	stampa << cat_coll;
 | 
						||
      	print_line(stampa);
 | 
						||
      }
 | 
						||
    } 
 | 
						||
    else            
 | 
						||
    {
 | 
						||
	    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);
 | 
						||
  
 | 
						||
  TString4 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 <20> bello perch<63> c'<27> 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 <20> 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.reset();
 | 
						||
	if (rigastampa.not_empty())
 | 
						||
		if (_intestazione.not_empty())
 | 
						||
		{                    
 | 
						||
			printer().print(row);
 | 
						||
			row.reset();
 | 
						||
			row.put((const char*) _intestazione);
 | 
						||
			printer().print(row);			         
 | 
						||
			_intestazione = "";
 | 
						||
			row.reset();
 | 
						||
		}
 | 
						||
	row.put((const char*) rigastampa);
 | 
						||
	printer().print(row);			
 | 
						||
}
 | 
						||
 | 
						||
void TCtpr2at::print_footer()
 | 
						||
{                     
 | 
						||
	printer().formfeed();
 | 
						||
	printer().close();
 | 
						||
}
 | 
						||
 | 
						||
void TCtpr2at::transfer_file(const bool prima)
 | 
						||
{
 | 
						||
	_dataagg = TODAY;
 | 
						||
  TString256 rigastampa;
 | 
						||
  TScanner      s(_msk->get(F_FILENAME));
 | 
						||
	TString16     key, archivio;
 | 
						||
	TString 			istruzione;
 | 
						||
  while (s.ok())
 | 
						||
  {   
 | 
						||
    const TString& line = s.line();
 | 
						||
    if (line.find("UPDATE") != -1)
 | 
						||
    	istruzione = line;
 | 
						||
    else
 | 
						||
    {
 | 
						||
    	if (line.find("INSERT") == -1)
 | 
						||
    		istruzione << line;
 | 
						||
			if (istruzione.not_empty())
 | 
						||
			{                 
 | 
						||
		    TToken_string* record = new TToken_string(istruzione);
 | 
						||
	    	archivio  = record->get(0);
 | 
						||
	    	archivio.trim(); archivio.upper();
 | 
						||
				int n = _configfile->get_int(archivio, "ARCHIVIO");
 | 
						||
  			_configfile->set_paragraph(archivio);
 | 
						||
  			if (prima)
 | 
						||
  			{
 | 
						||
					switch (n)
 | 
						||
					{
 | 
						||
						case 1: 
 | 
						||
							soggetto(record->get(1));
 | 
						||
						break;
 | 
						||
						case 2: 
 | 
						||
							sacca(record->get(1));
 | 
						||
						break;
 | 
						||
						case 4: 
 | 
						||
							intervalli(record->get(1));
 | 
						||
						break;
 | 
						||
						case 5: 
 | 
						||
							esclusione(record->get(1));
 | 
						||
						break;
 | 
						||
						default:
 | 
						||
						break;
 | 
						||
					}
 | 
						||
				}	
 | 
						||
				else	
 | 
						||
				{
 | 
						||
					switch (n)
 | 
						||
					{
 | 
						||
						case 3: 
 | 
						||
							analisi(record->get(1));
 | 
						||
						break;
 | 
						||
						case 6: 
 | 
						||
							accesso(record->get(1));
 | 
						||
						break;	
 | 
						||
						default:
 | 
						||
						break;
 | 
						||
					}				
 | 
						||
				}
 | 
						||
				istruzione = "";
 | 
						||
			}	    		
 | 
						||
    }
 | 
						||
  }  
 | 
						||
  s.close();
 | 
						||
}	
 | 
						||
 | 
						||
 | 
						||
// trasferimento dati da file CT su programma avis
 | 
						||
void TCtpr2at::transfer()
 | 
						||
{                                       
 | 
						||
	if (print_header())
 | 
						||
	{                    
 | 
						||
		transfer_file();
 | 
						||
		transfer_file(FALSE);		
 | 
						||
		print_footer();	  
 | 
						||
	}
 | 
						||
	else
 | 
						||
		error_box("Errore in apertura stampante.");	
 | 
						||
}
 | 
						||
 | 
						||
bool TCtpr2at::build_record(TAssoc_array& record, const TString& istruzione)
 | 
						||
{    
 | 
						||
	bool ok = TRUE;
 | 
						||
	record.destroy();
 | 
						||
	TString lavoro = istruzione;
 | 
						||
	TString80 campo;
 | 
						||
	TString valore;
 | 
						||
	int indice1 = lavoro.find(" SET ");
 | 
						||
	int indice2 = lavoro.find(" WHERE ");
 | 
						||
  if ((indice1 != -1) && (indice2 != -1))
 | 
						||
  {
 | 
						||
		lavoro = lavoro.sub(indice1+5,indice2);
 | 
						||
		lavoro.trim();
 | 
						||
		int i = lavoro.find("''");
 | 
						||
		if (i != -1)
 | 
						||
		{
 | 
						||
			TString aiuto = lavoro.sub(0,i);
 | 
						||
			aiuto << '~';
 | 
						||
			aiuto << lavoro.sub(i+2);
 | 
						||
			lavoro = aiuto;
 | 
						||
		}		
 | 
						||
		while (lavoro.not_empty())
 | 
						||
		{
 | 
						||
			indice1 = lavoro.find('=');
 | 
						||
			if (indice1 != -1)
 | 
						||
			{
 | 
						||
				campo = lavoro.sub(0, indice1-1);
 | 
						||
				campo.trim();
 | 
						||
				lavoro = lavoro.sub(indice1+1);		
 | 
						||
				lavoro.trim();
 | 
						||
				indice1 = lavoro.find(',');
 | 
						||
				if (indice1 != -1)
 | 
						||
				{
 | 
						||
					valore = lavoro.sub(0,indice1);
 | 
						||
					valore.trim();
 | 
						||
					if ((valore[0] == '\'') && (valore[valore.len()-1] == '\''))
 | 
						||
					{
 | 
						||
						// e' una stringa: tolgo le virgolette
 | 
						||
						valore = valore.sub(1,valore.len()-1);
 | 
						||
						lavoro = lavoro.sub(indice1+1);
 | 
						||
					}	
 | 
						||
					else
 | 
						||
					{
 | 
						||
						if ((valore[0] != '\'') && (valore[valore.len()-1] != '\''))
 | 
						||
						// e' un numero oppure null (in questo caso vuoto il valore
 | 
						||
						{
 | 
						||
							if (valore == "null")
 | 
						||
								valore = "";
 | 
						||
							lavoro = lavoro.sub(indice1+1);
 | 
						||
						}
 | 
						||
						else
 | 
						||
						// e' una stringa dove c'<27> una virgola, quindi elaboro diversamente per trovare il vero valore
 | 
						||
						{
 | 
						||
							indice1 = lavoro.find("\',");
 | 
						||
							indice2 = lavoro.find("\' ,");
 | 
						||
							if (indice1 != 1 && indice2 != -1)
 | 
						||
							{
 | 
						||
								if (indice2 > indice1)
 | 
						||
								{
 | 
						||
									valore = lavoro.sub(0,indice1+1);
 | 
						||
									lavoro = lavoro.sub(indice1+2);
 | 
						||
		            }
 | 
						||
	              else
 | 
						||
								{
 | 
						||
                	valore = lavoro.sub(0,indice2+1);
 | 
						||
									lavoro = lavoro.sub(indice2+3);
 | 
						||
								}	
 | 
						||
							}	
 | 
						||
							else
 | 
						||
							{   
 | 
						||
								if (indice1 != 0)
 | 
						||
								{
 | 
						||
									valore = lavoro.sub(0,indice1+1);
 | 
						||
									lavoro = lavoro.sub(indice1+2);
 | 
						||
								}
 | 
						||
								else
 | 
						||
								{
 | 
						||
									if (indice2 != 0)
 | 
						||
									{
 | 
						||
	                	valore = lavoro.sub(0,indice2-1);
 | 
						||
										lavoro = lavoro.sub(indice2+3);
 | 
						||
									}
 | 
						||
									else
 | 
						||
									{
 | 
						||
										// e' l'ultimo campo della lista, quindi non trova la virgola
 | 
						||
										valore = lavoro.trim();
 | 
						||
										lavoro = "";
 | 
						||
									}	
 | 
						||
								}	
 | 
						||
							}
 | 
						||
							valore = valore.sub(1,valore.len()-1);
 | 
						||
						}	
 | 
						||
					}	
 | 
						||
				}
 | 
						||
				else
 | 
						||
				{
 | 
						||
					valore = lavoro.trim();
 | 
						||
					lavoro = "";
 | 
						||
				}	
 | 
						||
			}
 | 
						||
			else
 | 
						||
				lavoro = "";
 | 
						||
			if ((valore[0] == '\'') && (valore[valore.len()-1] == '\''))
 | 
						||
				// e' una stringa: tolgo le virgolette
 | 
						||
				valore = valore.sub(1,valore.len()-1);
 | 
						||
			else if (valore == "null")
 | 
						||
				valore = "";
 | 
						||
			campo.upper();	
 | 
						||
			int doppie = valore.find("'");
 | 
						||
			while (doppie != -1)
 | 
						||
			{
 | 
						||
				if (valore[doppie+1] == '\'')
 | 
						||
				{
 | 
						||
					TString str = valore;
 | 
						||
					valore = str.sub(0,doppie);
 | 
						||
					valore << str.sub(doppie+1);
 | 
						||
				}	
 | 
						||
				doppie = valore.find("'", doppie+1);
 | 
						||
			}
 | 
						||
			i = valore.find('~');
 | 
						||
			if (i != -1)
 | 
						||
				valore.replace('~','\'');
 | 
						||
			record.add(campo, valore);
 | 
						||
		}
 | 
						||
	}	
 | 
						||
	else
 | 
						||
		ok = FALSE;
 | 
						||
	return ok;		
 | 
						||
}
 | 
						||
  
 | 
						||
bool TCtpr2at::soggetto(const TString& istruzione)
 | 
						||
{    
 | 
						||
	int error = NOERR;
 | 
						||
	TAssoc_array record;
 | 
						||
	if (build_record(record, istruzione))
 | 
						||
	{
 | 
						||
		// ricerca del soggetto per cognome, nome e data di nascita
 | 
						||
		TString80& cognome = (TString80&) record["COGNOME"];
 | 
						||
		TString80& nome = (TString80&) record["NOME"];
 | 
						||
		TString16& str = (TString16&) record["DT_NASCITA"]; 
 | 
						||
		TDate datanasc = TDate(atoi(str.sub(8,10)) ,atoi(str.sub(5,7)), atoi(str.sub(0,4)));
 | 
						||
		// codice centro trasfusionale per verifica cognome, nome, data di nascita
 | 
						||
		TString16& codct = (TString16&) record["ID_ANAGRAFICA"];
 | 
						||
		
 | 
						||
		_rel->lfile().setkey(2);
 | 
						||
		TRectype& recsog = _rel->curr();
 | 
						||
		recsog.zero();
 | 
						||
		recsog.put(SOG_COGNOME, cognome);
 | 
						||
		recsog.put(SOG_NOME, nome);			
 | 
						||
		recsog.put(SOG_DATANASC, datanasc);			
 | 
						||
		error = recsog.read(_rel->lfile());
 | 
						||
		TString80 stampa = "";            
 | 
						||
		_intestazione = "";
 | 
						||
		_intestazione << cognome << " " << nome << " " << datanasc;
 | 
						||
		if (error != NOERR)
 | 
						||
		{                           
 | 
						||
			// non ho trovato il donatore, cerco per cognome nome e codicesit
 | 
						||
			recsog.zero();
 | 
						||
			recsog.put(SOG_COGNOME, cognome);
 | 
						||
			recsog.put(SOG_NOME, nome);			
 | 
						||
			error = recsog.read(_rel->lfile());
 | 
						||
			bool trovato = FALSE;
 | 
						||
			while ((!trovato) && (cognome == recsog.get(SOG_COGNOME)) && (nome == recsog.get(SOG_NOME)) && (!_rel->lfile().eof()))
 | 
						||
			{
 | 
						||
				TString16 codicesit = recsog.get(SOG_CODCT);
 | 
						||
				if ((codicesit == codct) && (codicesit.not_empty()) && codct.not_empty())
 | 
						||
				{
 | 
						||
					datanasc = recsog.get_date(SOG_DATANASC);
 | 
						||
					trovato = TRUE;
 | 
						||
				}	
 | 
						||
				else
 | 
						||
					_rel->lfile().next();
 | 
						||
			}
 | 
						||
			if (trovato)
 | 
						||
			{
 | 
						||
				recsog.put(SOG_COGNOME, cognome);
 | 
						||
				recsog.put(SOG_NOME, nome);			
 | 
						||
				recsog.put(SOG_DATANASC, datanasc);			
 | 
						||
				error = recsog.read(_rel->lfile());
 | 
						||
				if (error == NOERR)
 | 
						||
				{
 | 
						||
					stampa = "Verificare la data di nascita: AVIS ";
 | 
						||
					stampa << datanasc;
 | 
						||
					print_line(stampa);
 | 
						||
				}	
 | 
						||
			}
 | 
						||
		}		                 
 | 
						||
		if (error != NOERR)
 | 
						||
		{                           
 | 
						||
			recsog.zero();
 | 
						||
			recsog.put(SOG_COGNOME, cognome);
 | 
						||
			recsog.put(SOG_NOME, nome);			
 | 
						||
			recsog.put(SOG_DATANASC, datanasc);			
 | 
						||
			recsog.put(SOG_NOTIZIARIO, 'X');			
 | 
						||
			recsog.put(SOG_BENEM, 'X');			
 | 
						||
			recsog.put(SOG_CODICE, get_next_key());
 | 
						||
			error = recsog.write(_rel->lfile());
 | 
						||
			stampa = "Inserito da CETRAPLUS";
 | 
						||
			print_line(stampa);
 | 
						||
		} 
 | 
						||
		if (update_record(recsog, record))
 | 
						||
		{
 | 
						||
			TDate oggi(TODAY);
 | 
						||
			recsog.put(SOG_DATAULTAGG, oggi);
 | 
						||
			recsog.put(SOG_UTENULTAGG, "CETRAPLUS");
 | 
						||
			error = recsog.rewrite(_rel->lfile());
 | 
						||
		}	
 | 
						||
		return (error == NOERR);
 | 
						||
	}          
 | 
						||
	else
 | 
						||
		return FALSE;		
 | 
						||
}
 | 
						||
    
 | 
						||
bool TCtpr2at::update_record(TRectype& record_at, TAssoc_array& record_ct)
 | 
						||
{            
 | 
						||
	TString256 stampa = "";
 | 
						||
	TString field, str;
 | 
						||
	bool update = FALSE;
 | 
						||
	FOR_EACH_ASSOC_STRING(record_ct, obj, key, val)
 | 
						||
	{
 | 
						||
		field = _configfile->get(key);
 | 
						||
		if (field.not_empty())           
 | 
						||
		{
 | 
						||
			update = TRUE;
 | 
						||
			if (field.sub(0,2) == "!_")
 | 
						||
			{
 | 
						||
				TString80 elab = field.sub(2);
 | 
						||
				TString16 campo = "";
 | 
						||
				const int virgola = elab.find(',');
 | 
						||
				if (virgola != -1)   
 | 
						||
				{
 | 
						||
					campo = elab.sub(virgola+1);
 | 
						||
					elab = elab.sub(0,virgola);
 | 
						||
				}	
 | 
						||
				if (elab == "STATO") // stato sanitario
 | 
						||
				{                                 
 | 
						||
					TRectype recpr1 = cache().get("PR1", val);
 | 
						||
					TString16 catdon = recpr1.get("S6");
 | 
						||
					TString16 catsog = record_at.get(SOG_CATDON);
 | 
						||
					if ((catdon.not_empty()) && (catdon != catsog))
 | 
						||
					{ 
 | 
						||
						bool dimissione = cache().get("CTD", catdon).get_bool("B0");
 | 
						||
						if (dimissione)
 | 
						||
						{
 | 
						||
							if (catsog == "NU")
 | 
						||
								catdon = "DN";
 | 
						||
							dimissione = cache().get("CTD", catsog).get_bool("B0");
 | 
						||
						}	
 | 
						||
						if (!dimissione)
 | 
						||
						{	
 | 
						||
							if (!(cache().get("CTD", catdon).get_bool("B0")) && (cache().get("CTD", catsog).get_bool("B0")))
 | 
						||
							{                   
 | 
						||
								stampa = "CATEGORIA diversa: avis ";
 | 
						||
								stampa << catsog << " sit " << catdon;
 | 
						||
								print_line(stampa);
 | 
						||
							}
 | 
						||
							else
 | 
						||
							{
 | 
						||
								if ((catdon == "NU") && (catsog == "AV"))
 | 
						||
								{
 | 
						||
									stampa = "CATEGORIA diversa: avis ";
 | 
						||
									stampa << catsog << " sit " << catdon;
 | 
						||
									print_line(stampa);
 | 
						||
								}
 | 
						||
								else
 | 
						||
								{
 | 
						||
									bool cambia = TRUE;
 | 
						||
									if ((catdon == "AV") && (catsog == "NU"))
 | 
						||
									{
 | 
						||
										const int totdon = record_at.get_int(SOG_TOTDON);
 | 
						||
										if (totdon < 1)  
 | 
						||
										{
 | 
						||
											cambia = FALSE;										
 | 
						||
											//stampa = "CATEGORIA diversa: avis ";
 | 
						||
											//stampa << catsog << " sit " << catdon << ", soggetto senza donazioni";
 | 
						||
											//print_line(stampa);
 | 
						||
										}	
 | 
						||
									}
 | 
						||
									if (cambia)
 | 
						||
									{
 | 
						||
										stampa = "Cambio categoria: da ";
 | 
						||
										stampa << catsog << " a " << catdon;
 | 
						||
										print_line(stampa);
 | 
						||
										record_at.put(SOG_CATDON, catdon);
 | 
						||
									 	if (cache().get("CTD", catdon).get_bool("B0"))
 | 
						||
									 	{ 
 | 
						||
									 		TString16 data = record_at.get(SOG_DATADIM);
 | 
						||
									 		if (data.empty())
 | 
						||
									 		{
 | 
						||
									 			record_at.put(SOG_DATADIM, _dataagg);
 | 
						||
									 			stampa = "Inserita data dimissione ";
 | 
						||
									 			stampa << _dataagg.string();
 | 
						||
									 			print_line(stampa);
 | 
						||
									 		}	
 | 
						||
									 	}	
 | 
						||
									 }	
 | 
						||
									//aggiorna_storico();
 | 
						||
								}	
 | 
						||
							}
 | 
						||
						}	
 | 
						||
					}
 | 
						||
					TString16 tipocontrollo = recpr1.get("S7");
 | 
						||
					if (tipocontrollo.not_empty())
 | 
						||
					{
 | 
						||
						//aggiorna_controlli();
 | 
						||
					}	
 | 
						||
				}
 | 
						||
				else if (elab == "SESSO") // sesso
 | 
						||
				{
 | 
						||
					if (val[0] == 'M')
 | 
						||
						record_at.put(SOG_SESSO, "1"); // maschio
 | 
						||
					else if (val[0] == 'F')
 | 
						||
						record_at.put(SOG_SESSO, "2"); // femmina
 | 
						||
					else record_at.put(SOG_SESSO, "0"); // non specificato
 | 
						||
				}	
 | 
						||
				else if (elab == "SEZIONE") // sezione/sottogruppo
 | 
						||
				{                                
 | 
						||
					str = val;
 | 
						||
					if (str[0] == '0')
 | 
						||
						str = str.sub(1);
 | 
						||
					if ((record_at.get(SOG_CODSEZ) != str.sub(0,2)) || (record_at.get(SOG_CODSOT) != str.sub(2,4)))
 | 
						||
					{
 | 
						||
						stampa << "SEZIONE diversa: avis " << record_at.get(SOG_CODSEZ);
 | 
						||
						stampa << record_at.get(SOG_CODSOT) << " sit " << str;
 | 
						||
						print_line(stampa);
 | 
						||
						if (record_at.get(SOG_CODSEZ).empty())
 | 
						||
						{
 | 
						||
							record_at.put(SOG_CODSEZ, str.sub(0,2));
 | 
						||
							record_at.put(SOG_CODSOT, str.sub(2,4));
 | 
						||
						}	
 | 
						||
					}	
 | 
						||
				}	
 | 
						||
				else if (elab == "GIORNOPREF") // giorno preferito donazione
 | 
						||
				{
 | 
						||
					str = val;
 | 
						||
					if (!str.empty())
 | 
						||
					{
 | 
						||
						str << "XXXXXXX";
 | 
						||
						str = str.sub(0,7);
 | 
						||
						for (int i = 0; i< 7; i++)
 | 
						||
						{
 | 
						||
							if (str[i] != 'X')
 | 
						||
								str[i] = 'X';
 | 
						||
							else
 | 
						||
								str[i] = ' ';	
 | 
						||
						}
 | 
						||
						record_at.put(SOG_GIOPREDON, str);
 | 
						||
					}	
 | 
						||
				}
 | 
						||
				else if (elab == "DATA") // data
 | 
						||
				{ 
 | 
						||
					str = val;                            
 | 
						||
					TDate data = TDate(atoi(str.sub(8,10)), atoi(str.sub(5,7)), atoi(str.sub(0,4)));
 | 
						||
					if (campo.not_empty())
 | 
						||
						record_at.put(campo, data);
 | 
						||
				}
 | 
						||
				else if (elab == "COMUNE") // comune nascita o domicilio
 | 
						||
				{   
 | 
						||
					update = FALSE;                                
 | 
						||
					TString16 codcom = "";
 | 
						||
					str = val;
 | 
						||
					if (str.not_empty())
 | 
						||
					{ 
 | 
						||
						if (_array_comuni->is_key(str))
 | 
						||
						{
 | 
						||
							codcom = (TString16&) _array_comuni->find(str);
 | 
						||
							update = (codcom != record_at.get(campo));
 | 
						||
						}								
 | 
						||
						else
 | 
						||
						{	
 | 
						||
							codcom = record_at.get(campo);
 | 
						||
							if (codcom.not_empty())
 | 
						||
							{
 | 
						||
								codcom = "   |";
 | 
						||
								codcom << record_at.get(campo);
 | 
						||
								TRectype reccom = cache().get(LF_COMUNI, codcom);
 | 
						||
								if (reccom.get_long(COM_CODISTAT) != atol(str))
 | 
						||
									update = TRUE;
 | 
						||
								else
 | 
						||
									_array_comuni->add(str, reccom.get(COM_COM))	;
 | 
						||
							} 
 | 
						||
							else
 | 
						||
								update = TRUE;
 | 
						||
							if (update)
 | 
						||
							{	                     
 | 
						||
								TString80 filtro = "";
 | 
						||
								filtro.format("%s == %ld", COM_CODISTAT, atol(str));
 | 
						||
								TCursor cur(_relcom, filtro);
 | 
						||
								if (cur.items() == 1)
 | 
						||
								{
 | 
						||
									cur.next_match(LF_COMUNI);
 | 
						||
									codcom = cur.curr().get(COM_COM);
 | 
						||
									_array_comuni->add(str, codcom);
 | 
						||
								}	
 | 
						||
								else
 | 
						||
									update = FALSE;	
 | 
						||
							}	
 | 
						||
						}	
 | 
						||
					}
 | 
						||
					if (campo.not_empty() && update)
 | 
						||
						record_at.put(campo, codcom);
 | 
						||
				}
 | 
						||
				else if (elab == "POSNEG") // positivo e negativo (rh, du)
 | 
						||
				{
 | 
						||
					if (val[0] == '+')
 | 
						||
						record_at.put(campo, "POS");
 | 
						||
					else if (val[0] == '-')	
 | 
						||
						record_at.put(campo, "NEG");
 | 
						||
					else record_at.put(campo, "");
 | 
						||
				}
 | 
						||
				else if (elab == "KELL") // kell (vuoto = vuoto, presenza di K maiuscola = POS, altrimenti = NEG)
 | 
						||
				{     
 | 
						||
					str = val;
 | 
						||
					if (str.empty())
 | 
						||
						record_at.put(SOG_KELL, "");
 | 
						||
					else if (str.find('K') != -1)      
 | 
						||
						record_at.put(SOG_KELL, "POS");
 | 
						||
					else record_at.put(SOG_KELL, "NEG");
 | 
						||
				}
 | 
						||
				else if ((elab == "TELEFONO") || (elab == "CELLULARE") || (elab == "NOCELLULARE")) // toglie barre e altre cose inutili dal numero di telefono
 | 
						||
				{
 | 
						||
					str = val;
 | 
						||
					str.trim();
 | 
						||
					if (str.not_empty())
 | 
						||
					{                
 | 
						||
						str.strip_spaces();
 | 
						||
						str.strip("/");
 | 
						||
						str.strip("\\");           
 | 
						||
						if (elab == "TELEFONO")
 | 
						||
							record_at.put(campo, str);							
 | 
						||
						else 
 | 
						||
						{
 | 
						||
							if ((elab == "CELLULARE") && ((str[0]!='0') && (str.len()>9)))
 | 
						||
							  record_at.put(campo, str);							
 | 
						||
							else
 | 
						||
								if ((elab == "NOCELLULARE") && (str[0]=='0'))
 | 
						||
									record_at.put(campo, str);															
 | 
						||
						}		
 | 
						||
					}
 | 
						||
				}
 | 
						||
				else if (elab == "SENUMERO") // campo da caricare solo se numerico (nello specifico tess. ssn)
 | 
						||
				{
 | 
						||
					long numero = atol(val);
 | 
						||
					if (numero != 0)
 | 
						||
						record_at.put(campo, val);											
 | 
						||
				}
 | 
						||
				else if (elab == "MEDICO")  // medico (solo confronto)
 | 
						||
				{                  
 | 
						||
					str = val;
 | 
						||
					TRectype recmed = cache().get(LF_MEDICI, record_at.get(SOG_CODMED));
 | 
						||
					TString80 medico = recmed.get(MED_COGNOME);
 | 
						||
					medico.trim();
 | 
						||
					medico << ' ';
 | 
						||
					medico << recmed.get(MED_NOME);
 | 
						||
					medico.trim();
 | 
						||
					str.trim();
 | 
						||
					if ((medico != str) && (medico.not_empty() || str.not_empty()))
 | 
						||
					{                       
 | 
						||
						bool segnala = TRUE;
 | 
						||
						int i = medico.len();
 | 
						||
						int j = str.len();
 | 
						||
						if (i != j)
 | 
						||
						{
 | 
						||
							if ((i < j) && i > 0) j = i;
 | 
						||
							if ((j > 0) && (i > 0))
 | 
						||
							 	segnala = (medico.sub(0,j-1) != str.sub(0,j-1));
 | 
						||
							else
 | 
						||
								segnala = TRUE; 	
 | 
						||
						}
 | 
						||
						if (segnala)
 | 
						||
						{	
 | 
						||
							TString256 stampa = "";
 | 
						||
							stampa << "MEDICO diverso: " << " avis " << medico << " sit " << str;
 | 
						||
							print_line(stampa);
 | 
						||
						}	
 | 
						||
					}	
 | 
						||
				}
 | 
						||
				else if (elab == "INDIRIZZO")  // indirizzo (per vedere di isolare la localita)
 | 
						||
				{   
 | 
						||
					TString80 localita = "";                       
 | 
						||
					str = val;
 | 
						||
					const int i = str.find('-');
 | 
						||
					if (i > 0)
 | 
						||
					{
 | 
						||
						localita = str.sub(i+1);
 | 
						||
						str = str.sub(0,i);
 | 
						||
						str.trim();
 | 
						||
						localita.trim();
 | 
						||
						localita.upper();
 | 
						||
					}	
 | 
						||
					TString tmp = record_at.get(SOG_DOM_INDIR);
 | 
						||
					str.trim();
 | 
						||
					str = str.upper();
 | 
						||
					tmp.trim();
 | 
						||
					tmp = tmp.upper();
 | 
						||
					if (tmp != str)
 | 
						||
					{               
 | 
						||
						TString256 stampa = "";
 | 
						||
						stampa << "INDIRIZZO ";
 | 
						||
						if (tmp.empty())
 | 
						||
						{
 | 
						||
							record_at.put(SOG_DOM_INDIR, str);
 | 
						||
							stampa << " inserito da CETRAPLUS: " << str;
 | 
						||
						}	                                                     
 | 
						||
						else
 | 
						||
							stampa << " diverso: avis " << tmp << " sit " << str;
 | 
						||
						print_line(stampa);
 | 
						||
						stampa = "";
 | 
						||
						if (localita.not_empty())
 | 
						||
						{
 | 
						||
							tmp = record_at.get(SOG_DOM_CODLOC);
 | 
						||
							TString80 desloc = cache().get("LCP",tmp).get("S0");
 | 
						||
							desloc.trim();
 | 
						||
							if (localita != desloc)
 | 
						||
							{
 | 
						||
								stampa << "LOCALITA ";
 | 
						||
								if (desloc.empty())
 | 
						||
								{       
 | 
						||
									TTable lcp("LCP");
 | 
						||
									lcp.setkey(2);           
 | 
						||
									lcp.put("S0", localita);
 | 
						||
									if (lcp.read() == NOERR)
 | 
						||
									{
 | 
						||
										tmp = lcp.get("CODTAB");
 | 
						||
										record_at.put(SOG_DOM_CODLOC, tmp);
 | 
						||
										stampa << " inserito da CETRAPLUS: " << tmp << " " << localita;
 | 
						||
									}	
 | 
						||
									else
 | 
						||
										stampa << " non presente in tabella avis " << localita;
 | 
						||
								}
 | 
						||
								else
 | 
						||
									stampa << " diverso: avis " << desloc << " sit " << localita;
 | 
						||
								print_line(stampa);	
 | 
						||
							}	
 | 
						||
						}
 | 
						||
					}	
 | 
						||
				}
 | 
						||
				else if ((elab == "CONFRONTA") || (elab == "SEGNALA")) // SEGNALA = solo segnalazione, CONFRONTA = segnala e modifica
 | 
						||
				{
 | 
						||
					if (campo.not_empty())
 | 
						||
					{
 | 
						||
						str = val;                            
 | 
						||
						TString tmp = record_at.get(campo);
 | 
						||
						str.trim();
 | 
						||
						str = str.upper();
 | 
						||
						tmp.trim();
 | 
						||
						tmp = tmp.upper();
 | 
						||
						if (tmp != str)
 | 
						||
						{               
 | 
						||
							TString256 stampa = "";
 | 
						||
							if (elab == "CONFRONTA")
 | 
						||
							{
 | 
						||
								stampa << "Cambio " << campo << ": da " << tmp << " a " << str;
 | 
						||
								print_line(stampa);
 | 
						||
								record_at.put(campo, str);
 | 
						||
							}	
 | 
						||
							else
 | 
						||
							{
 | 
						||
								stampa << campo << " diverso: avis " << tmp << " sit " << str;
 | 
						||
								print_line(stampa);
 | 
						||
							}
 | 
						||
						}	
 | 
						||
					}	
 | 
						||
				}
 | 
						||
				else if (elab == "SEVUOTO")		// segnala differenza, e modifica solo se vuoto
 | 
						||
				{
 | 
						||
					if (campo.not_empty())
 | 
						||
					{
 | 
						||
						str = val;                            
 | 
						||
						TString tmp = record_at.get(campo);
 | 
						||
						str.trim();
 | 
						||
						str = str.upper();
 | 
						||
						tmp.trim();
 | 
						||
						tmp = tmp.upper();
 | 
						||
						if (tmp != str)
 | 
						||
						{               
 | 
						||
							TString256 stampa = "";
 | 
						||
							stampa << campo;
 | 
						||
							if (tmp.empty())
 | 
						||
							{
 | 
						||
								record_at.put(campo, str);
 | 
						||
								stampa << " inserito da CETRAPLUS: " << str;
 | 
						||
							}	                                                     
 | 
						||
							else
 | 
						||
								stampa << " diverso: avis " << tmp << " sit " << str;
 | 
						||
							print_line(stampa);
 | 
						||
								
 | 
						||
						}	
 | 
						||
					}	
 | 
						||
				}
 | 
						||
				else if ((elab == "CONFRONTADATA") || (elab == "SEGNALADATA")) // come sopra ma per campi data
 | 
						||
				{
 | 
						||
					if (campo.not_empty())
 | 
						||
					{
 | 
						||
						str = val;                            
 | 
						||
						TDate tmp = record_at.get_date(campo);
 | 
						||
						TDate data = TDate(atoi(str.sub(8,10)), atoi(str.sub(5,7)), atoi(str.sub(0,4)));
 | 
						||
						if (tmp != data)
 | 
						||
						{               
 | 
						||
							TString256 stampa = "";
 | 
						||
							stampa << campo << " diverso: avis " << tmp.string();
 | 
						||
							stampa << " sit " << data.string();
 | 
						||
							print_line(stampa);
 | 
						||
							if (elab == "CONFRONTA")
 | 
						||
								record_at.put(campo, data);
 | 
						||
						}	
 | 
						||
					}	
 | 
						||
				}
 | 
						||
			}
 | 
						||
			else
 | 
						||
				record_at.put(field, val); // campi da passare semplicemente!
 | 
						||
		}	
 | 
						||
	}	
 | 
						||
	return update;	
 | 
						||
}
 | 
						||
 | 
						||
long TCtpr2at::get_next_key()
 | 
						||
{
 | 
						||
	TLocalisamfile soggetti(LF_SOGGETTI);
 | 
						||
	soggetti.setkey(1);
 | 
						||
	soggetti.last();
 | 
						||
	long codice = soggetti.get_long(SOG_CODICE);
 | 
						||
	return codice+1;
 | 
						||
}
 | 
						||
 | 
						||
bool TCtpr2at::accesso(const TString& istruzione)
 | 
						||
{
 | 
						||
	TString256 stampa = "";
 | 
						||
	int error = NOERR;
 | 
						||
	TAssoc_array record;
 | 
						||
	if (build_record(record, istruzione))
 | 
						||
	{
 | 
						||
		// ricerca del soggetto per codice SIT
 | 
						||
		TString16& id_anagrafica = (TString16&) record["ID_ANAGRAFICA"]; 
 | 
						||
		_rel->lfile().setkey(7);
 | 
						||
		TRectype& recsog = _rel->curr();
 | 
						||
		recsog.zero();
 | 
						||
		recsog.put(SOG_CODCT, id_anagrafica);
 | 
						||
		error = recsog.read(_rel->lfile());
 | 
						||
		if (error == NOERR)
 | 
						||
		{               
 | 
						||
			stampa = recsog.get(SOG_COGNOME); 
 | 
						||
			stampa << " " << recsog.get(SOG_NOME);
 | 
						||
			stampa << " " << recsog.get(SOG_DATANASC);
 | 
						||
			// ho trovato il soggetto, ora verifico che tipo di accesso <20>
 | 
						||
			TString8& tp_accesso = (TString8&)record["TP_ACCESSO"];
 | 
						||
			if (tp_accesso[0] == 'D')
 | 
						||
			{
 | 
						||
				// trattasi di donazione
 | 
						||
				// mi serve solo il codabar per decidere il punto di prelievo (la donazione c'<27> gi<67>)
 | 
						||
				TString8 luogodon_at;
 | 
						||
				TString16& str = (TString16&) record["DT_ACCESSO"]; 
 | 
						||
				const TDate datadon = TDate(atoi(str.sub(8,10)) ,atoi(str.sub(5,7)), atoi(str.sub(0,4)));
 | 
						||
				TString16& codabar = (TString16&) record["CODABAR"];
 | 
						||
				_donaz->setkey(2);
 | 
						||
				TRectype& recdon = _donaz->curr();
 | 
						||
				recdon.zero();
 | 
						||
				recdon.put(DON_CODICE, recsog.get(SOG_CODICE));
 | 
						||
				recdon.put(DON_DATADON, datadon);
 | 
						||
				if (_donaz->read() == NOERR)
 | 
						||
				{     
 | 
						||
					if ((codabar.left(2) == "52") || (codabar.left(2) == "53") || (codabar.left(2) == "54") || (codabar.left(2) == "55"))
 | 
						||
						luogodon_at = "0001";
 | 
						||
					else 
 | 
						||
					{
 | 
						||
						if (recsog.get(SOG_CODSEZ) == "13")
 | 
						||
							luogodon_at = "1301";            
 | 
						||
						else
 | 
						||
							luogodon_at = "0000";		
 | 
						||
					}	
 | 
						||
					recdon.put(DON_LUOGODON, luogodon_at);
 | 
						||
					_donaz->rewrite();
 | 
						||
					TString16& prog = (TString16&) record["PROG_GIORNAL"];
 | 
						||
					if (!_array_donaz->is_key(prog))
 | 
						||
						_array_donaz->add(prog, record["ID_ANAGRAFICA"])	;
 | 
						||
				}
 | 
						||
			}	
 | 
						||
			else
 | 
						||
			{
 | 
						||
				// trattasi di controllo o visita	
 | 
						||
				TString4 tipocon = _configfile->get(tp_accesso, "ACCESSI");
 | 
						||
				TString16& str = (TString16&) record["DT_ACCESSO"]; 
 | 
						||
				const TDate datacon = TDate(atoi(str.sub(8,10)) ,atoi(str.sub(5,7)), atoi(str.sub(0,4)));
 | 
						||
				if (tipocon.empty())
 | 
						||
				{
 | 
						||
					print_line(stampa);
 | 
						||
					stampa = "Tipo accesso ";
 | 
						||
					stampa << tp_accesso[0] << " del ";
 | 
						||
					stampa << datacon.string() << " senza corrispondenza. Non inserito.";
 | 
						||
					print_line(stampa);
 | 
						||
					tipocon = "VS";
 | 
						||
				}	
 | 
						||
				else
 | 
						||
				{
 | 
						||
					TRectype* recc = new TRectype(LF_CONTSAN);
 | 
						||
					recc->put(CON_CODICE, recsog.get(SOG_CODICE));
 | 
						||
					recc->put(CON_DATACON, datacon);
 | 
						||
					recc->put(CON_TIPOCON, tipocon);
 | 
						||
					recc->put(CON_RESPONSAB, "CETRAPLUS");
 | 
						||
	
 | 
						||
					bool insert = FALSE;
 | 
						||
					bool exist =  FALSE;
 | 
						||
					TRectype* keyc = new TRectype(LF_CONTSAN);
 | 
						||
					keyc->put(CON_CODICE, recsog.get(SOG_CODICE));
 | 
						||
					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 (datacon==d)	// esiste gia' un controllo in questa data
 | 
						||
							{
 | 
						||
								exist=TRUE;
 | 
						||
								r=0;
 | 
						||
								if (_message)
 | 
						||
								{
 | 
						||
									print_line(stampa);
 | 
						||
									stampa = "";
 | 
						||
									stampa << "Controllo gi<67> esistente in data " << datacon.string();
 | 
						||
									print_line(stampa);
 | 
						||
									print_line();
 | 
						||
								}	
 | 
						||
							}	 
 | 
						||
							else
 | 
						||
								if (datacon > 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);
 | 
						||
						if (_message)
 | 
						||
						{
 | 
						||
							print_line(stampa);
 | 
						||
							stampa = "";			
 | 
						||
							stampa << "Inserito controllo " << tipocon << " del " << datacon.string();
 | 
						||
							print_line(stampa);
 | 
						||
							print_line();
 | 
						||
						}
 | 
						||
					  // aggiorno data e utente ultimo aggiornamento
 | 
						||
						TDate oggi(TODAY);
 | 
						||
						recsog.put(SOG_DATAULTAGG, oggi);
 | 
						||
						recsog.put(SOG_UTENULTAGG, "CETRAPLUS");
 | 
						||
						err = recsog.rewrite(_rel->lfile());
 | 
						||
					}	
 | 
						||
				}	
 | 
						||
			}
 | 
						||
		} 
 | 
						||
		else
 | 
						||
		{
 | 
						||
			// soggetto non trovato
 | 
						||
			stampa << "Codice SIT " << id_anagrafica << " non trovato. Impossibile aggiornare accesso ";
 | 
						||
			stampa << record["TP_ACCESSO"] << " del ";
 | 
						||
			stampa << record["DT_ACCESSO"];
 | 
						||
			print_line(stampa);
 | 
						||
		}	
 | 
						||
		return (error == NOERR);
 | 
						||
	}          
 | 
						||
	else
 | 
						||
		return FALSE;		
 | 
						||
}
 | 
						||
 | 
						||
bool TCtpr2at::sacca(const TString& istruzione)
 | 
						||
{
 | 
						||
	TString256 stampa = "";
 | 
						||
	int err = NOERR;
 | 
						||
	TAssoc_array record;
 | 
						||
	if (build_record(record, istruzione))
 | 
						||
	{
 | 
						||
		// ricerca del soggetto per codice SIT
 | 
						||
		TString16& id_anagrafica = (TString16&) record["ID_ANAGRAFICA"]; 
 | 
						||
		_rel->lfile().setkey(7);
 | 
						||
		TRectype& recsog = _rel->curr();
 | 
						||
		recsog.zero();
 | 
						||
		recsog.put(SOG_CODCT, id_anagrafica);
 | 
						||
		err = recsog.read(_rel->lfile());
 | 
						||
		if (err == NOERR)
 | 
						||
		{               
 | 
						||
			stampa = recsog.get(SOG_COGNOME); 
 | 
						||
			stampa << " " << recsog.get(SOG_NOME);
 | 
						||
			stampa << " " << recsog.get(SOG_DATANASC);
 | 
						||
			// ho trovato il soggetto, ora verifico la donazione
 | 
						||
			TString16& str = (TString16&) record["DT_PRELIEVO"]; 
 | 
						||
			const TDate datadon = TDate(atoi(str.sub(8,10)) ,atoi(str.sub(5,7)), atoi(str.sub(0,4)));
 | 
						||
			_progins++;			
 | 
						||
			TRectype* rec = new TRectype(LF_DONAZ);
 | 
						||
			rec->put(DON_CODICE, recsog.get(SOG_CODICE));
 | 
						||
			rec->put(DON_DATADON, datadon);      
 | 
						||
			str = (TString16&) record["TP_DONAZIONE"]; 
 | 
						||
			TRectype recpr2 = cache().get("PR2", str);
 | 
						||
			TString16 tipodon = recpr2.get("S6");
 | 
						||
			if (tipodon.empty())
 | 
						||
			{   
 | 
						||
				print_line(stampa);
 | 
						||
				stampa = "";
 | 
						||
				stampa << "Tipo donazione SIT " << str << " senza corrispondenza: non inserita";
 | 
						||
				print_line(stampa);
 | 
						||
				stampa = "";
 | 
						||
			}
 | 
						||
			else
 | 
						||
			{
 | 
						||
				rec->put(DON_TIPODON, tipodon);
 | 
						||
				TString16& etichetta = (TString16&) record["ID_SACCA"];
 | 
						||
				rec->put(DON_ETICHETTA, etichetta);
 | 
						||
				rec->put(DON_CODSEZ, recsog.get(SOG_CODSEZ));
 | 
						||
				rec->put(DON_CODSOT, recsog.get(SOG_CODSOT));
 | 
						||
				rec->put(DON_PROGINS, _progins);
 | 
						||
	
 | 
						||
				bool insert = FALSE;
 | 
						||
				bool exist = FALSE;
 | 
						||
				TRectype* key = new TRectype(LF_DONAZ);
 | 
						||
				key->put(DON_CODICE, recsog.get(SOG_CODICE));
 | 
						||
				err = _sdonazioni->read(key);
 | 
						||
				if (err == NOERR)
 | 
						||
				{
 | 
						||
					int r=_sdonazioni->rows();
 | 
						||
					while (r>=1 && !insert && !exist)
 | 
						||
					{
 | 
						||
						const TRectype& riga = _sdonazioni->row(r);
 | 
						||
						const TDate d = riga.get(DON_DATADON);
 | 
						||
						if (datadon==d)	// esiste gia' una donazione in questa data
 | 
						||
						{
 | 
						||
							exist=TRUE;
 | 
						||
							r=0;                           
 | 
						||
							if (_message)
 | 
						||
							{
 | 
						||
								print_line(stampa);
 | 
						||
								stampa = "";
 | 
						||
								stampa << "Donazione gi<67> esistente in data " << datadon.string();
 | 
						||
								print_line(stampa);
 | 
						||
								print_line();
 | 
						||
							}	
 | 
						||
						}	 
 | 
						||
						else
 | 
						||
							if (datadon > d)
 | 
						||
							{                            
 | 
						||
								rec->put(DON_PROGDON,r+1);
 | 
						||
								_sdonazioni->insert_row(rec);
 | 
						||
								insert=TRUE;
 | 
						||
							}
 | 
						||
						r--;						
 | 
						||
					}
 | 
						||
					if (!exist && !insert)
 | 
						||
					{
 | 
						||
						rec->put(DON_PROGDON,1);
 | 
						||
						rec->put(DON_PRIMADON,'X');
 | 
						||
						_sdonazioni->insert_row(rec);
 | 
						||
					}	
 | 
						||
				}	
 | 
						||
				else
 | 
						||
			  	if (err == _iseof || err == _isemptyfile)
 | 
						||
			  	{
 | 
						||
						rec->put(DON_PROGDON,1);  
 | 
						||
						rec->put(DON_PRIMADON,'X');
 | 
						||
						_sdonazioni->insert_row(rec);		  	
 | 
						||
					}
 | 
						||
				if (!exist)					
 | 
						||
				{	
 | 
						||
					err = _sdonazioni->write(TRUE);
 | 
						||
					if (err == NOERR)
 | 
						||
					{   
 | 
						||
						if (_message)
 | 
						||
						{
 | 
						||
							print_line(stampa);
 | 
						||
							stampa = "";
 | 
						||
							stampa << "Inserita donazione del " << datadon;	
 | 
						||
							print_line(stampa);
 | 
						||
						}
 | 
						||
					  calcola_donazioni_lib(recsog, _sdonazioni); // questo metodo sistema tutto!!!
 | 
						||
						calcola_categoria(recsog); // modificato per dare i messaggi al posto dei veri cambiamenti
 | 
						||
						//print_line(); // tolto perch<63> altrimenti stampa alcuni fogli vuoti
 | 
						||
					  // aggiorno data e utente ultimo aggiornamento
 | 
						||
						TDate oggi(TODAY);
 | 
						||
						recsog.put(SOG_DATAULTAGG, oggi);
 | 
						||
						recsog.put(SOG_UTENULTAGG, "CETRAPLUS");
 | 
						||
						err = recsog.rewrite(_rel->lfile());
 | 
						||
					}					
 | 
						||
					//else
 | 
						||
						//error_box("Errore %d in scrittura archivio donazioni, riga %d", err, rigasog);
 | 
						||
				}	
 | 
						||
			}				
 | 
						||
		}	
 | 
						||
		else
 | 
						||
		{
 | 
						||
			// soggetto non trovato
 | 
						||
			stampa << "Codice SIT " << id_anagrafica << " non trovato. Impossibile inserire donazione ";
 | 
						||
			stampa << record["TP_DONAZIONE"] << " del ";
 | 
						||
			stampa << record["DT_PRELIEVO"];
 | 
						||
			print_line(stampa);
 | 
						||
			print_line();
 | 
						||
		}	
 | 
						||
	}
 | 
						||
	return TRUE;		
 | 
						||
}
 | 
						||
 | 
						||
bool TCtpr2at::analisi(const TString& istruzione)
 | 
						||
{
 | 
						||
	TString256 stampa = "";
 | 
						||
	int error = NOERR;
 | 
						||
	TAssoc_array record;
 | 
						||
	if (build_record(record, istruzione))
 | 
						||
	{
 | 
						||
		TString16& id_analisi = (TString16&) record["ID_ANALISI"];
 | 
						||
		TString4 tipocon = _configfile->get(id_analisi, "ANALISI");
 | 
						||
		if (!tipocon.empty())
 | 
						||
		{
 | 
						||
			TString16& prog = (TString16&) record["PROG_GIORNAL"];
 | 
						||
			if (_array_donaz->is_key(prog))
 | 
						||
			{               
 | 
						||
				// ricerca del soggetto per codice SIT
 | 
						||
				TString16& id_anagrafica = (TString16&) _array_donaz->find(prog);
 | 
						||
				_rel->lfile().setkey(7);
 | 
						||
				TRectype& recsog = _rel->curr();
 | 
						||
				recsog.zero();
 | 
						||
				recsog.put(SOG_CODCT, id_anagrafica);
 | 
						||
				error = recsog.read(_rel->lfile());
 | 
						||
				if (error == NOERR)
 | 
						||
				{               
 | 
						||
					stampa = recsog.get(SOG_COGNOME); 
 | 
						||
					stampa << " " << recsog.get(SOG_NOME);
 | 
						||
					stampa << " " << recsog.get(SOG_DATANASC);
 | 
						||
					TString16& str = (TString16&) record["DT_ACCESSO"]; 
 | 
						||
					const TDate datacon = TDate(atoi(str.sub(8,10)) ,atoi(str.sub(5,7)), atoi(str.sub(0,4)));
 | 
						||
	
 | 
						||
					TRectype* recc = new TRectype(LF_CONTSAN);
 | 
						||
					recc->put(CON_CODICE, recsog.get(SOG_CODICE));
 | 
						||
					recc->put(CON_DATACON, datacon);
 | 
						||
					recc->put(CON_TIPOCON, tipocon);
 | 
						||
					recc->put(CON_RESPONSAB, "CETRAPLUS");
 | 
						||
		
 | 
						||
					bool insert = FALSE;
 | 
						||
					bool exist =  FALSE;
 | 
						||
					TRectype* keyc = new TRectype(LF_CONTSAN);
 | 
						||
					keyc->put(CON_CODICE, recsog.get(SOG_CODICE));
 | 
						||
					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 (datacon==d)	// esiste gia' un controllo in questa data
 | 
						||
							{
 | 
						||
								exist=TRUE;
 | 
						||
								r=0;
 | 
						||
								if (_message)
 | 
						||
								{
 | 
						||
									print_line(stampa);
 | 
						||
									stampa = "";
 | 
						||
									stampa << "Controllo gi<67> esistente in data " << datacon.string();
 | 
						||
									print_line(stampa);
 | 
						||
									print_line();
 | 
						||
								}	
 | 
						||
							}	 
 | 
						||
							else
 | 
						||
								if (datacon > 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);
 | 
						||
						if (_message)
 | 
						||
						{
 | 
						||
							print_line(stampa);
 | 
						||
							stampa = "";			
 | 
						||
							stampa << "Inserito controllo " << tipocon << " del " << datacon.string();
 | 
						||
							print_line(stampa);
 | 
						||
							print_line();
 | 
						||
						}	
 | 
						||
					  // aggiorno data e utente ultimo aggiornamento
 | 
						||
						TDate oggi(TODAY);
 | 
						||
						recsog.put(SOG_DATAULTAGG, oggi);
 | 
						||
						recsog.put(SOG_UTENULTAGG, "CETRAPLUS");
 | 
						||
						err = recsog.rewrite(_rel->lfile());
 | 
						||
					}	
 | 
						||
				}	
 | 
						||
				else
 | 
						||
				{
 | 
						||
					// soggetto non trovato
 | 
						||
					stampa << "Codice SIT " << id_anagrafica << " non trovato. Impossibile inserire controllo ";
 | 
						||
					stampa << record["ID_ANALISI"] << " del ";
 | 
						||
					stampa << record["DT_ACCESSO"];
 | 
						||
					print_line(stampa);
 | 
						||
					print_line();
 | 
						||
				}	
 | 
						||
				return (error == NOERR);
 | 
						||
			}	
 | 
						||
		}	
 | 
						||
	}
 | 
						||
	return FALSE;
 | 
						||
}
 | 
						||
 | 
						||
bool TCtpr2at::intervalli(const TString& istruzione)
 | 
						||
{
 | 
						||
	return TRUE;
 | 
						||
}
 | 
						||
 | 
						||
bool TCtpr2at::esclusione(const TString& istruzione)
 | 
						||
{
 | 
						||
	int error = NOERR;
 | 
						||
	TAssoc_array record;
 | 
						||
	if (build_record(record, istruzione))
 | 
						||
	{ 
 | 
						||
		TString16& strc = (TString16&) record["DT_CANCEL"]; 
 | 
						||
		const TDate dt_cancel = TDate(atoi(strc.sub(8,10)) ,atoi(strc.sub(5,7)), atoi(strc.sub(0,4)));
 | 
						||
    if (dt_cancel.empty())
 | 
						||
    {
 | 
						||
			TString16& tp_esclusione = (TString16&) record["TP_ESCLUSIONE"];
 | 
						||
			TString4 tipocon = _configfile->get(tp_esclusione, "ESCLUSIONI");
 | 
						||
			if (!tipocon.empty())
 | 
						||
			{
 | 
						||
				// ricerca del soggetto per codice SIT
 | 
						||
				TString16& id_anagrafica = (TString16&) record["ID_ANAGRAFICA"]; 
 | 
						||
				_rel->lfile().setkey(7);
 | 
						||
				TRectype& recsog = _rel->curr();
 | 
						||
				recsog.zero();
 | 
						||
				recsog.put(SOG_CODCT, id_anagrafica);
 | 
						||
				error = recsog.read(_rel->lfile());
 | 
						||
				TString256 stampa = "";            
 | 
						||
				if (error == NOERR)
 | 
						||
				{                          
 | 
						||
					stampa = recsog.get(SOG_COGNOME); 
 | 
						||
					stampa << " " << recsog.get(SOG_NOME);
 | 
						||
					stampa << " " << recsog.get(SOG_DATANASC);
 | 
						||
					// ho trovato il soggetto
 | 
						||
					const long codsog = recsog.get_long(SOG_CODICE);
 | 
						||
					//TString16& str = (TString16&) record["DA_DATA"]; 
 | 
						||
					//const TDate datacon = TDate(atoi(str.sub(8,10)) ,atoi(str.sub(5,7)), atoi(str.sub(0,4)));
 | 
						||
					const TDate datacon(TODAY);
 | 
						||
					TString16& str = (TString16&) record["A_DATA"]; 
 | 
						||
					const TDate datapross = TDate(atoi(str.sub(8,10)) ,atoi(str.sub(5,7)), atoi(str.sub(0,4)));
 | 
						||
					TDate datanulla(NULLDATE);
 | 
						||
	        if ((datacon < datapross) || (datapross == datanulla))
 | 
						||
	        {
 | 
						||
						TRectype* recc = new TRectype(LF_CONTSAN);
 | 
						||
						recc->put(CON_CODICE, recsog.get(SOG_CODICE));
 | 
						||
						recc->put(CON_DATACON, datacon);
 | 
						||
						recc->put(CON_TIPOCON, tipocon);
 | 
						||
						recc->put(CON_PROSSDATA, datapross);
 | 
						||
						recc->put(CON_PROSSTIPO, tipocon);
 | 
						||
						recc->put(CON_RESPONSAB, "CETRAPLUS");
 | 
						||
				
 | 
						||
						bool insert = FALSE;
 | 
						||
						bool exist =  FALSE;
 | 
						||
						TRectype* keyc = new TRectype(LF_CONTSAN);
 | 
						||
						keyc->put(CON_CODICE, recsog.get(SOG_CODICE));
 | 
						||
						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 (datacon==d)	// esiste gia' un controllo in questa data
 | 
						||
								{
 | 
						||
									exist=TRUE;
 | 
						||
									r=0;
 | 
						||
									if (_message)
 | 
						||
									{
 | 
						||
										print_line(stampa);
 | 
						||
										stampa = "";
 | 
						||
										stampa << "Controllo gi<67> esistente in data " << datacon.string();
 | 
						||
										print_line(stampa);
 | 
						||
										print_line();
 | 
						||
									}	
 | 
						||
								}	 
 | 
						||
								else
 | 
						||
									if (datacon > 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* key = new TRectype(LF_IDONEITA);
 | 
						||
						  key->put(IDO_CODICE, recsog.get(SOG_CODICE));
 | 
						||
						  _sidoneita->read(key);
 | 
						||
						  con_reord(recsog, _scontrolli, _sidoneita);
 | 
						||
						  if (datapross.empty())
 | 
						||
						  {
 | 
						||
								print_line(stampa);
 | 
						||
								stampa = "";			
 | 
						||
								stampa << "Inserita sospensione " << tipocon << " dal " << datacon.string();
 | 
						||
								stampa << " al " << datapross.string();
 | 
						||
								print_line(stampa);
 | 
						||
								print_line();
 | 
						||
							}	
 | 
						||
						  // aggiorno data e utente ultimo aggiornamento
 | 
						||
							TDate oggi(TODAY);
 | 
						||
							recsog.put(SOG_DATAULTAGG, oggi);
 | 
						||
							recsog.put(SOG_UTENULTAGG, "CETRAPLUS");
 | 
						||
							err = recsog.rewrite(_rel->lfile());
 | 
						||
						}	
 | 
						||
					}
 | 
						||
					//else	
 | 
						||
					//{
 | 
						||
					//	print_line(stampa);
 | 
						||
					//	stampa = "";			
 | 
						||
					//	stampa << "Sospensione " << tipocon << " dal " << datacon.string();
 | 
						||
					//	stampa << " al " << datapross.string();
 | 
						||
					//	stampa << " non inserita perch<63> gi<67> scaduta";
 | 
						||
					//	print_line(stampa);
 | 
						||
					//	print_line();
 | 
						||
					//}
 | 
						||
				}	
 | 
						||
				else
 | 
						||
				{
 | 
						||
					// soggetto non trovato
 | 
						||
					stampa << "Codice SIT " << id_anagrafica << " non trovato. Impossibile inserire sospensione ";
 | 
						||
					stampa << record["TP_ESCLUSIONE"] << " dal ";
 | 
						||
					stampa << record["DA_DATA"];
 | 
						||
					stampa << " al " << record["A_DATA"];
 | 
						||
					print_line(stampa);
 | 
						||
					print_line();
 | 
						||
				}	
 | 
						||
				return (error == NOERR);
 | 
						||
			}	     
 | 
						||
		}	
 | 
						||
	}          
 | 
						||
	return FALSE;		
 | 
						||
 | 
						||
}
 | 
						||
 | 
						||
// 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;
 | 
						||
}
 | 
						||
 | 
						||
int at8900(int argc, char* argv[])
 | 
						||
{
 | 
						||
  TCtpr2at a;
 | 
						||
  a.run(argc, argv, "Acquisizione dati da SIT Parma");
 | 
						||
  return 0;
 | 
						||
}
 |