Files correlati : Ricompilazione Demo : [ ] Commento : tolto controllo inutile stringa.ok() git-svn-id: svn://10.65.10.50/trunk@9243 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			341 lines
		
	
	
		
			9.5 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			341 lines
		
	
	
		
			9.5 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <form.h>
 | 
						|
#include <mask.h>
 | 
						|
#include <printapp.h>
 | 
						|
#include <recarray.h>
 | 
						|
#include <tabutil.h>
 | 
						|
 | 
						|
#include "at8.h"
 | 
						|
#include "at8500a.h"
 | 
						|
#include "atlib.h"
 | 
						|
          
 | 
						|
// nomi dei campi
 | 
						|
#include "soggetti.h"
 | 
						|
#include "donaz.h"
 | 
						|
#include "contsan.h"
 | 
						|
#include "idoneita.h"
 | 
						|
#include "rconvoc.h"
 | 
						|
 | 
						|
class TIntegrita : public TPrintapp
 | 
						|
{
 | 
						|
  static bool filter_func_integrita(const TRelation* rel);
 | 
						|
 | 
						|
  TRelation*        		_rel;
 | 
						|
  TMask*            		_msk;
 | 
						|
 | 
						|
  TLocalisamfile* _soggetti;
 | 
						|
	TLocalisamfile* _donaz;
 | 
						|
	TLocalisamfile* _contsan;
 | 
						|
	TLocalisamfile* _idoneita;
 | 
						|
	TRecord_array*	_sdonazioni; 
 | 
						|
	TRecord_array*	_scontrolli;
 | 
						|
	TRecord_array*	_sidoneita;
 | 
						|
	// 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;
 | 
						|
  
 | 
						|
  TAssoc_array					_categorie;
 | 
						|
  TString16							_codsez, _codsot;
 | 
						|
  
 | 
						|
protected:
 | 
						|
  virtual bool user_create();
 | 
						|
  virtual bool user_destroy();
 | 
						|
  virtual bool set_print(int m);
 | 
						|
  virtual void set_page(int file, int cnt);
 | 
						|
  virtual bool preprocess_page (int file, int counter);
 | 
						|
  virtual print_action postprocess_print(int file, int counter);
 | 
						|
 | 
						|
public:
 | 
						|
  void crea_intestazione();
 | 
						|
  void filtra_sezioni();
 | 
						|
  //void header_sezione(const TString16 codsez, const TString16 codsot);
 | 
						|
  TMask& app_mask() { return *_msk; }
 | 
						|
 | 
						|
  TIntegrita(){}
 | 
						|
};
 | 
						|
 | 
						|
HIDDEN inline TIntegrita& app() { return (TIntegrita&) main_app(); }
 | 
						|
 | 
						|
print_action TIntegrita::postprocess_print(int file, int counter)
 | 
						|
{ 
 | 
						|
	printer().formfeed();		
 | 
						|
	return NEXT_PAGE;
 | 
						|
}
 | 
						|
 | 
						|
void TIntegrita::filtra_sezioni()
 | 
						|
{
 | 
						|
 	const TString16 sezini = _msk->get(F_SEZINI);
 | 
						|
 	const TString16 sotini = _msk->get(F_SOTINI);
 | 
						|
 	const TString16 sezfin = _msk->get(F_SEZFIN);
 | 
						|
 	const TString16 sotfin = _msk->get(F_SOTFIN);
 | 
						|
  TRectype da(LF_SOGGETTI);
 | 
						|
  TRectype a(LF_SOGGETTI);   
 | 
						|
  if (sezini.not_empty())
 | 
						|
		da.put(SOG_CODSEZ, sezini);
 | 
						|
  if (sotini.not_empty())
 | 
						|
		da.put(SOG_CODSOT, sotini);
 | 
						|
  if (sezfin.not_empty())
 | 
						|
		a.put(SOG_CODSEZ, sezfin);
 | 
						|
  if (sotfin.not_empty())
 | 
						|
		a.put(SOG_CODSOT, sotfin);
 | 
						|
	current_cursor()->setregion(da, a);
 | 
						|
}	
 | 
						|
 | 
						|
