modificato l'oggetto effetto per l'utilizzo nell'oggetto distinta

git-svn-id: svn://10.65.10.50/trunk@3898 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
paola 1996-11-14 17:36:49 +00:00
parent f022bd6ca4
commit 4a5b550d9b
3 changed files with 95 additions and 116 deletions

View File

@ -110,19 +110,17 @@ void TVariazione_effetti::common_f(const TMask& m)
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 ) if ( row.items()== 0 ) continue;
{ TRectype& rec = _effetto->row_c(ii+1, TRUE);
TRectype& rec = _effetto->row_c(ii+1, 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+1); 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()); rec.put(CES_COM, row.get());
rec.put(CES_COM, row.get()); ii++;
ii++;
}
} }
items = shrighe.items(); items = shrighe.items();

View File

@ -3,22 +3,6 @@
#include "cession.h" #include "cession.h"
#include "ef0101.h" #include "ef0101.h"
/////////////////////////////////////////////////////////////
//////// Riga Effetto
/////////////////////////////////////////////////////////////
TRiga_effetto::TRiga_effetto(TEffetto* eff)
: TRectype(LF_REFFETTI), _eff(eff)
{
}
TRiga_effetto::TRiga_effetto(const TRiga_effetto& rec, TEffetto* eff)
: TRectype(rec), _eff(eff)
{
}
/////////////////////////////////////////////////////////////
////////// Effetto
/////////////////////////////////////////////////////////////
TEffetto::TEffetto() TEffetto::TEffetto()
: TRectype(LF_EFFETTI), _righe(LF_REFFETTI, "NRIGATR"), _cess(LF_CESS, "NRIGA") : TRectype(LF_EFFETTI), _righe(LF_REFFETTI, "NRIGATR"), _cess(LF_CESS, "NRIGA")
{ {
@ -30,13 +14,13 @@ TEffetto::TEffetto(TRectype& rec)
read(rec); read(rec);
} }
void TEffetto::set_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("NPROGTR",numeff);
} }
void TEffetto::set_key4(TRectype& rec,char tipodist, long ndist, long nrigadist) void TEffetto::put_key(TRectype& rec,char tipodist, long ndist, long nrigadist)
{ {
CHECK(tipodist == 'I' || tipodist == 'S' || tipodist == 'B', "Tipo distinta"); CHECK(tipodist == 'I' || tipodist == 'S' || tipodist == 'B', "Tipo distinta");
CHECKD(ndist >= 0, "Numero distinta non valido ", ndist); CHECKD(ndist >= 0, "Numero distinta non valido ", ndist);
@ -54,7 +38,7 @@ long TEffetto::get_next_key(const long codcf) const
{ {
TLocalisamfile eff(LF_EFFETTI); TLocalisamfile eff(LF_EFFETTI);
TRectype& curr = eff.curr(); TRectype& curr = eff.curr();
set_key(curr, 9999999L); put_key(curr, 9999999L);
const int err = eff.read(_isgreat); const int err = eff.read(_isgreat);
@ -84,17 +68,14 @@ long TEffetto::renum(long numeff)
return numeff; return numeff;
} }
int TEffetto::read(const TRectype& rec) int TEffetto::read(TLocalisamfile &f, const TRectype& r)
{ {
head() = rec; int err = TRectype::read(f);
TRectype *k_reff = new TRectype(LF_REFFETTI), *k_cess= new TRectype(LF_CESS);
const long nu = numero(); const long nu = numero();
CHECK(nu > 0, "Numero effetto nullo."); TRectype *k_reff = new TRectype(LF_REFFETTI),
set_key(*k_reff, nu); *k_cess = new TRectype(LF_CESS);
set_key(*k_cess, nu); put_key(*k_reff, nu);
put_key(*k_cess, nu);
TLocalisamfile eff(LF_EFFETTI);
int err = TRectype::read(eff);
if (err == NOERR) if (err == NOERR)
{ {
_righe.read(k_reff); _righe.read(k_reff);
@ -102,33 +83,51 @@ int TEffetto::read(const TRectype& rec)
} }
else else
{ {
head() = rec; head() = r;
destroy_rows_r(); const long nu = numero();
destroy_rows_c(); put_key(*k_reff, nu);
_cess.set_key(k_cess); put_key(*k_cess, nu);
_righe.set_key(k_reff); if (nu !=0)
} {
return err; destroy_rows_r();
destroy_rows_c();
_cess.set_key(k_cess);
_righe.set_key(k_reff);
}
}
return err;
}
int TEffetto::read(const TRectype& rec)
{
TLocalisamfile eff(LF_EFFETTI);
head() = rec;
return read(eff, rec);
} }
int TEffetto::read(char tipodist, long ndist, long nrigadist) int TEffetto::read(char tipodist, long ndist, long nrigadist)
{ {
TLocalisamfile eff(LF_EFFETTI);
eff.setkey(4);
TRectype rec(LF_EFFETTI); TRectype rec(LF_EFFETTI);
set_key4(rec, tipodist,ndist, nrigadist); put_key(rec, tipodist,ndist, nrigadist);
return read(rec); head() = rec;
int err = read(eff, rec);
return err;
} }
int TEffetto::write(bool force) int TEffetto::write(bool force)
{ {
const bool nuovo = numero() <= 0; // E' nuovo di zecca! 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
TLocalisamfile eff(LF_EFFETTI); TLocalisamfile eff(LF_EFFETTI);
eff.setkey(1);
int err = NOERR; int err = NOERR;
if (force) if (force)
{ {
if ((err=_righe.write(force)) == NOERR) err = _cess.write(force); if ((err=_righe.write(force)) == NOERR) err= _cess.write(force);
if (err == NOERR) if (err == NOERR)
{ {
err = TRectype::rewrite(eff); err = TRectype::rewrite(eff);

View File

@ -2,78 +2,57 @@
#include <relation.h> #include <relation.h>
#endif #endif
class TEffetto;
/////////////////////////////////////////////////
// classe per gestire le righe di un effetto
////////////////////////////////////////////////
class TRiga_effetto : public TRectype
{
TEffetto * _eff;
protected:
TObject* dup() const // duplica l'oggetto corrente
{ return new TRiga_effetto(*this); }
public:
int numeror() const // restituisce il numero della riga
{ return get_int("NRIGATR");}
void set_numeror(int numero) // setta il valore del numero di riga con quello passato
{ put("NRIGATR", numero);}
void set_eff(TEffetto * eff) // setta l'effetto con quello passato
{ _eff = eff; }
const TEffetto & eff() const
{ CHECK(_eff, "Effetto nullo"); return *_eff;}
TRiga_effetto(TEffetto* eff);
TRiga_effetto(const TRiga_effetto& rec, TEffetto* eff);
virtual ~TRiga_effetto() {}
};
/////////////////////////////////////////////////
// classe per gestire gli effetti
////////////////////////////////////////////////
class TEffetto:public TRectype class TEffetto:public TRectype
{ {
TRecord_array _righe,_cess; TRecord_array _righe,_cess;
protected: protected:
// ritorna la prossima chiave
long get_next_key(const long codcf) const; // ritorna la prossima chiave long get_next_key(const long codcf) const;
int read(TLocalisamfile& f, const TRectype& rec);
public: public:
long renum(long numeff = 0); // rinumera le chiavi // rinumera le chiavi
long renum(long numeff = 0);
// ritorna la testata dell'effetto
const TRectype& head() const const TRectype& head() const
{ return *this; } // Ritorna la testata dell'effetto { return *this; }
// ritorna la testata dell'effetto
TRectype& head() TRectype& head()
{ return *this; } { return *this; }
TRecord_array& righe() {return _righe;}
TRecord_array& righe() {return _righe;} TRecord_array& cess() {return _cess;}
TRecord_array& cess() {return _cess;} // ritorna la riga i_esima dei cessionari
TRectype& row_c(int i, bool create=FALSE) TRectype& row_c(int i, bool create=FALSE)
{ return _cess.row(i,create); } // ritorna la riga i dei cessionari { return _cess.row(i,create); }
TRectype& row_r(int i, bool create=FALSE) // ritorna la riga i delle righe
{ return _righe.row(i,create); } // ritorna la riga i delle righe TRectype& row_r(int i, bool create=FALSE)
{ return _righe.row(i,create); }
int rows_r() const // ritorna il numero delle righe presenti // ritorna il numero delle righe presenti nelle righe effetto
{ return _righe.rows(); } // nelle righe effetto int rows_r() const
int rows_c() const // ritorna il numero delle righe presenti { return _righe.rows(); }
{ return _cess.rows(); } // nei cessionari // ritorna il numero delle righe presenti nei cessionari
int rows_c() const
bool destroy_row_r(int n, bool pack = FALSE) // elimina l'elemento riga nella posizione n { return _cess.rows(); }
{ return _righe.destroy_row(n, pack); } // nelle righe effetto // elimina l'elemento riga nella posizione n nelle righe effetto
void destroy_rows_r() // elimina tutti gli elementi riga bool destroy_row_r(int n, bool pack = FALSE)
{ _righe.destroy_rows(); } // nelle righe effetto { return _righe.destroy_row(n, pack); }
// elimina tutti gli elementi riga nelle righe effetto
bool destroy_row_c(int n, bool pack = FALSE) // elimina l'elemento riga nella posizione n void destroy_rows_r()
{ return _cess.destroy_row(n, pack); } // nei cessionari { _righe.destroy_rows(); }
void destroy_rows_c() // elimina tutti gli elementi riga // elimina l'elemento riga nella posizione n nei cessionari
{ _cess.destroy_rows(); } // nei cessionari bool destroy_row_c(int n, bool pack = FALSE)
{ return _cess.destroy_row(n, pack); }
// elimina tutti gli elementi riga nei cessionari
void destroy_rows_c()
{ _cess.destroy_rows(); }
int read(const TRectype& rec); int read(const TRectype& rec);
int read(char tipodist, long ndist, long nrigadist); int read(char tipodist, long ndist, long nrigadist);
int write(bool force=FALSE); int write(bool force=FALSE);
int rewrite() int rewrite()
{ return write(TRUE); } { return write(TRUE); }
int remove()const; int remove()const;
long numero() const // metodi per ritornare i campi chiave long numero() const
{ return get_long("NPROGTR"); } // del file EFFETTI { return get_long("NPROGTR"); }
long codicec() const long codicec() const
{ return get_long("CODCF"); } { return get_long("CODCF"); }
TDate datasc() const TDate datasc() const
@ -83,9 +62,12 @@ public:
long ndist() const long ndist() const
{ return get_long("NDIST"); } { return get_long("NDIST"); }
long nrgdist() const long nrgdist() const
{ return get_long("NRIGADIST"); } { return get_long("NRIGADIST"); }
void set_key4(TRectype& rec,char tipodist, long ndist, long nrigadist); //setta i campi per la quarta chiave del file //setta i campi per la quarta chiave del file
void set_key(TRectype& rec,long numeff) const; //setta i campi per la chiave void put_key(TRectype& rec,char tipodist, long ndist, long nrigadist = 0);
//setta i campi per la prima chiave del file
void put_key(TRectype& rec,long numeff) const;
TEffetto(); TEffetto();
TEffetto(TRectype& rec); TEffetto(TRectype& rec);
virtual ~TEffetto() {} virtual ~TEffetto() {}