git-svn-id: svn://10.65.10.50/branches/R_10_00@23019 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			598 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			598 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <automask.h>
 | 
						||
#include <dongle.h>
 | 
						||
#include <execp.h>
 | 
						||
#include <mailbox.h>
 | 
						||
#include <modaut.h>
 | 
						||
#include <recarray.h>
 | 
						||
#include <tabutil.h>
 | 
						||
#include <tabapp.h>
 | 
						||
 | 
						||
#include "../ca/calib01.h"
 | 
						||
#include "../ca/cdc.h"
 | 
						||
#include "../ca/commesse.h"
 | 
						||
#include "../ca/fasi.h"
 | 
						||
 | 
						||
#include "../cg/cglib01.h"
 | 
						||
 | 
						||
#include "ce0.h"
 | 
						||
#include "celib.h"
 | 
						||
 | 
						||
#include "cetbana.h"
 | 
						||
#include "cetbcac.h"
 | 
						||
#include "cetbccb.h"
 | 
						||
#include "cetbccc.h"
 | 
						||
#include "cetbcce.h"
 | 
						||
#include "cetbtmc.h"
 | 
						||
 | 
						||
#define MIN_CAT_COM   40
 | 
						||
 | 
						||
#ifndef TTable_application
 | 
						||
#define TTable_application Tab_application
 | 
						||
#endif
 | 
						||
 | 
						||
TTable_application& app() { return (TTable_application&)main_app(); }
 | 
						||
 | 
						||
///////////////////////////////////////////////////////////
 | 
						||
// TTMC_mask
 | 
						||
///////////////////////////////////////////////////////////
 | 
						||
 | 
						||
class TTMC_mask : public TAutomask
 | 
						||
{ 
 | 
						||
public:
 | 
						||
  virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | 
						||
 | 
						||
  TTMC_mask() : TAutomask("cetbtmc") { }
 | 
						||
  virtual ~TTMC_mask() { }
 | 
						||
};
 | 
						||
                                  
 | 
						||
                                  
 | 
						||
bool TTMC_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | 
						||
{             
 | 
						||
  switch (o.dlg())
 | 
						||
  {
 | 
						||
    case F_APPLICABLE1:
 | 
						||
      if (e == fe_close && !query_mode())
 | 
						||
      {
 | 
						||
        if ((!get_bool(F_APPLICABLE1)) && (!get_bool(F_APPLICABLE2)) && (!get_bool(F_APPLICABLE3)))
 | 
						||
          return error_box(TR("E' necessario specificare almeno un'applicabilita'"));
 | 
						||
      }
 | 
						||
    default:
 | 
						||
    break;
 | 
						||
  }
 | 
						||
  return true;
 | 
						||
}
 | 
						||
 | 
						||
///////////////////////////////////////////////////////////
 | 
						||
// TCAC_mask
 | 
						||
///////////////////////////////////////////////////////////
 | 
						||
 | 
						||
class TCAC_mask : public TAutomask
 | 
						||
{ 
 | 
						||
public:
 | 
						||
  virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | 
						||
 | 
						||
  TCAC_mask() : TAutomask("cetbcac") { }
 | 
						||
  virtual ~TCAC_mask() { }
 | 
						||
};
 | 
						||
                                  
 | 
						||
                                  
 | 
						||