void TIntegrita::set_page(int file, int cnt)
 | 
						|
{
 | 
						|
	set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"########"));
 | 
						|
	set_row(1,"@9g@S", FLD(LF_SOGGETTI,SOG_CATDON));
 | 
						|
	set_row(1,"@12g@S", FLD(LF_SOGGETTI,SOG_COGNOME));
 | 
						|
	set_row(1,"@38g@S", FLD(LF_SOGGETTI,SOG_NOME));
 | 
						|
	set_row(1,"@64g@d", FLD(LF_SOGGETTI,SOG_DATAULTDON));
 | 
						|
	set_row(2,"");				
 | 
						|
}
 | 
						|
 | 
						|
bool TIntegrita::filter_func_integrita(const TRelation* rel)
 | 
						|
{   
 | 
						|
	bool filtrato = TRUE;
 | 
						|
	TLocalisamfile& sog = rel->lfile(); 
 | 
						|
	//filtro per categorie
 | 
						|
	TAssoc_array& categorie = app()._categorie;
 | 
						|
	if (categorie.items() != 0)
 | 
						|
	{
 | 
						|
		const TString16 cat = sog.get(SOG_CATDON);
 | 
						|
		filtrato = categorie.is_key((const char*) cat);
 | 
						|
	}	
 | 
						|
  return filtrato;
 | 
						|
}
 | 
						|
 | 
						|
