Files correlati : Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/trunk@18941 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			230 lines
		
	
	
		
			6.3 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			230 lines
		
	
	
		
			6.3 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <applicat.h>
 | 
						|
#include <mask.h>
 | 
						|
#include <progind.h>
 | 
						|
#include <relation.h>
 | 
						|
#include <tabutil.h>
 | 
						|
#include <urldefid.h>
 | 
						|
 | 
						|
#include "at9.h"
 | 
						|
 | 
						|
#include "atlib.h"
 | 
						|
          
 | 
						|
// nomi dei campi
 | 
						|
#include "soggetti.h"
 | 
						|
#include "donaz.h"
 | 
						|
#include "contsan.h"
 | 
						|
#include "idoneita.h"
 | 
						|
#include "rconvoc.h"
 | 
						|
 | 
						|
class TReconstruction : public TApplication
 | 
						|
{
 | 
						|
	TMask*					_msk;
 | 
						|
	TRelation*   		_rel;
 | 
						|
 | 
						|
  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;
 | 
						|
	
 | 
						|
	
 | 
						|
protected:
 | 
						|
	virtual bool create();
 | 
						|
	virtual bool destroy();
 | 
						|
  virtual bool menu(MENU_TAG m);
 | 
						|
	virtual TMask& get_mask() { return *_msk; }
 | 
						|
	virtual TRelation* get_relation() const { return _rel; }
 | 
						|
	
 | 
						|
	int write(TSheet_field& s);
 | 
						|
 | 
						|
public:
 | 
						|
	TReconstruction() {}
 | 
						|
	
 | 
						|
};
 | 
						|
 | 
						|
HIDDEN inline TReconstruction& app() { return (TReconstruction&) main_app(); }
 | 
						|
 | 
						|
bool TReconstruction::create()
 | 
						|
{
 | 
						|
	TApplication::create();
 | 
						|
	_msk = new TMask("at9400a");
 | 
						|
	_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");
 | 
						|
  dispatch_e_menu(BAR_ITEM_ID(1));
 | 
						|
	return true;
 | 
						|
}	
 | 
						|
 | 
						|
bool TReconstruction::destroy()	
 | 
						|
{                          
 | 
						|
	delete _sidoneita;
 | 
						|
	delete _scontrolli;
 | 
						|
	delete _sdonazioni;
 | 
						|
	delete _idoneita;
 | 
						|
	delete _contsan;
 | 
						|
	delete _donaz;	
 | 
						|
	delete _rel;
 | 
						|
	delete _msk;
 | 
						|
	return TApplication::destroy();
 | 
						|
}
 | 
						|
 | 
						|
static int compare_date(const TObject** o1, const TObject** o2)
 | 
						|
{
 | 
						|
  const TRectype& s1 = *((TRectype*)*o1);
 | 
						|
  const TRectype& s2 = *((TRectype*)*o2);
 | 
						|
  
 | 
						|
  const TDate d1(s1.get(IDO_DATAIDO));
 | 
						|
  const TDate d2(s2.get(IDO_DATAIDO));
 | 
						|
  
 | 
						|
  int d=0;
 | 
						|
  if (d1>d2) d=+1;
 | 
						|
  else
 | 
						|
  	if (d1<d2) d=-1;
 | 
						|
	return d;
 | 
						|
}	
 | 
						|
 | 
						|
bool TReconstruction::menu(MENU_TAG m)
 | 
						|
{                         
 | 
						|
	bool _calcolacat = false;
 | 
						|
	
 | 
						|
 	KEY tasto = _msk->run();
 | 
						|
 	if (tasto == K_ENTER)
 | 
						|
 	{
 | 
						|
		TLocalisamfile rconvoc(LF_RCONVOC);
 | 
						|
		_rel->lfile().setkey(1);
 | 
						|
		bool modificato = false;
 | 
						|
		TDate oggi(TODAY);
 | 
						|
		TRectype& recsog = _rel->curr();
 | 
						|
  	TProgind pi(_rel->items(),"Aggiornamento situazione soggetti da appoggio", true, true, 10);
 | 
						|
  	pi.setstatus(1);
 | 
						|
  	for (_rel->first(); _rel->ok(); _rel->next())
 | 
						|
  	{
 | 
						|
   	  pi.addstatus(1);
 | 
						|
   	  if (pi.iscancelled()) break;
 | 
						|
			const long codsog = recsog.get_long("CODICE");	  	             
 | 
						|
			TRectype* keyd = new TRectype(LF_DONAZ);
 | 
						|
			keyd->put(DON_CODICE, codsog);
 | 
						|
			int err = _sdonazioni->read(keyd);
 | 
						|
			calcola_donazioni_lib(recsog, _sdonazioni);
 | 
						|
			_sdonazioni->rewrite();
 | 
						|
			recsog.rewrite(_rel->lfile());
 | 
						|
			TRectype* key = new TRectype(LF_IDONEITA);
 | 
						|
			key->put(IDO_CODICE, recsog.get(SOG_CODICE));
 | 
						|
			err = _sidoneita->read(key);
 | 
						|
			_sidoneita->sort(compare_date);				
 | 
						|
			_sidoneita->rewrite();
 | 
						|
			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());
 | 
						|
			}	
 | 
						|
			if (_calcolacat)
 | 
						|
			{
 | 
						|
				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);
 | 
						|
						catdon = _catfin1;
 | 
						|
					}	
 | 
						|
					const 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;
 | 
						|
					}	
 | 
						|
				}	
 | 
						|
			}
 | 
						|
			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())
 | 
						|
			{
 | 
						|
				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, oggi);
 | 
						|
      recsog.put(SOG_UTENULTAGG, "CONVE");
 | 
						|
			recsog.rewrite(_rel->lfile());
 | 
						|
		}
 | 
						|
 	}
 | 
						|
  return false;
 | 
						|
}  
 | 
						|
 | 
						|
int TReconstruction::write(TSheet_field& s)
 | 
						|
{ 
 | 
						|
	return NOERR;	
 | 
						|
}
 | 
						|
 | 
						|
		
 | 
						|
int at9400(int argc, char* argv[])
 | 
						|
{
 | 
						|
	TReconstruction a;
 | 
						|
	a.run(argc, argv, "Aggiornamento situazione soggetti");
 | 
						|
	return 0;
 | 
						|
}
 |