bool TCAC_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | 
						||
{             
 | 
						||
  switch (o.dlg())
 | 
						||
  {
 | 
						||
    case F_TIPOCE:
 | 
						||
      if (e == fe_modify)
 | 
						||
      {
 | 
						||
        const int tipo_cesp = get_int(F_TIPOCE);
 | 
						||
        if (tipo_cesp == 1)
 | 
						||
          field(F_TIPOAMMO).on_hit();
 | 
						||
      }
 | 
						||
    break;
 | 
						||
    case F_NUMANNI:
 | 
						||
      if ((e == fe_close && !query_mode()))
 | 
						||
      {
 | 
						||
        if (get(F_NUMANNI).empty())
 | 
						||
        {     
 | 
						||
          const int tipo_cesp = get_int(F_TIPOCE);
 | 
						||
          const int tipo_vinc = get_int(F_TIPOVINC);                       
 | 
						||
          const real pmin = get_real(F_PERC_MINAMF2);
 | 
						||
          const real pmax = get_real(F_PERC_MAXAMF2);
 | 
						||
 | 
						||
          if (tipo_cesp == 1 || (tipo_cesp == 2 && tipo_vinc != 3 && pmin == ZERO && 
 | 
						||
              pmax == ZERO))
 | 
						||
            return error_box(TR("Numero di anni per ammortamento costi obbligatori"));
 | 
						||
        }
 | 
						||
      }
 | 
						||
    break;
 | 
						||
    case F_CODCAT:
 | 
						||
      if (e == fe_close && query_mode())
 | 
						||
      {                
 | 
						||
        const int codgr = get_int(F_CODGR);
 | 
						||
        const int codsp = get_int(F_CODSP);
 | 
						||
        const int codcat = get_int(F_CODCAT);
 | 
						||
        
 | 
						||
        if (codgr == 0 && codsp == 0)
 | 
						||
        {     
 | 
						||
// categorie comuni        
 | 
						||
          if (codcat < MIN_CAT_COM)
 | 
						||
            return error_box(TR("Le categorie comuni non possono avere\n un codice inferiore a %d"), MIN_CAT_COM);
 | 
						||
        }
 | 
						||
        else
 | 
						||
        {
 | 
						||
// categorie noncomuni
 | 
						||
          if (codcat >= MIN_CAT_COM)
 | 
						||
            return error_box(TR("I codici categoria superiori o uguali\n a %d sono riservati alle  Categorie Comuni"),MIN_CAT_COM);
 | 
						||
        }
 | 
						||
      }
 | 
						||
    default:
 | 
						||
    break;
 | 
						||
  }
 | 
						||
  return true;
 | 
						||
}
 | 
						||
 | 
						||
///////////////////////////////////////////////////////////
 | 
						||
// TCCC_mask
 | 
						||
///////////////////////////////////////////////////////////
 | 
						||
 | 
						||
class TCCC_mask : public TAutomask
 | 
						||
{
 | 
						||
  bool _has_ca, _use_pdcc;
 | 
						||
 | 
						||
public:
 | 
						||
  virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | 
						||
  TCCC_mask();
 | 
						||
};
 | 
						||
 | 
						||
//costruttore: se la chiave ha l'analitica fa comparire i campi per cms/cdc/fase
 | 
						||
//se inoltre ha UsePdcc=false (ovvero usa pdc analitico puro) -> ci vogliono anche i conti!
 | 
						||
TCCC_mask::TCCC_mask() : TAutomask("cetbccc")
 | 
						||
{
 | 
						||
  //parte nascondendo i campi analitici
 | 
						||
  hide(-2);
 | 
						||
  
 | 
						||
  //inizializza i flag che servono un p<> dappertutto
 | 
						||
  //di base usa il pdcc
 | 
						||
  TConfig& cfg = ca_config();
 | 
						||
 | 
						||
  //controllo analitica su chiave e parametri
 | 
						||
  _has_ca = cfg.get_int("Authorizations") > 1;
 | 
						||
  _use_pdcc = cfg.get_bool("UsePdcc");
 | 
						||
 | 
						||
  //se la chiave ha CA -> campi cms/cdc/fase!
 | 
						||
  if (_has_ca)
 | 
						||
  {
 | 
						||
    show(-2);
 | 
						||
    //se <20> in uso il piano dei conti analitico puro, dagli di vagonata di campi per i conti, in base alla..
 | 
						||
    //..configurazione del PCONANA!
 | 
						||
    if (!_use_pdcc)
 | 
						||
    {
 | 
						||
      const int logicnum = LF_PCONANA;
 | 
						||
      const int nfields = ca_create_fields(*this, 1, LF_PCONANA, 2, 1, F_PDA1_NOR, F_DES1_NOR, 0x0, "S3");
 | 
						||
      ca_create_fields(*this, 1, LF_PCONANA, 2,  7, F_PDA1_ACC, F_DES1_ACC, 0x0, "S4");
 | 
						||
      ca_create_fields(*this, 1, LF_PCONANA, 2, 13, F_PDA1_ANT, F_DES1_ANT, 0x0, "S5");
 | 
						||
 | 
						||
	    for (int i = 0; i < nfields; i++)
 | 
						||
	    {
 | 
						||
        TMask_field& normale = field(F_PDA1_NOR + i);
 | 
						||
		    normale.set_group(2);
 | 
						||
		    normale.check_type(CHECK_REQUIRED);
 | 
						||
        TMask_field& accelerato = field(F_PDA1_ACC + i);
 | 
						||
		    accelerato.set_group(2);
 | 
						||
		    accelerato.check_type(CHECK_NORMAL);
 | 
						||
        TMask_field& anticipato = field(F_PDA1_ANT + i);
 | 
						||
		    anticipato.set_group(2);
 | 
						||
		    anticipato.check_type(CHECK_NORMAL);
 | 
						||
	    }
 | 
						||
    } //if(!_use_pdcc)
 | 
						||
  } //if (_has_ca)
 | 
						||
  else
 | 
						||
    hide(-2);
 | 
						||
}
 | 
						||
 | 
						||
