git-svn-id: svn://10.65.10.50/branches/R_10_00@22692 c028cbd2-c16b-5b4b-a496-9718f37d4682
732 lines
20 KiB
C++
Executable File
732 lines
20 KiB
C++
Executable File
#include <defmask.h>
|
|
#include <printer.h>
|
|
#include <recarray.h>
|
|
#include <tabapp.h>
|
|
|
|
#include "../cg/cglib03.h"
|
|
|
|
#include "../cg/cgtbcam.h"
|
|
#include "../cg/cgtbdel.h"
|
|
#include "../cg/cgtbreg.h"
|
|
#include "../cg/cgtbver.h"
|
|
|
|
#include "batbnoc.h"
|
|
#include "batbval.h"
|
|
|
|
#define F_NUM 104
|
|
#define F_PREZZO 107
|
|
|
|
#define REG_JOURNAL 5
|
|
#define REG_DICHINT 10
|
|
|
|
#define TAB_BANCHE "%BAN"
|
|
#define TAB_CAMBI "CAM"
|
|
#define TAB_DELEGHE "%DEL"
|
|
#define TAB_DET "%DET"
|
|
#define TAB_IVDIRETTIVA "%IVD"
|
|
#define TAB_REGISTRI "REG"
|
|
#define TAB_VALUTE "%VAL"
|
|
#define TAB_VERSAMENTI "%VER"
|
|
#define TAB_NOMENCOMB "%NOC"
|
|
#define TAB_PREST "PRS"
|
|
#define TAB_SPESE "SPP"
|
|
|
|
class TGeneric_table_app : public TTable_application
|
|
{
|
|
long _oldditta;
|
|
int _oldanno;
|
|
bool _exist_journal;
|
|
bool _exist_dich_int;
|
|
bool _stampa_intest;
|
|
|
|
// ------------- specifiche tabella versamenti ed interessi IVA
|
|
void load_rec_in_disabled_fields(TMask& m);
|
|
void copy_rec_in_insert_fields(TMask& m);
|
|
// ------------------------------------------------------------
|
|
|
|
protected: // TRelation_application
|
|
virtual bool user_destroy() ;
|
|
virtual bool user_create() ;
|
|
virtual bool protected_record(TRectype& rec) ;
|
|
virtual void init_insert_mode(TMask& m) ;
|
|
virtual void init_modify_mode(TMask& m);
|
|
virtual void init_query_mode (TMask&);
|
|
virtual int read(TMask& m);
|
|
virtual int write(const TMask& m);
|
|
virtual int rewrite(const TMask& m);
|
|
|
|
protected:
|
|
static bool valute_decimals_handler(TMask_field& f, KEY k);
|
|
static bool change_decimals_handler(TMask_field& f, KEY k);
|
|
static bool codcab_handler(TMask_field& f, KEY k);
|
|
static bool codmag_handler(TMask_field& f, KEY k);
|
|
static bool codnoc_handler(TMask_field& f, KEY k);
|
|
static bool numivd_handler(TMask_field& f, KEY k);
|
|
|
|
public:
|
|
bool exist_journal() { return _exist_journal; }
|
|
bool exist_dich_int() { return _exist_dich_int; }
|
|
char frequenza_versamenti(long firm, int year) const;
|
|
|
|
TGeneric_table_app();
|
|
virtual ~TGeneric_table_app() {}
|
|
};
|
|
|
|
HIDDEN inline TGeneric_table_app& app() { return (TGeneric_table_app&)main_app(); }
|
|
|
|
TGeneric_table_app::TGeneric_table_app()
|
|
: _exist_journal(false), _stampa_intest(false)
|
|
{
|
|
}
|
|
|
|
// - tabella versamenti-specific -------------------------------
|
|
void TGeneric_table_app::load_rec_in_disabled_fields(TMask& m)
|
|
// carica il record del periodo precedente a quello immesso
|
|
// nei campi disabilitati relativi.
|
|
{
|
|
TTable ver(TAB_VERSAMENTI);
|
|
|
|
TString16 key(m.get(F_ANNOES));
|
|
key << m.get(F_MESEES);
|
|
|
|
ver.put("CODTAB",key);
|
|
if (ver.read(_isgteq) == _iseof) // Se non lo trova si posiziona sull'ultimo
|
|
ver.last();
|
|
else
|
|
ver.prev(); // altrimenti legge il periodo precedente.
|
|
if (ver.good()) // se si e' immesso un periodo precedente al primo , non copiera' nulla
|
|
{
|
|
m.set(F_1_TRIMESTRE_P,ver.get("R0"));
|
|
m.set(F_2_TRIMESTRE_P,ver.get("R1"));
|
|
m.set(F_3_TRIMESTRE_P,ver.get("R2"));
|
|
m.set(F_4_TRIMESTRE_P,ver.get("R3"));
|
|
m.set(F_ANNUALE_P,ver.get("R4"));
|
|
m.set(F_I_PERIODO_P,ver.get("R5"));
|
|
m.set(F_I_ANNUALE_P,ver.get("R6"));
|
|
m.set(F_I_ACCONTO_P,ver.get("R7"));
|
|
m.set(F_I_INTEGRATIVO_P,ver.get("R8"));
|
|
m.set(F_I_CESSAZIONE_P,ver.get("R9"));
|
|
m.set(F_I_ART74_P,ver.get("R10"));
|
|
m.set(F_P_LIQ_NORMALE_P,ver.get("R11"));
|
|
m.set(F_P_LIQ_DIFFERI_P,ver.get("R12"));
|
|
}
|
|
}
|
|
|
|
void TGeneric_table_app::copy_rec_in_insert_fields(TMask& m)
|
|
{
|
|
TString tmp;
|
|
|
|
tmp = m.get(F_1_TRIMESTRE_P); m.set(F_1_TRIMESTRE, tmp);
|
|
tmp = m.get(F_2_TRIMESTRE_P); m.set(F_2_TRIMESTRE, tmp);
|
|
tmp = m.get(F_3_TRIMESTRE_P); m.set(F_3_TRIMESTRE, tmp);
|
|
tmp = m.get(F_4_TRIMESTRE_P); m.set(F_4_TRIMESTRE, tmp);
|
|
tmp = m.get(F_ANNUALE_P); m.set(F_ANNUALE, tmp);
|
|
tmp = m.get(F_I_PERIODO_P); m.set(F_I_PERIODO,tmp);
|
|
tmp = m.get(F_I_ANNUALE_P); m.set(F_I_ANNUALE,tmp);
|
|
tmp = m.get(F_I_ACCONTO_P); m.set(F_I_ACCONTO,tmp);
|
|
tmp = m.get(F_I_INTEGRATIVO_P); m.set(F_I_INTEGRATIVO,tmp);
|
|
tmp = m.get(F_I_CESSAZIONE_P); m.set(F_I_CESSAZIONE,tmp);
|
|
tmp = m.get(F_I_ART74_P); m.set(F_I_ART74,tmp);
|
|
tmp = m.get(F_P_LIQ_NORMALE_P); m.set(F_P_LIQ_NORMALE,tmp);
|
|
tmp = m.get(F_P_LIQ_DIFFERI_P); m.set(F_P_LIQ_DIFFERI,tmp);
|
|
}
|
|
// -------------------------------------------------------------
|
|
|
|
void TGeneric_table_app::init_insert_mode(TMask& m)
|
|
{
|
|
const TString& n = get_tabname();
|
|
if (n == TAB_REGISTRI)
|
|
{
|
|
const int anno = m.get_int(F_ANNO);
|
|
|
|
m.set(F_STAMPA_INTESTAZIONE, _stampa_intest ? "X" : "");
|
|
TTable reg(TAB_REGISTRI);
|
|
reg.put("CODTAB", m.get(F_ANNO));
|
|
|
|
const TRectype to(reg.curr());
|
|
|
|
_exist_journal = false;
|
|
_exist_dich_int = false;
|
|
|
|
// PIG programming mode
|
|
for (reg.read(_isgteq); !_exist_journal && reg.good() && reg.curr() <= to; reg.next())
|
|
_exist_journal = (reg.get_long("I0") == REG_JOURNAL);
|
|
reg.zero();
|
|
reg.put("CODTAB", m.get(F_ANNO));
|
|
for (reg.read(_isgteq); !_exist_dich_int && reg.good() && reg.curr() <= to; reg.next())
|
|
_exist_dich_int = (reg.get_long("I0") == REG_DICHINT);
|
|
}
|
|
else
|
|
if (n == TAB_VERSAMENTI)
|
|
{
|
|
// Se il record e' nuovo prima carica il record precedente
|
|
load_rec_in_disabled_fields(m);
|
|
// poi copia il contenuto nei campi di input, come valori predefiniti
|
|
copy_rec_in_insert_fields(m);
|
|
}
|
|
else
|
|
if (n == TAB_VALUTE)
|
|
m.enable(-3);
|
|
}
|
|
|
|
void TGeneric_table_app::init_modify_mode(TMask& m)
|
|
{
|
|
Tab_application::init_modify_mode(m);
|
|
const TString& n = get_tabname();
|
|
if (n == TAB_REGISTRI)
|
|
{
|
|
TString16 config;
|
|
config.format("REG%05ld", m.get_long(F_CODDITTA));
|
|
config << m.get(F_CODICE);
|
|
TConfig ini(CONFIG_STAMPE, config);
|
|
const int what = ini.get_int("Type", NULL, -1, -1);
|
|
m.set(F_CONFIG, what >= 0 ? "X" : "");
|
|
m.enable(F_CONFIG, what >= 0);
|
|
} else
|
|
if (n == TAB_VALUTE)
|
|
{
|
|
m.disable(-3); // Disabilita scelta decimali e contro-euro
|
|
} else
|
|
if (n == TAB_VERSAMENTI)
|
|
{
|
|
load_rec_in_disabled_fields(m);
|
|
}
|
|
if (n == TAB_DET)
|
|
{
|
|
const bool prot = get_relation()->curr().get_bool(FPC);
|
|
|
|
m.enable(DLG_SAVEREC, !prot);
|
|
m.enable(DLG_DELREC, !prot);
|
|
}
|
|
}
|
|
|
|
void TGeneric_table_app::init_query_mode(TMask& m)
|
|
{
|
|
Tab_application::init_query_mode(m);
|
|
if (get_tabname() == TAB_DELEGHE)
|
|
{
|
|
m.show(F_BANCA1);
|
|
m.show(F_BANCA2);
|
|
m.show(F_CONCESSIONE);
|
|
}
|
|
}
|
|
|
|
bool TGeneric_table_app::protected_record(TRectype& rec)
|
|
{
|
|
bool prot = rec.get_bool(FPC);
|
|
if (!prot)
|
|
{
|
|
if (get_tabname() == TAB_IVDIRETTIVA) // Impedisce la cancellazione di una classe se ha sottoclassi
|
|
{
|
|
TLocalisamfile& f = get_relation()->lfile();
|
|
const TRecnotype pos = f.recno();
|
|
const TString16 cod(rec.get("CODTAB"));
|
|
const int err = f.next();
|
|
if (err == NOERR)
|
|
{
|
|
TString16 next(f.get("CODTAB")); next.cut(cod.len());
|
|
prot = cod == next;
|
|
}
|
|
f.readat(pos);
|
|
}
|
|
}
|
|
return prot;
|
|
}
|
|
|
|
HIDDEN bool tiporeg_handler(TMask_field& f, KEY k)
|
|
{
|
|
const int tipo = atoi(f.get());
|
|
if ((k == K_TAB || k == K_ENTER) && app().exist_journal() && (tipo == REG_JOURNAL))
|
|
return f.error_box(TR("Non e' possibile avere due registri giornale nello stesso anno"));
|
|
if ((k == K_TAB || k == K_ENTER) && app().exist_dich_int() && (tipo == REG_DICHINT))
|
|
return f.error_box(TR("Non e' possibile avere due registri dichiarazioni d'intenti nello stesso anno"));
|
|
if (k == K_SPACE)
|
|
f.mask().enable_page(1, tipo != REG_DICHINT);
|
|
return true;
|
|
}
|
|
|
|
HIDDEN bool printer_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_SPACE)
|
|
{
|
|
TMask& m = f.mask();
|
|
if (!m.query_mode())
|
|
{
|
|
TString16 config;
|
|
config.format("REG%05ld", m.get_long(F_CODDITTA));
|
|
config << m.get(F_CODICE);
|
|
|
|
if (config.len() > 8) // REG+ANNO+CODICE di tre caratteri
|
|
{
|
|
TPrinter& p = printer();
|
|
p.set_printtype(winprinter); // Force configuration update
|
|
p.read_configuration(config);
|
|
if (p.set())
|
|
{
|
|
m.enable(F_CONFIG);
|
|
m.set(F_CONFIG, "X");
|
|
}
|
|
p.read_configuration();
|
|
}
|
|
else
|
|
return f.error_box(TR("Nessun registro selezionato"));
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
char TGeneric_table_app::frequenza_versamenti(long firm, int year) const
|
|
{
|
|
char freq = 'M';
|
|
|
|
TString16 key; key.format("%05ld%d", firm, year);
|
|
TTable lia("%LIA");
|
|
lia.put("CODTAB", key);
|
|
if (lia.read() != NOERR)
|
|
{
|
|
TLocalisamfile nditte(LF_NDITTE);
|
|
nditte.put("CODDITTA", firm);
|
|
nditte.read();
|
|
freq = nditte.get_char("FREQVIVA");
|
|
}
|
|
else
|
|
freq = lia.get_char("S7");
|
|
CHECK(freq == 'M' || freq == 'T', "Frequenza versamenti IVA assurda");
|
|
|
|
return freq;
|
|
}
|
|
|
|
HIDDEN bool ditta_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (f.to_check(k))
|
|
{
|
|
const long ditta = atol(f.get());
|
|
TFirm firm(ditta);
|
|
f.mask().set(F_CODVAL, firm.codice_valuta());
|
|
}
|
|
return true;
|
|
}
|
|
|
|
HIDDEN bool coddel_handler(TMask_field& f, KEY k)
|
|
{
|
|
TMask& m = f.mask();
|
|
|
|
if (!m.query_mode() && k == K_TAB)
|
|
{
|
|
const short id = f.dlg();
|
|
const long cod = m.get_long(id == F_BANCA1 ? F_BANCA1 : F_CONCESSIONE);
|
|
|
|
if (cod != 0)
|
|
{
|
|
const long firm = m.get_long(F_DITTA);
|
|
TLocalisamfile nditte(LF_NDITTE);
|
|
nditte.put("CODDITTA", firm);
|
|
if (nditte.read() == NOERR)
|
|
{
|
|
const char tipoa = nditte.get_char("TIPOA");
|
|
const long codan = nditte.get_long("CODANAGR");
|
|
TLocalisamfile anag(LF_ANAG);
|
|
anag.put("TIPOA", tipoa);
|
|
anag.put("CODANAGR", codan);
|
|
if (anag.read() == NOERR)
|
|
{
|
|
const bool titcf = anag.get_bool("TITCF");
|
|
const bool isdel = anag.get_long("TIPOSTDEL") == 0l;
|
|
|
|
if (titcf && isdel)
|
|
return true; // Se e' titolare CF e ha scelto la delega vanno abilitati sia
|
|
// Il codice conc. che la banca
|
|
if (id == F_CONCESSIONE)
|
|
{
|
|
if (!titcf)
|
|
{
|
|
m.hide(F_CONCESSIONE);
|
|
f.error_box(TR("Concessione non ammessa senza conto fiscale"));
|
|
}
|
|
else
|
|
{
|
|
m.hide(F_BANCA1);
|
|
m.hide(F_BANCA2);
|
|
}
|
|
}
|
|
else
|
|
m.hide(F_CONCESSIONE);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
HIDDEN bool intdel_handler(TMask_field& f, KEY k)
|
|
{
|
|
const TMask& m = f.mask();
|
|
|
|
if (!m.query_mode() && k == K_ENTER)
|
|
{
|
|
const long firm = m.get_long(F_DITTA);
|
|
const int anno = m.get_int(F_ANNODEL);
|
|
const real imp(m.get(F_IMPORTO));
|
|
const real intr(f.get());
|
|
if (!intr.is_zero())
|
|
if (app().frequenza_versamenti(firm, anno) == 'T')
|
|
{
|
|
TConfig cnf(CONFIG_DITTA, "cg");
|
|
bool isintr = cnf.get_bool("InTrTr");
|
|
if (isintr)
|
|
return f.error_box(TR("Interessi non ammessi: ditta con NO calcolo interessi"));
|
|
}
|
|
else return f.error_box(TR("Interessi non ammessi: ditta con versamenti mensili"));
|
|
|
|
if (imp < intr)
|
|
return f.error_box(TR("Incoerenza importo versato e interessi"));
|
|
else if (!imp.is_zero() && imp == intr)
|
|
return f.error_box(TR("Incoerenza importo versato e interessi"));
|
|
}
|
|
return true;
|
|
}
|
|
|
|
HIDDEN bool impdel_handler(TMask_field& f, KEY k)
|
|
{
|
|
const TMask& m = f.mask();
|
|
|
|
if (!m.query_mode() && f.to_check(k))
|
|
{
|
|
const int anno = m.get_int(F_ANNODEL);
|
|
const int tipo_del = m.get_int(F_TIPODEL);
|
|
const long ditta = m.get_long(F_DITTA);
|
|
TIva_round ir; ir.set_default_iva_mode(anno, tipo_del == 2, ditta);
|
|
|
|
real r(f.get());
|
|
ir.round(r);
|
|
f.set(r.string());
|
|
}
|
|
|
|
if (!m.query_mode() && k == K_ENTER)
|
|
{
|
|
const int tipo_del = m.get_int(F_TIPODEL);
|
|
if (tipo_del == 1 || tipo_del == 7)
|
|
{
|
|
TInteressi_IVA_table ver;
|
|
const int mese_del = m.get_int(F_MESEDEL);
|
|
real lim;
|
|
|
|
if (ver.read(m.get_int(F_ANNODEL), (mese_del>12) ? 12 : mese_del) != NOERR)
|
|
warning_box(FR("Errore %d in lettura tabella versamenti ed interessi."),ver.status());
|
|
if (tipo_del == 1)
|
|
{
|
|
if (mese_del == 12) lim = ver.get(I_ANNUALE);
|
|
else lim = ver.get(I_PERIODICO);
|
|
}
|
|
else lim = ver.get(I_ACCONTOIVA);
|
|
const real imp(m.get(F_IMPORTO));
|
|
if (imp < lim)
|
|
return f.yesno_box(FR("Importo inferiore a %s. Registrare ugualmente?"), lim.string("."));
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
HIDDEN bool mese_handler(TMask_field& f, KEY k)
|
|
{
|
|
|
|
if (k == K_ENTER)
|
|
{
|
|
TMask& m = f.mask();
|
|
const int vers = m.get_int(F_TIPODEL);
|
|
if (vers == 1)
|
|
{
|
|
const int mese = m.get_int(F_MESEDEL);
|
|
const long firm = m.get_long(F_DITTA);
|
|
const int anno = m.get_int(F_ANNODEL);
|
|
|
|
if (app().frequenza_versamenti(firm, anno) == 'T')
|
|
{
|
|
TLocalisamfile nditte(LF_NDITTE);
|
|
nditte.zero();
|
|
nditte.put("CODDITTA",firm);
|
|
if (nditte.read() == NOERR)
|
|
{
|
|
TString16 attprev = nditte.get("CODATTPREV");
|
|
TLocalisamfile attiv(LF_ATTIV);
|
|
attiv.zero();
|
|
attiv.put("CODDITTA",firm);
|
|
attiv.put("CODATT",attprev);
|
|
if (attiv.read() != NOERR) attiv.zero();
|
|
bool benzinaio = attiv.get_bool("ART74_4");
|
|
bool gest4 = false;
|
|
if (benzinaio)
|
|
{
|
|
TConfig cnf(CONFIG_DITTA, "cg");
|
|
gest4 = cnf.get_bool("GesT74");
|
|
}
|
|
if (benzinaio && gest4)
|
|
{
|
|
if (mese != 3 && mese != 6 && mese != 9 && mese != 12 && mese != 13)
|
|
{
|
|
TMask* mask = &m;
|
|
mask->reset();
|
|
return f.error_box(TR("Ditta trimestrale: indicare trimestre"));
|
|
}
|
|
}
|
|
else if (mese != 3 && mese != 6 && mese != 9 && mese != 13)
|
|
{
|
|
TMask* mask = &m;
|
|
mask->reset();
|
|
return f.error_box(TR("Ditta trimestrale: indicare trimestre"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
HIDDEN bool key_handler(TMask& m, KEY k)
|
|
{
|
|
// Per ora facciamo che il SHIFT+F12 attiva sempre il campo 3
|
|
if (m.edit_mode())
|
|
{
|
|
if (k == K_SHIFT+K_F12)
|
|
m.enable(-3);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool TGeneric_table_app::valute_decimals_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_SPACE)
|
|
{
|
|
TMask& m = f.mask();
|
|
const int dec = atoi(f.get());
|
|
TReal_field& exc = (TReal_field&)m.efield(VAL_CHANGE);
|
|
if (dec != exc.decimals())
|
|
{
|
|
exc.set_decimals(dec);
|
|
exc.set(exc.get());
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool TGeneric_table_app::change_decimals_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_TAB && f.to_check(k, true))
|
|
{
|
|
TMask& m = f.mask();
|
|
const int dec = m.get_int(FLD_TABCAM_I2);
|
|
TReal_field& exc = (TReal_field&)f;
|
|
if (dec != exc.decimals())
|
|
{
|
|
exc.set_decimals(dec);
|
|
exc.set(exc.get());
|
|
}
|
|
if (!m.is_running() && exc.empty())
|
|
exc.set(m.get(FLD_TABCAM_R10));
|
|
}
|
|
if (k == K_ENTER)
|
|
{
|
|
TMask& m = f.mask();
|
|
real cambio(f.get());
|
|
/* Obsoleto
|
|
if (cambio > ZERO && m.get_bool(FLD_TABCAM_B1))
|
|
{
|
|
// Se il cambio e' espresso in EURO metto in R10 il valore in lire
|
|
cambio = 1936.27 / cambio;
|
|
cambio.round(5);
|
|
}
|
|
*/
|
|
m.set(FLD_TABCAM_R10, cambio);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool TGeneric_table_app::codcab_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_ENTER && !f.empty())
|
|
{
|
|
TMask& m = f.mask();
|
|
const TString& abi = m.get(f.dlg()-1);
|
|
const TRectype& rec = cache().get(TAB_BANCHE, abi);
|
|
if (rec.empty())
|
|
return f.error_box(FR("Il codice ABI %s non esiste"), (const char*)abi);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool TGeneric_table_app::codmag_handler(TMask_field& f, KEY k)
|
|
{
|
|
TMask& m = f.mask();
|
|
if (m.query_mode() && k == K_ENTER)
|
|
{
|
|
const TString& codice = f.get(); //stringa immessa nella maschera
|
|
const TString& codtab = cache().get("MAG", codice, "CODTAB"); //stringa cercata nella tabella
|
|
if (codtab.empty()) //se non trovi la stringa in tabella (in codice magazzino non esiste->se in insert mode)
|
|
{
|
|
const int lungh = codice.len();
|
|
if (lungh > 0 && lungh < 3)
|
|
return f.error_box("Il codice magazzino deve avere obbligatoriamente lunghezza 3");
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool TGeneric_table_app::codnoc_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (f.to_check(k))
|
|
{
|
|
TString8 str; str << atoi(f.get());
|
|
if (str.len() < f.size())
|
|
str.right_just(f.size(), '0');
|
|
f.set(str);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
|
|
bool TGeneric_table_app::numivd_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (f.to_check(k))
|
|
{
|
|
const TString& val = f.get();
|
|
if (val.not_empty())
|
|
{
|
|
if (!isdigit(val[0]) || !isdigit(val[1]))
|
|
return error_box("i primi due caratteri devono eesere numerici");
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool TGeneric_table_app::user_create()
|
|
{
|
|
bool ok = TTable_application::user_create();
|
|
if (ok)
|
|
{
|
|
const TString& name = get_tabname();
|
|
TMask& mask = *get_mask();
|
|
|
|
if (name == TAB_DELEGHE)
|
|
{
|
|
mask.set_handler(F_DITTA, ditta_handler);
|
|
mask.set_handler(F_MESEDEL, mese_handler);
|
|
mask.set_handler(F_IMPORTO, impdel_handler);
|
|
mask.set_handler(F_INTERESSI, intdel_handler);
|
|
mask.set_handler(F_BANCA1, coddel_handler);
|
|
mask.set_handler(F_CONCESSIONE, coddel_handler);
|
|
}
|
|
if (name == TAB_REGISTRI)
|
|
{
|
|
mask.set_handler(F_TIPO, tiporeg_handler);
|
|
mask.set_handler(F_PRINTER, printer_handler);
|
|
|
|
TConfig st(CONFIG_STUDIO, "cg");
|
|
_stampa_intest = st.get_bool("StiReg");
|
|
}
|
|
if (name == TAB_VALUTE)
|
|
{
|
|
mask.set_handler(VAL_DECIMALS_CHANGE, valute_decimals_handler);
|
|
mask.set_handler(key_handler); // Handler dello SHIFT-F12
|
|
}
|
|
if (name == TAB_CAMBI)
|
|
{
|
|
mask.set_handler(FLD_TABCAM_S4, change_decimals_handler);
|
|
}
|
|
|
|
if (name == TAB_CAMBI)
|
|
set_search_field(FLD_TABCAM_D0);
|
|
|
|
if (name == TAB_BANCHE)
|
|
mask.set_handler(102, codcab_handler);
|
|
|
|
if (name == TAB_NOMENCOMB)
|
|
mask.set_handler(NOC_CODICE2, codnoc_handler);
|
|
|
|
if (name == TAB_IVDIRETTIVA)
|
|
mask.set_handler(F_NUM, numivd_handler);
|
|
}
|
|
|
|
return ok;
|
|
}
|
|
|
|
|
|
bool TGeneric_table_app::user_destroy()
|
|
{
|
|
return Tab_application::user_destroy();
|
|
}
|
|
|
|
int TGeneric_table_app::read(TMask& m)
|
|
{
|
|
int err = Tab_application::read(m);
|
|
const TString & table_name = get_tabname();
|
|
|
|
if (table_name == TAB_SPESE || table_name == TAB_PREST)
|
|
{
|
|
if (get_relation()->lfile().get_real("R10") == ZERO)
|
|
m.set(F_PREZZO, get_relation()->lfile().get("R0"));
|
|
}
|
|
else
|
|
if (table_name == TAB_VALUTE)
|
|
{
|
|
const int dec = m.get_int(VAL_DECIMALS_CHANGE);
|
|
TReal_field& exc = (TReal_field&)m.efield(VAL_CHANGE);
|
|
if (dec != exc.decimals())
|
|
{
|
|
exc.set_decimals(dec);
|
|
exc.set(get_relation()->lfile().get("S4"));
|
|
}
|
|
}
|
|
else
|
|
if (table_name == TAB_CAMBI)
|
|
{
|
|
const int dec = m.get_int(FLD_TABCAM_I2);
|
|
TReal_field& exc = (TReal_field&)m.efield(FLD_TABCAM_S4);
|
|
if (dec != exc.decimals())
|
|
{
|
|
exc.set_decimals(dec);
|
|
exc.set(get_relation()->lfile().get("S4"));
|
|
}
|
|
}
|
|
|
|
|
|
return err;
|
|
}
|
|
|
|
int TGeneric_table_app::write(const TMask& m)
|
|
{
|
|
const TString & table_name = get_tabname();
|
|
|
|
if (table_name == TAB_SPESE || table_name == TAB_PREST)
|
|
get_relation()->lfile().put("R0", m.get(F_PREZZO));
|
|
|
|
return Tab_application::write(m);
|
|
}
|
|
|
|
int TGeneric_table_app::rewrite(const TMask& m)
|
|
{
|
|
const TString & table_name = get_tabname();
|
|
|
|
if (table_name == TAB_REGISTRI && !m.get_bool(F_CONFIG))
|
|
{
|
|
TString16 config;
|
|
config.format("REG%05ld", m.get_long(F_CODDITTA));
|
|
config << m.get(F_CODICE);
|
|
TConfig ini(CONFIG_STAMPE, config);
|
|
const int what = ini.get_int("Type", NULL, -1, -1);
|
|
if (what >= 0)
|
|
ini.set("Type", -1);
|
|
}
|
|
|
|
if (table_name == TAB_SPESE || table_name == TAB_PREST)
|
|
get_relation()->lfile().put("R0", m.get(F_PREZZO));
|
|
|
|
return Tab_application::rewrite(m);
|
|
}
|
|
|
|
int ba3100(int argc, char* argv[])
|
|
{
|
|
TGeneric_table_app a;
|
|
a.run(argc, argv, TR("Tabella"));
|
|
return 0;
|
|
}
|