117 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			117 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <mask.h>
 | 
						|
#include <printapp.h>
 | 
						|
#include <tabutil.h>
 | 
						|
#include <utility.h>
 | 
						|
 | 
						|
#include "at7.h"
 | 
						|
#include "lf.h"				// se non lo metto non riesco a usare gli LF
 | 
						|
 | 
						|
// nomi dei campi
 | 
						|
#include "soggetti.h"
 | 
						|
 | 
						|
#define ALIAS_LCPD	100
 | 
						|
#define ALIAS_LCPR	200
 | 
						|
#define ALIAS_COMD	300
 | 
						|
#define ALIAS_COMR	400
 | 
						|
class TCAP_app : public TPrintapp
 | 
						|
{
 | 
						|
	TMask*						_msk;
 | 
						|
	TRelation*   			_rel;
 | 
						|
	int 							_cur;	
 | 
						|
 | 
						|
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);
 | 
						|
	
 | 
						|
public:
 | 
						|
	TCAP_app() {}
 | 
						|
};
 | 
						|
 | 
						|
HIDDEN inline TCAP_app& app() { return (TCAP_app&) main_app(); }
 | 
						|
 | 
						|
bool TCAP_app::preprocess_page(int file, int counter)
 | 
						|
{ 
 | 
						|
	bool rew = FALSE;
 | 
						|
	TString16 cap;
 | 
						|
	TString16 loc;
 | 
						|
	TString16 com;
 | 
						|
	TRectype& recsog = current_cursor()->curr();
 | 
						|
	cap = recsog.get(SOG_DOM_CAP);
 | 
						|
	com = recsog.get(SOG_DOM_CODCOM);
 | 
						|
	if (cap.empty() && com.not_empty())
 | 
						|
	{
 | 
						|
		loc = recsog.get(SOG_DOM_CODLOC);
 | 
						|
		if (loc.empty())
 | 
						|
			cap = current_cursor()->file(-ALIAS_COMD).get("CAPCOM");
 | 
						|
		else
 | 
						|
			cap = current_cursor()->file(-ALIAS_LCPD).get("S6");	
 | 
						|
		recsog.put(SOG_DOM_CAP, cap);
 | 
						|
		rew = TRUE;
 | 
						|
	}
 | 
						|
	cap = recsog.get(SOG_RES_CAP);
 | 
						|
	com = recsog.get(SOG_RES_CODCOM);
 | 
						|
	if (cap.empty() && com.not_empty())		
 | 
						|
	{
 | 
						|
		loc = recsog.get(SOG_RES_CODLOC);
 | 
						|
		if (loc.empty())
 | 
						|
			cap = current_cursor()->file(-ALIAS_COMR).get("CAPCOM");
 | 
						|
		else
 | 
						|
			cap = current_cursor()->file(-ALIAS_LCPR).get("S6");	
 | 
						|
		recsog.put(SOG_RES_CAP, cap);
 | 
						|
		rew = TRUE;
 | 
						|
	}		
 | 
						|
	if (rew)
 | 
						|
		current_cursor()->file().rewrite();
 | 
						|
  return rew;
 | 
						|
}
 | 
						|
 | 
						|
void TCAP_app::set_page(int file, int cnt)
 | 
						|
{ 
 | 
						|
	set_row(1,"@0g@pn", FLD(LF_SOGGETTI,SOG_CODICE,"########"));
 | 
						|
	set_row(1,"@10g@S", FLD(LF_SOGGETTI,SOG_COGNOME));
 | 
						|
	set_row(1,"@36g@S", FLD(LF_SOGGETTI,SOG_NOME));
 | 
						|
}
 | 
						|
 | 
						|
bool TCAP_app::set_print(int)
 | 
						|
{
 | 
						|
  KEY tasto;
 | 
						|
  tasto = _msk->run();
 | 
						|
	if (tasto == K_ENTER)
 | 
						|
	{  	 
 | 
						|
    reset_files(); 
 | 
						|
    add_file(LF_SOGGETTI);
 | 
						|
		reset_print();		
 | 
						|
    return TRUE;
 | 
						|
  }
 | 
						|
  else
 | 
						|
    return FALSE;
 | 
						|
}
 | 
						|
 | 
						|
bool TCAP_app::user_create()
 | 
						|
{
 | 
						|
	_msk = new TMask("at7100a");
 | 
						|
	_rel = new TRelation(LF_SOGGETTI);
 | 
						|
  _rel->add("LCP", "CODTAB==DOM_CODLOC",1,0,ALIAS_LCPD);
 | 
						|
  _rel->add(LF_COMUNI, "COM==DOM_CODCOM",1,0,ALIAS_COMD);
 | 
						|
  _rel->add("LCP", "CODTAB==RES_CODLOC",1,0,ALIAS_LCPR);
 | 
						|
  _rel->add(LF_COMUNI, "COM==RES_CODCOM",1,0,ALIAS_COMR);
 | 
						|
  _cur = add_cursor(new TCursor(_rel, "", 3));	//cursore ordinamento per sezione+sottogruppo+codice
 | 
						|
	return TRUE;
 | 
						|
}	
 | 
						|
 | 
						|
bool TCAP_app::user_destroy()	
 | 
						|
{
 | 
						|
	delete _rel;
 | 
						|
	delete _msk;
 | 
						|
	return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
int at7100(int argc, char* argv[])
 | 
						|
{
 | 
						|
	TCAP_app a;
 | 
						|
	a.run(argc, argv, "Aggiornamento CAP su indirizzi");
 | 
						|
	return 0;
 | 
						|
} |