From cfa88b17dc9f1fae3a1a9ef1cee100081bc3147b Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 24 Oct 1997 15:16:23 +0000 Subject: [PATCH] Aggiunto oggetto TAgente Corretta rate2rows nel caso di agente non definito git-svn-id: svn://10.65.10.50/trunk@5450 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- pr/prlib.h | 17 +++++ pr/prlib01.cpp | 170 +++++++++++++++++++++++++++++-------------------- 2 files changed, 119 insertions(+), 68 deletions(-) diff --git a/pr/prlib.h b/pr/prlib.h index a78715657..6809ad25b 100755 --- a/pr/prlib.h +++ b/pr/prlib.h @@ -124,4 +124,21 @@ public: ~TProvvigioni_agente(); }; +class TAgente : public TRectype +{ +protected: + int read(const char* codice); + virtual TAgente & copy(const TAgente & a) { return (TAgente &) TRectype::operator=((TRectype &)a);} + +public: + TObject* dup() const { return new TAgente(*this); } + const TString& codice() const { return get("CODAGE");} + const TString& ragsoc() const { return get("RAGSOC"); } + const TString& campoprovv() const { return get("CAMPOPROVV"); } + + TAgente(const char* codice = NULL); + TAgente(const TAgente & a); + TAgente(const TRectype& rec); + virtual ~TAgente() {} +}; #endif diff --git a/pr/prlib01.cpp b/pr/prlib01.cpp index 6ca6eca77..1bc4b9886 100755 --- a/pr/prlib01.cpp +++ b/pr/prlib01.cpp @@ -90,79 +90,83 @@ int TProvvigioni_agente::rate2rows(int action) // Scorre gli elementi di _rate (TDoc_rate) uno ad uno // per settare le righe provvigionali // Scrive tramite chiave 1: utilizzando un solo record array (CODAGE+NROW) - TRecord_array* rows = new TRecord_array(LF_PROVV,PROV_NROW); - TRectype* k = new TRectype(LF_PROVV); - k->put(PROV_CODAGE, _agente); - rows->set_key(k); - TString_array kl; - int nrow = 1; // Numero riga per agente e per documento - const int items = documenti(kl); // Prende l'elenco dei documenti - kl.sort(); // ordina per documento int err = NOERR; - for (int i = 0; i < items && err == NOERR; i++) + + if (_agente.not_empty()) { - TRate_doc& rd = (TRate_doc&)_rate[kl.row(i)]; - const int anno = rd.anno(); - const long ndoc = rd.ndoc(); - TString codnum(rd.codnum()); - TDate datadoc(rd.datadoc()); - real impdoc = rd.impdoc(); - real impprdoc = rd.impprdoc(); - real impnet = rd.impnet(); - const long codcf = rd.codcf(); - TString codval(rd.codval()); - TDate datacam(rd.datacam()); - real cambio = rd.cambio(); - // Chiave del TRecord_array - const int ritems = rd.items(); // Ciclo per rate di questo documento - for (int j = 0; j < ritems; j++) + TRecord_array * rows = new TRecord_array(LF_PROVV,PROV_NROW); + TRectype* k = new TRectype(LF_PROVV); + k->put(PROV_CODAGE, _agente); + rows->set_key(k); + TString_array kl; + int nrow = 1; // Numero riga per agente e per documento + const int items = documenti(kl); // Prende l'elenco dei documenti + kl.sort(); // ordina per documento + for (int i = 0; i < items && err == NOERR; i++) { - TRata& rt = rd[j]; - TRectype* record = new TRectype(LF_PROVV); - record->put(PROV_CODAGE,_agente); - record->put(PROV_ANNO,anno); - record->put(PROV_CODNUM,codnum); - record->put(PROV_NDOC,ndoc); - record->put(PROV_NROW,nrow++); - record->put(PROV_NRIGA,j+1); - record->put(PROV_NRATA,rt.rata()); - record->put(PROV_GENERATA,rt.generata()); - record->put(PROV_SALDATA,rt.saldata()); - record->put(PROV_TIPOPAGPR,rt.tipopagpr()); - record->put(PROV_DATADOC,datadoc); - record->put(PROV_IMPDOC,impdoc); - record->put(PROV_IMPPRDOC,impprdoc); - record->put(PROV_IMPNETDOC,impnet); - record->put(PROV_CODCLI,codcf); - record->put(PROV_CODVAL,codval); - record->put(PROV_DATACAMBIO,datacam); - record->put(PROV_CAMBIO,cambio); - record->put(PROV_DATASCAD,rt.datascad()); - record->put(PROV_IMPRATA,rt.imprata()); - record->put(PROV_TIPOPAG,rt.tipopag()); - record->put(PROV_IMPPROVV,rt.impprovv()); - record->put(PROV_PAGATO,rt.pagato()); - record->put(PROV_PROVVPAG,rt.provvpag()); - record->put(PROV_PAGMAT,rt.pagmat()); - record->put(PROV_PROVVMAT,rt.provvmat()); - rows->add_row(record); - } - switch (action) - { - case 0: // write - err = rows->write(); - break; - case 1: // rewrite - err = rows->rewrite(); - break; - case 2: // remove - err = rows->remove(); - break; - default: // remove - break; + TRate_doc& rd = (TRate_doc&)_rate[kl.row(i)]; + const int anno = rd.anno(); + const long ndoc = rd.ndoc(); + TString codnum(rd.codnum()); + TDate datadoc(rd.datadoc()); + real impdoc = rd.impdoc(); + real impprdoc = rd.impprdoc(); + real impnet = rd.impnet(); + const long codcf = rd.codcf(); + TString codval(rd.codval()); + TDate datacam(rd.datacam()); + real cambio = rd.cambio(); + // Chiave del TRecord_array + const int ritems = rd.items(); // Ciclo per rate di questo documento + for (int j = 0; j < ritems; j++) + { + TRata& rt = rd[j]; + TRectype* record = new TRectype(LF_PROVV); + record->put(PROV_CODAGE,_agente); + record->put(PROV_ANNO,anno); + record->put(PROV_CODNUM,codnum); + record->put(PROV_NDOC,ndoc); + record->put(PROV_NROW,nrow++); + record->put(PROV_NRIGA,j+1); + record->put(PROV_NRATA,rt.rata()); + record->put(PROV_GENERATA,rt.generata()); + record->put(PROV_SALDATA,rt.saldata()); + record->put(PROV_TIPOPAGPR,rt.tipopagpr()); + record->put(PROV_DATADOC,datadoc); + record->put(PROV_IMPDOC,impdoc); + record->put(PROV_IMPPRDOC,impprdoc); + record->put(PROV_IMPNETDOC,impnet); + record->put(PROV_CODCLI,codcf); + record->put(PROV_CODVAL,codval); + record->put(PROV_DATACAMBIO,datacam); + record->put(PROV_CAMBIO,cambio); + record->put(PROV_DATASCAD,rt.datascad()); + record->put(PROV_IMPRATA,rt.imprata()); + record->put(PROV_TIPOPAG,rt.tipopag()); + record->put(PROV_IMPPROVV,rt.impprovv()); + record->put(PROV_PAGATO,rt.pagato()); + record->put(PROV_PROVVPAG,rt.provvpag()); + record->put(PROV_PAGMAT,rt.pagmat()); + record->put(PROV_PROVVMAT,rt.provvmat()); + rows->add_row(record); + } + switch (action) + { + case 0: // write + err = rows->write(); + break; + case 1: // rewrite + err = rows->rewrite(); + break; + case 2: // remove + err = rows->remove(); + break; + default: // remove + break; + } } + delete rows; } - delete rows; return err; } @@ -324,3 +328,33 @@ TRata::TRata(TRectype& rec) set(rec); } +int TAgente::read(const char * codice) +{ + TLocalisamfile f(LF_AGENTI); + + put("CODAGE", codice); + int err = TRectype::read(f); + if (err != NOERR) + { + zero(); + put("CODAGE", codice); + } + return err; +} + +TAgente::TAgente(const char * codice) + : TRectype(LF_AGENTI) +{ + read(codice); +} + +TAgente::TAgente(const TAgente & a) + : TRectype(LF_AGENTI) +{ + copy(a); +} +TAgente::TAgente(const TRectype & rec) + : TRectype(LF_AGENTI) +{ + TRectype::operator=(rec); +}