2001-04-30 14:22:43 +00:00
|
|
|
|
#include <automask.h>
|
2010-06-01 14:59:53 +00:00
|
|
|
|
#include <dongle.h>
|
2001-04-30 14:22:43 +00:00
|
|
|
|
#include <execp.h>
|
|
|
|
|
#include <mailbox.h>
|
2010-06-01 14:59:53 +00:00
|
|
|
|
#include <modaut.h>
|
2010-06-18 14:55:20 +00:00
|
|
|
|
#include <recarray.h>
|
2001-04-30 14:22:43 +00:00
|
|
|
|
#include <tabutil.h>
|
|
|
|
|
#include <tabapp.h>
|
|
|
|
|
|
2010-06-18 14:55:20 +00:00
|
|
|
|
#include "../ca/calib01.h"
|
|
|
|
|
#include "../ca/cdc.h"
|
|
|
|
|
#include "../ca/commesse.h"
|
|
|
|
|
#include "../ca/fasi.h"
|
|
|
|
|
|
2010-06-21 14:47:40 +00:00
|
|
|
|
#include "../cg/cglib01.h"
|
|
|
|
|
|
2001-04-30 14:22:43 +00:00
|
|
|
|
#include "ce0.h"
|
2008-01-08 17:08:23 +00:00
|
|
|
|
#include "celib.h"
|
2001-04-30 14:22:43 +00:00
|
|
|
|
|
2010-06-18 14:55:20 +00:00
|
|
|
|
#include "cetbana.h"
|
2001-04-30 14:22:43 +00:00
|
|
|
|
#include "cetbcac.h"
|
|
|
|
|
#include "cetbccb.h"
|
2008-01-08 17:08:23 +00:00
|
|
|
|
#include "cetbccc.h"
|
2010-06-18 14:55:20 +00:00
|
|
|
|
#include "cetbcce.h"
|
|
|
|
|
#include "cetbtmc.h"
|
2010-06-01 14:59:53 +00:00
|
|
|
|
|
2001-04-30 14:22:43 +00:00
|
|
|
|
#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)))
|
2003-05-12 15:03:40 +00:00
|
|
|
|
return error_box(TR("E' necessario specificare almeno un'applicabilita'"));
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2008-01-08 17:08:23 +00:00
|
|
|
|
return true;
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// 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))
|
2003-05-12 15:03:40 +00:00
|
|
|
|
return error_box(TR("Numero di anni per ammortamento costi obbligatori"));
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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)
|
2003-05-12 15:03:40 +00:00
|
|
|
|
return error_box(TR("Le categorie comuni non possono avere\n un codice inferiore a %d"), MIN_CAT_COM);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// categorie noncomuni
|
|
|
|
|
if (codcat >= MIN_CAT_COM)
|
2003-05-12 15:03:40 +00:00
|
|
|
|
return error_box(TR("I codici categoria superiori o uguali\n a %d sono riservati alle Categorie Comuni"),MIN_CAT_COM);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2008-01-08 17:08:23 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TCCC_mask
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TCCC_mask : public TAutomask
|
2010-06-21 14:47:40 +00:00
|
|
|
|
{
|
|
|
|
|
bool _has_ca, _use_pdcc;
|
|
|
|
|
|
2008-01-08 17:08:23 +00:00
|
|
|
|
public:
|
|
|
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
|
|
2010-06-18 14:55:20 +00:00
|
|
|
|
TCCC_mask();
|
2008-01-08 17:08:23 +00:00
|
|
|
|
virtual ~TCCC_mask() { }
|
|
|
|
|
};
|
|
|
|
|
|
2010-06-18 14:55:20 +00:00
|
|
|
|
//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")
|
|
|
|
|
{
|
2010-06-21 14:47:40 +00:00
|
|
|
|
//parte nascondendo i campi analitici
|
|
|
|
|
hide(-2);
|
|
|
|
|
|
2010-06-18 14:55:20 +00:00
|
|
|
|
//controllo analitica su chiave
|
2010-06-21 14:47:40 +00:00
|
|
|
|
_has_ca = dongle().active(CAAUT);
|
|
|
|
|
|
|
|
|
|
//inizializza i flag che servono un p<> dappertutto
|
|
|
|
|
//di base usa il pdcc
|
|
|
|
|
TConfig& cfg = ca_config();
|
|
|
|
|
_use_pdcc = cfg.get_bool("UsePdcc");
|
|
|
|
|
|
2010-06-18 14:55:20 +00:00
|
|
|
|
//se la chiave ha CA -> campi cms/cdc/fase!
|
2010-06-21 14:47:40 +00:00
|
|
|
|
if (_has_ca)
|
2010-06-18 14:55:20 +00:00
|
|
|
|
{
|
|
|
|
|
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!
|
2010-06-21 14:47:40 +00:00
|
|
|
|
if (!_use_pdcc)
|
2010-06-18 14:55:20 +00:00
|
|
|
|
{
|
|
|
|
|
const int logicnum = LF_PCONANA;
|
2010-06-21 14:47:40 +00:00
|
|
|
|
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");
|
2010-06-18 14:55:20 +00:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
2010-06-21 14:47:40 +00:00
|
|
|
|
} //if(!_use_pdcc)
|
|
|
|
|
} //if (_has_ca)
|
|
|
|
|
else
|
|
|
|
|
hide(-2);
|
2010-06-18 14:55:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-01-08 17:08:23 +00:00
|
|
|
|
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;
|
2010-06-21 14:47:40 +00:00
|
|
|
|
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;
|
2008-01-08 17:08:23 +00:00
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TCCE_mask
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TCCE_mask : public TAutomask
|
|
|
|
|
{
|
2001-09-19 14:52:11 +00:00
|
|
|
|
protected:
|
|
|
|
|
bool is_leap(int year) const;
|
|
|
|
|
real calc_coeff(const TDate& ies, const TDate& fes) const;
|
|
|
|
|
|
2001-04-30 14:22:43 +00:00
|
|
|
|
public:
|
|
|
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
|
|
2010-06-01 14:59:53 +00:00
|
|
|
|
TCCE_mask();
|
2001-04-30 14:22:43 +00:00
|
|
|
|
virtual ~TCCE_mask() { }
|
|
|
|
|
};
|
2001-09-19 14:52:11 +00:00
|
|
|
|
|
2010-06-01 14:59:53 +00:00
|
|
|
|
//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);
|
2010-06-03 15:04:50 +00:00
|
|
|
|
/* QUESTO NON E' ASSOLUTAMENTE DETTO; E' DA VERIFICARE!
|
2010-06-01 14:59:53 +00:00
|
|
|
|
//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);
|
2010-06-03 15:04:50 +00:00
|
|
|
|
}*/
|
2010-06-01 14:59:53 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
enable_page(1, false);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2001-09-19 14:52:11 +00:00
|
|
|
|
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 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;
|
|
|
|
|
real coeff = tot_es / max_es;
|
|
|
|
|
coeff.round(9);
|
|
|
|
|
return coeff;
|
|
|
|
|
}
|
2001-04-30 14:22:43 +00:00
|
|
|
|
|
|
|
|
|
bool TCCE_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
|
|
|
{
|
|
|
|
|
switch (o.dlg())
|
|
|
|
|
{
|
2001-09-19 14:52:11 +00:00
|
|
|
|
case DLG_ATTIV:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
2009-02-05 12:16:30 +00:00
|
|
|
|
const char* const app = "ce0 -0 CCB";
|
2001-09-19 14:52:11 +00:00
|
|
|
|
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));
|
2001-04-30 14:22:43 +00:00
|
|
|
|
|
2001-09-19 14:52:11 +00:00
|
|
|
|
TMessage msg(app, MSG_FS, body);
|
|
|
|
|
mail.send(msg);
|
|
|
|
|
TExternal_app a(app);
|
|
|
|
|
a.run();
|
|
|
|
|
}
|
2001-04-30 14:22:43 +00:00
|
|
|
|
break;
|
2001-09-19 14:52:11 +00:00
|
|
|
|
case F_DURATA:
|
|
|
|
|
if (e == fe_init && !field(F_CODESER).empty())
|
|
|
|
|
{
|
2004-03-13 09:12:24 +00:00
|
|
|
|
const TDate ies = get_date(F_DATAINI);
|
|
|
|
|
const TDate fes = get_date(F_DATAFINE);
|
2001-09-19 14:52:11 +00:00
|
|
|
|
set(F_DURATA, fes-ies+1);
|
|
|
|
|
set(F_COEFF_DURATA, calc_coeff(ies, fes));
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
2008-01-08 17:08:23 +00:00
|
|
|
|
return true;
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// 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);
|
2008-01-08 17:08:23 +00:00
|
|
|
|
void show_hide_ccc_cat(TMask& m, const bool hide_cac);
|
|
|
|
|
|
2001-04-30 14:22:43 +00:00
|
|
|
|
virtual void init_query_mode(TMask& m);
|
2008-01-08 17:08:23 +00:00
|
|
|
|
virtual void init_insert_mode(TMask& m);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
virtual void init_query_insert_mode(TMask& m);
|
2001-06-25 10:41:20 +00:00
|
|
|
|
virtual void init_modify_mode(TMask& m);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2008-01-08 17:08:23 +00:00
|
|
|
|
const TString& tab = get_tabname();
|
2001-04-30 14:22:43 +00:00
|
|
|
|
if (m == NULL)
|
|
|
|
|
{
|
2008-01-08 17:08:23 +00:00
|
|
|
|
if (tab == "%TMC")
|
2001-04-30 14:22:43 +00:00
|
|
|
|
m = new TTMC_mask();
|
|
|
|
|
else
|
2008-01-08 17:08:23 +00:00
|
|
|
|
if (tab == "%CAC")
|
2001-04-30 14:22:43 +00:00
|
|
|
|
m = new TCAC_mask();
|
|
|
|
|
else
|
2008-01-08 17:08:23 +00:00
|
|
|
|
if (tab == "CCE")
|
2001-04-30 14:22:43 +00:00
|
|
|
|
m = new TCCE_mask();
|
|
|
|
|
else
|
2008-01-08 17:08:23 +00:00
|
|
|
|
if (tab == "CCC")
|
|
|
|
|
m = new TCCC_mask();
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TString name; get_mask_name(name);
|
|
|
|
|
m = new TMask(name);
|
|
|
|
|
}
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
{
|
2008-01-08 17:08:23 +00:00
|
|
|
|
const TString& tab = get_tabname();
|
|
|
|
|
if (tab == "%CGR")
|
2001-04-30 14:22:43 +00:00
|
|
|
|
{
|
|
|
|
|
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
|
2008-01-08 17:08:23 +00:00
|
|
|
|
if (tab == "%CAT")
|
2001-04-30 14:22:43 +00:00
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2008-01-08 17:08:23 +00:00
|
|
|
|
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);
|
2008-01-10 11:57:52 +00:00
|
|
|
|
m.disable(F_CODCAT_IN);
|
2008-01-08 17:08:23 +00:00
|
|
|
|
m.show(F_CODCAT);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m.hide(F_CODCAT);
|
|
|
|
|
m.show(F_CODCAT_IN);
|
2008-01-10 11:57:52 +00:00
|
|
|
|
m.enable(F_CODCAT_IN);
|
2008-01-08 17:08:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-04-30 14:22:43 +00:00
|
|
|
|
void TCEtables::init_query_mode(TMask& m)
|
|
|
|
|
{
|
2008-01-08 17:08:23 +00:00
|
|
|
|
const TString& tab = get_tabname();
|
|
|
|
|
if (tab == "CCE")
|
2001-06-25 10:41:20 +00:00
|
|
|
|
m.disable(DLG_ATTIV);
|
2008-01-08 17:08:23 +00:00
|
|
|
|
if (tab == "CCB")
|
2001-06-25 10:41:20 +00:00
|
|
|
|
{
|
2006-12-13 16:22:33 +00:00
|
|
|
|
m.show(F_CODSP_CCB);
|
|
|
|
|
m.hide(F_CODATT_CCB);
|
2008-01-08 17:08:23 +00:00
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
}
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TCEtables::init_query_insert_mode(TMask& m)
|
|
|
|
|
{
|
2008-01-08 17:08:23 +00:00
|
|
|
|
const TString& tab = get_tabname();
|
|
|
|
|
if (tab == "CCB")
|
2001-06-25 10:41:20 +00:00
|
|
|
|
{
|
2006-12-13 16:22:33 +00:00
|
|
|
|
m.hide(F_CODSP_CCB);
|
|
|
|
|
m.show(F_CODATT_CCB);
|
2001-06-25 10:41:20 +00:00
|
|
|
|
}
|
2008-01-08 17:08:23 +00:00
|
|
|
|
if (tab == "CCC")
|
|
|
|
|
{
|
|
|
|
|
show_hide_ccc_cat(m, false);
|
|
|
|
|
}
|
2001-06-25 10:41:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TCEtables::init_modify_mode(TMask& m)
|
|
|
|
|
{
|
2008-01-08 17:08:23 +00:00
|
|
|
|
const TString& tab = get_tabname();
|
|
|
|
|
if (tab == "CCE")
|
2001-06-25 10:41:20 +00:00
|
|
|
|
{
|
|
|
|
|
m.enable(DLG_ATTIV);
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
2008-01-08 17:08:23 +00:00
|
|
|
|
if (tab == "CCC")
|
|
|
|
|
{
|
|
|
|
|
show_hide_ccc_cat(m, true);
|
|
|
|
|
}
|
2001-04-30 14:22:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ce0100(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
if (argc > 2)
|
|
|
|
|
{
|
|
|
|
|
TString name;
|
2007-09-17 15:33:04 +00:00
|
|
|
|
name << TR("Tabella") << ' ' << argv[2];
|
2001-04-30 14:22:43 +00:00
|
|
|
|
TCEtables a;
|
|
|
|
|
a.run(argc, argv, name);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|