bool TIntegrita::preprocess_page(int file, int counter)
 | 
						|
{
 | 
						|
	TRectype& recsog = current_cursor()->curr();
 | 
						|
	// salto pagina se cambio sezione
 | 
						|
	/*
 | 
						|
	const TString16 codsez = recsog.get(SOG_CODSEZ);		
 | 
						|
	const TString16 codsot = recsog.get(SOG_CODSOT);		
 | 
						|
	if ((_codsez!=codsez)||(_codsot!=codsot))
 | 
						|
	{
 | 
						|
		if (_codsez != "**")
 | 
						|
			printer().formfeed();
 | 
						|
		_codsez = codsez;
 | 
						|
		_codsot = codsot;
 | 
						|
		header_sezione(codsez, codsot);
 | 
						|
	}	
 | 
						|
	*/
 | 
						|
	const long codice = recsog.get_long(SOG_CODICE);
 | 
						|
	TRectype* key = new TRectype(LF_DONAZ);
 | 
						|
	key->put(DON_CODICE, codice);
 | 
						|
	int err = _sdonazioni->read(key);
 | 
						|
	if ((err==NOERR) && (_sdonazioni->rows()>0))
 | 
						|
	{                    
 | 
						|
		const TRectype& riga = _sdonazioni->row(_sdonazioni->rows());
 | 
						|
		const TDate datadon = riga.get(DON_DATADON);
 | 
						|
		const TDate datasog = recsog.get_date(SOG_DATAULTDON);
 | 
						|
		if (datadon == datasog)
 | 
						|
			return FALSE;
 | 
						|
		else
 | 
						|
		{
 | 
						|
			calcola_donazioni_lib(recsog, _sdonazioni);
 | 
						|
			recsog.rewrite(_rel->lfile());
 | 
						|
			TRectype* key = new TRectype(LF_IDONEITA);
 | 
						|
			key->put(IDO_CODICE, recsog.get(SOG_CODICE));
 | 
						|
			_sidoneita->read(key);
 | 
						|
			TRectype* keyc = new TRectype(LF_CONTSAN);
 | 
						|
			keyc->put(CON_CODICE, recsog.get(SOG_CODICE));
 | 
						|
			_scontrolli->read(keyc);
 | 
						|
			if (_scontrolli->rows()>0 || _sidoneita->rows()>0)
 | 
						|
			{
 | 
						|
				con_reord(recsog,_scontrolli,_sidoneita);
 | 
						|
				recsog.rewrite(_rel->lfile());
 | 
						|
			}	
 | 
						|
			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)          
 | 
						|
				{
 | 
						|
					recsog.put(SOG_CATDON,ctd.get("S6"));		    				
 | 
						|
					if (ctd.get("S6").not_empty())
 | 
						|
						catdon = ctd.get("S6");							
 | 
						|
				}							
 | 
						|
				if ((catdon == _catini1 || _catini1.empty()) && (totdon==_numdon1) && _catfin1.not_empty())
 | 
						|
					recsog.put(SOG_CATDON, _catfin1);
 | 
						|
				if ((catdon == _catini2 || _catini2.empty()) && (totdon>=_numdon2) && _catfin2.not_empty() && (!_sttess2 || dimissione))
 | 
						|
					recsog.put(SOG_CATDON, _catfin2);
 | 
						|
		  }
 | 
						|
		  TDate dataiscsog = recsog.get_date(SOG_DATAISC);
 | 
						|
		  if (!dataiscsog.ok() && _dataisc)
 | 
						|
		  {                 
 | 
						|
				if (!recsog.get_date(SOG_DATAPRISI) == NULLDATE)
 | 
						|
					recsog.put(SOG_DATAISC,recsog.get(SOG_DATAPRISI));
 | 
						|
				else
 | 
						|
	  		{
 | 
						|
					const TRectype& riga = _sdonazioni->row(1);
 | 
						|
					recsog.put(SOG_DATAISC,riga.get(DON_DATADON));
 | 
						|
				}				  	
 | 
						|
			}					
 | 
						|
			const TDate dataprossi = recsog.get_date(SOG_DATAPROSSI);
 | 
						|
			const TDate dataconv = recsog.get_date(SOG_DATACONV);
 | 
						|
			const char stato = modstato_tcs(recsog.get(SOG_STATO));
 | 
						|
			const TString16 statosi = recsog.get(SOG_STATOSI);
 | 
						|
			if ((stato == 'S') || (statosi == SOSPENSIONE) || (dataprossi > dataconv) || !dataprossi.ok())
 | 
						|
			{
 | 
						|
				TLocalisamfile rconvoc(LF_RCONVOC);
 | 
						|
				rconvoc.setkey(3);
 | 
						|
				rconvoc.zero();
 | 
						|
				rconvoc.put(RCV_CODICE, recsog.get(SOG_CODICE));
 | 
						|
				rconvoc.put(RCV_DATACONV, recsog.get(SOG_DATACONV));
 | 
						|
				if (rconvoc.read() == NOERR)
 | 
						|
				{
 | 
						|
					rconvoc.put(RCV_ANNULLATO, TRUE);
 | 
						|
					int err = rconvoc.write();
 | 
						|
				}
 | 
						|
				const TDate datanulla(NULLDATE);
 | 
						|
				recsog.put(SOG_DATACONV, datanulla);
 | 
						|
				recsog.put(SOG_DATAULTSOL, datanulla);
 | 
						|
				const int numzero = 0;
 | 
						|
				recsog.put(SOG_NUMCONV,numzero);
 | 
						|
			}	
 | 
						|
			recsog.put(SOG_DATAULTAGG, TODAY);
 | 
						|
			recsog.put(SOG_UTENULTAGG, "V.I.D.");
 | 
						|
			recsog.rewrite(_rel->lfile());
 | 
						|
		}	
 | 
						|
	}	
 | 
						|
	else
 | 
						|
		return FALSE;
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
/*
 | 
						|
void TIntegrita::header_sezione(const TString16 codsez, const TString16 codsot)
 | 
						|
{
 | 
						|
	const TString80 densez = current_cursor()->curr(LF_SEZIONI).get(SEZ_DENSEZ);
 | 
						|
	const TString80 densot = current_cursor()->curr(LF_SEZIONI).get(SEZ_DENSOT);
 | 
						|
	TString intestazione(132);
 | 
						|
	intestazione = "Sezione: ";
 | 
						|
	intestazione << codsez;
 | 
						|
	intestazione << "/";
 | 
						|
	intestazione << codsot;
 | 
						|
	intestazione << " ";
 | 
						|
	intestazione << densez;
 | 
						|
	if (densot.not_empty())
 | 
						|
	{
 | 
						|
		intestazione << "/";
 | 
						|
		intestazione << densot;
 | 
						|
	}		
 | 
						|
	intestazione.center_just();
 | 
						|
	set_header(1,"@0g%s", (const char*) intestazione);
 | 
						|
	return;
 | 
						|
} 
 | 
						|
*/
 | 
						|
 | 
						|
