diff --git a/cg/cg5200.cpp b/cg/cg5200.cpp index 60d5cf87a..eb5076412 100755 --- a/cg/cg5200.cpp +++ b/cg/cg5200.cpp @@ -64,7 +64,9 @@ bool TRiga_array::add_riga(const TRectype& rec_saldi) udatar = rec_saldi.get(SLD_DATAULMOV); unumr = rec_saldi.get_long(SLD_NUMULTMOV); udatar = fnc_max(udatar,udata); - unumr = (unum > unumr) ? unum : unumr; + //unumr = (unum > unumr) ? unum : unumr; + if (udata > udatar) + unumr = unum; if (flagr == flag) saldoinir += saldoini; else saldoinir -= saldoini; @@ -99,12 +101,10 @@ bool TRiga_array::add_riga(const TRectype& rec_saldi) return found; } -bool gruppo_handler (TMask_field& f, KEY k); bool sottoc_handler (TMask_field& f, KEY k); class CG5200_application : public TBrowse_application { - friend bool gruppo_handler (TMask_field& f, KEY k); friend bool sottoc_handler (TMask_field& f, KEY k); TMask* _msk; @@ -153,17 +153,17 @@ bool CG5200_application::fai_filtro() { TSaldo sld; int annop = 0; - TString tipo (1); + char tipo; _saldo_gruppo = _saldo_conto = _saldo_sottoc = FALSE; TMask* m = app()->main_mask(); - tipo = m->get(F_TIPOCF); + tipo = m->get(F_TIPOCF)[0]; _anno = m->get_int(F_ANNO); _g = m->get_int(F_GRUPPO); _c = m->get_int(F_CONTO); - if (tipo == "") + if (tipo == '\0') _s = m->get_long(F_SOTTOCONTO); - else if (tipo == "C") + else if (tipo == 'C') _s = m->get_long(F_SOTTOC_CLIENTE); else _s = m->get_long(F_SOTTOC_FORN); if (_c == 0) @@ -212,73 +212,30 @@ bool CG5200_application::fai_filtro() return TRUE; } -bool gruppo_handler(TMask_field& f, KEY key) -{ - if ( key == K_TAB && f.mask().is_running() ) - { - TMask& m = f.mask(); - const int gruppo = m.get_int(F_GRUPPO); - const int conto = m.get_int(F_CONTO); - const long sottoc = m.get_long(F_SOTTOCONTO); - TLocalisamfile& pconti = app()->get_relation()->lfile(); - - if (gruppo == 0) - { - if (conto != 0 || sottoc != 0) - return f.warning_box("Codice conto impossibile!"); - else - return f.error_box("E' obbligatorio l'inserimento del gruppo"); - } - if (conto > 0 && sottoc == 0) // conto => ricerca gruppo - { - pconti.zero() ; - pconti.put(PCN_GRUPPO, gruppo) ; - pconti.setkey(1) ; - pconti.read(_isequal, _nolock ); - if (pconti.bad()) - return f.warning_box ("Non esiste il gruppo relativo a questo conto"); - } - if (sottoc > 0) // sottoconto => ricerca conto - { - pconti.zero() ; - pconti.put(PCN_GRUPPO, gruppo) ; - pconti.put(PCN_CONTO, conto) ; - pconti.setkey(1) ; - pconti.read(_isequal, _nolock ); - if (pconti.bad()) - return f.warning_box ("Non esiste il conto relativo a questo sottoconto"); - /* - else - { - TString tmcf = pconti.get(PCN_TMCF); - if (tmcf.not_empty()) - return f.warning_box ("Non puoi inserire un sottoconto di un conto relativo ad un cliente/fornitore"); - } - */ - } - } - return TRUE; -} - - bool sottoc_handler(TMask_field& f, KEY key) { const short id = f.dlg(); - int gruppo; - long sottoconto = f.mask().get_long(id); + const int gruppo = f.mask().get_int(F_GRUPPO); + const int conto = f.mask().get_int(F_CONTO); + const long sottoconto = f.mask().get_long(id); + TLocalisamfile& pconti = app()->get_relation()->lfile(); - if (key == K_TAB) + if ( key == K_TAB && f.mask().is_running() ) { - TLocalisamfile pconti(LF_PCON); - gruppo = f.mask().get_int(F_GRUPPO); - - if (gruppo == 0) - return TRUE; - - int conto = f.mask().get_int(F_CONTO); - + if (!f.focusdirty() && gruppo == 0 && conto == 0) return TRUE; + if (sottoconto != 0 && conto == 0) - return f.error_box("Manca il CONTO"); + { + f.warning_box("Manca il CONTO"); + f.mask().stop_run(K_ESC); + return FALSE; + } + if (conto != 0 && gruppo == 0) + { + f.warning_box("Manca il GRUPPO"); + f.mask().stop_run(K_ESC); + return FALSE; + } if (id == F_SOTTOCONTO) { @@ -289,9 +246,15 @@ bool sottoc_handler(TMask_field& f, KEY key) pconti.setkey(1); pconti.read(_isequal, _nolock); if (pconti.good()) + { + TString ds = pconti.get(PCN_DESCR); + f.mask().set(F_DESCR_CONTO, ds); + f.mask().set(F_DESCR_CLIENTE, ds); + f.mask().set(F_DESCR_FORN, ds); f.mask().stop_run(K_AUTO_ENTER); + } + else return f.warning_box("Registrazione assente"); } - if (id == F_SOTTOC_CLIENTE || id == F_SOTTOC_FORN) { char tipo = id == F_SOTTOC_CLIENTE ? 'C' : 'F'; @@ -309,8 +272,7 @@ bool sottoc_handler(TMask_field& f, KEY key) f.mask().set(F_DESCR_FORN, rs); f.mask().stop_run(K_AUTO_ENTER); } - else return f.error_box("Registrazione assente"); - + else return f.warning_box("Registrazione assente"); } else if (gruppo != 0 && conto != 0) @@ -325,11 +287,11 @@ bool sottoc_handler(TMask_field& f, KEY key) TString ds = pconti.get(PCN_DESCR); f.mask().set(F_DESCR_CLIENTE, ds); f.mask().set(F_DESCR_FORN, ds); + f.mask().set(F_DESCR_CONTO, ds); } + // if (!f.focusdirty()) f.mask().stop_run(K_AUTO_ENTER); f.mask().stop_run(K_AUTO_ENTER); - } - // else - // return f.error_box("Registrazione assente"); + } } } // f.mask().stop_run(K_AUTO_ENTER); @@ -339,7 +301,6 @@ bool sottoc_handler(TMask_field& f, KEY key) bool CG5200_application::user_create() { _msk = new TMask("cg5200a"); - _msk->set_handler(F_GRUPPO, gruppo_handler); _msk->set_handler(F_SOTTOCONTO, sottoc_handler); _msk->set_handler(F_SOTTOC_CLIENTE, sottoc_handler); _msk->set_handler(F_SOTTOC_FORN, sottoc_handler); diff --git a/cg/cg5200a.uml b/cg/cg5200a.uml index e207cd835..116a71ca1 100755 --- a/cg/cg5200a.uml +++ b/cg/cg5200a.uml @@ -47,8 +47,7 @@ BEGIN DISPLAY "Gruppo" GRUPPO DISPLAY "Descrizione@50" DESCR OUTPUT F_GRUPPO GRUPPO - OUTPUT F_DESCR_CONTO DESCR - CHECKTYPE NORMAL + //OUTPUT F_DESCR_CONTO DESCR FLAGS "R" END @@ -63,21 +62,25 @@ BEGIN DISPLAY "Gruppo" GRUPPO DISPLAY "Conto" CONTO DISPLAY "Descrizione@50" DESCR - OUTPUT F_TIPOCF TMCF - OUTPUT F_GRUPPO GRUPPO OUTPUT F_CONTO CONTO - OUTPUT F_DESCR_CONTO DESCR + OUTPUT F_GRUPPO GRUPPO + OUTPUT F_TIPOCF TMCF + //OUTPUT F_DESCR_CLIENTE DESCR + //OUTPUT F_DESCR_FORN DESCR + //OUTPUT F_DESCR_CONTO DESCR + FLAGS "R" CHECKTYPE NORMAL WARNING "Conto inesistente o mancante" - MESSAGE DIRTY,F_DESCR_CONTO|DIRTY,F_DESCR_CLIENTE|DIRTY,F_DESCR_FORN + //MESSAGE DIRTY,F_SOTTOCONTO|DIRTY,F_SOTTOC_CLIENTE|DIRTY,F_SOTTOC_FORN + //MESSAGE DIRTY,F_DESCR_CONTO|DIRTY,F_DESCR_CLIENTE|DIRTY,F_DESCR_FORN END NUMBER F_SOTTOCONTO 6 BEGIN PROMPT 54 3 "Sottoconto " - USE LF_PCON - FIELD LF_PCON->SOTTOCONTO + USE LF_PCON SELECT SOTTOCONTO!="" + FIELD LF_PCON->SOTTOCONTO KEY 1 INPUT GRUPPO F_GRUPPO INPUT CONTO F_CONTO @@ -86,12 +89,18 @@ BEGIN DISPLAY "Conto" CONTO DISPLAY "Sottoconto" SOTTOCONTO DISPLAY "Descrizione@50" DESCR + OUTPUT F_SOTTOCONTO SOTTOCONTO OUTPUT F_GRUPPO GRUPPO OUTPUT F_CONTO CONTO - OUTPUT F_SOTTOCONTO SOTTOCONTO - OUTPUT F_DESCR_CONTO DESCR + //OUTPUT F_DESCR_CONTO DESCR + //OUTPUT F_DESCR_CLIENTE DESCR + //OUTPUT F_DESCR_FORN DESCR + //CHECKTYPE NORMAL + //MESSAGE COPY,F_SOTTOC_FORN //li gestisco da programma senno' fanno casino + //MESSAGE COPY,F_SOTTOC_CLIENTE FLAGS "R" CHECKTYPE NORMAL + //VALIDATE AUTOEXIT_FUNC 3 F_GRUPPO F_CONTO F_SOTTOCONTO GROUP 1 WARNING "Conto inesistente" END @@ -100,6 +109,7 @@ NUMBER F_SOTTOC_CLIENTE 6 BEGIN PROMPT 54 3 "Cliente " USE LF_CLIFO +//FIELD LF_CLIFO->CODCF INPUT TIPOCF "C" INPUT CODCF F_SOTTOC_CLIENTE DISPLAY "Codice" CODCF @@ -107,11 +117,14 @@ BEGIN DISPLAY "Gruppo" GRUPPO DISPLAY "Conto" CONTO OUTPUT F_SOTTOC_CLIENTE CODCF - OUTPUT F_DESCR_CONTO RAGSOC +//OUTPUT F_DESCR_CONTO RAGSOC +//OUTPUT F_DESCR_CLIENTE RAGSOC +//OUTPUT F_DESCR_FORN RAGSOC FLAGS "R" + CHECKTYPE NORMAL KEY 1 - CHECKTYPE NORMAL WARNING "Cliente inesistente" + //VALIDATE AUTOEXIT_FUNC 3 F_GRUPPO F_CONTO F_SOTTOC_CLIENTE GROUP 2 END @@ -126,11 +139,15 @@ BEGIN DISPLAY "Gruppo" GRUPPO DISPLAY "Conto" CONTO OUTPUT F_SOTTOC_FORN CODCF - OUTPUT F_DESCR_CONTO RAGSOC +// OUTPUT F_DESCR_FORN RAGSOC +// OUTPUT F_DESCR_CONTO RAGSOC +// OUTPUT F_DESCR_CLIENTE RAGSOC FLAGS "R" - KEY 1 CHECKTYPE NORMAL +// serve per l' autopremimento + KEY 1 WARNING "Fornitore inesistente" + //VALIDATE AUTOEXIT_FUNC 3 F_GRUPPO F_CONTO F_SOTTOC_FORN GROUP 3 END @@ -159,7 +176,7 @@ BEGIN DISPLAY "Gruppo" GRUPPO DISPLAY "Conto" CONTO DISPLAY "Codice" CODCF - COPY OUTPUT F_SOTTOC_CLIENTE + COPY OUTPUT F_SOTTOC_CLIENTE KEY 1 CHECKTYPE NORMAL GROUP 2