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
		
			
				
	
	
		
			807 lines
		
	
	
		
			19 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			807 lines
		
	
	
		
			19 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| // 771100.cpp - Manutenzione dati anagrafici
 | |
| //
 | |
| // 771mod -0 A  : "Dichiarante"
 | |
| // 771mod -0 C  : "Rappresentante"
 | |
| // 771mod -0 D  : "Scritture contabili"
 | |
| // 771mod -0 E  : "Dati C.A.A.F."
 | |
| // 771mod -0 F  : "Direttore / Professionista"
 | |
| // 771mod -0 G  : "Concessione / UIDD"
 | |
| //
 | |
| // Lista modifiche:
 | |
| //
 | |
| // 1.4.96 Rappresentante: codice e carica rappr. non vengono piu' registrati
 | |
| //          su NDITTE ma bensi' su BASE
 | |
| //
 | |
| #include <printapp.h>
 | |
| #include <defmask.h>
 | |
| #include <mailbox.h>
 | |
| #include <execp.h>
 | |
| 
 | |
| #include "771.h"
 | |
| #include "771100.h"
 | |
| #include "77lib.h"
 | |
|  
 | |
| #include "../ba/ba4200.h"
 | |
| #include "../ba/ba4300.h"  // per il f_coddittah
 | |
| #include "../ba/ba4500.h"
 | |
| 
 | |
| #include <comuni.h>
 | |
| #include <anagr.h>
 | |
| #include <nditte.h>
 | |
| 
 | |
| class TDati_anagrafici : public TSkeleton_application
 | |
| {
 | |
|   private:
 | |
|     static bool indirizzo (TMask_field&, KEY);
 | |
|     static bool cod_conc  (TMask_field&, KEY);
 | |
|     static bool niscraa   (TMask_field&, KEY);
 | |
|     static bool ditta_caaf(TMask_field&, KEY);
 | |
|     static bool attivita_handler(TMask_field&, KEY);
 | |
|     static bool fisica_handler(TMask_field&, KEY);
 | |
|     static bool giuridica_handler(TMask_field&, KEY);
 | |
|     static bool anagrafica_handler(TMask_field&, KEY);  
 | |
|     static bool anagr_dich_handler(TMask_field&, KEY);
 | |
|                
 | |
| // bottone ditta in DatiCAAF
 | |
|     static bool DCditta_handler(TMask_field&, KEY);            
 | |
|     TMask*      _msk;  
 | |
|     TRelation*  _rel;            
 | |
|     char        _ana;
 | |
|     long        _codditta;
 | |
|     bool Dichiarante()        const { return _ana == 'A'; }
 | |
|     bool Rappresentante()     const { return _ana == 'C'; }
 | |
|     bool ScrittureContabili() const { return _ana == 'D'; }
 | |
|     bool DatiCAAF()           const { return _ana == 'E'; }        
 | |
|     bool DirProf()            const { return _ana == 'F'; }        
 | |
|     bool ConcUIDD()           const { return _ana == 'G'; }            
 | |
|   public:
 | |
|     TString     _titolo;
 | |
|     virtual bool create();
 | |
|     virtual bool destroy();
 | |
|     virtual void main_loop();
 | |
|     KEY       registra(TMask& m, bool check_dirty);
 | |
|     void      registra_fis_giu();
 | |
|     void      registra_rappr();  
 | |
|     void      registra_caaf();    
 | |
|     void      registra_dirprof();  
 | |
|     void      registra_dativari(); 
 | |
|     static bool codditta_hnd(TMask_field& f, KEY k);
 | |
|     TDati_anagrafici(char anagrafica);
 | |
| };
 | |
| 
 | |
| TDati_anagrafici::TDati_anagrafici(char anagrafica) : _titolo(50), _ana(toupper(anagrafica))
 | |
| {
 | |
|   if (Dichiarante())
 | |
|     _titolo = "Dichiarante";
 | |
| 
 | |
|   if (Rappresentante())      
 | |
|     _titolo = "Rappresentante";
 | |
|     
 | |
|   if (ScrittureContabili()) 
 | |
|     _titolo = "Scritture contabili";
 | |
|     
 | |
|   if (DatiCAAF())
 | |
|     _titolo = "Dati C.A.A.";
 | |
|     
 | |
|   if (DirProf())
 | |
|     _titolo = "Direttore / Professionista";
 | |
|     
 | |
|   if (ConcUIDD()) 
 | |
|     _titolo = "Concessione / UIDD";    
 | |
| }
 | |
