Files correlati : Ricompilazione Demo : [ ] Commento : 0000830: schermate da allineare Descrizione i bottoni sono ancora vecchio stile, in fondo alla videate in: ricerca soci, stampe anagrafiche, stampa codici iva, stampa codici attività, tutte le stampe tabelle ministeriali,visualizzazione liquidazione richiesta parametri. git-svn-id: svn://10.65.10.50/trunk@17596 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			599 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			599 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <defmask.h>
 | 
						|
#include <execp.h>
 | 
						|
#include <golem.h>
 | 
						|
#include <mailbox.h>
 | 
						|
#include <recarray.h>
 | 
						|
#include <relapp.h>
 | 
						|
#include <validate.h>
 | 
						|
 | 
						|
#include "ba4.h"
 | 
						|
#include "ba4200.h"
 | 
						|
 | 
						|
#define FLD_GD1_TIPOA     126
 | 
						|
#define FLD_GD1_CODANAGR  127
 | 
						|
#define FLD_GD1_CODDITTAH 627
 | 
						|
 | 
						|
class TPersone_app : public TRelation_application
 | 
						|
{
 | 
						|
  char _tip_ana;
 | 
						|
  bool _reset_uff_conc;          
 | 
						|
  char _next_ana;
 | 
						|
  bool _reset_codreg;
 | 
						|
  TString16  _cod_ana;
 | 
						|
  TMask*     _msk[2];
 | 
						|
  TRelation* _rel[2];
 | 
						|
 | 
						|
protected:
 | 
						|
  virtual bool user_create() ;
 | 
						|
  virtual bool user_destroy() ;
 | 
						|
  virtual int read(TMask& m);
 | 
						|
  virtual int rewrite(const TMask& m);
 | 
						|
  virtual void  init_query_mode(TMask& m);
 | 
						|
  virtual void  init_insert_mode(TMask& m);
 | 
						|
  virtual void  init_modify_mode(TMask& m);
 | 
						|
  virtual bool changing_mask(int mode) {return _tip_ana != _next_ana;}
 | 
						|
  virtual bool get_next_key(TToken_string& key);
 | 
						|
  virtual TMask* get_mask(int mode) ;
 | 
						|
  virtual void write_enable(bool on = TRUE);
 | 
						|
  
 | 
						|
  static bool email_handler(TMask_field& f, KEY k);
 | 
						|
  static bool ba4200_handler(TMask& m, KEY k);
 | 
						|
  
 | 
						|
public:
 | 
						|
  virtual int write(const TMask& m);
 | 
						|
  virtual TRelation* get_relation() const { return _rel[tip_msk()];}
 | 
						|
  void manual_save(const TMask& m);
 | 
						|
  int tip_msk() const { return _tip_ana == TFIS ? MSKF : MSKG;}
 | 
						|
  bool ana_fis() const { return _tip_ana == TFIS;}
 | 
						|
  bool ana_giu() const { return _tip_ana == TGIU;}
 | 
						|
  void set_tip_ana(char tip) { _tip_ana = _next_ana = toupper(tip);}
 | 
						|
  void set_next_ana(char tip) { _next_ana = toupper(tip);}
 | 
						|
  void set_cod_ana(const char* cod) { _cod_ana = cod;}
 | 
						|
  const char* cod_ana() const { return _cod_ana;}
 | 
						|
  char tip_ana() const { return _tip_ana;}
 | 
						|
  virtual bool has_filtered_cursor() const { return TRUE;}
 | 
						|
  void set_reset_uff_conc(bool reset) { _reset_uff_conc = reset; }
 | 
						|
  void set_reset_codreg(bool reset) { _reset_codreg = reset; }
 | 
						|
 | 
						|
  TPersone_app(char ta) : _reset_uff_conc(FALSE), _reset_codreg(FALSE) { set_tip_ana(ta); }
 | 
						|
  virtual ~TPersone_app() {}
 | 
						|
};
 | 
						|
 | 
						|