bool TCCC_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | 
						||
{             
 | 
						||
  switch (o.dlg())
 | 
						||
  {
 | 
						||
  case F_CODCAT_IN:
 | 
						||
    if (o.active())
 | 
						||
    {
 | 
						||
      TDitta_cespiti& dc = ditta_cespiti();
 | 
						||
      bool ok = dc.on_category_event(o, e, jolly);
 | 
						||
      if (ok)
 | 
						||
      { 
 | 
						||
        if (e == fe_modify && !o.empty())
 | 
						||
        {
 | 
						||
          const TRectype& cac = dc.categoria(0, NULL, get_int(F_CODCAT_IN));
 | 
						||
          if (o.dlg() == F_CODCAT_IN)
 | 
						||
            set(F_DESCCAT, cac.get("S0"));
 | 
						||
        }
 | 
						||
        if (e == fe_close && o.empty())
 | 
						||
          return error_box(TR("<EFBFBD> necessario specificare la categoria!"));
 | 
						||
      }
 | 
						||
    }
 | 
						||
    break;
 | 
						||
  case F_CODES:
 | 
						||
    if (e == fe_init)
 | 
						||
    {
 | 
						||
      if (_has_ca)
 | 
						||
      {
 | 
						||
        show(-2);
 | 
						||
        //Riempie i campi di cdc/cms/fase standard in base a quanto configurato nell'esercizio cespiti
 | 
						||
        const TString& codes = get(F_CODES);
 | 
						||
        const TRectype& rec_cce = cache().get("CCE", codes);
 | 
						||
        const TString& codcdc = rec_cce.get("S2");
 | 
						||
        const TString& descdc = cache().get(LF_CDC, codcdc, CDC_DESCRIZ);
 | 
						||
        set(F_CODCDC, codcdc);
 | 
						||
        set(F_DESCDC, descdc);
 | 
						||
        const TString& codcms = rec_cce.get("S3");
 | 
						||
        const TString& descms = cache().get(LF_COMMESSE, codcms, COMMESSE_DESCRIZ);
 | 
						||
        set(F_CODCMS, codcms);
 | 
						||
        set(F_DESCMS, descms);
 | 
						||
        const TString& codfase = rec_cce.get("S4");
 | 
						||
        //per le fasi <20> necessario sapere se hanno un padre e quale <20>!
 | 
						||
        TToken_string key_fasi;
 | 
						||
        TConfig& cfg = ca_config();
 | 
						||
        const TString& fath_fasi = cfg.get("FathFasi");
 | 
						||
        if (fath_fasi.full())
 | 
						||
        {
 | 
						||
          if (fath_fasi == "CMS")
 | 
						||
            key_fasi.add(codcms);
 | 
						||
          else
 | 
						||
            key_fasi.add(codcdc);
 | 
						||
        }
 | 
						||
        else
 | 
						||
          key_fasi.add("");
 | 
						||
 | 
						||
        key_fasi.add(codfase);
 | 
						||
        const TString& desfase = cache().get(LF_FASI, key_fasi, FASI_DESCRIZ);
 | 
						||
        set(F_CODFASE, codfase);
 | 
						||
        set(F_DESFASE, desfase);
 | 
						||
 | 
						||
        //sistemati i campi di cdc/cms/fase, scatta il controllo sui campi dei conti analitici degli ammortamenti
 | 
						||
        if (_use_pdcc)
 | 
						||
          disable_page(1);
 | 
						||
        else
 | 
						||
          enable_page(1);
 | 
						||
      }
 | 
						||
      else  //if(_has_ca)
 | 
						||
        hide(-2);
 | 
						||
    }
 | 
						||
    break;
 | 
						||
  case F_QNOR_SOT:
 | 
						||
  case F_QACC_SOT:
 | 
						||
  case F_QANT_SOT:
 | 
						||
    if (e == fe_close && !o.empty())
 | 
						||
    {
 | 
						||
      //in caso sia presente la CA, e sia UsePdcc = true, -> i conti degli ammortamenti devono valere anche..
 | 
						||
      //..per l'analitica
 | 
						||
      if (_has_ca && _use_pdcc)
 | 
						||
      {
 | 
						||
        const long sot = o.get_long();
 | 
						||
        const int gr = get_int(o.dlg() - 2);
 | 
						||
        const int co = get_int(o.dlg() -1);
 | 
						||
        TBill zio(gr, co, sot);
 | 
						||
        if (!zio.is_analitico())
 | 
						||
          return error_box(TR("Il conto selezionato non <20> valido per la contabilit<69> analitica!"));
 | 
						||
      }
 | 
						||
    }
 | 
						||
    break;
 | 
						||
  default:
 | 
						||
    break;
 | 
						||
  }
 | 
						||
  return true;
 | 
						||
}
 | 
						||
 | 
						||
