Corretti erroti MI0141 e MI0130

git-svn-id: svn://10.65.10.50/trunk@616 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 1994-11-14 12:10:38 +00:00
parent 00b86d414e
commit dafe562bd5

View File

@ -33,6 +33,7 @@ public:
virtual TRelation* get_relation() const {return _rel;} virtual TRelation* get_relation() const {return _rel;}
CG0100_application() {} CG0100_application() {}
}; };
HIDDEN inline CG0100_application & app() { return (CG0100_application &) main_app();}
int CG0100_application::read(TMask& m) int CG0100_application::read(TMask& m)
@ -124,6 +125,7 @@ bool CG0100_application::protected_record(TRectype &rec)
conto ==_saldi->get_int(PCN_CONTO) && conto ==_saldi->get_int(PCN_CONTO) &&
sottoc ==_saldi->get_long(PCN_SOTTOCONTO); sottoc ==_saldi->get_long(PCN_SOTTOCONTO);
} }
get_relation()->save_status();
pconti.zero() ; pconti.zero() ;
pconti.put(PCN_GRUPPO, gruppo); pconti.put(PCN_GRUPPO, gruppo);
// Se e' un conto controllo se ha dei sottoconti // Se e' un conto controllo se ha dei sottoconti
@ -134,8 +136,9 @@ bool CG0100_application::protected_record(TRectype &rec)
pconti.setkey(1) ; pconti.setkey(1) ;
pconti.read(); pconti.read();
pconti.next(); pconti.next();
const bool prot = (pconti.good() && (pconti.curr() == rec1));
return pconti.good() && (pconti.curr() == rec1); get_relation()->restore_status();
return prot;
} }
void CG0100_application::init_query_mode(TMask& m) void CG0100_application::init_query_mode(TMask& m)
@ -250,38 +253,43 @@ HIDDEN bool gruppo_handler(TMask_field& f, KEY key)
const TMask& m = f.mask(); const TMask& m = f.mask();
const int gruppo = atoi(m.get(FLD_CM1_GRUPPO)); const int gruppo = atoi(m.get(FLD_CM1_GRUPPO));
const int conto = atoi(m.get(FLD_CM1_CONTO)); const int conto = atoi(m.get(FLD_CM1_CONTO));
const long sottoc = atol(m.get(FLD_CM1_SOTTOCONTO)); TLocalisamfile& pconti = app().get_relation()->lfile();
if (gruppo == 0 && conto == 0 && sottoc == 0) if (gruppo != 0 && conto != 0)
return TRUE;
CG0100_application & app = (CG0100_application &) main_app();
TLocalisamfile& pconti = app.get_relation()->lfile();
if ((gruppo == 0) && (conto != 0 || sottoc != 0))
return f.warning_box("Codice conto impossibile!");
if (conto > 0 && sottoc == 0) // conto => ricerca gruppo
{ {
pconti.zero() ; pconti.zero() ;
pconti.put(PCN_GRUPPO, gruppo) ; pconti.put(PCN_GRUPPO, gruppo) ;
pconti.setkey(1) ; pconti.setkey(1) ;
pconti.read(_isequal, _nolock ); pconti.read();
if (pconti.bad()) if (pconti.bad())
return f.warning_box ("Non esiste il gruppo relativo a questo conto"); return f.warning_box ("Il gruppo non esiste");
} }
if (sottoc > 0) // sottoconto => ricerca conto }
return TRUE;
}
HIDDEN bool conto_handler(TMask_field& f, KEY key)
{
if (key == K_ENTER)
{
const TMask& m = f.mask();
const int gruppo = atoi(m.get(FLD_CM1_GRUPPO));
const int conto = atoi(m.get(FLD_CM1_CONTO));
const long sottoc = atol(m.get(FLD_CM1_SOTTOCONTO));
TLocalisamfile& pconti = app().get_relation()->lfile();
if (gruppo != 0 && conto != 0 && sottoc != 0)
{ {
pconti.zero() ; pconti.zero() ;
pconti.put(PCN_GRUPPO, gruppo) ; pconti.put(PCN_GRUPPO, gruppo) ;
pconti.put(PCN_CONTO, conto) ; pconti.put(PCN_CONTO, conto) ;
pconti.setkey(1) ; pconti.setkey(1) ;
pconti.read(_isequal, _nolock ); pconti.read();
if (pconti.bad()) if (pconti.bad())
return f.warning_box ("Non esiste il conto relativo a questo sottoconto"); return m.field(FLD_CM1_CONTO).warning_box ("Il conto non esiste");
else else
{ {
TString tmcf = pconti.get(PCN_TMCF); if (pconti.get(PCN_TMCF).not_empty())
if (tmcf.not_empty()) return m.field(FLD_CM1_SOTTOCONTO).warning_box ("Non e' possibile inserire un sottoconto di un conto relativo ad un cliente/fornitore");
return f.warning_box ("Non puoi inserire un sottoconto di un conto relativo ad un cliente/fornitore");
} }
} }
} }
@ -292,12 +300,13 @@ HIDDEN bool sottoc_handler(TMask_field& f, KEY key)
{ {
if (key == K_TAB) if (key == K_TAB)
{ {
int gruppo = f.mask().get_int(FLD_CM1_GRUPPO); const int gruppo = f.mask().get_int(FLD_CM1_GRUPPO);
if (gruppo == 0) return TRUE; if (gruppo == 0) return TRUE;
int conto = f.mask().get_int(FLD_CM1_CONTO); const int conto = f.mask().get_int(FLD_CM1_CONTO);
long sottoconto = f.mask().get_long(FLD_CM1_SOTTOCONTO); const long sottoconto = f.mask().get_long(FLD_CM1_SOTTOCONTO);
if (sottoconto != 0 && conto == 0) return f.error_box("Manca il CONTO"); if (sottoconto != 0 && conto == 0)
f.mask().stop_run(K_AUTO_ENTER); return f.mask().field(FLD_CM1_CONTO).error_box("Manca il conto");
return f.mask().stop_run(K_AUTO_ENTER);
} }
return TRUE; return TRUE;
} }
@ -306,8 +315,8 @@ bool CG0100_application::user_create()
{ {
_msk = new TMask("cg0100a") ; _msk = new TMask("cg0100a") ;
_msk->set_handler(FLD_CM1_GRUPPO, gruppo_handler); _msk->set_handler(FLD_CM1_GRUPPO, gruppo_handler);
_msk->set_handler(FLD_CM1_CONTO, conto_handler);
_msk->set_handler(FLD_CM1_SOTTOCONTO, sottoc_handler); _msk->set_handler(FLD_CM1_SOTTOCONTO, sottoc_handler);
/* _msk->set_handler(FLD_CM1_INDBIL, indbil_handler); */
_msk->set_handler(FLD_CM1_TMCF, tmcf_handler); _msk->set_handler(FLD_CM1_TMCF, tmcf_handler);
_rel = new TRelation(LF_PCON); _rel = new TRelation(LF_PCON);