registrate modifiche effettuate al progettto durante lo sviluppo

git-svn-id: svn://10.65.10.50/trunk@3973 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
paola 1996-12-06 15:50:15 +00:00
parent f9e12e3dff
commit 089b5d6014
11 changed files with 387 additions and 228 deletions

View File

@ -11,16 +11,19 @@ int main(int argc, char** argv)
switch (op) switch (op)
{ {
case 0: case 0:
res = ef0100(argc,argv); res = ef0100(argc,argv);// GESTIONE EFFETTI
break; break;
case 1: case 1:
res = ef0200(argc,argv); res = ef0200(argc,argv);// GENERAZIONE EFFETTI DA E/C
break; break;
case 2: case 2:
res = ef0300(argc,argv); res = ef0300(argc,argv);// GESTIONE DISTINTE
break; break;
case 3: case 3:
res = ef0400(argc,argv); res = ef0400(argc,argv);// ELIMINAZIONE EFFETTI
break;
case 4:
res = ef0500(argc,argv);// EMISSIONE EFFETTI/DISTINTE
break; break;
default: default:
error_box(usage, argv[0]); error_box(usage, argv[0]);

View File

@ -1,10 +1,11 @@
#ifndef __EF0_H #ifndef __EF0_H
#define __EF0_H #define __EF0_H
int ef0100(int argc, char* argv[]); int ef0100(int argc, char* argv[]);// GESTIONE EFFETTI
int ef0200(int argc, char* argv[]); int ef0200(int argc, char* argv[]);// GENERAZIONE EFFETTI DA E/C
int ef0300(int argc, char* argv[]); int ef0300(int argc, char* argv[]);// GESTIONE DISTINTE
int ef0400(int argc, char* argv[]); int ef0400(int argc, char* argv[]);// ELIMINAZIONE EFFETTI
int ef0500(int argc, char* argv[]);// EMISSIONE EFFETTI/DISTINTE
#endif // __EF0_H #endif // __EF0_H

View File

@ -21,3 +21,9 @@ MENUBAR MENU_BAR(3)
MENU MENU_BAR(3) MENU MENU_BAR(3)
SUBMENU MENU_FILE "~File" SUBMENU MENU_FILE "~File"
/* ef0 -4 */
MENUBAR MENU_BAR(4)
MENU MENU_BAR(4)
SUBMENU MENU_FILE "~File"

View File

@ -3,7 +3,6 @@
#include <sheet.h> #include <sheet.h>
#include <utility.h> #include <utility.h>
#include <lffiles.h> #include <lffiles.h>
#include <clifo.h>
#include <comuni.h> #include <comuni.h>
#include <effetti.h> #include <effetti.h>
#include <reffetti.h> #include <reffetti.h>
@ -11,8 +10,12 @@
#include "ef0.h" #include "ef0.h"
#include "ef0100.h" #include "ef0100.h"
#include "ef0101.h" #include "ef0101.h"
// Classe per la gestione di effetti con metodi standard di:
// inserimento, modifica, cancellazione. //////////////////////////////////////////////////////////////
// Classe per la gestione di effetti con metodi standard di://
// inserimento, modifica, cancellazione. //
//////////////////////////////////////////////////////////////
class TVariazione_effetti: public TRelation_application class TVariazione_effetti: public TRelation_application
{ {
TMask *_msk; TMask *_msk;
@ -47,7 +50,7 @@ public:
// restituisce un riferimento all' applicazione // restituisce un riferimento all' applicazione
inline TVariazione_effetti& app() {return (TVariazione_effetti&)main_app();} inline TVariazione_effetti& app() {return (TVariazione_effetti&)main_app();}
// quando si va in query mode resetta i due campi della maschera // quando si va in query mode resetta i due campi della maschera relativi ai totali
void TVariazione_effetti::init_query_mode(TMask&) void TVariazione_effetti::init_query_mode(TMask&)
{ {
_msk->reset(F_TOTIMP); _msk->reset(F_TOTIMP);
@ -62,22 +65,22 @@ void TVariazione_effetti::init_insert_mode(TMask&)
_msk->reset(F_TOTIMP); _msk->reset(F_TOTIMP);
_msk->reset(F_TOTIMPVAL); _msk->reset(F_TOTIMPVAL);
TToken_string riga("|||||||||"); TToken_string riga("|||||||||");
righe_sheet().row(0)=riga; righe_sheet().row(0) = riga;
righe_sheet().set_dirty(); righe_sheet().set_dirty();
} }
// ritorna il prossimo numero valido di chiave // ritorna il prossimo numero valido di chiave
const char* TVariazione_effetti::get_next_key() const char* TVariazione_effetti::get_next_key()
{ {
TLocalisamfile& effetti=_rel->lfile(); TLocalisamfile& effetti = _rel->lfile();
long nprogtr=1L; long nprogtr = 1L;
if ( !effetti.empty() ) if ( !effetti.empty() )
{ {
effetti.zero(); effetti.zero();
effetti.setkey(1); effetti.setkey(1);
effetti.last(); effetti.last();
if ( effetti.good() ) if ( effetti.good() )
nprogtr+=effetti.get_long(EFF_NPROGTR); nprogtr += effetti.get_long(EFF_NPROGTR);
} }
return format("%d|%ld",F_NPROGTR,nprogtr); return format("%d|%ld",F_NPROGTR,nprogtr);
} }
@ -107,16 +110,17 @@ void TVariazione_effetti::common_f(const TMask& m)
TSheet_field& shrighe = righe_sheet(); TSheet_field& shrighe = righe_sheet();
int items = shcess.items(); int items = shcess.items();
_effetto->destroy_rows_c(); _effetto->destroy_rows_c();
int ii = 0; int ii = 1;
// scarico tutte le righe dei cessionari dallo sheet sul file
for (int i = 0; i < items; i++) for (int i = 0; i < items; i++)
{ {
TToken_string& row = shcess.row(i); TToken_string& row = shcess.row(i);
if ( row.items()== 0 ) continue; if ( row.items()== 0 ) continue; // salta le righe vuote
TRectype& rec = _effetto->row_c(ii+1, TRUE); TRectype& rec = _effetto->row_c(ii, TRUE);
row.restart(); row.restart();
rec.zero(); rec.zero();
rec.put(CES_NPROGTR, nprogtr); rec.put(CES_NPROGTR, nprogtr);
rec.put(CES_NRIGA, ii+1); rec.put(CES_NRIGA, ii);
rec.put(CES_RAGSOC, row.get()); rec.put(CES_RAGSOC, row.get());
rec.put(CES_LOCALITA, row.get()); rec.put(CES_LOCALITA, row.get());
rec.put(CES_STATO, row.get_int()); rec.put(CES_STATO, row.get_int());
@ -125,17 +129,18 @@ void TVariazione_effetti::common_f(const TMask& m)
} }
items = shrighe.items(); items = shrighe.items();
_effetto->destroy_rows_r(); _effetto->destroy_rows_r();
ii = 0; ii = 1;
// scarico tutte le righe dell'effetto dallo sheet sul file
for (i = 0; i < items; i++) for (i = 0; i < items; i++)
{ {
TToken_string& row = shrighe.row(i); TToken_string& row = shrighe.row(i);
real imp_eff(row.get(1)); real imp_eff(row.get(1));
if (imp_eff == 0.0) continue; if (imp_eff == 0.0) continue; // salta le righe con importo nullo
row.restart(); row.restart();
TRectype& rec = _effetto->row_r(ii+1, TRUE); TRectype& rec = _effetto->row_r(ii, TRUE);
rec.zero(); rec.zero();
rec.put(REFF_NPROGTR, nprogtr); rec.put(REFF_NPROGTR, nprogtr);
rec.put(REFF_NRIGATR, ii+1); rec.put(REFF_NRIGATR, ii);
rec.put(REFF_IMPFATT, row.get()); rec.put(REFF_IMPFATT, row.get());
rec.put(REFF_IMPORTO, row.get()); rec.put(REFF_IMPORTO, row.get());
rec.put(REFF_IMPFATTVAL, row.get()); rec.put(REFF_IMPFATTVAL, row.get());
@ -159,7 +164,7 @@ int TVariazione_effetti::read(TMask& m)
int err = _rel->status(); int err = _rel->status();
if (err == NOERR) if (err == NOERR)
{ {
err = _effetto->read(f, _rel->curr()); err = _effetto->read(f, _rel->curr()); // legge l'effetto dal record corrente della relazione
if (err == NOERR) if (err == NOERR)
{ {
TString16 codcom(3); TString16 codcom(3);
@ -169,6 +174,7 @@ int TVariazione_effetti::read(TMask& m)
TSheet_field& shrighe = righe_sheet(); TSheet_field& shrighe = righe_sheet();
shrighe.reset(); shrighe.reset();
int items = _effetto->rows_c(); int items = _effetto->rows_c();
// carica tutti i cessionari nello sheet dal file
for (int i = 1; i <= items; i++) for (int i = 1; i <= items; i++)
{ {
const TRectype& rec = _effetto->row_c(i); const TRectype& rec = _effetto->row_c(i);
@ -180,12 +186,13 @@ int TVariazione_effetti::read(TMask& m)
codcom = rec.get(CES_COM);//per caricare nello sheet dei cessionari la denominazione codcom = rec.get(CES_COM);//per caricare nello sheet dei cessionari la denominazione
riga.add(codcom); //del comune di cui si conosce il codice riga.add(codcom); //del comune di cui si conosce il codice
_com->zero(); _com->zero();
_com->put("COM", codcom); _com->put(COM_COM, codcom);
if (_com->read() == NOERR) riga.add(_com->get(COM_DENCOM)); if (_com->read() == NOERR) riga.add(_com->get(COM_DENCOM));
shcess.row(i-1)=riga; shcess.row(i-1)=riga;
} }
items = _effetto->rows_r(); items = _effetto->rows_r();
// carica tutte le righe dell'effetto nello sheet dal file
for (i = 1; i <= items; i++) for (i = 1; i <= items; i++)
{ {
const TRectype& rec = _effetto->row_r(i); const TRectype& rec = _effetto->row_r(i);
@ -207,10 +214,10 @@ int TVariazione_effetti::read(TMask& m)
return err; return err;
} }
// riscrive i dati su file // riscrive effetto
int TVariazione_effetti::rewrite(const TMask& m) int TVariazione_effetti::rewrite(const TMask& m)
{ {
common_f(m); common_f(m);// scarica i dati dalla maschera
TLocalisamfile f(LF_EFFETTI); TLocalisamfile f(LF_EFFETTI);
return _effetto->rewrite(f); return _effetto->rewrite(f);
} }
@ -218,7 +225,7 @@ int TVariazione_effetti::rewrite(const TMask& m)
// scrive i dati su file // scrive i dati su file
int TVariazione_effetti::write(const TMask& m) int TVariazione_effetti::write(const TMask& m)
{ {
common_f(m); common_f(m);// scarica i dati dalla maschera
TLocalisamfile f(LF_EFFETTI); TLocalisamfile f(LF_EFFETTI);
int err = _effetto->write(f); int err = _effetto->write(f);
if (err == NOERR) if (err == NOERR)
@ -226,13 +233,14 @@ int TVariazione_effetti::write(const TMask& m)
return err; return err;
} }
// rimuove i dati dell'effetto // rimuove l'effetto
bool TVariazione_effetti::remove() bool TVariazione_effetti::remove()
{ {
TLocalisamfile f(LF_EFFETTI); TLocalisamfile f(LF_EFFETTI);
return _effetto->remove(f) == NOERR; return _effetto->remove(f) == NOERR;
} }
// crea la relap
bool TVariazione_effetti::user_create() bool TVariazione_effetti::user_create()
{ {
_msk = new TMask("ef0100a") ; _msk = new TMask("ef0100a") ;
@ -248,6 +256,7 @@ bool TVariazione_effetti::user_create()
return TRUE; return TRUE;
} }
// distrugge la relap
bool TVariazione_effetti::user_destroy() bool TVariazione_effetti::user_destroy()
{ {
delete _msk; delete _msk;
@ -265,19 +274,19 @@ bool TVariazione_effetti::handle_sheet(TMask_field &f, KEY k)
{ {
TMask& m = f.mask(); TMask& m = f.mask();
const int mode = m.mode(); const int mode = m.mode();
if ( k==K_ENTER && (mode== MODE_INS || mode== MODE_MOD) ) if ( k == K_ENTER && (mode == MODE_INS || mode == MODE_MOD) ) // se si vuole salvare e si è in uno dei due modi di funzionamento
{ { // si controllano le righe del effetto nello sheet
TSheet_field& sf = (TSheet_field&)m.field(F_SHEET_RIGHE); TSheet_field& sf = (TSheet_field&)m.field(F_SHEET_RIGHE);
int items = sf.items(); int items = sf.items();
bool found=FALSE; bool found = FALSE;
for (int i=0; i< items && !found; i++) for (int i = 0; i < items && !found; i++)// scandisco tutte le righe dello sheet
{ {
TToken_string& row=sf.row(i); TToken_string& row = sf.row(i);
real imp_eff(row.get(1)); real imp_eff(row.get(1));
if (imp_eff != 0.0) found=TRUE; if (imp_eff != 0.0) found = TRUE;// controlla che le righe abbiano un importo
} }
if (!found) if (!found)// se non ha trovato righe nello sheet oppure se quelle che ci sono non hanno importo
{ { // non permetto di salvare l'effetto
error_box("L'effetto non può contenere righe con importo nullo!"); error_box("L'effetto non può contenere righe con importo nullo!");
return FALSE; return FALSE;
} }
@ -293,15 +302,15 @@ bool TVariazione_effetti::codval_handler(TMask_field& f, KEY k)
TString val(f.get()); TString val(f.get());
if (f.to_check(k, TRUE)) if (f.to_check(k, TRUE))
{ {
const bool condition = (val == "LIT" || val.empty()); const bool condition = (val == "LIT" || val.empty());// se non c'e valuta o se è lire
m.enable(-1,!condition); m.enable(-1,!condition); // disabilito i campi collegati
TSheet_field& sf = (TSheet_field&)m.field(F_SHEET_RIGHE); TSheet_field& sf = (TSheet_field&)m.field(F_SHEET_RIGHE);
if (condition) if (condition)
{ {
m.reset(-1); m.reset(-1);
m.reset(F_TOTIMPVAL); m.reset(F_TOTIMPVAL);
int items = sf.items(); int items = sf.items();
for (int i= 0; i < items; i++) for (int i = 0; i < items; i++)
{ {
TToken_string& row = sf.row(i); TToken_string& row = sf.row(i);
row.add(" ", 2); row.add(" ", 2);
@ -323,8 +332,8 @@ void TVariazione_effetti::calcola_totali()
TSheet_field& sf = (TSheet_field&)m->field(F_SHEET_RIGHE); TSheet_field& sf = (TSheet_field&)m->field(F_SHEET_RIGHE);
int items = sf.items(); int items = sf.items();
real imp, impval, impeff, impeffval; real imp, impval, impeff, impeffval;
for (int i = 0; i < items; i++) for (int i = 0; i < items; i++)// scandisco tutte le righe dello sheet e ne prendo gli importi
{ { // (in lire ed in valuta) e li sommo al totale
TToken_string& row = sf.row(i); TToken_string& row = sf.row(i);
imp = row.get(1); imp = row.get(1);
impeff += imp; impeff += imp;
@ -340,7 +349,7 @@ void TVariazione_effetti::calcola_totali()
bool TVariazione_effetti::impeff_notify(TSheet_field& s, int r, KEY key) bool TVariazione_effetti::impeff_notify(TSheet_field& s, int r, KEY key)
{ {
if (s.to_check(key, TRUE)) calcola_totali(); if (s.to_check(key, TRUE)) calcola_totali();
if (key == K_DEL && s.items()==1) if (key == K_DEL && s.items() == 1)//se rimane una sola riga nello sheet non la si può cancellare
{ {
error_box("IMPOSSIBILE CANCELLARE: L'effetto deve contenere almeno una riga!"); error_box("IMPOSSIBILE CANCELLARE: L'effetto deve contenere almeno una riga!");
return FALSE; return FALSE;

View File

@ -3,15 +3,19 @@
#include "cession.h" #include "cession.h"
#include "ef0101.h" #include "ef0101.h"
//////////////////////////////////////////////////
// definizione dei metodi della classe TEffetto //
//////////////////////////////////////////////////
// costruttore di default // costruttore di default
TEffetto::TEffetto() TEffetto::TEffetto()
: TRectype(LF_EFFETTI), _righe(LF_REFFETTI, "NRIGATR"), _cess(LF_CESS, "NRIGA") : TRectype(LF_EFFETTI), _righe(LF_REFFETTI, REFF_NRIGATR), _cess(LF_CESS, CES_NRIGA)
{ {
} }
// costuisce l'effetto con il record passato // costuisce l'effetto con il record passato
TEffetto::TEffetto(TRectype& rec) TEffetto::TEffetto(TRectype& rec)
: TRectype(LF_EFFETTI), _righe(LF_REFFETTI, "NRIGATR"), _cess(LF_CESS, "NRIGA") : TRectype(LF_EFFETTI), _righe(LF_REFFETTI, REFF_NRIGATR), _cess(LF_CESS, CES_NRIGA)
{ {
TLocalisamfile f(LF_EFFETTI); TLocalisamfile f(LF_EFFETTI);
read(f,rec); read(f,rec);
@ -21,7 +25,7 @@ TEffetto::TEffetto(TRectype& rec)
void TEffetto::put_key(TRectype& rec, long numeff) const void TEffetto::put_key(TRectype& rec, long numeff) const
{ {
CHECKD(numeff >= 0, "Numero effetto non valido ", numeff); CHECKD(numeff >= 0, "Numero effetto non valido ", numeff);
rec.put("NPROGTR",numeff); rec.put(EFF_NPROGTR, numeff);
} }
//setta i campi per la quarta chiave (tipodist+ndist+nrigadist) del file //setta i campi per la quarta chiave (tipodist+ndist+nrigadist) del file
@ -30,9 +34,9 @@ void TEffetto::put_key(TRectype& rec,char tipodist, long ndist, long nrigadist)
CHECK(tipodist == 'I' || tipodist == 'S' || tipodist == 'B' || tipodist == 0, "Tipo distinta"); CHECK(tipodist == 'I' || tipodist == 'S' || tipodist == 'B' || tipodist == 0, "Tipo distinta");
CHECKD(ndist >= 0, "Numero distinta non valido ", ndist); CHECKD(ndist >= 0, "Numero distinta non valido ", ndist);
CHECKD(nrigadist >= 0, "Numero riga distinta non valido ", nrigadist); CHECKD(nrigadist >= 0, "Numero riga distinta non valido ", nrigadist);
rec.put("TIPODIST", tipodist); rec.put(EFF_TIPODIST, tipodist);
rec.put("NDIST", ndist); rec.put(EFF_NDIST, ndist);
rec.put("NRIGADIST", nrigadist); rec.put(EFF_NRIGADIST, nrigadist);
} }
// ritorna la prossima chiave utilizzabile (il prossimo numero progressivo) // ritorna la prossima chiave utilizzabile (il prossimo numero progressivo)
@ -49,15 +53,15 @@ long TEffetto::get_next_key(const long codcf) const
{ {
if (err == NOERR) if (err == NOERR)
eff.prev(); eff.prev();
if (curr.get_long("CODCF")==codcf) if (curr.get_long(EFF_CODCF) == codcf)
n = curr.get_long("NPROGTR"); n = curr.get_long(EFF_NPROGTR);
} }
} }
n++; n++;
return n; return n;
} }
// rinumera la chiave 1 // rinumera la chiave 1 (nprogtr)
long TEffetto::renum(long numeff) long TEffetto::renum(long numeff)
{ {
if (numeff <= 0) if (numeff <= 0)
@ -86,16 +90,16 @@ int TEffetto::leggi(TLocalisamfile &f, const TRectype& r)
{ {
int err = TRectype::read(f); int err = TRectype::read(f);
const long nu = numero(); const long nu = numero();
TRectype *k_reff = new TRectype(LF_REFFETTI),//necessari per poter andare a leggere i due record array TRectype *k_reff = new TRectype(LF_REFFETTI),// necessari per poter andare a leggere i due record array
*k_cess = new TRectype(LF_CESS); //cessionari e righe effetto *k_cess = new TRectype(LF_CESS); // cessionari e righe effetto
put_key(*k_reff, nu); put_key(*k_reff, nu); // setto la chiave per poter leggere dai due
put_key(*k_cess, nu); put_key(*k_cess, nu); // record array
if (err == NOERR) if (err == NOERR)
{ { // leggo dai record array
_righe.read(k_reff); _righe.read(k_reff);
_cess.read(k_cess); _cess.read(k_cess);
} }
else else // se ho trovato un errore
{ {
head() = r; head() = r;
const long nu = numero(); const long nu = numero();
@ -126,8 +130,7 @@ int TEffetto::read(TLocalisamfile& f, char tipodist, long ndist, long nrigadist)
TRectype rec(LF_EFFETTI); TRectype rec(LF_EFFETTI);
put_key(rec, tipodist, ndist, nrigadist); put_key(rec, tipodist, ndist, nrigadist);
head() = rec; head() = rec;
int err = leggi(f, rec); return leggi(f, rec);
return err;
} }
// scrive l'effetto, usando la chiave 1 // scrive l'effetto, usando la chiave 1
@ -136,7 +139,7 @@ int TEffetto::write(TLocalisamfile& f, bool force)
const bool nuovo = numero() <= 0; // E' nuovo! const bool nuovo = numero() <= 0; // E' nuovo!
if (nuovo && force) // quindi ... if (nuovo && force) // quindi ...
force = FALSE; // ... non fare la rewrite force = FALSE; // ... non fare la rewrite
f.setkey(1);//per evitare problemi in quanto la chiave 4 e' duplicabile f.setkey(1); // per evitare problemi in quanto la chiave 4 e' duplicabile
int err = NOERR; int err = NOERR;
if (force) if (force)
{ {
@ -183,3 +186,39 @@ int TEffetto::remove(TLocalisamfile& f)const
err = TRectype::remove(f); err = TRectype::remove(f);
return err; return err;
} }
// restituisce true se l'effetto si riferisce ad una sola fattura
// ovvero se l'effetto non è raggruppato
bool TEffetto::fatt(long num)
{
TLocalisamfile righe_eff(LF_REFFETTI);
righe_eff.put(REFF_NPROGTR, num);
righe_eff.read();
TString16 n = righe_eff.get(REFF_NFATT);// prende il numero fattura della prima riga
int items = rows_r(); // prende il numero delle righe dell'effetto
bool condition = (items == 1); // se la fattura ha una sola riga farà riferimento ad una sola fattura
// se invece ha più righe sarà raggruppato
return condition;
}
// restituisce i dati relativi alle fatture a cui si riferisce l'effetto
// costruendo una TToken_string del tipo
// "num_fatt0|data_fatt0|imp_fatt0|num_fatt1|data_fatt1|imp_fatt1|..."
TToken_string* TEffetto::dati_fatt(long num)
{
TToken_string* dati= new TToken_string;
dati->cut(0);
TLocalisamfile righe_eff(LF_REFFETTI);
righe_eff.put(REFF_NPROGTR, num);
righe_eff.read();
int items = rows_r(); // prende il numero delle righe dell'effetto
for (int i = 1; i <= items; i++)// le legge tutte
{
dati->add(righe_eff.get(REFF_NFATT));//prende il numero
dati->add(righe_eff.get(REFF_DATAFATT));//prende la data
dati->add(righe_eff.get(REFF_IMPFATT));//prende l' importo
righe_eff.next(); // passa alla riga successiva
}
return dati;
}

View File

@ -2,6 +2,10 @@
#include <relation.h> #include <relation.h>
#endif #endif
/////////////////////////////////////////////////////////////
// definizione dell'oggetto Effetto con la classe TEffetto //
/////////////////////////////////////////////////////////////
class TEffetto:public TRectype class TEffetto:public TRectype
{ {
TRecord_array _righe,// righe dell'effetto TRecord_array _righe,// righe dell'effetto
@ -38,9 +42,9 @@ public:
bool destroy_row_c(int n, bool pack = FALSE) { return _cess.destroy_row(n, pack); } bool destroy_row_c(int n, bool pack = FALSE) { return _cess.destroy_row(n, pack); }
// elimina tutti gli elementi riga nei cessionari // elimina tutti gli elementi riga nei cessionari
void destroy_rows_c() { _cess.destroy_rows(); } void destroy_rows_c() { _cess.destroy_rows(); }
// legge il record passato, con chiave 1
// restituisce il prossimo effetto // restituisce il prossimo effetto
int next(TBaseisamfile& f); int next(TBaseisamfile& f);
// legge il record passato, con chiave 1
int read(TLocalisamfile& f, const TRectype& rec); int read(TLocalisamfile& f, const TRectype& rec);
// legge il record passato, con chiave 4 // legge il record passato, con chiave 4
int read(TLocalisamfile& f, char tipodist, long ndist, long nrigadist); int read(TLocalisamfile& f, char tipodist, long ndist, long nrigadist);
@ -62,10 +66,16 @@ public:
long ndist() const { return get_long("NDIST"); } long ndist() const { return get_long("NDIST"); }
// restituisce il numero della riga distinta a cui appartiene l'effetto estraendolo dal record // restituisce il numero della riga distinta a cui appartiene l'effetto estraendolo dal record
long nrgdist() const { return get_long("NRIGADIST"); } long nrgdist() const { return get_long("NRIGADIST"); }
// restituisce l'importo dell'effetto
long importo() const { return get_long("IMPORTO"); }
//setta i campi per la quarta chiave del file //setta i campi per la quarta chiave del file
void put_key(TRectype& rec,char tipodist, long ndist, long nrigadist = 0); void put_key(TRectype& rec,char tipodist, long ndist, long nrigadist = 0);
//setta i campi per la prima chiave del file //setta i campi per la prima chiave del file
void put_key(TRectype& rec,long numeff) const; void put_key(TRectype& rec,long numeff) const;
//restituisce true se l'effetto si riferisce ad una sola fattura
bool fatt(long num);
//restituisce i dati relativi alle fatture a cui si riferisce l'effetto
TToken_string* dati_fatt(long num);
// costruttore di default // costruttore di default
TEffetto(); TEffetto();
// costuisce l'effetto con il record passato // costuisce l'effetto con il record passato

View File

@ -10,8 +10,10 @@
#include "ef0300.h" #include "ef0300.h"
#include "ef0301.h" #include "ef0301.h"
//Classe per la gestione di distinte (inserimento, modifica, cancellazione) //////////////////////////////////////////////////////////////////////////////
// e per la creazione automatica di distinte per importi. //Classe per la gestione di distinte (inserimento, modifica, cancellazione) //
// e per la creazione automatica di distinte per importi. //
//////////////////////////////////////////////////////////////////////////////
class TVariazione_distinte: public TRelation_application class TVariazione_distinte: public TRelation_application
{ {
TMask *_msk, *_m2; TMask *_msk, *_m2;
@ -59,11 +61,11 @@ public:
virtual ~TVariazione_distinte() {}; virtual ~TVariazione_distinte() {};
}; };
inline TVariazione_distinte& app() // restituisce un riferimento all' applicazione
{ inline TVariazione_distinte& app(){ return (TVariazione_distinte&)main_app(); }
return (TVariazione_distinte&)main_app();
}
// quando si va in query mode abilita i campi relativi alla chiave di ricerca e resetta i campi
// relativi ai totali
void TVariazione_distinte::init_query_mode(TMask&) void TVariazione_distinte::init_query_mode(TMask&)
{ {
_msk->enable(F_NUMBER); _msk->enable(F_NUMBER);
@ -72,6 +74,8 @@ void TVariazione_distinte::init_query_mode(TMask&)
_msk->reset(F_TOTIMPVAL); _msk->reset(F_TOTIMPVAL);
} }
// quando si va in insert mode resetta i campi della maschera relativi ai totali,
// abilita i campi relativi alla valuta e disabilta i campi relativi alla chiave di ricerca
void TVariazione_distinte::init_insert_mode(TMask&) void TVariazione_distinte::init_insert_mode(TMask&)
{ {
_msk->reset(F_TOTIMP); _msk->reset(F_TOTIMP);
@ -82,18 +86,19 @@ void TVariazione_distinte::init_insert_mode(TMask&)
_msk->disable(F_TIPODIST); _msk->disable(F_TIPODIST);
} }
// quando si va in modify mode disabilta i campi relativi alla chiave di ricerca
void TVariazione_distinte::init_modify_mode(TMask&) void TVariazione_distinte::init_modify_mode(TMask&)
{ {
_msk->disable(F_NUMBER); _msk->disable(F_NUMBER);
_msk->disable(F_TIPODIST); _msk->disable(F_TIPODIST);
} }
//Ritorna il prossimo numero di distanta valido // ritorna il prossimo numero di distanta valido
const char* TVariazione_distinte::get_next_key() const char* TVariazione_distinte::get_next_key()
{ {
long ndist = 1L; long ndist = 1L;
TLocalisamfile& effetti = _rel->lfile(); TLocalisamfile& effetti = _rel->lfile();
effetti.zero(); effetti.first(); // mi posiziono all'inizio del file
effetti.put("NDIST",ndist); effetti.put("NDIST",ndist);
effetti.setkey(4); effetti.setkey(4);
int err = effetti.read(_isgteq); int err = effetti.read(_isgteq);
@ -102,6 +107,8 @@ const char* TVariazione_distinte::get_next_key()
err == NOERR; err == NOERR;
return format("%d|%ld", F_NUMBER, ndist); return format("%d|%ld", F_NUMBER, ndist);
} }
effetti.setkey(1); // mi posiziono all'inizio del file
effetti.first(); // utilizzando la chiave 1
while (err == NOERR) //se esitono già delle distinte: while (err == NOERR) //se esitono già delle distinte:
{ // le leggo tutte e ne prendo il { // le leggo tutte e ne prendo il
effetti.setkey(4); // numero, al verificarsi della fine file effetti.setkey(4); // numero, al verificarsi della fine file
@ -110,31 +117,31 @@ const char* TVariazione_distinte::get_next_key()
if (n > ndist) if (n > ndist)
ndist = n; ndist = n;
} }
return format("%d|%ld",F_NUMBER,++ndist); return format("%d|%ld",F_NUMBER,++ndist); // ritorna una stringa costruita utilizzando il numero della distinta
} }
//Ritorna un riferimento allo sheet degli effetti (righe) nella distinta // ritorna un riferimento allo sheet degli effetti (righe) nella distinta
TSheet_field& TVariazione_distinte::righe_sheet() const TSheet_field& TVariazione_distinte::righe_sheet() const
{ {
TSheet_field& r_sheet = (TSheet_field&)_msk->field(F_SHEET_RIBA); TSheet_field& r_sheet = (TSheet_field&)_msk->field(F_SHEET_RIBA);
return r_sheet; return r_sheet;
} }
//Ritorna un riferimento allo sheet delle righe // ritorna un riferimento allo sheet delle righe
TSheet_field& TVariazione_distinte::righe_sel_sheet() const TSheet_field& TVariazione_distinte::righe_sel_sheet() const
{ {
TSheet_field& r_sheet = (TSheet_field&)_m2->field(F_SHEET); TSheet_field& r_sheet = (TSheet_field&)_m2->field(F_SHEET);
return r_sheet; return r_sheet;
} }
//Ritorna TRUE se trovo nel'array delle righe distinta l'effetto passato // ritorna TRUE se trovo nell'array delle righe distinta l'effetto passato
bool TVariazione_distinte::cerca(long num) bool TVariazione_distinte::cerca(long num)
{ {
bool trovato = FALSE; bool trovato = FALSE;
int items = _distinta->items(); int items = _distinta->items();
TArray& righedist = _distinta->righe(); TArray& righedist = _distinta->righe();
for (int i = 0; i < items; i++)//ciclo sugli elementi dell'array for (int i = 0; i < items; i++)// ciclo sugli elementi dell'array
{ //se l'array è vuoto non trova nulla ed esce subito { // se l'array è vuoto non trova nulla ed esce subito
TEffetto& eff = (TEffetto&)righedist[i]; TEffetto& eff = (TEffetto&)righedist[i];
long num_eff = eff.get_long("NPROGTR"); long num_eff = eff.get_long("NPROGTR");
if (num_eff == num) if (num_eff == num)
@ -146,25 +153,25 @@ bool TVariazione_distinte::cerca(long num)
return trovato; return trovato;
} }
//Metodo che permette di scivere sull'array (in memoria) gli effetti presenti nello sheet // metodo che permette di scivere sull'array (in memoria) gli effetti presenti nello sheet
void TVariazione_distinte::aggiorna() void TVariazione_distinte::aggiorna()
{ {
TSheet_field& shrighe = righe_sheet(); TSheet_field& shrighe = righe_sheet();
int items = shrighe.items(); int items = shrighe.items();
for (int i = 0; i < items; i++) for (int i = 0; i < items; i++) // prendo tutte le righe dello sheet
{ {
TToken_string& row = shrighe.row(i); TToken_string& row = shrighe.row(i);
row.restart(); row.restart();
long num = row.get_long(1); long num = row.get_long(1);
if (!cerca(num)) if (!cerca(num)) // se non sia già presente in memoria
{ { // carico l'effetto nell'array
TLocalisamfile eff(LF_EFFETTI); TLocalisamfile eff(LF_EFFETTI);
TRectype rec = eff.curr(); TRectype rec = eff.curr();
eff.setkey(1); eff.setkey(1);
rec.zero(); rec.zero();
rec.put(EFF_NPROGTR, num); rec.put(EFF_NPROGTR, num);
int err = eff.read(); int err = eff.read();
TEffetto* effetto= new TEffetto(rec); TEffetto* effetto= new TEffetto(rec);// istanzio un puntatore all'effetto utilizzando il record corrente del file
TArray& righedist = _distinta->righe(); TArray& righedist = _distinta->righe();
righedist.add(effetto); righedist.add(effetto);
} }
@ -172,25 +179,28 @@ void TVariazione_distinte::aggiorna()
} }
//Metodo che permette di prendere i dati dalla maschera e metterli in una TToken_string //Metodo che permette di prendere i dati dalla maschera e metterli in una TToken_string
//che servirà per passare i dati alla write della distinta //che servirà per passarli alla write della distinta
TToken_string* TVariazione_distinte::common_f(const TMask& m) TToken_string* TVariazione_distinte::common_f(const TMask& m)
{ {
char tipodist = m.get(F_TIPODIST)[0]; char tipodist = m.get(F_TIPODIST)[0]; // prendo i dati
long ndist = m.get_long(F_NUMBER); long ndist = m.get_long(F_NUMBER); // identificatvi della
TDate datadist = (TDate)m.get(F_DATA); TDate datadist = (TDate)m.get(F_DATA);// distinta
long codabi = m.get_long(F_CODABIP); long codabi = m.get_long(F_CODABIP); // dalla maschera
long codcab = m.get_long(F_CODCABP); long codcab = m.get_long(F_CODCABP);
m.autosave(*_rel); m.autosave(*_rel);
TToken_string* datidist= new TToken_string;
TToken_string* datidist= new TToken_string; // creo la token string
datidist->cut(0); datidist->cut(0);
datidist->add(tipodist); datidist->add(tipodist); // inserisco i dati nella
datidist->add(ndist); datidist->add(ndist); // token string
datidist->add(datadist); datidist->add(datadist);
datidist->add(codabi); datidist->add(codabi);
datidist->add(codcab); datidist->add(codcab);
return datidist; return datidist;
} }
// carica nella maschera i dati dai files
int TVariazione_distinte::read(TMask& m) int TVariazione_distinte::read(TMask& m)
{ {
m.autoload(*_rel); m.autoload(*_rel);
@ -198,39 +208,45 @@ int TVariazione_distinte::read(TMask& m)
if (err == NOERR) if (err == NOERR)
{ {
err = _distinta->reset(); //resetto l'array che contiene gli effetti nella distinta err = _distinta->reset(); //resetto l'array che contiene gli effetti nella distinta
err = _distinta->read(_rel->curr()); err = _distinta->read(_rel->curr()); // legge la distinta dal record corrente della relazione
if (err == NOERR) if (err == NOERR)
{ {
TToken_string riga(80); TToken_string riga(80);
TSheet_field& shrighe = righe_sheet(); TSheet_field& shrighe = righe_sheet();
shrighe.reset(); shrighe.reset();
int items = _distinta->items(); int items = _distinta->items();// prendo il numero di effetti nella distinta
TArray& righedist = _distinta->righe(); TArray& righedist = _distinta->righe();
for (int i = 0; i < items; i++) // carico tutti gli effetti della distinta nello sheet // carico tutti gli effetti della distinta nello sheet
for (int i = 0; i < items; i++)
{ {
TEffetto& eff = (TEffetto&)righedist[i]; TEffetto& eff = (TEffetto&)righedist[i];// prendo l'effetto dall'array
riga.cut(0); riga.cut(0);
riga.add(' '); riga.add(' ');
riga.add(eff.get(EFF_NPROGTR)); const long numero = eff.get_long(EFF_NPROGTR);
riga.add(numero);
riga.add(eff.get(EFF_DATASCAD)); riga.add(eff.get(EFF_DATASCAD));
long codcf = eff.get_long(EFF_CODCF); //prendo la ragione sociale del cliente long codcf = eff.get_long(EFF_CODCF); //prendo la ragione sociale del cliente
_clifo->zero(); //conoscendone il codice _clifo->zero(); //conoscendone il codice
_clifo->put("TIPOCF", 'C'); _clifo->put("TIPOCF", 'C');
_clifo->put("CODCF", codcf); _clifo->put("CODCF", codcf);
if (_clifo->read() == NOERR) riga.add(_clifo->get("RAGSOC")); if (_clifo->read() == NOERR) riga.add(_clifo->get("RAGSOC"));
if (eff.rows_r() == 1) //se l'effetto contiene solo una riga metto i
if (eff.fatt(numero)) //se l'effetto contiene solo una fattura metto i
{ //riferimenti al documento ed al numero di rata { //riferimenti al documento ed al numero di rata
const TRectype& rec_r = eff.row_r(1); const TRectype& rec_r = eff.row_r(1);
riga.add(rec_r.get(REFF_NFATT)); riga.add(rec_r.get(REFF_NFATT));
riga.add(rec_r.get(REFF_DATAFATT)); riga.add(rec_r.get(REFF_DATAFATT));
riga.add(rec_r.get(REFF_NRATA)); if (eff.rows_r() == 1) riga.add(rec_r.get(REFF_NRATA));
else riga.add(("Varie"));
} }
else //se l'effetto contiene più di una riga non metto i else //se l'effetto contiene più di una fattura non metto i
{ //riferimenti al documento ed al numero di rata { //riferimenti al documento ed al numero di rata
riga.add(("Varie")); riga.add(("Varie"));
riga.add(("Varie")); riga.add(("Varie"));
riga.add(("Varie")); riga.add(("Varie"));
} }
TString codval(3); //gestisco il controllo sulla presenza o meno di una valuta TString codval(3); //gestisco il controllo sulla presenza o meno di una valuta
codval = eff.get(EFF_CODVAL); codval = eff.get(EFF_CODVAL);
if (i == 0) if (i == 0)
@ -242,6 +258,7 @@ int TVariazione_distinte::read(TMask& m)
m.set(F_CODVAL, codval); m.set(F_CODVAL, codval);
} }
riga.add(codval); riga.add(codval);
riga.add(eff.get(EFF_IMPORTO)); riga.add(eff.get(EFF_IMPORTO));
riga.add(eff.get(EFF_IMPORTOVAL)); riga.add(eff.get(EFF_IMPORTOVAL));
shrighe.row(i) = riga; shrighe.row(i) = riga;
@ -266,8 +283,8 @@ void TVariazione_distinte::elimina()
TArray& righedist = distinta->righe(); TArray& righedist = distinta->righe();
for (int i = 0, k = i+1; i < sf.items(); i++, k++)//ciclo sugli elementi dello sheet for (int i = 0, k = i+1; i < sf.items(); i++, k++)//ciclo sugli elementi dello sheet
{ {
if (deleted) i--; //per posizionarsi correttamente sulla prima riga dello sheet if (deleted) i--; // per posizionarsi correttamente sulla prima riga dello sheet
if (sf.items() == 1) if (sf.items() == 1)// non posso cancellare l'effetto se è l'unico della distinta
{ {
error_box("IMPOSSIBILE CANCELLARE: La distinta deve contenere almeno un effetto!"); error_box("IMPOSSIBILE CANCELLARE: La distinta deve contenere almeno un effetto!");
break; break;
@ -283,11 +300,11 @@ void TVariazione_distinte::elimina()
long num_eff = eff.get_long("NPROGTR"); long num_eff = eff.get_long("NPROGTR");
if (num_eff == num) if (num_eff == num)
{ {
righedist.destroy(j,TRUE); righedist.destroy(j,TRUE);// tolgo l'effetto dall'array
break; break;
} }
} }
sf.destroy(i); deleted = TRUE; sf.destroy(i); deleted = TRUE;// tolgo l'effetto dallo sheet
eff.read(file, tipodist, ndist, k); eff.read(file, tipodist, ndist, k);
eff.zero("TIPODIST"); eff.zero("TIPODIST");
eff.zero("NDIST"); eff.zero("NDIST");
@ -301,25 +318,30 @@ void TVariazione_distinte::elimina()
} }
} }
// riscrive distinta
int TVariazione_distinte::rewrite(const TMask& m) int TVariazione_distinte::rewrite(const TMask& m)
{ {
// prima di riscrive controllo se ci sono effetti nello sheet selezionati per l'eliminazione
TSheet_field& sf = righe_sheet(); TSheet_field& sf = righe_sheet();
bool condition = FALSE; bool condition = FALSE;
for (int i = 0; i < sf.items(); i++) for (int i = 0; i < sf.items(); i++)
{ {
TToken_string& row = sf.row(i); TToken_string& row = sf.row(i);
if (condition = *row.get(0) == 'X') break; if (condition = *row.get(0) == 'X') break;// se trovo un effetto selezionato esco dal ciclo
} }
// solo se ho trovato effetti selezionati
if (condition) if (condition)
if (yesno_box("Vuoi veramete eliminare gli effetti selezionati")) if (yesno_box("Vuoi veramete eliminare gli effetti selezionati"))
elimina(); //elimino gli effetti nello sheet che sono selezionati con la "X" elimina(); //elimino gli effetti nello sheet che sono selezionati con la "X"
int err = _distinta->reset(); //resetto l'array che contiene gli effetti nella distinta int err = _distinta->reset(); //resetto l'array che contiene gli effetti nella distinta
// procedo con la riscrittura
char tipodist = m.get(F_TIPODIST)[0]; char tipodist = m.get(F_TIPODIST)[0];
long ndist = m.get_long(F_NUMBER); long ndist = m.get_long(F_NUMBER);
aggiorna(); aggiorna(); // aggiorno l'array
err = _distinta->rewrite(common_f(m)); err = _distinta->rewrite(common_f(m));
// riposiziono la relazione
if (err == NOERR) if (err == NOERR)
{ //riposiziono la relazione {
_rel->lfile().setkey(4); _rel->lfile().setkey(4);
TRectype& curr = _rel->curr(); TRectype& curr = _rel->curr();
curr.put("TIPODIST", tipodist); curr.put("TIPODIST", tipodist);
@ -330,15 +352,17 @@ int TVariazione_distinte::rewrite(const TMask& m)
return err; return err;
} }
// scrive distinta
int TVariazione_distinte::write(const TMask& m) int TVariazione_distinte::write(const TMask& m)
{ {
int err = _distinta->reset(); //resetto l'array che contiene gli effetti nella distinta int err = _distinta->reset(); //resetto l'array che contiene gli effetti nella distinta
char tipodist = m.get(F_TIPODIST)[0]; char tipodist = m.get(F_TIPODIST)[0];
long ndist = m.get_long(F_NUMBER); long ndist = m.get_long(F_NUMBER);
aggiorna(); aggiorna(); // aggiorno l'array
err = _distinta->write(TRUE, common_f(m)); err = _distinta->write(TRUE, common_f(m));
//riposiziono la relazione
if (err == NOERR) if (err == NOERR)
{ //riposiziono la relazione {
_rel->lfile().setkey(4); _rel->lfile().setkey(4);
TRectype& curr = _rel->curr(); TRectype& curr = _rel->curr();
curr.put("TIPODIST", tipodist); curr.put("TIPODIST", tipodist);
@ -360,6 +384,7 @@ bool TVariazione_distinte::remove()
return err; return err;
} }
// creo la relap
bool TVariazione_distinte::user_create() bool TVariazione_distinte::user_create()
{ {
_msk = new TMask("ef0300a"); _msk = new TMask("ef0300a");
@ -383,6 +408,7 @@ bool TVariazione_distinte::user_create()
return TRUE; return TRUE;
} }
// distruggo la relap
bool TVariazione_distinte::user_destroy() bool TVariazione_distinte::user_destroy()
{ {
delete _msk; delete _msk;
@ -400,12 +426,14 @@ bool TVariazione_distinte::user_destroy()
// una distinta // una distinta
void TVariazione_distinte::carica_riba() void TVariazione_distinte::carica_riba()
{ {
// deve caricare solo quegli effetti che non hanno riferimento alla distinta
// quindi setta i campi ad essa relativi a zero
char tipodist = 0; char tipodist = 0;
long ndist = 0; long ndist = 0;
long nrigadist = 0; long nrigadist = 0;
TEffetto eff; TEffetto eff;
TLocalisamfile f(LF_EFFETTI); TLocalisamfile f(LF_EFFETTI);
TLocalisamfile * clifo = app()._clifo; TLocalisamfile * clifo = app()._clifo;// per prendere la ragione sociale del cliente di cui ho il codice
TToken_string riga(80); TToken_string riga(80);
TMask* m2 = app()._m2; TMask* m2 = app()._m2;
m2->reset(); m2->reset();
@ -414,37 +442,40 @@ void TVariazione_distinte::carica_riba()
int err, i = 0; int err, i = 0;
err = eff.read(f, tipodist, ndist, nrigadist); err = eff.read(f, tipodist, ndist, nrigadist);
while ( (err == NOERR) && (tipodist == 0) ) while ( (err == NOERR) && (tipodist == 0) )
{ //carico tutti gli effetti che soddisfano alla condizione nello sheet { //carico tutti gli effetti, che soddisfano alla condizione, nello sheet
riga.cut(0); riga.cut(0);
riga.add(' '); riga.add(' ');
riga.add(eff.get(EFF_NPROGTR)); const long numero = eff.get_long(EFF_NPROGTR);
riga.add(numero);
riga.add(eff.get(EFF_DATASCAD)); riga.add(eff.get(EFF_DATASCAD));
long codcf = eff.get_long(EFF_CODCF); long codcf = eff.get_long(EFF_CODCF);
clifo->zero(); clifo->zero();
clifo->put("TIPOCF", 'C'); clifo->put("TIPOCF", 'C');
clifo->put("CODCF", codcf); clifo->put("CODCF", codcf);
if (clifo->read() == NOERR) riga.add(clifo->get("RAGSOC")); if (clifo->read() == NOERR) riga.add(clifo->get("RAGSOC"));
if (eff.rows_r() == 1) //se l'effetto contiene solo una riga metto i if (eff.fatt(numero)) //se l'effetto contiene solo una fattura metto i
{ //riferimenti al documento ed al numero di rata { //riferimenti al documento ed al numero di rata
const TRectype& rec_r = eff.row_r(1); const TRectype& rec_r = eff.row_r(1);
riga.add(rec_r.get(REFF_NFATT)); riga.add(rec_r.get(REFF_NFATT));
riga.add(rec_r.get(REFF_DATAFATT)); riga.add(rec_r.get(REFF_DATAFATT));
riga.add(rec_r.get(REFF_NRATA)); if (eff.rows_r() == 1) riga.add(rec_r.get(REFF_NRATA));
else riga.add(("Varie"));
} }
else //se l'effetto contiene più di una riga non metto i else //se l'effetto contiene più di una fattura non metto i
{ //riferimenti al documento ed al numero di rata { //riferimenti al documento ed al numero di rata
riga.add(("Varie")); riga.add(("Varie"));
riga.add(("Varie")); riga.add(("Varie"));
riga.add(("Varie")); riga.add(("Varie"));
} }
riga.add(eff.get(EFF_CODVAL)); riga.add(eff.get(EFF_CODVAL));
riga.add(eff.get(EFF_IMPORTO)); riga.add(eff.get(EFF_IMPORTO));
riga.add(eff.get(EFF_IMPORTOVAL)); riga.add(eff.get(EFF_IMPORTOVAL));
sf.row(i) = riga; sf.row(i) = riga;
i++; i++;
f.setkey(4); f.setkey(4);
err = eff.next(f); err = eff.next(f); // leggo l'effetto successivo e ne prendo il tipodistinta per il controllo
tipodist = eff.get("TIPODIST")[0]; tipodist = eff.get("TIPODIST")[0];// della condizione del ciclo di caricamento
} }
} }
@ -476,9 +507,11 @@ bool TVariazione_distinte::importo_handler(TMask_field& f, KEY k)
if( mode == MODE_INS || mode == MODE_MOD ) if( mode == MODE_INS || mode == MODE_MOD )
{ {
TMask* m2 = app()._m2; TMask* m2 = app()._m2;
long imp_pres = m.get_long(F_TOTIMP); long imp_pres = m.get_long(F_TOTIMP);// importo presentato
long imp = m.get_long(F_IMP); long imp = m.get_long(F_IMP);// importo distinta
long impdist = imp - imp_pres; long impdist = imp - imp_pres;
// se importo distinta maggiore importo presentato si devono andare a caricare effetti in ...
// ... automatico per un valore minore uguale alla differenza dei suddetti importi
if (impdist > 0) if (impdist > 0)
{ {
app().begin_wait(); app().begin_wait();
@ -494,7 +527,6 @@ bool TVariazione_distinte::importo_handler(TMask_field& f, KEY k)
} }
} }
sf_riba.force_update(); sf_riba.force_update();
sf_riba.set_dirty();
return TRUE; return TRUE;
} }
@ -503,17 +535,39 @@ bool TVariazione_distinte::importo_handler(TMask_field& f, KEY k)
bool TVariazione_distinte::imp_aut_handler(TMask_field& f, KEY k) bool TVariazione_distinte::imp_aut_handler(TMask_field& f, KEY k)
{ {
TMask& m2 = f.mask(); TMask& m2 = f.mask();
// se quando si entra nell maschera il campo contiene un valore significa che si deve procedere
// con il caricamento automatico di effetti per l'importo iscritto nel campo
if (f.to_check(k, TRUE)) if (f.to_check(k, TRUE))
{ {
TMask* m = app()._msk; TMask* m = app()._msk;
TSheet_field& sf = (TSheet_field&)m2.field(F_SHEET); TSheet_field& sf = (TSheet_field&)m2.field(F_SHEET);
TSheet_field& sf_riba = (TSheet_field&)m->field(F_SHEET_RIBA); TSheet_field& sf_riba = (TSheet_field&)m->field(F_SHEET_RIBA);
long impdist = m->get_long(F_IMP) - m->get_long(F_TOTIMP); long impdist = m->get_long(F_IMP) - m->get_long(F_TOTIMP);// prendo l'importo da caricare
long tot_imp_dist = m2.get_long(F_TOTIMPDIST), impsel = 0; long tot_imp_dist = m2.get_long(F_TOTIMPDIST), // prendo l'importo iscritto nel campo
if (tot_imp_dist != 0 && impdist != 0) impsel = 0;
if (tot_imp_dist != 0 && impdist != 0)// se i due importi sono diversi da zero
{ {
TString val = m->get(F_CODVAL); TString val = m->get(F_CODVAL);
int items = sf.items(); int items = sf.items();
// cerca se esiste un effetto con importo uguale a quello da caricare
bool caricato = FALSE;
for(int i = 0; i < items && !caricato; i++)
{
TToken_string& row = sf.row(i);
TString codval = row.get(7);
if (codval == " " || codval == "LIT")//se la valuta non appare o è lire
codval.trim(); //faccio in modo che vengano presi gli effetti con valuta inesistente
long imp = row.get_long(8);
if (imp == tot_imp_dist && codval == val)
{
row.add('X',0);//seleziono l'effetto poichè soddisfa alle condizione richieste
impsel += imp;
caricato = TRUE;
}
}
// se non esiste carico l'importo sommando più effetti
if (!caricato)
{
for(int i = 0; i < items; i++) for(int i = 0; i < items; i++)
{ {
TToken_string& row = sf.row(i); TToken_string& row = sf.row(i);
@ -521,6 +575,9 @@ bool TVariazione_distinte::imp_aut_handler(TMask_field& f, KEY k)
if (codval == " " || codval == "LIT")//se la valuta non appare o è lire if (codval == " " || codval == "LIT")//se la valuta non appare o è lire
codval.trim(); //faccio in modo che vengano presi gli effetti con valuta inesistente codval.trim(); //faccio in modo che vengano presi gli effetti con valuta inesistente
long imp = row.get_long(8); long imp = row.get_long(8);
// se l'importo, della riga corrente dello sheet, è minore dell 'importo che si deve caricare e
// se lo rimane anche sommato all'importo già selezionato, si procede a rendere la riga selezionata
// per il caricamento
if ((imp <= tot_imp_dist) && ((impsel+imp) <= tot_imp_dist)) if ((imp <= tot_imp_dist) && ((impsel+imp) <= tot_imp_dist))
{ {
if ((sf_riba.items() == 0) && (val.empty()|| val == "LIT"))//se non è stata specificata una valuta si prende quella del if ((sf_riba.items() == 0) && (val.empty()|| val == "LIT"))//se non è stata specificata una valuta si prende quella del
@ -537,6 +594,7 @@ bool TVariazione_distinte::imp_aut_handler(TMask_field& f, KEY k)
if (impsel <= tot_imp_dist) continue; if (impsel <= tot_imp_dist) continue;
else break; else break;
} }
}
sf.force_update(); sf.force_update();
calcola(); calcola();
} }
@ -553,7 +611,9 @@ bool TVariazione_distinte::conferma_handler(TMask_field& f, KEY k)
if (k==K_ENTER) if (k==K_ENTER)
{ {
TMask& m = f.mask(); TMask& m = f.mask();
m.close(); m.close(); // chiudo la maschera secondaria
// scarico tutte le righe, selezionate, dello sheet della maschera secondaria nello sheet della
// maschera primaria della relap (ef0300a)
TSheet_field& sf = (TSheet_field&)m.field(F_SHEET); TSheet_field& sf = (TSheet_field&)m.field(F_SHEET);
int items = sf.items(); int items = sf.items();
bool condition = FALSE; bool condition = FALSE;
@ -568,8 +628,8 @@ bool TVariazione_distinte::conferma_handler(TMask_field& f, KEY k)
} }
} }
} }
sf_riba.force_update(); sf_riba.force_update();// obbligo all'aggiornamento dello sheet
calcola_totale(); calcola_totale(); // obbligo al ricalcolo del totale
return TRUE; return TRUE;
} }
@ -582,7 +642,7 @@ bool TVariazione_distinte::annulla_handler(TMask_field& f, KEY k)
return TRUE; return TRUE;
} }
//Handler per gestire la scelta per data //Handler per gestire la scelta per data ,nella maschera di scelta delle riba (ef0300c)
bool TVariazione_distinte::from_data_handler(TMask_field& f, KEY k) bool TVariazione_distinte::from_data_handler(TMask_field& f, KEY k)
{ {
if (k == K_TAB) if (k == K_TAB)
@ -593,6 +653,7 @@ bool TVariazione_distinte::from_data_handler(TMask_field& f, KEY k)
bool deleted = FALSE; bool deleted = FALSE;
TDate data = m.get_date(F_DADATA); TDate data = m.get_date(F_DADATA);
TSheet_field& sf = (TSheet_field&)m.field(F_SHEET); TSheet_field& sf = (TSheet_field&)m.field(F_SHEET);
// tolgo dallo sheet gli effetti che hanno una data minore a quella indicata nel campo della maschera
for(int i = 0; i < sf.items(); i++) for(int i = 0; i < sf.items(); i++)
{ {
if (deleted) i--; if (deleted) i--;
@ -610,7 +671,7 @@ bool TVariazione_distinte::from_data_handler(TMask_field& f, KEY k)
return TRUE; return TRUE;
} }
//Handler per gestire la scelta per data //Handler per gestire la scelta per data, nella maschera di scelta delle riba (ef0300c)
bool TVariazione_distinte::to_data_handler(TMask_field& f, KEY k) bool TVariazione_distinte::to_data_handler(TMask_field& f, KEY k)
{ {
if (k == K_TAB) if (k == K_TAB)
@ -621,6 +682,7 @@ bool TVariazione_distinte::to_data_handler(TMask_field& f, KEY k)
bool deleted = FALSE; bool deleted = FALSE;
TDate data = m.get_date(F_ADATA); TDate data = m.get_date(F_ADATA);
TSheet_field& sf = (TSheet_field&)m.field(F_SHEET); TSheet_field& sf = (TSheet_field&)m.field(F_SHEET);
// tolgo dallo sheet gli effetti che hanno una data maggiore a quella indicata nel campo della maschera
for(int i = 0; i < sf.items(); i++) for(int i = 0; i < sf.items(); i++)
{ {
if (deleted) i--; if (deleted) i--;
@ -637,7 +699,9 @@ bool TVariazione_distinte::to_data_handler(TMask_field& f, KEY k)
} }
return TRUE; return TRUE;
} }
//COMPARE FUNCTION per l'ordinamento per data degli effetti presenti nello sheet
//COMPARE FUNCTION per l'ordinamento per data degli effetti presenti nello sheet,
// nella maschera di scelta delle riba (ef0300c)
HIDDEN int confronta_data(const TObject** o1, const TObject** o2) HIDDEN int confronta_data(const TObject** o1, const TObject** o2)
{ {
int val; int val;
@ -652,19 +716,21 @@ HIDDEN int confronta_data(const TObject** o1, const TObject** o2)
return val; return val;
} }
//Handler per gestire l'ordinamento per data degli effetti presenti nello sheet //Handler per gestire l'ordinamento per data degli effetti presenti nello sheet,
// nella maschera di scelta delle riba (ef0300c)
void TVariazione_distinte::ord_data() void TVariazione_distinte::ord_data()
{ {
TMask* m = app()._m2; TMask* m = app()._m2;
TSheet_field& sf = (TSheet_field&)m->field(F_SHEET); TSheet_field& sf = (TSheet_field&)m->field(F_SHEET);
TArray& effetti = sf.rows_array(); TArray& effetti = sf.rows_array();// scarico tutte le righe dello sheet in un array
app().begin_wait(); app().begin_wait();
effetti.sort(confronta_data); effetti.sort(confronta_data);// faccio l'ordinamento degli elementi dell'array
app().end_wait(); app().end_wait();
sf.force_update(); sf.force_update();
} }
//COMPARE FUNCTION per l'ordinamento per numero e data fattura degli effetti presenti nello sheet //COMPARE FUNCTION per l'ordinamento per numero e data fattura degli effetti presenti nello sheet,
// nella maschera di scelta delle riba (ef0300c)
HIDDEN int confronta_fatt(const TObject** o1, const TObject** o2) HIDDEN int confronta_fatt(const TObject** o1, const TObject** o2)
{ {
int val; int val;
@ -674,11 +740,13 @@ HIDDEN int confronta_fatt(const TObject** o1, const TObject** o2)
long num2 = s2->get_long(4); long num2 = s2->get_long(4);
TDate data1 = s1->get(5); TDate data1 = s1->get(5);
TDate data2 = s2->get(5); TDate data2 = s2->get(5);
// ordinamento sul numero fattura
if (num1 != num2) if (num1 != num2)
{ {
val = (num1 > num2) ? +1 : -1; val = (num1 > num2) ? +1 : -1;
return val; return val;
} }
// ordinamento sulla data fattura
if (data1 == data2) if (data1 == data2)
{ {
val = 0; val = 0;
@ -691,19 +759,20 @@ HIDDEN int confronta_fatt(const TObject** o1, const TObject** o2)
} }
} }
//Handler per gestire l'ordinamento per numero e data fattura degli effetti presenti nello sheet //Handler per gestire l'ordinamento per numero e data fattura degli effetti presenti nello sheet,
// nella maschera di scelta delle riba (ef0300c)
void TVariazione_distinte::ord_fatt() void TVariazione_distinte::ord_fatt()
{ {
TMask* m = app()._m2; TMask* m = app()._m2;
TSheet_field& sf = (TSheet_field&)m->field(F_SHEET); TSheet_field& sf = (TSheet_field&)m->field(F_SHEET);
TArray& effetti = sf.rows_array(); TArray& effetti = sf.rows_array();// scarico le righe dello sheet in un array
app().begin_wait(); app().begin_wait();
effetti.sort(confronta_fatt); effetti.sort(confronta_fatt);// ordino gli elementi dell'array
app().end_wait(); app().end_wait();
sf.force_update(); sf.force_update();
} }
//Handler per gestire i diversi ordinamenti //Handler per gestire i diversi ordinamenti, nella maschera di scelta delle riba (ef0300c)
bool TVariazione_distinte::ordina_handler(TMask_field& f, KEY k) bool TVariazione_distinte::ordina_handler(TMask_field& f, KEY k)
{ {
if (f.to_check(k, TRUE)) if (f.to_check(k, TRUE))
@ -718,6 +787,7 @@ bool TVariazione_distinte::ordina_handler(TMask_field& f, KEY k)
} }
//Metodo che calcola i totali relativi alla distinta (totale in lire e totale in valuta(se presente)) //Metodo che calcola i totali relativi alla distinta (totale in lire e totale in valuta(se presente))
// nella maschera principale (ef0300a)
void TVariazione_distinte::calcola_totale() void TVariazione_distinte::calcola_totale()
{ {
TMask* m = app()._msk; TMask* m = app()._msk;
@ -727,6 +797,8 @@ void TVariazione_distinte::calcola_totale()
for (int i = 0; i < items; i++) for (int i = 0; i < items; i++)
{ {
TToken_string& row = sf.row(i); TToken_string& row = sf.row(i);
// se l'effetto è selezionato per l'eliminazione tolgo il suo importo dal totale
// presentazione della distinta
bool condition = *row.get(0) == 'X'; bool condition = *row.get(0) == 'X';
if (condition) if (condition)
{ {
@ -735,6 +807,7 @@ void TVariazione_distinte::calcola_totale()
impval = row.get(9); impval = row.get(9);
impdistval -= impval; impdistval -= impval;
} }
// se l'effetto no è selzionato aggiungo il suo importo al totale presentazione della distinta
imp = row.get(8); imp = row.get(8);
impdist += imp; impdist += imp;
impval = row.get(9); impval = row.get(9);
@ -746,6 +819,7 @@ void TVariazione_distinte::calcola_totale()
} }
//Metodo che calcola i totali relativi alla selezione effetti per la distinta //Metodo che calcola i totali relativi alla selezione effetti per la distinta
// nella maschera di scelta delle riba (ef0300c)
void TVariazione_distinte::calcola() void TVariazione_distinte::calcola()
{ {
TMask* m2 = app()._m2; TMask* m2 = app()._m2;
@ -761,6 +835,7 @@ void TVariazione_distinte::calcola()
for (int i = 0; i < items; i++) for (int i = 0; i < items; i++)
{ {
TToken_string& row = sf.row(i); TToken_string& row = sf.row(i);
// se l'effetto è selezionato aggiungo il suo importo al totale importo selezionato
bool condition = *row.get(0) == 'X'; bool condition = *row.get(0) == 'X';
if (condition) if (condition)
{ {
@ -769,13 +844,12 @@ void TVariazione_distinte::calcola()
m2->set(F_IMPSEL, impsel); m2->set(F_IMPSEL, impsel);
if (impdist == 0 && imp_pres == 0) if (impdist == 0 && imp_pres == 0)
m2->set(F_TOTIMPDIST, impsel); m2->set(F_TOTIMPDIST, impsel);
/*if (impdist != 0 && imp_pres != 0)
m2->set(F_TOTIMPDIST, imp_pres+impsel);*/
} }
} }
} }
//Handler per il calcolo dei totali relativi alla selezione effetti per la distinta //Handler per il calcolo dei totali relativi alla selezione effetti per la distinta
// nella maschera di scelta delle riba (ef0300c)
bool TVariazione_distinte::imp_notify(TSheet_field& s, int r, KEY key) bool TVariazione_distinte::imp_notify(TSheet_field& s, int r, KEY key)
{ {
if (s.to_check(key, TRUE)) if (s.to_check(key, TRUE))
@ -783,7 +857,8 @@ bool TVariazione_distinte::imp_notify(TSheet_field& s, int r, KEY key)
return TRUE; return TRUE;
} }
//Metodo che permette di aggiungere effetti alla distinta caricandoli tra quelli non ancora assegnati //Metodo che permette di aggiungere effetti alla distinta caricandoli tra quelli
//non ancora assegnati, chiamato quando si aggiunge una riga allo sheet degli effetti della distinta
void TVariazione_distinte::aggiungi() void TVariazione_distinte::aggiungi()
{ {
TMask* m2 = app()._m2; TMask* m2 = app()._m2;
@ -796,11 +871,12 @@ void TVariazione_distinte::aggiungi()
} }
//Handler per il calcolo dei totali relativi alla distinta //Handler per il calcolo dei totali relativi alla distinta
// nella maschera della relap (ef0300a)
bool TVariazione_distinte::impdist_notify(TSheet_field& s, int r, KEY key) bool TVariazione_distinte::impdist_notify(TSheet_field& s, int r, KEY key)
{ {
if (s.to_check(key, TRUE)) if (s.to_check(key, TRUE))
calcola_totale(); calcola_totale();
if (key == K_INS) if (key == K_INS) // se si vuole aggiungere una riga alla sheet degli effetti nella distinta
aggiungi(); aggiungi();
return TRUE; return TRUE;
} }

View File

@ -84,6 +84,7 @@ BEGIN
DISPLAY "Denominazione@50" S0 DISPLAY "Denominazione@50" S0
OUTPUT F_CODABIP CODTAB[1,5] OUTPUT F_CODABIP CODTAB[1,5]
OUTPUT F_CODCABP CODTAB[6,10] OUTPUT F_CODCABP CODTAB[6,10]
OUTPUT F_DENBANP S0
CHECKTYPE REQUIRED CHECKTYPE REQUIRED
WARNING "Codice ABI assente" WARNING "Codice ABI assente"
END END
@ -101,7 +102,6 @@ BEGIN
DISPLAY "Denominazione@50" S0 DISPLAY "Denominazione@50" S0
OUTPUT F_CODABIP CODTAB[1,5] OUTPUT F_CODABIP CODTAB[1,5]
OUTPUT F_CODCABP CODTAB[6,10] OUTPUT F_CODCABP CODTAB[6,10]
OUTPUT F_DENBANP S0
CHECKTYPE REQUIRED CHECKTYPE REQUIRED
VALIDATE REQIF_FUNC 1 F_CODCABP VALIDATE REQIF_FUNC 1 F_CODCABP
WARNING "Banca assente" WARNING "Banca assente"

View File

@ -3,7 +3,11 @@
#include "cession.h" #include "cession.h"
#include "ef0301.h" #include "ef0301.h"
// costruttore di default ///////////////////////////////////////////////////
// definizione dei metodi della classe TDistinta //
///////////////////////////////////////////////////
// costruttore distinta utilizzando il record passato
TDistinta::TDistinta(const TRectype& rec) TDistinta::TDistinta(const TRectype& rec)
{ {
read(rec); read(rec);
@ -33,7 +37,7 @@ int TDistinta::read(const char tipo, const long numero)
return err; return err;
} }
// permette di leggere il record passato // permette di leggere la distinta dal record passato
int TDistinta::read(const TRectype& rec) int TDistinta::read(const TRectype& rec)
{ {
CHECK(rec.num() == LF_EFFETTI,"Can't read distinta from a different record type"); CHECK(rec.num() == LF_EFFETTI,"Can't read distinta from a different record type");
@ -51,7 +55,7 @@ int TDistinta::write(bool force, TToken_string* dati_dist)
for (int i=0; i<elem && err==NOERR; i++) for (int i=0; i<elem && err==NOERR; i++)
{ {
TEffetto& effetto = (TEffetto&)_righe_dist[i]; TEffetto& effetto = (TEffetto&)_righe_dist[i];
dati_dist->restart(); dati_dist->restart();// token string che contiene i dati da registrare sull'effetto
effetto.put("TIPODIST", dati_dist->get()); effetto.put("TIPODIST", dati_dist->get());
effetto.put("NDIST", dati_dist->get_long()); effetto.put("NDIST", dati_dist->get_long());
effetto.put("DATADIST", dati_dist->get()); effetto.put("DATADIST", dati_dist->get());
@ -63,12 +67,14 @@ int TDistinta::write(bool force, TToken_string* dati_dist)
return err; return err;
} }
// rimuove la distinta // rimuove la distinta (non si effettua la rimozione del record su file ma si elimina dal file il
// collegamento tra gli effetti e la distinta)
int TDistinta::remove(char tipodist, long ndist) int TDistinta::remove(char tipodist, long ndist)
{ {
int err; int err;
//elimino dal file il collegamento tra gli effetti e la distinta
TLocalisamfile file(LF_EFFETTI); TLocalisamfile file(LF_EFFETTI);
// scandisco tutti gli effetti della distinta (nell'array),
// cancello i dati della distinta e riscrivo gli effetti
for (int i = 0; i < items(); i++) for (int i = 0; i < items(); i++)
{ {
TEffetto& effetto = (TEffetto&)_righe_dist[i]; TEffetto& effetto = (TEffetto&)_righe_dist[i];
@ -81,6 +87,6 @@ int TDistinta::remove(char tipodist, long ndist)
effetto.zero("CODCABP"); effetto.zero("CODCABP");
err = effetto.rewrite(file); err = effetto.rewrite(file);
} }
reset();//elimino gli effetti dalla memoria reset();//elimino gli effetti dalla memoria resettando l'array
return err; return err;
} }

View File

@ -3,28 +3,40 @@
#endif #endif
#include "ef0101.h" #include "ef0101.h"
///////////////////////////////////////////////////////////////
// definizione dell'oggetto Distinta con la classe TDistinta //
///////////////////////////////////////////////////////////////
class TDistinta:public TObject class TDistinta:public TObject
{ {
TArray _righe_dist; TArray _righe_dist; // array che contiene puntatori agli effetti nella distinta
public: public:
TArray& righe() //ritorna un riferimento all'array degli effetti nella distinta
{ return _righe_dist;} TArray& righe(){ return _righe_dist;}
//ritorna il numero degli effetti nella distinta (nell'array) //ritorna il numero degli effetti nella distinta (nell'array)
const int items() const const int items() const{ return _righe_dist.items(); }
{ return _righe_dist.items(); }
//elimina tutti gli effetti nella distinta (appartenti all'array) //elimina tutti gli effetti nella distinta (appartenti all'array)
int reset() int reset(){ return _righe_dist.destroy() == NOERR; }
{ return _righe_dist.destroy() == NOERR; } // legge la distinta del tipo e numero passati
int read(const char tipo, const long numero); int read(const char tipo, const long numero);
// legge il record passato
int read(const TRectype& rec); int read(const TRectype& rec);
// scrive la distinta utilizzando la rewrite degli effetti
int write(bool force = FALSE, TToken_string* dati_dist = NULL); int write(bool force = FALSE, TToken_string* dati_dist = NULL);
int rewrite(TToken_string* dati_dist) // riscrive la distinta
{ return write(TRUE, dati_dist); } int rewrite(TToken_string* dati_dist){ return write(TRUE, dati_dist); }
// rimuove la distinta del tipo e numero passati
int remove(char tipodist, long ndist); int remove(char tipodist, long ndist);
// restituisce il tipo di distinta
const char tipodist() const { return ((TRectype&)_righe_dist[0]).get_char(EFF_TIPODIST); } const char tipodist() const { return ((TRectype&)_righe_dist[0]).get_char(EFF_TIPODIST); }
// restituisce il numero di distinta
const long ndist() const { return ((TRectype&)_righe_dist[0]).get_long(EFF_NDIST); } const long ndist() const { return ((TRectype&)_righe_dist[0]).get_long(EFF_NDIST); }
// costruttore di default
TDistinta() {}; TDistinta() {};
// costruttore distinta del tipo e numero passato
TDistinta(const char tipo, const long numero); TDistinta(const char tipo, const long numero);
// costruttore distinta utilizzando il record passato
TDistinta(const TRectype& rec); TDistinta(const TRectype& rec);
// distruttore di default
virtual ~TDistinta() {} virtual ~TDistinta() {}
}; };

View File

@ -11,7 +11,9 @@
#include "ef0101.h" #include "ef0101.h"
#include "ef0400.h" #include "ef0400.h"
//Classe per l'eliminazione di effetti di effetti con selezione per gruppi /////////////////////////////////////////////////////////////////////////////
//Classe per l'eliminazione di effetti di effetti con selezione per gruppi //
/////////////////////////////////////////////////////////////////////////////
class TEliminazione_effetti: public TApplication class TEliminazione_effetti: public TApplication
{ {
TMask *_msk; TMask *_msk;
@ -34,11 +36,10 @@ public:
virtual ~TEliminazione_effetti() {}; virtual ~TEliminazione_effetti() {};
}; };
inline TEliminazione_effetti& app() // restituisce un riferimento all' applicazione
{ inline TEliminazione_effetti& app(){return (TEliminazione_effetti&)main_app();}
return (TEliminazione_effetti&)main_app();
}
// crea l'applicazione
bool TEliminazione_effetti::create() bool TEliminazione_effetti::create()
{ {
_msk = new TMask("ef0400a"); _msk = new TMask("ef0400a");
@ -59,6 +60,7 @@ bool TEliminazione_effetti::create()
return TRUE; return TRUE;
} }
// distrugge l'applicazione
bool TEliminazione_effetti::destroy() bool TEliminazione_effetti::destroy()
{ {
delete _msk; delete _msk;
@ -87,7 +89,7 @@ bool TEliminazione_effetti::from_numero_handler(TMask_field& f, KEY k)
TMask &m = f.mask(); TMask &m = f.mask();
if (k == K_TAB) if (k == K_TAB)
{ {
if (!f.get().empty()) if (!f.get().empty())// se il campo non è vuoto
{ {
TRectype* from = app()._from; TRectype* from = app()._from;
long num = m.get_long(F_DA_RIBA); long num = m.get_long(F_DA_RIBA);
@ -103,7 +105,7 @@ bool TEliminazione_effetti::to_numero_handler(TMask_field& f, KEY k)
TMask &m = f.mask(); TMask &m = f.mask();
if (k == K_TAB) if (k == K_TAB)
{ {
if (!f.get().empty()) if (!f.get().empty())// se il campo non è vuoto
{ {
TRectype* to = app()._to; TRectype* to = app()._to;
long num = m.get_long(F_A_RIBA); long num = m.get_long(F_A_RIBA);
@ -119,7 +121,7 @@ bool TEliminazione_effetti::from_data_handler(TMask_field& f, KEY k)
TMask &m = f.mask(); TMask &m = f.mask();
if (k == K_TAB) if (k == K_TAB)
{ {
if (!f.get().empty()) if (!f.get().empty())// se il campo non è vuoto
{ {
TRectype* from = app()._from; TRectype* from = app()._from;
TDate data = m.get(F_DA_DATA); TDate data = m.get(F_DA_DATA);
@ -137,7 +139,7 @@ bool TEliminazione_effetti::to_data_handler(TMask_field& f, KEY k)
TMask &m = f.mask(); TMask &m = f.mask();
if (k == K_TAB) if (k == K_TAB)
{ {
if (!f.get().empty()) if (!f.get().empty())// se il campo non è vuoto
{ {
TRectype* to = app()._to; TRectype* to = app()._to;
TDate data = m.get(F_A_DATA); TDate data = m.get(F_A_DATA);
@ -160,7 +162,6 @@ void TEliminazione_effetti::elimina()
int key; int key;
char op1 = m->get(F_TIPOSEL)[0]; char op1 = m->get(F_TIPOSEL)[0];
char op2 = m->get(F_TIPOCANC)[0]; char op2 = m->get(F_TIPOCANC)[0];
switch (op1) //scelgo la chiave per il cursore switch (op1) //scelgo la chiave per il cursore
{ {
case 'N': //selezione effetti per numero case 'N': //selezione effetti per numero
@ -170,7 +171,6 @@ void TEliminazione_effetti::elimina()
key = 3; key = 3;
break; break;
} }
switch (op2) //scelgo il filtro per il cursore switch (op2) //scelgo il filtro per il cursore
{ {
case 'S': //cancello effetti stampati case 'S': //cancello effetti stampati
@ -183,17 +183,14 @@ void TEliminazione_effetti::elimina()
filter = ""; filter = "";
break; break;
} }
TCursor cur(rel,filter,key,from,to); // istanzio il cursore
TCursor cur(rel,filter,key,from,to); TLocalisamfile& delfile = cur.file();// prendo un riferimento al file del cursore
TLocalisamfile& delfile = cur.file(); long n = cur.items();// prendo il numero di elementi del cursore
cur.freeze();// congelo lo stato del cursore
long n = cur.items(); for (cur=0; cur.pos() < n; ++cur)// scandisco tutti gli elementi del cursore
cur.freeze();
for (cur=0; cur.pos() < n; ++cur)
{ {
TEffetto eff(delfile.curr()); TEffetto eff(delfile.curr());// istanzio un effetto con il file corrente del cursore
eff.remove(delfile); eff.remove(delfile); // e lo cancello
} }
} }