2855c57074
ba4300.cpp cambiato modo barabaro di definire TTable(TABATT) git-svn-id: svn://10.65.10.50/trunk@4229 c028cbd2-c16b-5b4b-a496-9718f37d4682
708 lines
18 KiB
C++
Executable File
708 lines
18 KiB
C++
Executable File
#include <config.h>
|
|
#include <defmask.h>
|
|
#include <execp.h>
|
|
#include <golem.h>
|
|
#include <mask.h>
|
|
#include <mailbox.h>
|
|
#include <relapp.h>
|
|
#include <tabutil.h>
|
|
#include <utility.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];
|
|
TLocalisamfile* _comuni;
|
|
TLocalisamfile* _tabcom;
|
|
|
|
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 const char* get_next_key();
|
|
virtual TMask* get_mask(int mode) ;
|
|
virtual void write_enable(bool on = TRUE);
|
|
|
|
static bool fax_handler(TMask_field& f, KEY k);
|
|
static bool ba4200_handler(TMask& m, KEY k);
|
|
static bool ind_handler(TMask_field& f, 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 force_cursor_usage() 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_F10)
|
|
{
|
|
if (app.ana_fis()) app.set_next_ana(TGIU);
|
|
else app.set_next_ana(TFIS);
|
|
m.stop_run(K_ESC);
|
|
return FALSE;
|
|
}
|
|
if (k != K_F5 || m.mode() != MODE_MOD) return TRUE;
|
|
TToken_string body(16);
|
|
|
|
body.add(format("%d", FLD_GD1_CODDITTAH));
|
|
if ( app.tip_ana() == TFIS )
|
|
{
|
|
body.add(format("%d=F", FLD_GD1_TIPOA));
|
|
body.add(format("%d=%s", FLD_GD1_CODANAGR, (const char*) app.cod_ana()));
|
|
}
|
|
else
|
|
{
|
|
body.add(format("%d=G", FLD_GD1_TIPOA));
|
|
body.add(format("%d=%s", FLD_GD1_CODANAGR, (const char*) app.cod_ana()));
|
|
}
|
|
TString16 cmd("ba4 -2");
|
|
TMessage msg(cmd2name(cmd), MSG_FS, (const char*) body);
|
|
|
|
msg.send();
|
|
TExternal_app a(cmd);
|
|
a.run();
|
|
m.set_focus();
|
|
return FALSE;
|
|
}
|
|
|
|
bool TPersone_app::fax_handler(TMask_field& f, KEY k)
|
|
{
|
|
bool ok = TRUE;
|
|
if (k == K_SPACE)
|
|
{
|
|
TConfig ini(CONFIG_USER, "Link");
|
|
TFilename editor = ini.get("Editor", NULL, -1, "notepad");
|
|
TExternal_app app(editor);
|
|
ok = app.run(TRUE, FALSE) == 0;
|
|
if (ok)
|
|
{
|
|
const TPersone_app& app = (const TPersone_app&)main_app();
|
|
const char* tipo = app.tip_ana() == 'F' ? "Fisiche" : "Giuridiche";
|
|
const char* codice = app.cod_ana();
|
|
|
|
TDDE dde;
|
|
TString cmd(80);
|
|
cmd << "[SetRecipient(" << tipo << ',' << codice << ")]";
|
|
ok = dde.execute("EASYFAX", "FAX", cmd, "bafax");
|
|
}
|
|
}
|
|
return ok;
|
|
}
|
|
|
|
bool TPersone_app::ind_handler(TMask_field& f, KEY k)
|
|
{
|
|
TMask & m = f.mask();
|
|
|
|
if (!m.query_mode() && (k == K_TAB || k == K_ENTER) && f.empty())
|
|
{
|
|
const bool giuridica = ((TPersone_app&)main_app()).ana_giu();
|
|
|
|
m.set(giuridica ? FLD_AG2_INDCORR : FLD_AF2_INDCORR,
|
|
m.get(giuridica ? FLD_AG2_INDRES : FLD_AF1_INDRES));
|
|
m.set(giuridica ? FLD_AG2_CIVCORR : FLD_AF2_CIVCORR,
|
|
m.get(giuridica ? FLD_AG2_CIVRES : FLD_AF1_CIVRES));
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
void TPersone_app::init_query_mode(TMask& m)
|
|
|
|
{
|
|
m.disable(DLG_DITTE);
|
|
m.enable(DLG_CHGTIP);
|
|
}
|
|
|
|
const char* TPersone_app::get_next_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);
|
|
return format("%d|%ld", FLD_CODANAGR, cod_anagr);
|
|
}
|
|
|
|
|
|
void TPersone_app::init_insert_mode(TMask& m)
|
|
{
|
|
m.disable(DLG_DITTE);
|
|
m.disable(DLG_CHGTIP);
|
|
}
|
|
|
|
|
|
void TPersone_app::init_modify_mode(TMask& m)
|
|
{
|
|
m.enable(DLG_DITTE);
|
|
m.disable(DLG_CHGTIP);
|
|
}
|
|
|
|
HIDDEN bool stato_hnd(TMask_field& f, KEY key)
|
|
{
|
|
if (f.get().empty())
|
|
f.mask().set(FLD_AF1_STATONASC_TABSTE_S0, "Italiana");
|
|
return TRUE;
|
|
}
|
|
|
|
HIDDEN bool corr_hnd(TMask_field& f, bool giuridica)
|
|
{
|
|
TMask & m = f.mask();
|
|
|
|
if (f.get().empty())
|
|
{
|
|
m.set(giuridica ? FLD_AG2_CIVCORR : FLD_AF2_CIVCORR,
|
|
m.get(giuridica ? FLD_AG2_CIVRES : FLD_AF1_CIVRES));
|
|
const TString80 s(m.get(giuridica ? FLD_AG2_COMRES : FLD_AF1_COMRES));
|
|
|
|
if (s.not_empty())
|
|
{
|
|
m.set(giuridica ? FLD_AG2_STATOCORR : FLD_AF2_STATOCORR, m.get(F_STATORES));
|
|
f.set(s);
|
|
m.set(giuridica ? FLD_AG2_CAPCORR : FLD_AF2_CAPCORR,
|
|
m.get(giuridica ? FLD_AG2_CAPRES : FLD_ANAG_CAPRES));
|
|
f.check();
|
|
}
|
|
}
|
|
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 bool giuridica = ((TPersone_app&)main_app()).ana_giu();
|
|
if (dlg == FLD_AG2_COMCORR || dlg == FLD_AF2_COMCORR)
|
|
corr_hnd(f, giuridica);
|
|
|
|
const TString16 val(f.get());
|
|
|
|
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;
|
|
|
|
TString 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;
|
|
|
|
TLocalisamfile comuni(LF_COMUNI);
|
|
|
|
comuni.setkey(1) ;
|
|
comuni.zero() ;
|
|
comuni.put(N_COM, cod_com );
|
|
if (comuni.read() == NOERR)
|
|
{
|
|
msk.set(F_IMP_DENCOM, comuni.get("DENCOM"));
|
|
msk.set(F_IMP_PROVCOM, comuni.get("PROVCOM"));
|
|
|
|
TString s(comuni.get(N_IMPDIR1)) ;
|
|
if (s.empty()) s = comuni.get(N_IMPDIR2) ;
|
|
if (s.empty()) s = comuni.get(N_IMPDIR3) ;
|
|
if (msk.get(F_UFFIIDD).empty() || msk.is_running())
|
|
{
|
|
msk.set(F_UFFIIDD, s) ; msk.field(F_UFFIIDD).on_key(K_TAB);
|
|
}
|
|
s = comuni.get(N_IVA1);
|
|
if (s.empty()) s = comuni.get(N_IVA2) ;
|
|
if (s.empty()) s = comuni.get(N_IVA3) ;
|
|
if (msk.get(F_UFFIVA).empty() || msk.is_running())
|
|
{
|
|
msk.set(F_UFFIVA, s) ; msk.field(F_UFFIVA).on_key(K_TAB);
|
|
}
|
|
msk.set(F_UFFREG, comuni.get("UFFREG")); msk.field(F_UFFREG).on_key(K_TAB);
|
|
if (msk.get_bool(F_TITCF))
|
|
{
|
|
if (msk.get(F_UFFCONC).empty() || msk.is_running())
|
|
msk.set(F_UFFCONC, comuni.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, comuni.get("CODREG"));
|
|
msk.field(F_CODREG96).on_key(K_TAB);
|
|
}
|
|
msk.set(F_UFFCONC_P, comuni.get("UFFCONC")); msk.field(F_UFFCONC_P).on_key(K_TAB);
|
|
msk.set(F_UFFSERV, comuni.get("UFFCSERV")); msk.field(F_UFFSERV).on_key(K_TAB);
|
|
|
|
msk.set(F_CODCONTR_EP, comuni.get("UFFESPROV").mid(1, 2));
|
|
msk.set(F_CODCONTR_EC, comuni.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())
|
|
{
|
|
TLocalisamfile comuni(LF_COMUNI);
|
|
|
|
comuni.setkey(1) ;
|
|
comuni.zero() ;
|
|
comuni.put(N_COM, cod_com );
|
|
if (comuni.read() == NOERR)
|
|
{
|
|
if (msk.get(F_UFFCONC).empty() || msk.is_running())
|
|
msk.set(F_UFFCONC, comuni.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())
|
|
{
|
|
TLocalisamfile comuni(LF_COMUNI);
|
|
|
|
comuni.setkey(1) ;
|
|
comuni.zero() ;
|
|
comuni.put(N_COM, cod_com );
|
|
app.set_reset_uff_conc(comuni.read() == NOERR && msk.get(F_UFFCONC) == comuni.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())
|
|
{
|
|
TLocalisamfile comuni(LF_COMUNI);
|
|
|
|
comuni.setkey(1) ;
|
|
comuni.zero() ;
|
|
comuni.put(N_COM, cod_com );
|
|
app.set_reset_codreg(comuni.read() == NOERR && msk.get(F_CODREG96) == comuni.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("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("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("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(FLD_AF2_INDCORR, ind_handler);
|
|
_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_FAX, fax_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_AG2_INDCORR, ind_handler);
|
|
// _msk[MSKG]->set_handler(FLD_AG1_COFI, no_dup_iva_g);
|
|
_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_FAX, fax_handler);
|
|
|
|
_msk[MSKG]->set_handler(ba4200_handler);
|
|
}
|
|
|
|
return _msk[tip_msk()];
|
|
}
|
|
|
|
bool TPersone_app::user_create()
|
|
|
|
{
|
|
_msk[MSKF] = NULL;
|
|
_rel[MSKF] = new TRelation(LF_ANAG);
|
|
_rel[MSKF]->add(LF_ANAGFIS, "CODANAGR=CODANAGR", 1, 0, 0);
|
|
|
|
_msk[MSKG] = NULL;
|
|
_rel[MSKG] = new TRelation(LF_ANAG);
|
|
_rel[MSKG]->add(LF_ANAGGIU, "CODANAGR=CODANAGR", 1, 0, 0);
|
|
|
|
_comuni = new TLocalisamfile(LF_COMUNI) ;
|
|
_tabcom = new TLocalisamfile(LF_TABCOM) ;
|
|
|
|
if (argc() > 3)
|
|
{
|
|
get_mask(MODE_QUERY);
|
|
TString16 s("1|");
|
|
|
|
s << argv(3);
|
|
set_link(*_msk[tip_msk()], s);
|
|
}
|
|
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 = 0 ; j < 2 ; j++ )
|
|
{
|
|
if (_msk[j]) delete _msk[j] ;
|
|
if (_rel[j]) delete _rel[j] ;
|
|
}
|
|
delete _comuni;
|
|
delete _tabcom;
|
|
|
|
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);
|
|
/* if (ana_fis())
|
|
{
|
|
if (m.field(FLD_AF2_INDRF).dirty() || m.field(FLD_AF2_CIVRF).dirty() ||
|
|
m.field(FLD_AF2_CAPRF).dirty() || m.field(FLD_AF2_COMRF).dirty())
|
|
message_box("Attenzione e' stata variata la residenza fiscale. Controllare le unita' locali");
|
|
}
|
|
else
|
|
{
|
|
if (m.field(FLD_AG1_INDRF).dirty() || m.field(FLD_AG1_CIVRF).dirty() ||
|
|
m.field(FLD_AG1_CAPRF).dirty() || m.field(FLD_AG1_COMRF).dirty())
|
|
message_box("Attenzione e' stata variata la residenza fiscale. Controllare le unita' locali");
|
|
} */
|
|
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, "Anagrafica Persone");
|
|
return 0;
|
|
}
|