///////////////////////////////////////////////////////////
 | 
						||
// TCCE_mask
 | 
						||
///////////////////////////////////////////////////////////
 | 
						||
 | 
						||
class TCCE_mask : public TAutomask
 | 
						||
{ 
 | 
						||
protected:
 | 
						||
  bool is_leap(int year) const;
 | 
						||
  real calc_coeff(const TDate& ies, const TDate& fes) const;
 | 
						||
 | 
						||
public:
 | 
						||
  virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | 
						||
 | 
						||
  TCCE_mask();
 | 
						||
  virtual ~TCCE_mask() { }
 | 
						||
};
 | 
						||
 | 
						||
//costruttore; gestisce apparizioni e sparizioni!! (<28> come il mago Oronzo)
 | 
						||
TCCE_mask::TCCE_mask() : TAutomask("cetbcce")
 | 
						||
{
 | 
						||
  //i campi di analitica li vede solo chi ha l'analitica
 | 
						||
  const bool has_ca = dongle().active(CAAUT);
 | 
						||
  //se la chiave ha CA mostra i campi gruppo 1 (analitica)..
 | 
						||
  if (has_ca)
 | 
						||
  {
 | 
						||
    enable_page(1, true);
 | 
						||
/*  QUESTO NON E' ASSOLUTAMENTE DETTO; E' DA VERIFICARE!
 | 
						||
    //se ha l'analitica gli tocca pure controllare la configurazione per sapere..
 | 
						||
    //..quali campi diventano obbligatori!
 | 
						||
    TConfig& cfg = ca_config();
 | 
						||
 | 
						||
    if (cfg.get_bool("CmsRequired"))
 | 
						||
    {
 | 
						||
      TEdit_field& e_cms = efield(F_CODCMS);
 | 
						||
      e_cms.check_type(CHECK_REQUIRED);
 | 
						||
    }
 | 
						||
    if (cfg.get_bool("CdcRequired"))
 | 
						||
    {
 | 
						||
      TEdit_field& e_cdc = efield(F_CODCDC);
 | 
						||
      e_cdc.check_type(CHECK_REQUIRED);
 | 
						||
    }
 | 
						||
    if (cfg.get_bool("FscRequired"))
 | 
						||
    {
 | 
						||
      TEdit_field& e_fase = efield(F_CODFASE);
 | 
						||
      e_fase.check_type(CHECK_REQUIRED);
 | 
						||
    }*/
 | 
						||
  }
 | 
						||
  else
 | 
						||
    enable_page(1, false);
 | 
						||
 | 
						||
}
 | 
						||
 | 
						||
