Patch level : 10.0
Files correlati : cg0 Ricompilazione Demo : [ ] Commento : Migliorato controllo di protezione dalla cancellazione dei sottoconti git-svn-id: svn://10.65.10.50/trunk@17360 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
ade0661ad8
commit
f25b2776e7
152
cg/cg0100.cpp
152
cg/cg0100.cpp
@ -1,6 +1,5 @@
|
|||||||
#include <recarray.h>
|
#include <recarray.h>
|
||||||
#include <relapp.h>
|
#include <relapp.h>
|
||||||
#include <defmask.h>
|
|
||||||
|
|
||||||
#include "cg0.h"
|
#include "cg0.h"
|
||||||
#include "cg0100.h"
|
#include "cg0100.h"
|
||||||
@ -8,17 +7,12 @@
|
|||||||
#include <pconti.h>
|
#include <pconti.h>
|
||||||
#include <saldi.h>
|
#include <saldi.h>
|
||||||
|
|
||||||
#define ATTIVITA 1
|
enum TIndicatore_bilancio { ATTIVITA=1, PASSIVITA, COSTI, RICAVI, ORDINE };
|
||||||
#define PASSIVITA 2
|
|
||||||
#define COSTI 3
|
|
||||||
#define RICAVI 4
|
|
||||||
#define ORDINE 5
|
|
||||||
|
|
||||||
class TPianoconti_app : public TRelation_application
|
class TPianoconti_app : public TRelation_application
|
||||||
{
|
{
|
||||||
TMask* _msk;
|
TMask* _msk;
|
||||||
TRelation *_rel;
|
TRelation *_rel;
|
||||||
bool _pcon_com;
|
|
||||||
|
|
||||||
bool user_create();
|
bool user_create();
|
||||||
bool user_destroy();
|
bool user_destroy();
|
||||||
@ -31,22 +25,18 @@ class TPianoconti_app : public TRelation_application
|
|||||||
virtual int write(const TMask& m);
|
virtual int write(const TMask& m);
|
||||||
virtual int rewrite(const TMask & m);
|
virtual int rewrite(const TMask & m);
|
||||||
virtual int read(TMask& m);
|
virtual int read(TMask& m);
|
||||||
virtual void on_firm_change();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// @cmember Disabilita la verifica del modulo : essendo una anagrafica, va sempre abilitata
|
// @cmember Disabilita la verifica del modulo : essendo una anagrafica, va sempre abilitata
|
||||||
virtual bool check_autorization() const
|
virtual bool check_autorization() const { return false; }
|
||||||
{return FALSE;}
|
|
||||||
virtual TRelation* get_relation() const {return _rel;}
|
virtual TRelation* get_relation() const {return _rel;}
|
||||||
TPianoconti_app() : _pcon_com(FALSE) {}
|
|
||||||
};
|
};
|
||||||
HIDDEN inline TPianoconti_app & app() { return (TPianoconti_app &) main_app();}
|
|
||||||
|
|
||||||
|
HIDDEN inline TPianoconti_app& app() { return (TPianoconti_app&) main_app();}
|
||||||
|
|
||||||
int TPianoconti_app::read(TMask& m)
|
int TPianoconti_app::read(TMask& m)
|
||||||
|
|
||||||
{
|
{
|
||||||
const TRelation *r = get_relation();
|
const TRelation* r = get_relation();
|
||||||
m.autoload(*r);
|
m.autoload(*r);
|
||||||
if (m.get(FLD_CM1_LETTIVD).empty())
|
if (m.get(FLD_CM1_LETTIVD).empty())
|
||||||
{
|
{
|
||||||
@ -115,60 +105,39 @@ int TPianoconti_app::write(const TMask& m)
|
|||||||
return r->write();
|
return r->write();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Controlla se puo' essere effettuata la cancellazione di un conto
|
|
||||||
void TPianoconti_app::on_firm_change()
|
|
||||||
{
|
|
||||||
TDir d;
|
|
||||||
d.get(LF_PCON, _nolock, _nordir, _sysdirop);
|
|
||||||
_pcon_com = d.is_com();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TPianoconti_app::protected_record(TRectype &rec)
|
bool TPianoconti_app::protected_record(TRectype &rec)
|
||||||
{
|
{
|
||||||
if (!_pcon_com )
|
bool prot = false;
|
||||||
|
|
||||||
|
const int gruppo = rec.get_int(PCN_GRUPPO);
|
||||||
|
const int conto = rec.get_int(PCN_CONTO);
|
||||||
|
const long sottoc = rec.get_long(PCN_SOTTOCONTO);
|
||||||
|
|
||||||
|
// Se e' un sottoconto posso cancellarlo se non esistono saldi
|
||||||
|
if (sottoc != 0)
|
||||||
{
|
{
|
||||||
TMask* m = get_mask(MODE_MOD);
|
TLocalisamfile saldi(LF_SALDI);
|
||||||
const int gruppo = m->get_int(FLD_CM1_GRUPPO);
|
saldi.setkey(2);
|
||||||
const int conto = m->get_int(FLD_CM1_CONTO);
|
saldi.put(PCN_GRUPPO, gruppo);
|
||||||
const long sottoc = m->get_long(FLD_CM1_SOTTOCONTO);
|
saldi.put(PCN_CONTO, conto);
|
||||||
|
saldi.put(PCN_SOTTOCONTO, sottoc);
|
||||||
// Se e' un sottoconto posso cancellarlo se non esistono saldi
|
prot = saldi.read(_isgteq) == NOERR &&
|
||||||
if ((gruppo != 0) && (conto != 0) && (sottoc != 0))
|
gruppo == saldi.get_int(PCN_GRUPPO) && conto == saldi.get_int(PCN_CONTO) && sottoc == saldi.get_long(PCN_SOTTOCONTO) &&
|
||||||
{
|
(saldi.get_real(SLD_SALDO) != ZERO || saldi.get_real(SLD_PDARE) != ZERO ||
|
||||||
TLocalisamfile saldi(LF_SALDI);
|
saldi.get_real(SLD_PAVERE) != ZERO || saldi.get_real(SLD_SALDOFIN) != ZERO ||
|
||||||
|
saldi.get_real(SLD_PDAREPRO) != ZERO || saldi.get_real(SLD_PAVEREPRO) != ZERO);
|
||||||
saldi.setkey(2);
|
|
||||||
saldi.put(PCN_GRUPPO, gruppo);
|
|
||||||
saldi.put(PCN_CONTO, conto);
|
|
||||||
saldi.put(PCN_SOTTOCONTO, sottoc);
|
|
||||||
saldi.read(_isgteq);
|
|
||||||
return saldi.good() &&
|
|
||||||
gruppo == saldi.get_int(PCN_GRUPPO) && conto == saldi.get_int(PCN_CONTO) && sottoc == saldi.get_long(PCN_SOTTOCONTO) &&
|
|
||||||
(saldi.get_real(SLD_SALDO) != ZERO || saldi.get_real(SLD_PDARE) != ZERO ||
|
|
||||||
saldi.get_real(SLD_PAVERE) != ZERO || saldi.get_real(SLD_SALDOFIN) != ZERO ||
|
|
||||||
saldi.get_real(SLD_PDAREPRO) != ZERO || saldi.get_real(SLD_PAVEREPRO) != ZERO);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
TLocalisamfile& pconti = _rel->lfile();
|
|
||||||
|
|
||||||
get_relation()->save_status();
|
|
||||||
pconti.zero() ;
|
|
||||||
pconti.put(PCN_GRUPPO, gruppo);
|
|
||||||
// Se e' un conto controllo se ha dei sottoconti
|
|
||||||
if (conto != 0)
|
|
||||||
pconti.put(PCN_CONTO, conto);
|
|
||||||
TRectype rec1(pconti.curr());
|
|
||||||
|
|
||||||
pconti.setkey(1) ;
|
|
||||||
pconti.read();
|
|
||||||
pconti.next();
|
|
||||||
bool prot = (pconti.good() && (pconti.curr() == rec1));
|
|
||||||
get_relation()->restore_status();
|
|
||||||
return prot;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return FALSE;
|
else
|
||||||
|
{
|
||||||
|
TLocalisamfile pconti(LF_PCON);
|
||||||
|
pconti.put(PCN_GRUPPO, gruppo);
|
||||||
|
// Se e' un conto controllo se ha dei sottoconti
|
||||||
|
if (conto != 0)
|
||||||
|
pconti.put(PCN_CONTO, conto);
|
||||||
|
const TRectype rec1(pconti.curr());
|
||||||
|
prot = pconti.read(_isgreat) == NOERR && pconti.curr().same_key(rec1, 1, 1);
|
||||||
|
}
|
||||||
|
return prot;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TPianoconti_app::init_query_mode(TMask& m)
|
void TPianoconti_app::init_query_mode(TMask& m)
|
||||||
@ -289,71 +258,47 @@ void TPianoconti_app::init_insert_mode(TMask& m)
|
|||||||
|
|
||||||
HIDDEN bool gruppo_handler(TMask_field& f, KEY key)
|
HIDDEN bool gruppo_handler(TMask_field& f, KEY key)
|
||||||
{
|
{
|
||||||
TMask& m = f.mask();
|
|
||||||
const int gruppo = m.get_int(FLD_CM1_GRUPPO);
|
|
||||||
const int conto = m.get_int(FLD_CM1_CONTO);
|
|
||||||
// const long sottoc = m.get_long(FLD_CM1_SOTTOCONTO);
|
|
||||||
|
|
||||||
if (key == K_ENTER)
|
if (key == K_ENTER)
|
||||||
{
|
{
|
||||||
TLocalisamfile& pconti = app().get_relation()->lfile();
|
TMask& m = f.mask();
|
||||||
|
const int gruppo = m.get_int(FLD_CM1_GRUPPO);
|
||||||
|
const int conto = m.get_int(FLD_CM1_CONTO);
|
||||||
if (gruppo != 0 && conto != 0)
|
if (gruppo != 0 && conto != 0)
|
||||||
{
|
{
|
||||||
pconti.zero() ;
|
TLocalisamfile pconti(LF_PCON);
|
||||||
pconti.put(PCN_GRUPPO, gruppo) ;
|
pconti.put(PCN_GRUPPO, gruppo) ;
|
||||||
pconti.setkey(1) ;
|
if (pconti.read() != NOERR)
|
||||||
pconti.read();
|
return f.error_box (TR("Il gruppo non esiste"));
|
||||||
if (pconti.bad())
|
|
||||||
return f.warning_box (TR("Il gruppo non esiste"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HIDDEN bool conto_handler(TMask_field& f, KEY key)
|
HIDDEN bool conto_handler(TMask_field& f, KEY key)
|
||||||
{
|
{
|
||||||
TMask& m = f.mask();
|
|
||||||
const int gruppo = m.get_int(FLD_CM1_GRUPPO);
|
|
||||||
const int conto = m.get_int(FLD_CM1_CONTO);
|
|
||||||
const long sottoc = m.get_long(FLD_CM1_SOTTOCONTO);
|
|
||||||
|
|
||||||
if (key == K_ENTER)
|
if (key == K_ENTER)
|
||||||
{
|
{
|
||||||
TLocalisamfile& pconti = app().get_relation()->lfile();
|
TMask& m = f.mask();
|
||||||
|
const int gruppo = m.get_int(FLD_CM1_GRUPPO);
|
||||||
|
const int conto = m.get_int(FLD_CM1_CONTO);
|
||||||
|
const long sottoc = m.get_long(FLD_CM1_SOTTOCONTO);
|
||||||
if (gruppo != 0 && conto != 0 && sottoc != 0)
|
if (gruppo != 0 && conto != 0 && sottoc != 0)
|
||||||
{
|
{
|
||||||
pconti.zero() ;
|
TLocalisamfile pconti(LF_PCON);
|
||||||
pconti.put(PCN_GRUPPO, gruppo) ;
|
pconti.put(PCN_GRUPPO, gruppo) ;
|
||||||
pconti.put(PCN_CONTO, conto) ;
|
pconti.put(PCN_CONTO, conto) ;
|
||||||
pconti.setkey(1) ;
|
if (pconti.read() != NOERR)
|
||||||
pconti.read();
|
return m.field(FLD_CM1_CONTO).error_box (TR("Il conto non esiste"));
|
||||||
if (pconti.bad())
|
|
||||||
return m.field(FLD_CM1_CONTO).warning_box (TR("Il conto non esiste"));
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (pconti.get(PCN_TMCF).not_empty())
|
if (pconti.get(PCN_TMCF).not_empty())
|
||||||
return m.field(FLD_CM1_SOTTOCONTO).warning_box (TR("Non e' possibile inserire un sottoconto di un conto relativo ad un cliente/fornitore"));
|
return m.field(FLD_CM1_SOTTOCONTO).error_box (TR("Non e' possibile inserire un sottoconto di un conto relativo ad un cliente/fornitore"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
HIDDEN bool sottoc_handler(TMask_field& f, KEY key)
|
|
||||||
{
|
|
||||||
TMask& m = f.mask();
|
|
||||||
if (m.query_mode() && key == K_TAB)
|
|
||||||
{
|
|
||||||
const int gruppo = m.get_int(FLD_CM1_GRUPPO);
|
|
||||||
// const int conto = m.get_int(FLD_CM1_CONTO);
|
|
||||||
// const long sottoc = m.get_long(FLD_CM1_SOTTOCONTO);
|
|
||||||
if (gruppo == 0) return TRUE;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TPianoconti_app::user_create()
|
bool TPianoconti_app::user_create()
|
||||||
{
|
{
|
||||||
open_files(LF_PCON, LF_SALDI, LF_TABCOM, LF_ABPCON, 0);
|
open_files(LF_PCON, LF_SALDI, LF_TABCOM, LF_ABPCON, 0);
|
||||||
@ -361,7 +306,6 @@ bool TPianoconti_app::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_CONTO, conto_handler);
|
||||||
_msk->set_handler(FLD_CM1_SOTTOCONTO, sottoc_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);
|
||||||
// set_search_field(FH_SOTTOCONTO); // Ottima trovata, ma non funziona
|
// set_search_field(FH_SOTTOCONTO); // Ottima trovata, ma non funziona
|
||||||
|
Loading…
x
Reference in New Issue
Block a user