| 
 | |
| HIDDEN TDati_anagrafici& app() { return (TDati_anagrafici &) main_app(); }
 | |
| 
 | |
| 
 | |
| bool TDati_anagrafici::codditta_hnd(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 TDati_anagrafici::attivita_handler(TMask_field& m, KEY k)
 | |
| {
 | |
|   if (k != K_SPACE)
 | |
|     return TRUE;
 | |
|     
 | |
|   app().registra(m.mask(),FALSE);
 | |
|   m.mask().stop_run(K_ESC);
 | |
|   
 | |
|   TString appname;
 | |
| 
 | |
|   appname = "ba4 -4";
 | |
| 
 | |
|   TString body(16);
 | |
| 
 | |
|   body << "1" << "|";
 | |
|   body << m.mask().get(F_CODDITTA) << "|";
 | |
|   body << m.mask().get(F_ATTIV) << "|";
 | |
|   body << m.mask().get(F_ATTIV);
 | |
| 
 | |
|   TMessage msg(appname, MSG_LN, (const char*) body);
 | |
|   msg.send();                                     
 | |
|   
 | |
|   TExternal_app a(appname);
 | |
|   a.run(); 
 | |
|   
 | |
|   m.set_focus();
 | |
|   xvtil_statbar_set("");  
 | |
| 
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TDati_anagrafici::DCditta_handler(TMask_field& f, KEY k)
 | |
| {
 | |
|   if (k != K_SPACE)
 | |
|     return TRUE;
 | |
|   else
 | |
|   {
 | |
|     TMask& m = f.mask();
 | |
|     app().registra(m, FALSE);
 | |
|     m.stop_run(K_ESC);
 | |
|     const long lDittaCaaf = m.get_long(F_DITTACAAF);
 | |
|     TToken_string body(16);                
 | |
|     body.add("1");        // usa la chiave 1
 | |
|     body.add(lDittaCaaf); // ditta per il campo codice ditta 
 | |
|     body.add(lDittaCaaf); // ditta per il secondo campo codice ditta 
 | |
|     TString16 cmd("ba4 -2");
 | |
|     TMessage msg(cmd, MSG_LN, (const char*) body);
 | |
|     msg.send();
 | |
|     TExternal_app a(cmd);
 | |
|     a.run();
 | |
|     m.set_focus(); 
 | |
|     xvtil_statbar_set("");    
 | |
|   }
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TDati_anagrafici::fisica_handler(TMask_field& m, KEY k)
 | |
| {       
 | |
|   if (k != K_SPACE)
 | |
|     return TRUE;
 | |
|   
 | |
|   app().registra(m.mask(),FALSE);
 | |
|   m.mask().stop_run(K_ESC);
 | |
| 
 | |
|   TToken_string body(16);
 | |
| 
 | |
|   body << "1" << "|";
 | |
|   body << m.mask().get(F_ANAGR);
 | |
| 
 | |
|   TString16 cmd ("ba4 -1 F");
 | |
|       
 | |
|   TMessage  msg(cmd, MSG_LN, (const char*) body);
 | |
|   TMailbox mb;
 | |
|   mb.send(msg);
 | |
|   
 | |
|   TExternal_app a(cmd);
 | |
|   a.run();
 | |
|   m.set_focus();                 
 | |
|   xvtil_statbar_set("");
 | |
|   
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| bool TDati_anagrafici::giuridica_handler(TMask_field& m, KEY k)
 | |
| {       
 | |
|   if (k != K_SPACE)
 | |
|     return TRUE;
 | |
|   
 | |
|   app().registra(m.mask(),FALSE);
 | |
|   m.mask().stop_run(K_ESC);
 | |
| 
 | |
|   TToken_string body(16);
 | |
| 
 | |
|   body << "1" << "|";
 | |
|   body << m.mask().get(F_ANAGR);
 | |
|   
 | |
|   TString16 cmd ("ba4 -1 G");
 | |
|       
 | |
|   TMessage  msg(cmd, MSG_LN, (const char*) body);
 | |
|   TMailbox mb;
 | |
|   mb.send(msg);
 | |
| 
 | |
|   TExternal_app a(cmd);
 | |
|   a.run();
 | |
|   m.set_focus();                   
 | |
|   xvtil_statbar_set("");           
 | |
|   
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| bool TDati_anagrafici::anagrafica_handler(TMask_field& m, KEY k)
 | |
| {  
 | |
|   TString16 cmd;
 | |
|      
 | |
|   if (k != K_SPACE)
 | |
|     return TRUE;
 | |
|   
 | |
|   app().registra(m.mask(),FALSE);
 | |
|   m.mask().stop_run(K_ESC);
 | |
| 
 | |
|   TToken_string body(16);
 | |
| 
 | |
|   body << "1" << "|";
 | |
|   body << m.mask().get(F_ANAGR);
 | |
|   
 | |
|   char tipoa = m.mask().get(ASCF_TIPOA)[0];
 | |
|   
 | |
|   if (tipoa == 'F')
 | |
|     cmd = "ba4 -1 F";
 | |
|   else
 | |
|     if (tipoa == 'G')
 | |
|       cmd = "ba4 -1 G";
 | |
|       
 | |
|   TMessage  msg(cmd, MSG_LN, (const char*) body);
 | |
|   TMailbox mb;
 | |
|   mb.send(msg);
 | |
|   
 | |
|   TExternal_app a(cmd);
 | |
|   a.run();
 | |
|   m.set_focus();           
 | |
|   xvtil_statbar_set("");
 | |
|   
 | |
|   return FALSE;
 | |
| }  
 | |
| 
 | |
| bool TDati_anagrafici::anagr_dich_handler(TMask_field& m, KEY k)
 | |
| {  
 | |
|   TString16 cmd;
 | |
|      
 | |
|   if (k != K_SPACE)
 | |
|     return TRUE;
 | |
|   
 | |
|   app().registra(m.mask(),FALSE);
 | |
|   m.mask().stop_run(K_ESC);
 | |
| 
 | |
|   TToken_string body(16);
 | |
| 
 | |
|   body << "1" << "|";
 | |
|   body << m.mask().get(F_ANAGR);
 | |
|   
 | |
|   char tipoa = m.mask().get(F_TIPOA)[0];
 | |
|   
 | |
|   if (tipoa == 'F')
 | |
|     cmd = "ba4 -1 F";
 | |
|   else
 | |
|     if (tipoa == 'G')
 | |
|       cmd = "ba4 -1 G";
 | |
|       
 | |
|   TMessage  msg(cmd, MSG_LN, (const char*) body);
 | |
|   TMailbox mb;
 | |
|   mb.send(msg);
 | |
|   
 | |
|   TExternal_app a(cmd);
 | |
|   a.run();
 | |
|   m.set_focus();           
 | |
|   xvtil_statbar_set("");
 | |
| 
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| bool TDati_anagrafici::indirizzo (TMask_field& f, KEY k)
 | |
| {                                          
 | |
|   TLocalisamfile anag (LF_ANAG);
 | |
|   TLocalisamfile comuni (LF_COMUNI);
 | |
|   long    codanagr;
 | |
|   char    tipoa;
 | |
|   TString ragione,nome,cognome,ind,civ,cap,com,prov,codcom;
 | |
|   
 | |
|   if (k == K_TAB)
 | |
|   {           
 | |
|     tipoa    = f.mask().get     (ASCF_TIPOA)[0];
 | |
|     codanagr = f.mask().get_long(F_ANAGR);
 | |
|     
 | |
| // Ricerca sull'archivio anagrafiche dei dati relativi al depositario
 | |
|     anag.setkey(1);
 | |
|     anag.zero();
 | |
|     anag.put("TIPOA",    tipoa);
 | |
|     anag.put("CODANAGR", codanagr);
 | |
|     if (anag.read() == NOERR)
 | |
|     {  
 | |
|       ragione   = anag.get("RAGSOC");
 | |
|       codcom    = anag.get("COMRF");
 | |
|       
 | |
|       if (codcom != "")
 | |
|       {
 | |
|         ind    = anag.get("INDRF");
 | |
|         civ    = anag.get("CIVRF");
 | |
|         cap    = anag.get("CAPRF");
 | |
|       }        
 | |
|       else
 | |
|       {
 | |
|         ind    = anag.get("INDRES");
 | |
|         civ    = anag.get("CIVRES");
 | |
|         cap    = anag.get("CAPRES");
 | |
|         codcom = anag.get("COMRES");
 | |
|       }
 | |
|     }                                      
 | |
|     
 | |
|     if (tipoa == 'F')
 | |
|     { 
 | |
|       cognome = ragione.mid(0,30);
 | |
|       nome    = ragione.mid(30,20);
 | |
|       f.mask().hide(F_RAGIONE);
 | |
|       f.mask().show(F_COGNOME);
 | |
|       f.mask().show(F_NOME);       
 | |
|       f.mask().set(F_COGNOME, cognome);
 | |
|       f.mask().set(F_NOME,    nome);
 | |
|     }                       
 | |
|     else
 | |
|       if (tipoa == 'G')
 | |
|       {
 | |
|         f.mask().hide(F_COGNOME);
 | |
|         f.mask().hide(F_NOME);
 | |
|         f.mask().show(F_RAGIONE);   
 | |
|         f.mask().set(F_RAGIONE, ragione);
 | |
|       }                                  
 | |
|       
 | |
|     // Ricerca dati relativi al comune del depositario
 | |
|     
 | |
|     comuni.setkey(1);
 | |
|     comuni.zero();
 | |
|     comuni.put("STATO", "");
 | |
|     comuni.put("COM",   codcom);
 | |
|     if (comuni.read() == NOERR)
 | |
|     {
 | |
|       com  = comuni.get("DENCOM");
 | |
|       prov = comuni.get("PROVCOM");
 | |
|     }                              
 | |
|     
 | |
|     f.mask().set(F_IND,  ind);
 | |
|     f.mask().set(F_CIV,  civ);
 | |
|     f.mask().set(F_CAP,  cap);
 | |
|     f.mask().set(F_COM,  com);
 | |
|     f.mask().set(F_PROV, prov);
 | |
|   }     
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TDati_anagrafici::cod_conc (TMask_field& f, KEY k)
 | |
| {                                          
 | |
|   TLocalisamfile anag (LF_ANAG);
 | |
|   TLocalisamfile comuni (LF_COMUNI);
 | |
|   long    codanagr;
 | |
|   char    tipoa;
 | |
|   int     codconc,uffiidd,codcs;        
 | |
|   TString codcom;
 | |
|   
 | |
|   if ( k == K_TAB )// && f.mask().is_running() )
 | |
|   {           
 | |
|     tipoa    = f.mask().get     (F_TIPOA)[0];
 | |
|     codanagr = f.mask().get_long(F_ANAGR);  
 | |
| 
 | |
| // Setta il prompt del button di uscita sull'anagrafica del dichiarante
 | |
| //    if (tipoa == 'G')
 | |
| //      f.mask().field(F_ANAGR_DICH).set_prompt("Giuridiche");
 | |
| //    if (tipoa == 'F')
 | |
| //      f.mask().field(F_ANAGR_DICH).set_prompt("Fisiche");     
 | |
|     
 | |
| // Ricerca sull'archivio anagrafiche dei dati 
 | |
|     anag.setkey(1);
 | |
|     anag.zero();
 | |
|     anag.put("TIPOA",    tipoa);
 | |
|     anag.put("CODANAGR", codanagr);
 | |
|     if (anag.read() == NOERR)
 | |
|     {  
 | |
|       codcom = anag.get("COMRF");
 | |
|             
 | |
|       if (codcom == "")
 | |
|         codcom = anag.get("COMRES");
 | |
|     }                                      
 | |
|     
 | |
| // Ricerca dati relativi al comune 
 | |
|     comuni.setkey(1);
 | |
|     comuni.zero();
 | |
|     comuni.put("STATO", "");
 | |
|     comuni.put("COM",   codcom);
 | |
|     if (comuni.read() == NOERR)
 | |
|     {
 | |
|       codconc  = comuni.get_int("UFFCONC");
 | |
|       uffiidd  = comuni.get_int("UFFIIDD1");
 | |
|       codcs = comuni.get_int("UFFCSERV");
 | |
|       
 | |
|       if (uffiidd == 0)
 | |
|         uffiidd = comuni.get_int("UFFIIDD2");
 | |
|       
 | |
|       if (uffiidd == 0)
 | |
|         uffiidd = comuni.get_int("UFFIIDD3");
 | |
|       
 | |
|       if (codconc != 0)
 | |
|         f.mask().set(F_CODCONC1, codconc);
 | |
|       if (uffiidd != 0)  
 | |
|         f.mask().set(F_CODUI,    uffiidd);
 | |
|       if (codcs != 0)  
 | |
|         f.mask().set(F_CODCS,    codcs);  
 | |
| 
 | |
|       f.mask().check_field(F_CODCS);
 | |
|       f.mask().check_field(F_CODUI);
 | |
|     }
 | |
|   }     
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| 
 | |
| bool TDati_anagrafici::niscraa(TMask_field& f, KEY k)
 | |
| {
 | |
|   if (k == K_TAB && !f.mask().is_running())
 | |
|   {
 | |
|     TLocalisamfile base (LF_BASE);
 | |
|     TLocalisamfile ditte(LF_NDITTE);
 | |
|     TString16 niscraa   = "";
 | |
|     long      dittacaaf = 0;
 | |
|                                    
 | |
|     long codditta = f.mask().get_long(F_CODDITTA);                              
 | |
|     
 | |
|     base.setkey(1);
 | |
|     base.zero();
 | |
|     base.put("CODDITTA", codditta);               
 | |
|     if (base.read() == NOERR)
 | |
|     {
 | |
|       dittacaaf = base.get_long("DITTACAAF");
 | |
|       
 | |
|       ditte.setkey(1);
 | |
|       ditte.zero();
 | |
|       ditte.put(NDT_CODDITTA, dittacaaf);
 | |
|       if (ditte.read() == NOERR)
 | |
|         niscraa = ditte.get(NDT_NISCRAA);
 | |
|     }                                    
 | |
|     f.mask().set(F_NISCRAA, niscraa);
 | |
|     if (dittacaaf != 0)
 | |
|       f.mask().set(F_DITTACAAF, dittacaaf);
 | |
|   }
 | |
|   return TRUE;
 | |
| }
 | |
|                                        
 | |
| bool TDati_anagrafici::ditta_caaf(TMask_field& f, KEY k)
 | |
| {
 | |
|   if (k == K_TAB || k == K_ENTER)
 | |
|   {
 | |
|     long caaf  = f.mask().get_long(F_ANAGR);
 | |
|     long ditta = atol(f.get());
 | |
|     
 | |
|     if (caaf == 0 && ditta != 0)
 | |
|       return f.warning_box("Se non indicato il codice del CAAF la ditta non deve essere indicata");
 | |
|       
 | |
|     if (caaf != 0 && ditta == 0)
 | |
|       return f.warning_box("Se indicato il codice del CAAF deve essere indicata anche la ditta a cui e' collegato");
 | |
|   }
 | |
|   return TRUE;
 | |
| }
 | |
|                                        
 | |
| bool TDati_anagrafici::create()
 | |
| {
 | |
|   _msk = NULL; 
 | |
|   
 | |
|   _rel = new TRelation (LF_NDITTE);
 | |
|   _rel->add(LF_BASE,    "CODDITTA=CODDITTA");
 | |
|   _rel->add(LF_BASEBIS, "CODDITTA=CODDITTA");
 | |
| 
 | |
|   _codditta = get_firm_770();
 | |
|   
 | |
|   if (Dichiarante())
 | |
|   {                        
 | |
|     char tipo_pers = tipo_persona(_codditta);
 | |
|     if (tipo_pers == ' ' || tipo_pers == '\0')
 | |
|     {
 | |
|       message_box("Il titolare della ditta non e' stato compilato correttamente.");
 | |
|       return TRUE;
 | |
|     }   
 | |
|     if (tipo_pers == 'G')
 | |
|     {
 | |
|       _msk = new TMask ("771100b");
 | |
|       _msk->set_handler(F_GIURIDICA, giuridica_handler);
 | |
|     }    
 | |
|     else
 | |
|       if (tipo_pers == 'F')
 | |
|       {
 | |
|         _msk = new TMask ("771100a");
 | |
|         _msk->set_handler(F_FISICA, fisica_handler);   
 | |
|       }                                              
 | |
|     _msk->set_handler(F_ATTIVITA,  attivita_handler);
 | |
|   }
 | |
| 
 | |
|   if (Rappresentante())      
 | |
|   {
 | |
|     _msk = new TMask ("771100c");
 | |
|     _msk->set_handler(F_FISICA, fisica_handler);      
 | |
| 
 | |
|   }
 | |
|     
 | |
|   if (ScrittureContabili()) 
 | |
|   {
 | |
|     _msk = new TMask ("771100d");                
 | |
|     _msk->set_handler(F_ANAGR,    indirizzo);
 | |
|     _msk->set_handler(F_ATTIVITA, attivita_handler);
 | |
|     _msk->set_handler(F_FISICA,   anagrafica_handler);
 | |
|     _msk->set_handler(F_GIURIDICA,anagrafica_handler);
 | |
|     _msk->disable(DLG_SAVEREC);
 | |
|     _msk->disable(DLG_CANCEL);
 | |
|   }
 | |
|     
 | |
|   if (DatiCAAF())
 | |
|   {
 | |
|     _msk = new TMask ("771100e");                
 | |
|     _msk->set_handler(F_ANAGR,     niscraa);
 | |
|     _msk->set_handler(F_GIURIDICA, giuridica_handler);
 | |
|     _msk->set_handler(F_DITTACAAF, ditta_caaf);
 | |
|     _msk->set_handler(DCF_DITTA,   DCditta_handler);
 | |
|   }
 | |
|     
 | |
|   if (DirProf())
 | |
|   {
 | |
|     _msk = new TMask ("771100f");                
 | |
|     _msk->set_handler(F_FISICA, fisica_handler);
 | |
|   }
 | |
|     
 | |
|   if (ConcUIDD()) 
 | |
|   {
 | |
|     _msk = new TMask ("771100g");                
 | |
|     _msk->field(F_CODCONC2).set_dirty();
 | |
|     _msk->set_handler(F_CODCONC2, cod_conc);               
 | |
|     _msk->set_handler(F_BTN_GIURIDICA, anagr_dich_handler); 
 | |
|     _msk->set_handler(F_BTN_FISICA, anagr_dich_handler);
 | |
|   }
 | |
| 
 | |
|   if (_msk)
 | |
|   {
 | |
|     _msk->set_mode(MODE_MOD);
 | |
|     TString16 codditta; codditta << _codditta;
 | |
|     if (codditta != "0")        
 | |
|       _msk->set(F_CODDITTA,codditta);
 | |
|       
 | |
|     return TSkeleton_application::create();
 | |
|   }
 | |
|   return FALSE;  
 | |
| }
 | |
| 
 | |
| bool TDati_anagrafici::destroy()
 | |
| {   
 | |
|   delete _msk;     
 | |
|   delete _rel;
 | |
|   return TApplication::destroy();
 | |
| }
 | |
| 
 | |
| void TDati_anagrafici::main_loop()
 | |
| {
 | |
|   KEY tasto = K_ESC;
 | |
|   _msk->open_modal();  
 | |
|         
 | |
|   while (tasto != K_QUIT) 
 | |
|   {                     
 | |
|     _rel->lfile().put("CODDITTA", _codditta);
 | |
|     _rel->read();
 | |
|     _msk->autoload(*_rel); 
 | |
|     
 | |
|     // controllo se indicato rappresentante
 | |
|     if (Rappresentante() && (_msk->get_long(F_ANAGR) == 0L))
 | |
|       message_box("Il rappresentante non e' stato indicato.");
 | |
|   
 | |
|     tasto = _msk->run();
 | |
|     
 | |
|     switch (tasto)
 | |
|     {
 | |
|       case K_ESC :
 | |
|         break;
 | |
|       case K_QUIT :           
 | |
|         if (registra(*_msk,TRUE) == K_ESC)
 | |
|           tasto = K_ESC;
 | |
|         break;       
 | |
|       case K_SAVE :
 | |
|         registra(*_msk,FALSE);
 | |
|         break;
 | |
|       default:
 | |
|         break;
 | |
|     }
 | |
|   }
 | |
|   
 | |
|   _msk->close_modal();
 | |
| }
 | |
|                      
 | |
| KEY TDati_anagrafici::registra(TMask& m, bool check_dirty)
 | |
| {
 | |
|   KEY k = K_YES;
 | |
|   
 | |
|   if (check_dirty && m.dirty())                   
 | |
|     k = yesnocancel_box("Registrare le modifiche?");
 | |
| 
 | |
|   if (k == K_YES) 
 | |
|   { 
 | |
|     if (_ana == 'A' || _ana == 'B')
 | |
|       registra_fis_giu();          
 | |
|     
 | |
|     if (_ana == 'C') 
 | |
|       registra_rappr();    
 | |
|     
 | |
|     if (_ana == 'E')
 | |
|       registra_caaf();       
 | |
|     
 | |
|     if (_ana == 'F')
 | |
|       registra_dirprof();       
 | |
|     
 | |
|     if (_ana == 'G')
 | |
|       registra_dativari(); 
 | |
|   }
 | |
|   
 | |
|   return k;       
 | |
| }
 | |
|                        
 | |
| void TDati_anagrafici::registra_fis_giu()
 | |
| { 
 | |
|   TLocalisamfile base(LF_BASE);
 | |
|   long codditta;
 | |
|   
 | |
|   codditta = _msk->get_long(F_CODDITTA);
 | |
|   
 | |
|   base.setkey(1);
 | |
|   base.zero();
 | |
|   base.put("CODDITTA", codditta);
 | |
|   if (base.read() == NOERR)
 | |
|   {
 | |
|     int rss = _msk->get_int(F_RSS);
 | |
|     base.put("RSS", rss);
 | |
|     base.rewrite();
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     int rss = _msk->get_int(F_RSS); 
 | |
|     base.zero();
 | |
|     base.put("CODDITTA", codditta);
 | |
|     base.put("RSS",      rss);
 | |
|     base.write();
 | |
|   }
 | |
| }
 | |
|                      
 | |
| void TDati_anagrafici::registra_rappr()
 | |
| {
 | |
|   TLocalisamfile base(LF_BASE);
 | |
|   const long codditta    = _msk->get_long(F_CODDITTA);
 | |
|   const long CodiceRappr = _msk->get_long(F_ANAGR);
 | |
|   const int CaricaRappr  = _msk->get_int(F_CARRAP);
 | |
|   
 | |
|   base.setkey(1);
 | |
|   base.zero();
 | |
|   base.put("CODDITTA", codditta);
 | |
|   if (base.read() == NOERR)
 | |
|   {
 | |
|     base.put("RAPPR",   CodiceRappr);
 | |
|     base.put("CARRAPP", CaricaRappr);
 | |
|     base.rewrite();
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     base.zero();
 | |
|     base.put("RAPPR",   CodiceRappr);
 | |
|     base.put("CARRAPP", CaricaRappr);
 | |
|     base.write();
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TDati_anagrafici::registra_caaf()
 | |
| {
 | |
|   TLocalisamfile ditte(LF_NDITTE);      
 | |
|   TLocalisamfile base (LF_BASE);        
 | |
|   long codditta;
 | |
|   char tipoa = 'G';
 | |
|   
 | |
| // Registro il codice caaf sull'archivio base
 | |
|   codditta  = _msk->get_long(F_CODDITTA);
 | |
|   
 | |
|   base.setkey(1);
 | |
|   base.zero();
 | |
|   base.put("CODDITTA", codditta);
 | |
|   if (base.read() == NOERR)
 | |
|   {
 | |
|     long codice    = _msk->get_long(F_ANAGR);
 | |
|     long dittacaaf = _msk->get_long(F_DITTACAAF);
 | |
|     
 | |
|     base.put("CODCAAF",   codice);          
 | |
|     base.put("DITTACAAF", dittacaaf);
 | |
|     base.rewrite();
 | |
|   }       
 | |
|   else          
 | |
|   {
 | |
|     long codice    = _msk->get_long(F_ANAGR);
 | |
|     long dittacaaf = _msk->get_long(F_DITTACAAF);
 | |
|     
 | |
|     base.zero();
 | |
|     base.put("CODDITTA",  codditta);
 | |
|     base.put("CODCAAF",   codice);     
 | |
|     base.put("DITTACAAF", dittacaaf);
 | |
|     base.write();
 | |
|   }
 | |
| } 
 | |
|           
 | |
| void TDati_anagrafici::registra_dirprof()
 | |
| {
 | |
|   TLocalisamfile base (LF_BASE);
 | |
|   long codditta;
 | |
|   
 | |
|   codditta = _msk->get_long(F_CODDITTA);
 | |
|   
 | |
|   base.setkey(1);
 | |
|   base.zero();
 | |
|   base.put("CODDITTA", codditta);
 | |
|   if (base.read() == NOERR)
 | |
|   {
 | |
|     long codpro = _msk->get_long(F_ANAGR);
 | |
|     bool flart4 = _msk->get_bool(F_CONTROLLI);
 | |
|     
 | |
|     base.put("CODPRO", codpro);
 | |
|     base.put("FLART4", flart4);
 | |
|     base.rewrite();
 | |
|   }       
 | |
|   else
 | |
|   {
 | |
|     long codpro = _msk->get_long(F_ANAGR);
 | |
|     bool flart4 = _msk->get_bool(F_CONTROLLI);
 | |
|     
 | |
|     base.zero();
 | |
|     base.put("CODDITTA", codditta);
 | |
|     base.put("CODPRO",   codpro);
 | |
|     base.put("FLART4",   flart4);
 | |
|     base.write();
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TDati_anagrafici::registra_dativari()
 | |
| { 
 | |
|   TLocalisamfile base(LF_BASEBIS);
 | |
|   long codditta;
 | |
|   
 | |
|   codditta = _msk->get_long(F_CODDITTA);
 | |
|   
 | |
|   base.setkey(1);
 | |
|   base.zero();
 | |
|   base.put("CODDITTA", codditta);
 | |
|   if (base.read() == NOERR)
 | |
|   { 
 | |
|     TString16 codconc1(_msk->get(F_CODCONC1));
 | |
|     TString16 codconc2(_msk->get(F_CODCONC2));
 | |
|     TString16 codconc3(_msk->get(F_CODCONC3));
 | |
|     int codtes1  = _msk->get_int(F_CODTES1);
 | |
|     int codtes2  = _msk->get_int(F_CODTES2);
 | |
|     int codtes3  = _msk->get_int(F_CODTES3);
 | |
|     base.put("L0CCONC1", codconc1);
 | |
|     base.put("L0CCONC2", codconc2);
 | |
|     base.put("L0CCONC3", codconc3);
 | |
|     base.put("L0CTES1", codtes1);
 | |
|     base.put("L0CTES2", codtes2);
 | |
|     base.put("L0CTES3", codtes3);
 | |
|     base.rewrite();
 | |
|   }      
 | |
|   else
 | |
|   { 
 | |
|     TString16 codconc1(_msk->get(F_CODCONC1));
 | |
|     TString16 codconc2(_msk->get(F_CODCONC2));
 | |
|     TString16 codconc3(_msk->get_int(F_CODCONC3));
 | |
|     int codtes1  = _msk->get_int(F_CODTES1);
 | |
|     int codtes2  = _msk->get_int(F_CODTES2);
 | |
|     int codtes3  = _msk->get_int(F_CODTES3);
 | |
|     base.zero();
 | |
|     base.put("CODDITTA", codditta);
 | |
|     base.put("L0CCONC1", codconc1);
 | |
|     base.put("L0CCONC2", codconc2);
 | |
|     base.put("L0CCONC3", codconc3);
 | |
|     base.put("L0CTES1", codtes1);
 | |
|     base.put("L0CTES2", codtes2);
 | |
|     base.put("L0CTES3", codtes3);
 | |
|     base.write();
 | |
|   }
 | |
| }
 | |
|           
 | |
| int m71100 (int argc, char* argv[])
 | |
| {                                
 | |
|   TDati_anagrafici main_app(*argv[2]);
 | |
|   main_app.run(argc, argv, main_app._titolo);
 | |
|   return TRUE;
 | |
| }
 |