bool TIntegrita::set_print(int)
 | 
						|
{
 | 
						|
  KEY tasto;
 | 
						|
  tasto = _msk->run();
 | 
						|
	if (tasto == K_ENTER)
 | 
						|
  {
 | 
						|
  	_codsez = "**";
 | 
						|
  	_codsez = "**";
 | 
						|
    reset_files(); 
 | 
						|
    add_file(LF_SOGGETTI);
 | 
						|
		filtra_sezioni();
 | 
						|
		// filtro per categorie		
 | 
						|
    _categorie.destroy();		
 | 
						|
  	const TString16 catpri = _msk->get(F_CAT1);
 | 
						|
  	const TString16 catsec = _msk->get(F_CAT2);
 | 
						|
  	const TString16 catter = _msk->get(F_CAT3);
 | 
						|
  	const TString16 catqua = _msk->get(F_CAT4);
 | 
						|
  	const TString16 catqui = _msk->get(F_CAT5);
 | 
						|
  	const TString16 catses = _msk->get(F_CAT6);
 | 
						|
  	if (catpri.not_empty())
 | 
						|
  		_categorie.add((const char*) catpri);
 | 
						|
  	if (catsec.not_empty())
 | 
						|
  		_categorie.add((const char*) catsec);
 | 
						|
  	if (catter.not_empty())
 | 
						|
  		_categorie.add((const char*) catter);
 | 
						|
  	if (catqua.not_empty())
 | 
						|
  		_categorie.add((const char*) catqua);
 | 
						|
  	if (catqui.not_empty())
 | 
						|
  		_categorie.add((const char*) catqui);
 | 
						|
  	if (catses.not_empty())
 | 
						|
  		_categorie.add((const char*) catses);
 | 
						|
		current_cursor()->set_filterfunction(filter_func_integrita);
 | 
						|
		reset_print();
 | 
						|
    crea_intestazione();
 | 
						|
    return TRUE;
 | 
						|
  }
 | 
						|
  else
 | 
						|
    return FALSE;
 | 
						|
}
 | 
						|
 | 
						|
void TIntegrita::crea_intestazione()
 | 
						|
{
 | 
						|
  reset_header();
 | 
						|
	TString sep(132);
 | 
						|
	sep = "VERIFICA INTEGRITA DATI";
 | 
						|
	sep.center_just();
 | 
						|
	set_header(2, "@0g%s", (const char*) sep);
 | 
						|
	//TString16 data_stampa = _data_stampa.string();
 | 
						|
	//set_header(2,"@0g%10s", (const char*) data_stampa);
 | 
						|
	sep = "";
 | 
						|
	sep << "Pag. @#";
 | 
						|
	set_header(2, "@120g%s", (const char*) sep);  
 | 
						|
	sep = "";
 | 
						|
	sep.fill('-');
 | 
						|
	set_header(3, (const char *) sep);
 | 
						|
}
 | 
						|
 | 
						|
bool TIntegrita::user_create()
 | 
						|
{
 | 
						|
  _msk = new TMask("at8500a");
 | 
						|
  _rel = new TRelation(LF_SOGGETTI);
 | 
						|
	_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);
 | 
						|
  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");
 | 
						|
  _nomessage = config.get_bool("NoMessage");
 | 
						|
  _etadonne = config.get_int("EtaDonne");
 | 
						|
  _intsi_f1 = config.get_int("IntSI_F1");
 | 
						|
  _intsi_f2 = config.get_int("IntSI_F2");
 | 
						|
  _intsi_m = config.get_int("IntSI_M");
 | 
						|
  _intaf_m = config.get_int("IntAF_M");
 | 
						|
  add_cursor(new TCursor(_rel, "", 3));
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
bool TIntegrita::user_destroy()
 | 
						|
{
 | 
						|
	delete _sidoneita;
 | 
						|
	delete _scontrolli;
 | 
						|
	delete _sdonazioni;
 | 
						|
	delete _idoneita;
 | 
						|
	delete _contsan;
 | 
						|
	delete _donaz;	
 | 
						|
	delete _rel;
 | 
						|
	delete _msk;
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
int at8500(int argc, char* argv[])
 | 
						|
{
 | 
						|
  TIntegrita a;
 | 
						|
  a.run(argc, argv, "Verifica integrita' dati");
 | 
						|
  return 0;
 | 
						|
}
 |