Corretto numero riga distinta
git-svn-id: svn://10.65.10.50/trunk@4482 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
3b319547c8
commit
ddb6256d91
154
ef/ef0101.cpp
154
ef/ef0101.cpp
@ -1,21 +1,21 @@
|
||||
#include "ef0101.h"
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Definizione dei metodi della classe TEffetto //
|
||||
// Definizione dei metodi della classe TEffetto //
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
// costruttore di default
|
||||
// costruttore di default
|
||||
TEffetto::TEffetto()
|
||||
: TRectype(LF_EFFETTI), _righe(LF_REFFETTI, REFF_NRIGATR), _cess(LF_CESS, CES_NRIGA)
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
// costuisce l'effetto con il record passato
|
||||
TEffetto::TEffetto(TRectype& rec)
|
||||
: TRectype(LF_EFFETTI), _righe(LF_REFFETTI, REFF_NRIGATR), _cess(LF_CESS, CES_NRIGA)
|
||||
{
|
||||
{
|
||||
TLocalisamfile f(LF_EFFETTI);
|
||||
read(f,rec);
|
||||
read(f,rec);
|
||||
}
|
||||
|
||||
TEffetto::TEffetto(const TEffetto& eff)
|
||||
@ -23,33 +23,33 @@ TEffetto::TEffetto(const TEffetto& eff)
|
||||
{
|
||||
}
|
||||
|
||||
TObject* TEffetto::dup() const
|
||||
TObject* TEffetto::dup() const
|
||||
{
|
||||
TEffetto* e = new TEffetto((const TEffetto&)*this);
|
||||
return e;
|
||||
}
|
||||
|
||||
// setta i campi per la prima chiave (nprogtr)
|
||||
// setta i campi per la prima chiave (nprogtr)
|
||||
void TEffetto::put_key(TRectype& rec, long numeff) const
|
||||
{
|
||||
CHECKD(numeff >= 0, "Numero effetto non valido ", numeff);
|
||||
rec.put(EFF_NPROGTR, numeff);
|
||||
}
|
||||
|
||||
// setta i campi per la quarta chiave (tipodist+ndist+nrigadist)
|
||||
void TEffetto::put_key(TRectype& rec,char tipodist, long ndist, long nrigadist)
|
||||
// setta i campi per la quarta chiave (tipodist+ndist+nrigadist)
|
||||
void TEffetto::put_key(TRectype& rec,char tipodist, long ndist, int nrigadist)
|
||||
{
|
||||
CHECK(tipodist == 'I' || tipodist == 'S' || tipodist == 'B' || tipodist == 0, "Tipo distinta");
|
||||
CHECKD(ndist >= 0, "Numero distinta non valido ", ndist);
|
||||
CHECKD(nrigadist >= 0, "Numero riga distinta non valido ", nrigadist);
|
||||
rec.put(EFF_TIPODIST, tipodist);
|
||||
rec.put(EFF_TIPODIST, tipodist);
|
||||
rec.put(EFF_NDIST, ndist);
|
||||
rec.put(EFF_NRIGADIST, nrigadist);
|
||||
}
|
||||
|
||||
// ritorna la prossima chiave utilizzabile
|
||||
// ritorna la prossima chiave utilizzabile
|
||||
long TEffetto::get_next_key(const long codcf) const
|
||||
{
|
||||
{
|
||||
static long n = 0;
|
||||
if (n == 0)
|
||||
{
|
||||
@ -63,20 +63,20 @@ long TEffetto::get_next_key(const long codcf) const
|
||||
eff.prev();
|
||||
if (curr.get_long(EFF_CODCF) == codcf)
|
||||
n = curr.get_long(EFF_NPROGTR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
n++;
|
||||
return n;
|
||||
return n;
|
||||
}
|
||||
|
||||
// rinumera la chiave 1 (nprogtr)
|
||||
long TEffetto::renum(long numeff)
|
||||
{
|
||||
if (numeff <= 0)
|
||||
{
|
||||
{
|
||||
long codcf = codicec();
|
||||
numeff = get_next_key(codcf);
|
||||
}
|
||||
}
|
||||
char num[7]; sprintf(num, "%ld", numeff);
|
||||
renum_key(EFF_NPROGTR, num); // aggiorna testata
|
||||
_righe.renum_key(EFF_NPROGTR, num); // aggiorna righe ok
|
||||
@ -86,87 +86,87 @@ long TEffetto::renum(long numeff)
|
||||
|
||||
// restituisce il prossimo effetto
|
||||
int TEffetto::next(TBaseisamfile& f)
|
||||
{
|
||||
const int err = f.next();
|
||||
{
|
||||
const int err = f.next();
|
||||
*this = f.curr();
|
||||
return err;
|
||||
return err;
|
||||
}
|
||||
|
||||
// permette di leggere il record passato nel file passato, comune alla
|
||||
// lettura per chiave 1 e per chiave 4
|
||||
int TEffetto::leggi(TLocalisamfile &f, const TRectype& r, word lockop)
|
||||
{
|
||||
//int err = TRectype::read(f);
|
||||
// lettura per chiave 1 e per chiave 4
|
||||
int TEffetto::leggi(TLocalisamfile &f, const TRectype& r, word lockop)
|
||||
{
|
||||
//int err = TRectype::read(f);
|
||||
int err = f.read(*this, _isequal, lockop);
|
||||
const long nu = numero();
|
||||
// necessari per poter andare a leggere i due record array
|
||||
// cessionari e righe effetto
|
||||
// cessionari e righe effetto
|
||||
TRectype *k_reff = new TRectype(LF_REFFETTI),
|
||||
*k_cess = new TRectype(LF_CESS);
|
||||
*k_cess = new TRectype(LF_CESS);
|
||||
// setto la chiave per poter leggere dai due record array
|
||||
put_key(*k_reff, nu);
|
||||
put_key(*k_cess, nu);
|
||||
put_key(*k_reff, nu);
|
||||
put_key(*k_cess, nu);
|
||||
if (err == NOERR)
|
||||
{ // leggo dai record array
|
||||
_righe.read(k_reff);
|
||||
{ // leggo dai record array
|
||||
_righe.read(k_reff);
|
||||
_cess.read(k_cess);
|
||||
}
|
||||
}
|
||||
else // se ho trovato un errore
|
||||
{
|
||||
head() = r;
|
||||
head() = r;
|
||||
const long nu = numero();
|
||||
put_key(*k_reff, nu);
|
||||
put_key(*k_cess, nu);
|
||||
if (nu !=0)
|
||||
{
|
||||
{
|
||||
destroy_rows_r();
|
||||
destroy_rows_c();
|
||||
_cess.set_key(k_cess);
|
||||
_righe.set_key(k_reff);
|
||||
_righe.set_key(k_reff);
|
||||
}
|
||||
}
|
||||
return err;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
// legge il record passato, con chiave 1
|
||||
int TEffetto::read(TLocalisamfile& f, const TRectype& rec, word lockop)
|
||||
{
|
||||
head() = rec;
|
||||
return leggi(f, rec, lockop);
|
||||
{
|
||||
head() = rec;
|
||||
return leggi(f, rec, lockop);
|
||||
}
|
||||
|
||||
// legge l'effetto usando la chiave 4
|
||||
int TEffetto::read(TLocalisamfile& f, char tipodist, long ndist, long nrigadist, word lockop)
|
||||
{
|
||||
f.setkey(4);
|
||||
int TEffetto::read(TLocalisamfile& f, char tipodist, long ndist, int nrigadist)
|
||||
{
|
||||
f.setkey(4);
|
||||
TRectype rec(LF_EFFETTI);
|
||||
put_key(rec, tipodist, ndist, nrigadist);
|
||||
put_key(rec, tipodist, ndist, nrigadist);
|
||||
head() = rec;
|
||||
return leggi(f, rec, lockop);
|
||||
}
|
||||
|
||||
// scrive l'effetto, usando la chiave 1
|
||||
int TEffetto::write(TLocalisamfile& f, bool force)
|
||||
{
|
||||
{
|
||||
const bool nuovo = numero() <= 0; // E' nuovo!
|
||||
if (nuovo && force) // quindi ...
|
||||
force = FALSE; // ... non fare la rewrite
|
||||
f.setkey(1);
|
||||
f.setkey(1);
|
||||
int err = NOERR;
|
||||
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)
|
||||
{
|
||||
err = TRectype::rewrite(f);
|
||||
if (err != NOERR)
|
||||
err = TRectype::write(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
if (nuovo)
|
||||
{
|
||||
{
|
||||
TEffetto& myself = *(TEffetto*)this;
|
||||
if (numero() <= 0)
|
||||
myself.renum();
|
||||
@ -177,60 +177,60 @@ int TEffetto::write(TLocalisamfile& f, bool force)
|
||||
myself.renum();
|
||||
} while (err == _isreinsert);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
err = TRectype::write(f);
|
||||
if (err != NOERR)
|
||||
err = TRectype::rewrite(f);
|
||||
}
|
||||
}
|
||||
if (err == NOERR)
|
||||
if ((err=_righe.write(force)) == NOERR) err= _cess.write(force);
|
||||
if ((err=_righe.write(force)) == NOERR) err= _cess.write(force);
|
||||
}
|
||||
return err;
|
||||
return err;
|
||||
}
|
||||
|
||||
// rimuove l'effetto
|
||||
int TEffetto::remove(TLocalisamfile& f)const
|
||||
{
|
||||
{
|
||||
int err;
|
||||
if ((err=_righe.remove()) == NOERR) err= _cess.remove();
|
||||
if ((err=_righe.remove()) == NOERR) err= _cess.remove();
|
||||
if (err == NOERR)
|
||||
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);
|
||||
{
|
||||
TLocalisamfile righe_eff(LF_REFFETTI);
|
||||
righe_eff.put(REFF_NPROGTR, num);
|
||||
righe_eff.read();
|
||||
// prende il numero delle righe dell'effetto
|
||||
righe_eff.read();
|
||||
// prende il numero delle righe dell'effetto
|
||||
// ovvero di fatture a cui fa riferimento
|
||||
int items = rows_r();
|
||||
bool condition = (items == 1);
|
||||
return condition;
|
||||
}
|
||||
bool condition = (items == 1);
|
||||
return condition;
|
||||
}
|
||||
|
||||
// restituisce i dati relativi alle fatture a cui si riferisce l'effetto
|
||||
// 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);
|
||||
{
|
||||
TToken_string* dati= new TToken_string;
|
||||
dati->cut(0);
|
||||
|
||||
TLocalisamfile righe_eff(LF_REFFETTI);
|
||||
righe_eff.put(REFF_NPROGTR, num);
|
||||
righe_eff.read();
|
||||
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
|
||||
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
|
||||
dati->add(righe_eff.get(REFF_IMPFATT));//prende l' importo
|
||||
righe_eff.next();// passa alla riga successiva
|
||||
}
|
||||
return dati;
|
||||
}
|
||||
}
|
||||
return dati;
|
||||
}
|
||||
|
82
ef/ef0101.h
82
ef/ef0101.h
@ -6,7 +6,7 @@
|
||||
#endif
|
||||
#ifndef __RECTYPES_H
|
||||
#include <rectypes.h>
|
||||
#endif
|
||||
#endif
|
||||
#ifndef __RECARRAY_H
|
||||
#include <recarray.h>
|
||||
#endif
|
||||
@ -15,88 +15,88 @@
|
||||
#include <cession.h>
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// Definizione dell'oggetto Effetto con la classe TEffetto//
|
||||
// Definizione dell'oggetto Effetto con la classe TEffetto//
|
||||
////////////////////////////////////////////////////////////
|
||||
class TEffetto:public TRectype
|
||||
{
|
||||
TRecord_array _righe;// righe dell'effetto
|
||||
TRecord_array _righe;// righe dell'effetto
|
||||
TRecord_array _cess;// cessionari dell'effetto
|
||||
protected:
|
||||
// ritorna la prossima chiave
|
||||
long get_next_key(const long codcf) const;
|
||||
// permette di leggere il record passato nel file passato
|
||||
protected:
|
||||
// ritorna la prossima chiave
|
||||
long get_next_key(const long codcf) const;
|
||||
// permette di leggere il record passato nel file passato
|
||||
int leggi(TLocalisamfile& f, const TRectype& rec, word lockop = _nolock);
|
||||
public:
|
||||
public:
|
||||
// Duplica l'effetto
|
||||
virtual TObject* dup() const;
|
||||
// rinumera la chiave 1
|
||||
long renum(long numeff = 0);
|
||||
long renum(long numeff = 0);
|
||||
// ritorna un riferimento alla testata dell'effetto
|
||||
const TRectype& head() const { return *this; }
|
||||
// ritorna un riferimento alla testata dell'effetto
|
||||
TRectype& head() { return *this; }
|
||||
// ritorna un riferimento alle righe dell'effetto
|
||||
TRecord_array& righe() {return _righe;}
|
||||
const TRectype& head() const { return *this; }
|
||||
// ritorna un riferimento alla testata dell'effetto
|
||||
TRectype& head() { return *this; }
|
||||
// ritorna un riferimento alle righe dell'effetto
|
||||
TRecord_array& righe() {return _righe;}
|
||||
// ritorna un riferimento ai cessionari dell'effetto
|
||||
TRecord_array& cess() {return _cess;}
|
||||
// ritorna la riga i_esima dei cessionari
|
||||
TRectype& row_c(int i, bool create=FALSE) { return _cess.row(i,create); }
|
||||
TRectype& row_c(int i, bool create=FALSE) { return _cess.row(i,create); }
|
||||
// ritorna la riga i delle righe
|
||||
TRectype& row_r(int i, bool create=FALSE) { return _righe.row(i,create); }
|
||||
TRectype& row_r(int i, bool create=FALSE) { return _righe.row(i,create); }
|
||||
// ritorna il numero delle righe presenti nelle righe effetto
|
||||
int rows_r() const { return _righe.rows(); }
|
||||
int rows_r() const { return _righe.rows(); }
|
||||
// ritorna il numero delle righe presenti nei cessionari
|
||||
int rows_c() const { return _cess.rows(); }
|
||||
// elimina l'elemento riga nella posizione n nelle righe effetto
|
||||
bool destroy_row_r(int n, bool pack = FALSE) { return _righe.destroy_row(n, pack); }
|
||||
int rows_c() const { return _cess.rows(); }
|
||||
// elimina l'elemento riga nella posizione n nelle righe effetto
|
||||
bool destroy_row_r(int n, bool pack = FALSE) { return _righe.destroy_row(n, pack); }
|
||||
// elimina tutti gli elementi riga nelle righe effetto
|
||||
void destroy_rows_r() { _righe.destroy_rows(); }
|
||||
void destroy_rows_r() { _righe.destroy_rows(); }
|
||||
// elimina l'elemento riga nella posizione n 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(); }
|
||||
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(); }
|
||||
// restituisce il prossimo effetto
|
||||
int next(TBaseisamfile& f);
|
||||
// legge il record passato, con chiave 1
|
||||
int read(TLocalisamfile& f, const TRectype& rec, word lockop = _nolock);
|
||||
int next(TBaseisamfile& f);
|
||||
// legge il record passato, con chiave 1
|
||||
int read(TLocalisamfile& f, const TRectype& rec, word lockop = _nolock);
|
||||
// legge il record passato, con chiave 4
|
||||
int read(TLocalisamfile& f, char tipodist, long ndist, long nrigadist, word lockop = _nolock);
|
||||
int read(TLocalisamfile& f, char tipodist, long ndist, int nrigadist);
|
||||
// scrive l'effetto, sempre usando la chiave 1
|
||||
int write(TLocalisamfile& f, bool force = FALSE);
|
||||
// riscrive l'effetto
|
||||
int rewrite(TLocalisamfile& f) { return write(f, TRUE); }
|
||||
// rimuove l'effetto
|
||||
int remove(TLocalisamfile& f)const;
|
||||
int remove(TLocalisamfile& f)const;
|
||||
// restituisce il numero progressivo dell'effetto estraendolo dal record
|
||||
long numero() const { return get_long(EFF_NPROGTR); }
|
||||
// restituisce il codice del cliente intestatario dell'effetto estraendolo dal record
|
||||
// restituisce il codice del cliente intestatario dell'effetto estraendolo dal record
|
||||
long codicec() const { return get_long(EFF_CODCF); }
|
||||
// restituisce la data di scadenza dell'effetto estraendola dal record
|
||||
TDate datasc() const { return get_date(EFF_DATASCAD); }
|
||||
TDate datasc() const { return get_date(EFF_DATASCAD); }
|
||||
// restituisce il tipo di distinta a cui appartiene l'effetto estraendolo dal record
|
||||
char tipodist() const { return get_char(EFF_TIPODIST); }
|
||||
// restituisce il numero della distinta a cui appartiene l'effetto estraendolo dal record
|
||||
// restituisce il numero della distinta a cui appartiene l'effetto estraendolo dal record
|
||||
long ndist() const { return get_long(EFF_NDIST); }
|
||||
// restituisce il numero della riga distinta a cui appartiene l'effetto estraendolo dal record
|
||||
long nrgdist() const { return get_long(EFF_NRIGADIST); }
|
||||
// restituisce il numero della riga distinta a cui appartiene l'effetto estraendolo dal record
|
||||
int nrgdist() const { return get_int(EFF_NRIGADIST); }
|
||||
// restituisce l'importo dell'effetto
|
||||
real importo() const { return get_real(EFF_IMPORTO); }
|
||||
// setta i campi per la quarta chiave del file
|
||||
void put_key(TRectype& rec,char tipodist, long ndist, long nrigadist = 0);
|
||||
// setta i campi per la quarta chiave del file
|
||||
void put_key(TRectype& rec,char tipodist, long ndist, int nrigadist = 0);
|
||||
// setta i campi per la prima chiave del file
|
||||
void put_key(TRectype& rec,long numeff) const;
|
||||
// restituisce true se l'effetto si riferisce ad una sola fattura
|
||||
bool fatt(long num);
|
||||
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
|
||||
TEffetto();
|
||||
TEffetto();
|
||||
// costuisce l'effetto con il record passato
|
||||
TEffetto(TRectype& rec);
|
||||
TEffetto(TRectype& rec);
|
||||
// costuttore di copia
|
||||
TEffetto(const TEffetto& eff);
|
||||
TEffetto(const TEffetto& eff);
|
||||
// distruttore di default
|
||||
virtual ~TEffetto() {}
|
||||
};
|
||||
|
||||
#endif//__EF0101_H
|
||||
#endif//__EF0101_H
|
||||
|
@ -1,3 +1,3 @@
|
||||
31
|
||||
0
|
||||
$effetti|0|0|157|34|Effetti|NEFF||
|
||||
$effetti|0|0|154|34|Effetti|NEFF||
|
||||
|
Loading…
x
Reference in New Issue
Block a user