diff --git a/ve/velib01.cpp b/ve/velib01.cpp index 8d04b95cf..c1e3fddd5 100755 --- a/ve/velib01.cpp +++ b/ve/velib01.cpp @@ -95,21 +95,11 @@ int TTipo_documento::read(const char* tipodoc) return err; } -TMask& TTipo_documento::mask() -{ - if (_mask == NULL) - { - TFilename profile_file = _rec.get("S4"); - profile_file.ext("ini"); - TConfig p(profile_file); - _mask = new TVariable_mask(p.get("MSKFILE", "MAIN")); - } - return *_mask; -} - /////////////////////////////////////////////////////////// // Documento per vendite /////////////////////////////////////////////////////////// + +TAssoc_array TDocumento::_tipi; TDocumento::TDocumento() : _head(LF_DOC), _rows(LF_RIGHEDOC, "NRIGA") @@ -137,6 +127,8 @@ int TDocumento::read(const TRectype& rec) key->put("NUMDOC", doc.get("NUMDOC")); err = _rows.read(key); } + else + _head = rec; return err; } @@ -146,13 +138,15 @@ int TDocumento::read(const char* codnum, int anno, char provv, long numdoc) CHECK(codnum && *codnum && anno > 0 && (provv == 'D' || provv == 'P') && numdoc > 0, "Codice documento non valido"); - _head.zero(); - _head.put("CODNUM", codnum); - _head.put("ANNO", anno); - _head.put("PROVV", provv); - _head.put("NUMDOC", numdoc); + TRectype rec(_head); + + rec.zero(); + rec.put("CODNUM", codnum); + rec.put("ANNO", anno); + rec.put("PROVV", provv); + rec.put("NUMDOC", numdoc); - return read(_head); + return read(rec); } int TDocumento::write(bool re) const diff --git a/ve/velib01.h b/ve/velib01.h index cb1c0dcdd..0c89a6969 100755 --- a/ve/velib01.h +++ b/ve/velib01.h @@ -29,8 +29,9 @@ public: pagamento, banca_appoggio, listino, agente, spedizione, porto, causale_trasporto, vettori }; - const TString& tipodoc() const { return _rec.get("CODTAB");} - TMask& mask(); + const TString & tipodoc() const { return _rec.get("CODTAB");} + const TString & profile_name() const { return _rec.get("S4");} + const TString & mask_name() const { return _rec.get("S4");} bool uguale(TCondizione_uguaglianza u) const { return _rec.get("S2")[(int)u]; } @@ -49,24 +50,30 @@ class TDocumento : public TObject public: int rows() const { return _rows.rows(); } - const TRectype& head() const { return _head; } // Ritorna la testata del documento - const TRectype& operator[](int index) const { return _rows.row(index); } // Ritorna la riga n-esima del documento - TRectype& operator[](int index) { return _rows.row(index, FALSE); } + const TRectype & head() const { return _head; } // Ritorna la testata del documento + TRectype & head() { return _head; } // Ritorna la testata del documento + const TRectype & operator[](int index) const { return _rows.row(index); } // Ritorna la riga n-esima del documento + TRectype & operator[](int index) { return _rows.row(index, FALSE); } TRectype& add_row() { return _rows.row(-1, TRUE); } bool destroy_row(int n) { return _rows.destroy_row(n); } + void destroy_rows() { _rows.destroy_rows(); } - int read(const char* codnum, int anno, char provv, long numdoc); - int read(const TRectype& rec); + int read(const char * codnum, int anno, char provv, long numdoc); + int read(const TRectype & rec); int write(bool re = FALSE) const; int rewrite() const { return write(TRUE); } int remove() const; - const TTipo_documento& tipo() const; - const TDate& data() const { return _head.get_date("DATADOC"); } + const TTipo_documento & tipo() const; + const TString & tipodoc() { return _head.get("TIPODOC"); } + const TDate & data() const { return _head.get_date("DATADOC"); } + const TString & numerazione() { return _head.get("CODNUM"); } + int anno() const { return _head.get_int("ANNO"); } + char tipo_numerazione() { return _head.get_int("PROVV"); } long numero() const { return _head.get_long("NDOC"); } TDocumento (); - TDocumento(const char* codnum, int anno, char provv, long numdoc); + TDocumento(const char * codnum, int anno, char provv, long numdoc); virtual ~TDocumento() { } };