bool TPersone_app::ba4200_handler(TMask& m, KEY k)
 | 
						|
{
 | 
						|
  TPersone_app& app = (TPersone_app&)main_app();
 | 
						|
 | 
						|
  if (k != K_F5 || m.mode() != MODE_MOD) 
 | 
						|
    return TRUE;
 | 
						|
  
 | 
						|
  TToken_string body;
 | 
						|
  body.add(FLD_GD1_CODDITTAH);
 | 
						|
 | 
						|
  body.add(FLD_GD1_TIPOA);
 | 
						|
  body << '=' << app.tip_ana();
 | 
						|
 | 
						|
  body.add(FLD_GD1_CODANAGR);
 | 
						|
  body << '=' << app.cod_ana();
 | 
						|
 | 
						|
  const char* const cmd = "ba4 -2";
 | 
						|
  TMessage msg(cmd, MSG_FS, body);
 | 
						|
  msg.send();
 | 
						|
  TExternal_app a(cmd);
 | 
						|
  a.run();
 | 
						|
  m.set_focus();
 | 
						|
  return FALSE;
 | 
						|
}
 | 
						|
 | 
						|
bool TPersone_app::email_handler(TMask_field& f, KEY k)
 | 
						|
{           
 | 
						|
  if (k == K_SPACE)
 | 
						|
  {                                     
 | 
						|
    TMail_message msg(f.mask().get(F_MAIL));
 | 
						|
    msg.send();
 | 
						|
  }
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
void TPersone_app::init_query_mode(TMask& m)
 | 
						|
 | 
						|
{
 | 
						|
  m.disable(DLG_DITTE);
 | 
						|
}
 | 
						|
 | 
						|
bool TPersone_app::get_next_key(TToken_string& key)
 | 
						|
{
 | 
						|
  TLocalisamfile& anag = get_relation()->lfile() ;
 | 
						|
  long cod_anagr = 1;
 | 
						|
 | 
						|
  if (!anag.empty() )
 | 
						|
  {
 | 
						|
    anag.zero() ;
 | 
						|
    anag.setkey(1) ;
 | 
						|
    if (ana_fis())
 | 
						|
    {
 | 
						|
      anag.put(N_TIPOA, TGIU);
 | 
						|
      anag.read(_isgteq) ;
 | 
						|
      if (anag.good()) anag.prev();
 | 
						|
      const char t_ret = anag.get_char(N_TIPOA);
 | 
						|
      if ( t_ret == TFIS ) 
 | 
						|
        cod_anagr = anag.get_long(N_CODANAGR)+1;
 | 
						|
    }
 | 
						|
    else
 | 
						|
    {
 | 
						|
      anag.last( ) ;
 | 
						|
      if (anag.good())
 | 
						|
      {
 | 
						|
        const char t_ret = anag.get_char(N_TIPOA);
 | 
						|
        if ( t_ret == TGIU ) 
 | 
						|
          cod_anagr = anag.get_long(N_CODANAGR)+1;
 | 
						|
      }
 | 
						|
    }
 | 
						|
  }
 | 
						|
  _cod_ana.format("%ld", cod_anagr);
 | 
						|
  key.format("%d|%ld", FLD_CODANAGR, cod_anagr);
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
void  TPersone_app::init_insert_mode(TMask& m)
 | 
						|
{
 | 
						|
  m.disable(DLG_DITTE);
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
void  TPersone_app::init_modify_mode(TMask& m)
 | 
						|
{
 | 
						|
  m.enable(DLG_DITTE);
 | 
						|
}
 | 
						|
 | 
						|
HIDDEN bool stato_hnd(TMask_field& f, KEY key)
 | 
						|
{
 | 
						|
  if (f.get().empty())
 | 
						|
    f.mask().set(FLD_AF1_STATONASC_TABSTE_S0, TR("Italiana"));
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
HIDDEN bool clear_cap(TMask_field& f, KEY key)
 | 
						|
{                     
 | 
						|
  if (f.mask().query_mode()) 
 | 
						|
    return TRUE;
 | 
						|
 | 
						|
  TMask& msk = f.mask() ;
 | 
						|
  const short   dlg = f.dlg();
 | 
						|
 | 
						|
  if (dlg != FLD_AG2_COMRES && dlg != FLD_AF1_COMRES && !f.to_check(key, TRUE)) 
 | 
						|
    return TRUE;
 | 
						|
 | 
						|
  const TString16 val(f.get());
 | 
						|
  const bool giuridica = ((TPersone_app&)main_app()).ana_giu();
 | 
						|
 | 
						|
  if ( giuridica )
 | 
						|
  {
 | 
						|
    if (val.empty())
 | 
						|
    {
 | 
						|
      if (dlg == FLD_AG1_COMRF)
 | 
						|
        msk.set(FLD_AG1_CAPRF, "");
 | 
						|
      else
 | 
						|
        if (dlg == FLD_AG2_COMRES)
 | 
						|
          msk.set(FLD_AG2_CAPRES, "");
 | 
						|
        else
 | 
						|
          if (dlg == FLD_AG2_COMCORR)
 | 
						|
            msk.set(FLD_AG2_CAPCORR, "");
 | 
						|
    }
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
    if (val.empty())
 | 
						|
    {
 | 
						|
      if (dlg == FLD_AF2_COMRF)
 | 
						|
        msk.set(FLD_AF2_CAPRF, "");
 | 
						|
      else
 | 
						|
        if (dlg == FLD_AF1_COMRES)
 | 
						|
          msk.set(FLD_ANAG_CAPRES, "");
 | 
						|
        else
 | 
						|
          if (dlg == FLD_AF2_COMCORR)
 | 
						|
            msk.set(FLD_AF2_CAPCORR, "");
 | 
						|
    }
 | 
						|
  }  
 | 
						|
  return TRUE; 
 | 
						|
} 
 | 
						|
 | 
						|
 | 
						|
// Handler del comunde di residenza e residenza fiscale                                            
 | 
						|
bool gest_uff_imp(TMask_field& f, KEY key)
 | 
						|
{
 | 
						|
  if (f.mask().query_mode()) 
 | 
						|
    return TRUE;
 | 
						|
 | 
						|
  TMask& msk = f.mask() ;
 | 
						|
  const short   dlg = f.dlg();
 | 
						|
  const bool giuridica = ((TPersone_app&)main_app()).ana_giu();
 | 
						|
 | 
						|
  if (giuridica && dlg == FLD_AG2_COMRES)
 | 
						|
    clear_cap(f,key);
 | 
						|
 | 
						|
  if (!giuridica && dlg == FLD_AF1_COMRES)
 | 
						|
    clear_cap(f,key);
 | 
						|
 | 
						|
  if (!f.to_check(key, TRUE)) 
 | 
						|
    return TRUE;
 | 
						|
 | 
						|
  TString8 cod_com;
 | 
						|
 | 
						|
  if ( giuridica )
 | 
						|
  {
 | 
						|
    cod_com = msk.get(FLD_AG1_COMRF);
 | 
						|
    if (dlg == FLD_AG2_COMRES)
 | 
						|
      if (cod_com.not_empty()) return TRUE;
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
    cod_com = msk.get(FLD_AF2_COMRF);
 | 
						|
    if (dlg == FLD_AF1_COMRES)
 | 
						|
      if (cod_com.not_empty()) return TRUE;
 | 
						|
  }
 | 
						|
  clear_cap(f,key);
 | 
						|
  if (cod_com.empty())
 | 
						|
    cod_com = msk.get(giuridica ? FLD_AG2_COMRES : FLD_AF1_COMRES) ;
 | 
						|
  
 | 
						|
  if (cod_com.empty())
 | 
						|
    return TRUE;                                   
 | 
						|
 | 
						|
	TString8 cod("|"); cod<< cod_com;
 | 
						|
 | 
						|
  const TRectype & comune = cache().get(LF_COMUNI, cod);
 | 
						|
 | 
						|
	msk.set(F_IMP_DENCOM, comune.get("DENCOM"));
 | 
						|
  msk.set(F_IMP_PROVCOM, comune.get("PROVCOM"));
 | 
						|
  msk.set(F_UFFUUE, comune.get("CODUUE1"));
 | 
						|
  msk.check_field(F_UFFUUE);      
 | 
						|
 | 
						|
  TString80 s(comune.get(N_IMPDIR1)) ; 
 | 
						|
  if (s.empty()) s = comune.get(N_IMPDIR2) ; 
 | 
						|
  if (s.empty()) s = comune.get(N_IMPDIR3) ; 
 | 
						|
  if (msk.get(F_UFFIIDD).empty() || msk.is_running()) 
 | 
						|
  {
 | 
						|
    msk.set(F_UFFIIDD, s);
 | 
						|
    msk.check_field(F_UFFIIDD);      
 | 
						|
  }
 | 
						|
 | 
						|
  s = comune.get(N_IVA1); 
 | 
						|
  if (s.empty()) s = comune.get(N_IVA2) ; 
 | 
						|
  if (s.empty()) s = comune.get(N_IVA3) ; 
 | 
						|
  if (msk.get(F_UFFIVA).empty() || msk.is_running()) 
 | 
						|
  {
 | 
						|
    msk.set(F_UFFIVA, s);
 | 
						|
    msk.check_field(F_UFFIVA);
 | 
						|
  }
 | 
						|
  msk.set(F_UFFREG, comune.get("UFFREG"));
 | 
						|
  msk.check_field(F_UFFREG);
 | 
						|
  if (msk.get_bool(F_TITCF))
 | 
						|
  {
 | 
						|
    if (msk.get(F_UFFCONC).empty() || msk.is_running()) 
 | 
						|
      msk.set(F_UFFCONC, comune.get("UFFCONC")); 
 | 
						|
    msk.set(F_CONFIS, msk.get(giuridica ? FLD_AG1_COFI : FLD_AF1_COFI)); 
 | 
						|
  } 
 | 
						|
  const bool fisica = ! giuridica;
 | 
						|
  if (fisica && (msk.get(F_CODREG96).empty() || msk.is_running()))
 | 
						|
  {
 | 
						|
    msk.set(F_CODREG96, comune.get("CODREG")); 
 | 
						|
    msk.check_field(F_CODREG96);
 | 
						|
  }
 | 
						|
  msk.set(F_UFFCONC_P, comune.get("UFFCONC"));
 | 
						|
  msk.check_field(F_UFFCONC_P);
 | 
						|
 | 
						|
  msk.set(F_UFFSERV, comune.get("UFFCSERV"));
 | 
						|
  msk.check_field(F_UFFSERV);
 | 
						|
 | 
						|
  msk.set(F_CODCONTR_EP, comune.get("UFFESPROV").mid(1, 2));
 | 
						|
  msk.set(F_CODCONTR_EC, comune.get("UFFESCOM"));
 | 
						|
  
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
// Handler del titolare conto fiscale                                           
 | 
						|
bool tit_cf(TMask_field& f, KEY key)
 | 
						|
{ 
 | 
						|
  if (key == K_SPACE && f.mask().get_bool(F_TITCF))
 | 
						|
  {
 | 
						|
    TMask& msk = f.mask() ;   
 | 
						|
    TPersone_app& app = (TPersone_app&)main_app();
 | 
						|
    const bool giuridica = app.ana_giu();
 | 
						|
    TString16  cod_com(msk.get(giuridica ? FLD_AG1_COMRF : FLD_AF2_COMRF));
 | 
						|
    
 | 
						|
    if (cod_com.empty())
 | 
						|
      cod_com = msk.get(giuridica ? FLD_AG2_COMRES : FLD_AF1_COMRES) ;
 | 
						|
    
 | 
						|
    if (cod_com.not_empty())
 | 
						|
    { 
 | 
						|
			TString16 key("|"); key << cod_com;
 | 
						|
		  const TRectype & comune = cache().get(LF_COMUNI, key);
 | 
						|
 | 
						|
        if (msk.get(F_UFFCONC).empty() || msk.is_running()) 
 | 
						|
          msk.set(F_UFFCONC, comune.get("UFFCONC")); 
 | 
						|
    } 
 | 
						|
    msk.set(F_CONFIS, msk.get(giuridica ? FLD_AG1_COFI : FLD_AF1_COFI)); 
 | 
						|
  }
 | 
						|
  return TRUE;          
 | 
						|
}
 | 
						|
 | 
						|
// Handler dell'ufficio concessione                                           
 | 
						|
bool uff_conc(TMask_field& f, KEY key)
 | 
						|
{     
 | 
						|
  if (f.mask().query_mode()) 
 | 
						|
    return TRUE;
 | 
						|
  
 | 
						|
  if (key == K_ENTER)
 | 
						|
  {
 | 
						|
    TMask& msk = f.mask() ;   
 | 
						|
    TPersone_app& app = (TPersone_app&)main_app();
 | 
						|
    const bool giuridica = app.ana_giu();
 | 
						|
    TString16  cod_com(msk.get(giuridica ? FLD_AG1_COMRF : FLD_AF2_COMRF));
 | 
						|
    
 | 
						|
    if (cod_com.empty())
 | 
						|
      cod_com = msk.get(giuridica ? FLD_AG2_COMRES : FLD_AF1_COMRES) ;
 | 
						|
    
 | 
						|
    if (cod_com.not_empty())
 | 
						|
    { 
 | 
						|
			TString16 key("|"); key << cod_com;
 | 
						|
		  const TRectype & comune = cache().get(LF_COMUNI, key);
 | 
						|
 | 
						|
      app.set_reset_uff_conc((!comune.empty()) && msk.get(F_UFFCONC) == comune.get("UFFCONC"));
 | 
						|
    } 
 | 
						|
  } 
 | 
						|
  return TRUE;
 | 
						|
}        
 | 
						|
 | 
						|
// Handler dell'codice regione                                          
 | 
						|
bool cod_reg(TMask_field& f, KEY key)
 | 
						|
{     
 | 
						|
  if (f.mask().query_mode()) 
 | 
						|
    return TRUE;
 | 
						|
  
 | 
						|
  if (key == K_ENTER)
 | 
						|
  {
 | 
						|
    TMask& msk = f.mask() ;   
 | 
						|
    TPersone_app& app = (TPersone_app&)main_app();
 | 
						|
    const bool giuridica = app.ana_giu();
 | 
						|
    TString16  cod_com(msk.get(giuridica ? FLD_AG1_COMRF : FLD_AF2_COMRF));
 | 
						|
    
 | 
						|
    if (cod_com.empty())
 | 
						|
      cod_com = msk.get(giuridica ? FLD_AG2_COMRES : FLD_AF1_COMRES) ;
 | 
						|
    
 | 
						|
    if (cod_com.not_empty() && !msk.field(F_CODREG96).empty())
 | 
						|
    { 
 | 
						|
			TString16 key("|"); key << cod_com;
 | 
						|
		  const TRectype & comune = cache().get(LF_COMUNI, key);
 | 
						|
      app.set_reset_codreg(msk.get(F_CODREG96) == comune.get("CODREG"));
 | 
						|
    } 
 | 
						|
  } 
 | 
						|
  return TRUE;
 | 
						|
}        
 | 
						|
 | 
						|
bool no_dup_fis(TMask_field& f, KEY key)
 | 
						|
{
 | 
						|
  if (f.mask().query_mode() || !f.to_check(key)) return TRUE;
 | 
						|
  TPersone_app& app = (TPersone_app&)main_app();
 | 
						|
  TLocalisamfile&       anag = app.get_relation()->lfile(LF_ANAG) ;
 | 
						|
  
 | 
						|
  const TString16 cofi(f.get());                     
 | 
						|
  if ( cofi.not_empty() )
 | 
						|
  { 
 | 
						|
    anag.zero() ;
 | 
						|
    anag.put(N_TIPOA, app.tip_ana());
 | 
						|
    anag.put(N_COFI, cofi ) ;
 | 
						|
    anag.setkey(3) ;
 | 
						|
    anag.read() ;
 | 
						|
    anag.setkey(1) ;
 | 
						|
    const char t = anag.get_char(N_TIPOA), t1 = app.tip_ana();
 | 
						|
    const TString16     s = anag.get(N_CODANAGR), s1 = app.cod_ana();
 | 
						|
 | 
						|
    if (anag.good() && (t1 != t || s1 != s))
 | 
						|
      f.message_box(FR("Codice fiscale gia' utilizzato per il codice %c/%s"),
 | 
						|
                    t, (const char*)s);
 | 
						|
  }
 | 
						|
  return TRUE ;
 | 
						|
}
 | 
						|
 | 
						|
bool gest_iva(TMask_field& f, KEY key , short   fd_sta ,short fd_iva )
 | 
						|
{
 | 
						|
  if (f.mask().query_mode() || !f.to_check(key)) return TRUE;
 | 
						|
  
 | 
						|
  TPersone_app& app = (TPersone_app&)main_app();
 | 
						|
  TLocalisamfile&       anag = app.get_relation()->lfile(LF_ANAG) ;
 | 
						|
  TMask& msk = f.mask() ;
 | 
						|
 | 
						|
  if ( f.get().not_empty() && !anag.empty() )
 | 
						|
  {
 | 
						|
    anag.zero() ;        
 | 
						|
    anag.put(N_TIPOA, app.tip_ana());
 | 
						|
    anag.put(N_STATOPAIV, msk.get(fd_sta) ) ;
 | 
						|
    anag.put(N_PAIV, msk.get(fd_iva) ) ;
 | 
						|
    anag.setkey(4) ;
 | 
						|
    anag.read() ;
 | 
						|
    anag.setkey(1) ;
 | 
						|
    const char t  = anag.get_char(N_TIPOA), t1 = app.tip_ana();
 | 
						|
    const TFixed_string s(anag.get(N_CODANAGR)),        s1(app.cod_ana());
 | 
						|
    if (anag.good() && (t1 != t || s1 != s))
 | 
						|
      f.message_box(FR("Partita iva gia' definita per il codice : %c/%s"),
 | 
						|
                    t, (const char*) s);
 | 
						|
  }
 | 
						|
  return TRUE ;
 | 
						|
}
 | 
						|
 | 
						|
bool no_dup_iva_f(TMask_field& f, KEY key)
 | 
						|
 | 
						|
{
 | 
						|
  if (f.mask().query_mode() || !f.to_check(key)) return TRUE;
 | 
						|
  return ( gest_iva(f , key , FLD_AF1_STATOPAIV ,FLD_AF1_PAIV ) ) ;
 | 
						|
}
 | 
						|
 | 
						|
bool no_dup_iva_g(TMask_field& f, KEY key)
 | 
						|
{ 
 | 
						|
  if (key == K_ENTER && !f.mask().query_mode() && f.get().empty())
 | 
						|
  {                                    
 | 
						|
    bool ok = FALSE;   
 | 
						|
    if (!f.mask().get_bool(CHK_AG1_ENTENCOMM))
 | 
						|
    {
 | 
						|
      const TString cofi(f.mask().get(FLD_AG1_COFI));
 | 
						|
      if (pi_check("IT", cofi)) 
 | 
						|
      {
 | 
						|
        f.set(cofi);
 | 
						|
        ok = TRUE;
 | 
						|
      }  
 | 
						|
    }
 | 
						|
    if (!ok) return error_box(TR("Partita IVA obbligatoria!"));
 | 
						|
  }
 | 
						|
 | 
						|
  return gest_iva(f , key , FLD_AG1_STATOPAIV ,FLD_AG1_PAIV ) ;
 | 
						|
}
 | 
						|
 | 
						|
TMask* TPersone_app::get_mask(int mode)
 | 
						|
{  
 | 
						|
  set_tip_ana(_next_ana);
 | 
						|
  if (ana_fis() && _msk[MSKF] == NULL)
 | 
						|
  { 
 | 
						|
    _msk[MSKF] = new TMask("ba4200b") ;
 | 
						|
    _msk[MSKF]->set_handler(F_STATO, stato_hnd);
 | 
						|
    _msk[MSKF]->set_handler(FLD_AF1_PAIV, no_dup_iva_f);
 | 
						|
    _msk[MSKF]->set_handler(FLD_AF1_COFI, no_dup_fis);
 | 
						|
    _msk[MSKF]->set_handler(FLD_AF1_COMRES, gest_uff_imp);
 | 
						|
    _msk[MSKF]->set_handler(FLD_AF2_COMRF, gest_uff_imp);
 | 
						|
    _msk[MSKF]->set_handler(FLD_AF2_COMCORR, clear_cap);
 | 
						|
    _msk[MSKF]->set_handler(F_UFFCONC, uff_conc);
 | 
						|
    _msk[MSKF]->set_handler(F_CODREG96, cod_reg);
 | 
						|
    _msk[MSKF]->set_handler(F_TITCF, tit_cf);
 | 
						|
    _msk[MSKF]->set_handler(DLG_EMAIL, email_handler);
 | 
						|
 | 
						|
    _msk[MSKF]->set_handler(ba4200_handler);
 | 
						|
  }
 | 
						|
  else
 | 
						|
    if (ana_giu() && _msk[MSKG] == NULL)
 | 
						|
    {
 | 
						|
      _msk[MSKG] = new TMask("ba4200c") ;
 | 
						|
      _msk[MSKG]->set_handler(FLD_AG2_COMRES, gest_uff_imp);
 | 
						|
      _msk[MSKG]->set_handler(FLD_AG1_COMRF, gest_uff_imp);
 | 
						|
      _msk[MSKG]->set_handler(FLD_AG2_COMCORR, clear_cap);
 | 
						|
      _msk[MSKG]->set_handler(FLD_AG1_PAIV, no_dup_iva_g);
 | 
						|
      _msk[MSKG]->set_handler(F_UFFCONC, uff_conc);
 | 
						|
      _msk[MSKG]->set_handler(F_TITCF, tit_cf);
 | 
						|
      _msk[MSKG]->set_handler(DLG_EMAIL, email_handler);
 | 
						|
 | 
						|
      _msk[MSKG]->set_handler(ba4200_handler);
 | 
						|
    }
 | 
						|
    
 | 
						|
  return _msk[tip_msk()];
 | 
						|
}
 | 
						|
 | 
						|
bool TPersone_app::user_create() 
 | 
						|
{
 | 
						|
  open_files(LF_COMUNI, LF_ANAG, LF_ANAGFIS, LF_ANAGGIU, LF_TABCOM, 0) ;
 | 
						|
  
 | 
						|
	_msk[MSKF] = NULL;
 | 
						|
  _rel[MSKF] = new TRelation(LF_ANAG);
 | 
						|
  _rel[MSKF]->add(LF_ANAGFIS, "CODANAGR=CODANAGR", 1);
 | 
						|
 | 
						|
  _msk[MSKG] = NULL;
 | 
						|
  _rel[MSKG] = new TRelation(LF_ANAG);
 | 
						|
  _rel[MSKG]->add(LF_ANAGGIU, "CODANAGR=CODANAGR", 1);
 | 
						|
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
void TPersone_app::write_enable(bool on)
 | 
						|
{
 | 
						|
  _rel[MSKF]->write_enable(0, on);
 | 
						|
  _rel[MSKG]->write_enable(0, on);
 | 
						|
}
 | 
						|
 | 
						|
bool TPersone_app::user_destroy() 
 | 
						|
{
 | 
						|
  for (int j = 1; j >= 0; j--)
 | 
						|
  {
 | 
						|
    if (_msk[j]) delete _msk[j] ;
 | 
						|
    if (_rel[j]) delete _rel[j] ;
 | 
						|
  }
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
void TPersone_app::manual_save(const TMask& m)
 | 
						|
 | 
						|
{
 | 
						|
  TRelation *r = get_relation();
 | 
						|
  TLocalisamfile& anag = r->lfile(LF_ANAG) ;
 | 
						|
 | 
						|
  if (ana_fis())
 | 
						|
  {
 | 
						|
    TLocalisamfile&     anafis = r->lfile(LF_ANAGFIS) ;
 | 
						|
 | 
						|
    anafis.put(N_CODANAGR, _cod_ana);
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
    TLocalisamfile&     anagiu = r->lfile(LF_ANAGGIU) ;
 | 
						|
    anagiu.put(N_CODANAGR, _cod_ana);
 | 
						|
  }
 | 
						|
 | 
						|
  const TDate   oggi(TODAY) ;
 | 
						|
  anag.put(N_DATAAGG, oggi.string());
 | 
						|
}
 | 
						|
 | 
						|
int TPersone_app::read(TMask& m) 
 | 
						|
 | 
						|
{
 | 
						|
  const TRelation & r = *get_relation();
 | 
						|
  m.autoload(r);
 | 
						|
  _cod_ana = r.lfile().get(N_CODANAGR);
 | 
						|
  return NOERR;
 | 
						|
}
 | 
						|
 | 
						|
int TPersone_app::write(const TMask& m) 
 | 
						|
 | 
						|
{
 | 
						|
  TRelation &r = *get_relation();
 | 
						|
  r.zero();
 | 
						|
  m.autosave(r);
 | 
						|
  set_cod_ana(r.lfile().get(N_CODANAGR));
 | 
						|
  if (_reset_uff_conc)
 | 
						|
  {
 | 
						|
    _reset_uff_conc = FALSE;
 | 
						|
    r.lfile().zero("UFFCONC");
 | 
						|
  }
 | 
						|
  if (_reset_codreg)
 | 
						|
  {
 | 
						|
    _reset_codreg = FALSE;
 | 
						|
    r.lfile(LF_ANAGFIS).zero("CODREG96");
 | 
						|
  }
 | 
						|
  manual_save(m);
 | 
						|
  return r.write();
 | 
						|
}
 | 
						|
 | 
						|
int TPersone_app::rewrite(const TMask& m) 
 | 
						|
 | 
						|
{
 | 
						|
  TRelation & r = *get_relation();
 | 
						|
 | 
						|
  m.autosave(r);
 | 
						|
  if (_reset_uff_conc)
 | 
						|
  {
 | 
						|
    _reset_uff_conc = FALSE;
 | 
						|
    r.lfile().zero("UFFCONC");
 | 
						|
  }
 | 
						|
  if (_reset_codreg)
 | 
						|
  {
 | 
						|
    _reset_codreg = FALSE;
 | 
						|
    r.lfile(LF_ANAGFIS).zero("CODREG96");
 | 
						|
  }
 | 
						|
  manual_save(m);     
 | 
						|
  return r.rewrite();
 | 
						|
}
 | 
						|
 | 
						|
int ba4200(int argc, char* argv[])
 | 
						|
{                         
 | 
						|
  TApplication::check_parameters(argc, argv);
 | 
						|
  const char ta =  (argc > 2 && toupper(*argv[2]) == 'G') ? 'G' : 'F';
 | 
						|
  TPersone_app a(ta);
 | 
						|
  a.run(argc, argv, TR("Anagrafica Persone"));
 | 
						|
  return 0;
 | 
						|
}
 |