Files correlati : ve6.exe Ricompilazione Demo : [ ] Commento : Riportata la versione 3.1 patch 979 git-svn-id: svn://10.65.10.50/trunk@15623 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			158 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			158 lines
		
	
	
		
			3.6 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| // 775100.cpp - Gestione archivio percipienti
 | |
| #include <relapp.h> 
 | |
| 
 | |
| #include "77lib.h"
 | |
| #include "775100a.h"
 | |
| 
 | |
| class TGestionePercipienti : public TRelation_application
 | |
| {
 | |
|   private:
 | |
|     TRelation*          _rel;
 | |
|     TMask*              _msk;
 | |
|     long				_codditta;
 | |
|     char				_tipoa;
 | |
|     long				_codanagr;  
 | |
|     bool				_auto_posiz, _deleted;
 | |
|     int					_anno_dic;
 | |
|   protected:
 | |
|     virtual void	on_config_change();
 | |
|     virtual void	init_query_mode(TMask& m);
 | |
|     virtual void	init_modify_mode(TMask& m);
 | |
|     void 			init_mask(TMask& m);
 | |
|     virtual bool 	user_create();
 | |
|     virtual bool 	user_destroy();  
 | |
|     virtual TRelation*   get_relation() const { return _rel; }
 | |
|     virtual TMask*       get_mask(int mode)   { return _msk; }
 | |
|     virtual bool         changing_mask(int mode) { return FALSE; }
 | |
|     virtual bool	remove();
 | |
|     static  bool		codditta_handler(TMask_field& f, KEY k);
 | |
|   public:
 | |
|     TGestionePercipienti(const long codditta=0L, const char tipoa='\0', const long codanagr=0L);
 | |
|     virtual ~TGestionePercipienti() {};    
 | |
| };
 | |
| 
 | |
| inline TGestionePercipienti& app() { return (TGestionePercipienti&) main_app(); }
 | |
| 
 | |
| bool TGestionePercipienti::remove()
 | |
| {
 | |
|   bool ok1 = FALSE, ok2 = FALSE, ha_schede = FALSE;
 | |
|   int err;
 | |
|   TPercipiente perc(_rel->curr());                
 | |
|   
 | |
|   ha_schede = perc.esiste_scheda();
 | |
|   if (ha_schede)
 | |
|     ok1 = yesno_box("Esistono in archivio delle schede riguardanti il percipiente selezionato\nEliminare ugualmente?");  
 | |
|   if (!ok1)
 | |
|     return TRUE;
 | |
|   err = _rel->remove();
 | |
| 
 | |
| // Non ri-compilare i dati in init_query_mode()
 | |
|   _deleted = TRUE;
 | |
| 
 | |
|   if (err != NOERR) 
 | |
|     return TRUE;
 | |
|   if (ha_schede)
 | |
|   {
 | |
|     ok2 = yesno_box("Eliminare anche le schede collegate?");
 | |
|     err = perc.elimina_schede();
 | |
|   }
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| void TGestionePercipienti::init_mask(TMask& m)
 | |
| { 
 | |
|   TString16 tipo;
 | |
|   m.set(F_ANNODIC, _anno_dic);  
 | |
|   tipo << _tipoa; 
 | |
|   m.set(F_TIPOA, tipo);
 | |
| }
 | |
| 
 | |
| void TGestionePercipienti::init_query_mode(TMask& m)
 | |
| {
 | |
|   init_mask(m);
 | |
|   if (_auto_posiz && !_deleted) 
 | |
|   {
 | |
|     TString16 dit, tipo, coda;
 | |
|     dit << _codditta;
 | |
|     tipo << _tipoa;
 | |
|     coda << _codanagr;
 | |
|     m.set(F_CODDITTA, dit);
 | |
|     m.set(F_TIPOA,    tipo);
 | |
|     m.set(F_CODANAGR, coda);
 | |
|     m.send_key(K_AUTO_ENTER, 0);
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TGestionePercipienti::init_modify_mode(TMask& m)
 | |
| {
 | |
|   init_mask(m);
 | |
| }
 | |
| 
 | |
| TGestionePercipienti::TGestionePercipienti(const long codditta, const char tipoa, const long codanagr)
 | |
|  : _codditta(codditta), _tipoa(tipoa), _codanagr(codanagr), _auto_posiz(FALSE)
 | |
| {
 | |
|   _auto_posiz = _codanagr != 0L;
 | |
|   _deleted    = FALSE;
 | |
| }
 | |
| 
 | |
| void TGestionePercipienti::on_config_change()
 | |
| {
 | |
|   TConfig conf(CONFIG_STUDIO);
 | |
|   _anno_dic = (int)conf.get_long(ANNO_SEL, NULL); 
 | |
| }
 | |
| 
 | |
| bool TGestionePercipienti::codditta_handler(TMask_field& f, KEY k)
 | |
| {         
 | |
|   if (k == K_TAB && !(f.mask().is_running()) )
 | |
|   {
 | |
|     TString16 codditta; codditta << app()._codditta;
 | |
|     if (codditta != "0")        
 | |
|     {
 | |
|       f.set(codditta);
 | |
|       f.check();
 | |
|     }
 | |
|   }   
 | |
|   return TRUE;                                           
 | |
| }
 | |
| 
 | |
| bool TGestionePercipienti::user_create()
 | |
| {
 | |
|   _rel  = new TRelation(LF_PERC);
 | |
|   _msk  = new TMask("775100a");
 | |
| 
 | |
|   if (!_auto_posiz) 
 | |
|     _codditta = get_firm_770();
 | |
| 
 | |
|   _msk->set_handler(F_CODDITTA, codditta_handler);  
 | |
|   set_search_field(F_CODANAGR);
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TGestionePercipienti::user_destroy()
 | |
| {
 | |
|   delete _rel; delete _msk;
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| // 775 -0 10001 F 10
 | |
| int GestPerc(int argc, char* argv[])
 | |
| { 
 | |
|   long codditta = 0L;
 | |
|   char tipoa = 'F';
 | |
|   long codanagr = 0L;
 | |
|     
 | |
|   if (argc >= 5)   
 | |
|   {
 | |
|     codditta = atol(argv[2]);
 | |
|     tipoa    = *argv[3];
 | |
|     codanagr = atol(argv[4]); 
 | |
|   }
 | |
|   
 | |
|   TGestionePercipienti a(codditta, tipoa, codanagr);
 | |
|   a.run(argc, argv, "Gestione percipienti");
 | |
|   return 0;
 | |
| }
 | |
| 
 | |
| 
 | |
| 
 |