bool TCCE_mask::is_leap(int year) const
 | 
						||
{
 | 
						||
  TDate d(28,2,year);
 | 
						||
  ++d;
 | 
						||
  return d.day() == 29;
 | 
						||
}
 | 
						||
 | 
						||
real TCCE_mask::calc_coeff(const TDate& ies, const TDate& fes) const
 | 
						||
{
 | 
						||
  const bool rip_by_day = get_int(F_TIPO_RIP) != 1;
 | 
						||
  real coeff = UNO;
 | 
						||
  if (rip_by_day) // ripartizione per giorno
 | 
						||
  {
 | 
						||
    const real tot_es = fes - ies + 1;
 | 
						||
    real max_es = 365;
 | 
						||
    const int im = ies.month();
 | 
						||
    const int iy = ies.year();
 | 
						||
    const int fm = fes.month();
 | 
						||
    const int fy = fes.year();
 | 
						||
    if ((im < 3 && (fm >= 3 || fy > iy) && is_leap(iy)) || 
 | 
						||
        (fm >= 3 && (im < 3 || iy < fy) && is_leap(fy)))
 | 
						||
      max_es += 1.0;
 | 
						||
    coeff = tot_es / max_es;
 | 
						||
  }
 | 
						||
  else  // ripartizione mensile
 | 
						||
  {
 | 
						||
    const int fm = fes.year()*12 + fes.month();
 | 
						||
    const int sm = ies.year()*12 + ies.month();
 | 
						||
    coeff = real(fm - sm + 1) / real(12);
 | 
						||
  }
 | 
						||
  return coeff;
 | 
						||
}                                  
 | 
						||
 | 
						||
bool TCCE_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | 
						||
{             
 | 
						||
  switch (o.dlg())
 | 
						||
  {
 | 
						||
  case DLG_ATTIV:
 | 
						||
    if (e == fe_button)
 | 
						||
    {                
 | 
						||
      const char* const app = "ce0 -0 CCB";
 | 
						||
      TMailbox mail;            
 | 
						||
      TString body; body.format("%d|%d=%s|%d=%s|%d=%s", F_CODSP_CCB, F_CODESER_CCB, (const char *)get(F_CODESER),
 | 
						||
                                                                     F_DATAINI_CCB, (const char *)get(F_DATAINI),
 | 
						||
                                                                     F_DATAFINE_CCB, (const char *)get(F_DATAFINE));
 | 
						||
                                                                 
 | 
						||
      TMessage msg(app, MSG_FS, body);
 | 
						||
      mail.send(msg);
 | 
						||
      TExternal_app a(app);
 | 
						||
      a.run();
 | 
						||
    }     
 | 
						||
    break;
 | 
						||
  case F_TIPO_RIP:
 | 
						||
    if (e == fe_modify || e == fe_init)
 | 
						||
    {
 | 
						||
      const TDate ies = get_date(F_DATAINI);
 | 
						||
      const TDate fes = get_date(F_DATAFINE);
 | 
						||
      if (ies.ok() && fes >= ies)
 | 
						||
      {
 | 
						||
        set(F_DURATA, fes-ies+1);
 | 
						||
        TReal_field& cd = (TReal_field&)efield(F_COEFF_DURATA);
 | 
						||
        cd.set(calc_coeff(ies, fes).string(0, cd.decimals()));
 | 
						||
      }
 | 
						||
    }
 | 
						||
    break;  
 | 
						||
  default:
 | 
						||
  break;
 | 
						||
  }
 | 
						||
  return true;
 | 
						||
}
 | 
						||
 | 
						||
///////////////////////////////////////////////////////////
 | 
						||
// TCEtables
 | 
						||
///////////////////////////////////////////////////////////
 | 
						||
 | 
						||
class TCEtables : public TTable_application
 | 
						||
{
 | 
						||
protected:
 | 
						||
  virtual TString& get_mask_name(TString& name) const;
 | 
						||
  virtual TMask* set_mask(TMask* m);
 | 
						||
 | 
						||
  virtual int read(TMask& m);
 | 
						||
  virtual int write(const TMask& m);
 | 
						||
  virtual int rewrite(const TMask& m);
 | 
						||
  virtual bool remove();      
 | 
						||
  virtual bool protected_record(TRectype& rec);
 | 
						||
  void show_hide_ccc_cat(TMask& m, const bool hide_cac);
 | 
						||
 | 
						||
  virtual void init_query_mode(TMask& m);
 | 
						||
  virtual void init_insert_mode(TMask& m);
 | 
						||
  virtual void init_query_insert_mode(TMask& m);
 | 
						||
  virtual void init_modify_mode(TMask& m);
 | 
						||
};
 | 
						||
 | 
						||
TString& TCEtables::get_mask_name(TString& name) const
 | 
						||
{
 | 
						||
  name = get_tabname();
 | 
						||
  if (name[0] == '%')
 | 
						||
    name = name.mid(1);
 | 
						||
  name.insert("cetb", 0);
 | 
						||
  return name;
 | 
						||
}
 | 
						||
 | 
						||
TMask* TCEtables::set_mask(TMask* m)
 | 
						||
{
 | 
						||
  const TString& tab = get_tabname();
 | 
						||
  if (m == NULL)
 | 
						||
  {
 | 
						||
    if (tab == "%TMC")
 | 
						||
      m = new TTMC_mask();
 | 
						||
    else                
 | 
						||
      if (tab == "%CAC")
 | 
						||
        m = new TCAC_mask();
 | 
						||
      else                
 | 
						||
        if (tab == "CCE")
 | 
						||
          m = new TCCE_mask();
 | 
						||
        else
 | 
						||
          if (tab == "CCC")
 | 
						||
            m = new TCCC_mask();
 | 
						||
          else
 | 
						||
          {
 | 
						||
            TString name; get_mask_name(name);
 | 
						||
            m = new TMask(name);
 | 
						||
          }  
 | 
						||
  }
 | 
						||
  return TTable_application::set_mask(m);
 | 
						||
}
 | 
						||
 | 
						||
int TCEtables::read(TMask& m)
 | 
						||
{
 | 
						||
  const int err = TTable_application::read(m);
 | 
						||
  return err;
 | 
						||
}
 | 
						||
 | 
						||
int TCEtables::write(const TMask& m)
 | 
						||
{
 | 
						||
  const int err = TTable_application::write(m);
 | 
						||
  return err;
 | 
						||
}
 | 
						||
 | 
						||
int TCEtables::rewrite(const TMask& m)
 | 
						||
{
 | 
						||
  const int err = TTable_application::rewrite(m);
 | 
						||
  return err;
 | 
						||
}
 | 
						||
 | 
						||
bool TCEtables::remove()
 | 
						||
{
 | 
						||
  const bool ok = TTable_application::remove();
 | 
						||
  return ok;
 | 
						||
}
 | 
						||
 | 
						||
bool TCEtables::protected_record(TRectype& rec)
 | 
						||
{
 | 
						||
  const TString& tab = get_tabname();
 | 
						||
  if (tab == "%CGR")                    
 | 
						||
  {
 | 
						||
    TTable cat("%CAT");
 | 
						||
    
 | 
						||
    const TString16 key(rec.get("CODTAB"));
 | 
						||
    cat.put("CODTAB", key);
 | 
						||
    if (cat.read(_isgteq) == NOERR)
 | 
						||
      return key == cat.get("CODTAB").left(2);
 | 
						||
  }
 | 
						||
  else
 | 
						||
    if (tab == "%CAT")
 | 
						||
    {
 | 
						||
      TTable cac("%CAC");
 | 
						||
    
 | 
						||
      const TString16 key(rec.get("CODTAB"));
 | 
						||
      cac.put("CODTAB", key);
 | 
						||
      if (cac.read(_isgteq) == NOERR)
 | 
						||
      {
 | 
						||
        TString16 keyfound = cac.get("CODTAB").left(6); keyfound.trim();
 | 
						||
        return key == keyfound;
 | 
						||
      }
 | 
						||
    }
 | 
						||
  return TTable_application::protected_record(rec);
 | 
						||
}
 | 
						||
 | 
						||
void TCEtables::show_hide_ccc_cat(TMask& m, const bool hide_cac)
 | 
						||
{
 | 
						||
  //hide_cac = nasconde i campi che mostrano i record della tabella comune %CAC
 | 
						||
  if (hide_cac)
 | 
						||
  {
 | 
						||
    m.hide(F_CODCAT_IN);
 | 
						||
    m.disable(F_CODCAT_IN);
 | 
						||
    m.show(F_CODCAT);
 | 
						||
  }
 | 
						||
  else
 | 
						||
  {
 | 
						||
    m.hide(F_CODCAT);
 | 
						||
    m.show(F_CODCAT_IN);
 | 
						||
    m.enable(F_CODCAT_IN);
 | 
						||
  }
 | 
						||
}
 | 
						||
 | 
						||
void TCEtables::init_query_mode(TMask& m)
 | 
						||
{ 
 | 
						||
  const TString& tab = get_tabname();
 | 
						||
  if (tab == "CCE")
 | 
						||
    m.disable(DLG_ATTIV);
 | 
						||
  if (tab == "CCB")
 | 
						||
  {
 | 
						||
    m.show(F_CODSP_CCB);
 | 
						||
    m.hide(F_CODATT_CCB);
 | 
						||
  }
 | 
						||
  if (tab == "CCC")
 | 
						||
  {
 | 
						||
    show_hide_ccc_cat(m, true);
 | 
						||
  }
 | 
						||
}
 | 
						||
 | 
						||
void TCEtables::init_insert_mode(TMask& m)
 | 
						||
{
 | 
						||
  const TString& tab = get_tabname();
 | 
						||
  if (tab == "CCC")
 | 
						||
  {
 | 
						||
    show_hide_ccc_cat(m, true);
 | 
						||
  }
 | 
						||
}
 | 
						||
 | 
						||
void TCEtables::init_query_insert_mode(TMask& m)
 | 
						||
{
 | 
						||
  const TString& tab = get_tabname(); 
 | 
						||
  if (tab == "CCB")
 | 
						||
  {
 | 
						||
		m.hide(F_CODSP_CCB);
 | 
						||
		m.show(F_CODATT_CCB);
 | 
						||
  }
 | 
						||
  if (tab == "CCC")
 | 
						||
  {
 | 
						||
    show_hide_ccc_cat(m, false);
 | 
						||
  }
 | 
						||
}
 | 
						||
 | 
						||
void TCEtables::init_modify_mode(TMask& m)
 | 
						||
{
 | 
						||
  const TString& tab = get_tabname();
 | 
						||
  if (tab == "CCE")
 | 
						||
  {
 | 
						||
    m.enable(DLG_ATTIV);
 | 
						||
  }
 | 
						||
  if (tab == "CCC")
 | 
						||
  {
 | 
						||
    show_hide_ccc_cat(m, true);
 | 
						||
  }
 | 
						||
}
 | 
						||
 | 
						||
int ce0100(int argc, char* argv[])
 | 
						||
{
 | 
						||
  if (argc > 2)
 | 
						||
  {
 | 
						||
    TString name;
 | 
						||
    name << TR("Tabella") << ' ' << argv[2];
 | 
						||
    TCEtables a;
 | 
						||
    a.run(argc, argv, name);
 | 
						||
  }
 | 
						||
  return 0;
 | 
						||
}
 | 
						||
 |