From 82a27843a6f8637efd9fa089baabbe2252dd4a0b Mon Sep 17 00:00:00 2001 From: luca83 Date: Tue, 18 May 2010 14:42:41 +0000 Subject: [PATCH] Patch level : 10.0 patch ??? Files correlati : ps0713 Ricompilazione Demo : [ ] Commento : Spostate alcune classi comuni a tutti i programmi in questa piccola libreria git-svn-id: svn://10.65.10.50/trunk@20467 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ps/ps0713lib.cpp | 143 +++++++++++++++++++++++++++++++++++++++++++++++ ps/ps0713lib.h | 64 +++++++++++++++++++++ 2 files changed, 207 insertions(+) create mode 100755 ps/ps0713lib.cpp create mode 100755 ps/ps0713lib.h diff --git a/ps/ps0713lib.cpp b/ps/ps0713lib.cpp new file mode 100755 index 000000000..911144271 --- /dev/null +++ b/ps/ps0713lib.cpp @@ -0,0 +1,143 @@ +#include "ps0713lib.h" + + //////////////////////////////// + //// TCOMMESSA_STRING //// + //////////////////////////////// + +//IDLAVORO: metodo che restituisce l'Idlavoro +const long TCommessa_string::idlavoro() +{ + return get_long(0); +} + +//GRUPPO: metodo che restituisce il gruppo +const int TCommessa_string::gruppo() +{ + return get_int(1); +} + +//CONTO: metodo che restituisce il conto +const int TCommessa_string::conto() +{ + return get_int(2); +} + +//SOTCO: metodo che restituisce il sottoconto +const long TCommessa_string::sotco() +{ + return get_long(3); +} + +//metodo costruttore +TCommessa_string::TCommessa_string(const long idlavoro, const int gruppo, const int conto, const long sotco) +{ + add(idlavoro); + add(gruppo); + add(conto); + add(sotco); +} + + + + ///////////////////////// + //// TCOMMESSA //// + ///////////////////////// + +//CODICE: metodo che restituisce il codice di ripartizione +const TString8 TCommessa::codice() const +{ + return _codice; +} + +//CMSSTR: metodo che restituisce la TToken_string contenente le informazioni di codcms e del conto +const TCommessa_string TCommessa::cmsstr() const +{ + return _commessa; +} + +//metodo costruttore +TCommessa::TCommessa(const char* codcms) +{ + TString query; + query << "USE RIP KEY 4\n" + << "FROM TIPO=\"B\" CODCOSTO=\"\" CODCMS=\"" << codcms << "\"\n" + << "TO TIPO=\"B\" CODCOSTO=\"\" CODCMS=\"" << codcms << "\"\n"; + + TISAM_recordset rip(query); + rip.move_first(); + + if(!rip.empty()) + { + _codice = rip.get("CODICE").as_string(); + + const long codcms = rip.get("CODCMS").as_int(); + + query.cut(0); + query << "USE RRIP\n" + << "FROM TIPO=\"B\" CODICE=" << _codice << " NRIGA=1\n" + << "TO TIPO=\"B\" CODICE=" << _codice << " NRIGA=1\n"; + + TISAM_recordset rrip(query); + rrip.move_first(); + + TString80 str = rrip.get("CODCONTO").as_string(); + const int gruppo = atoi(str.left(3)); + const int conto = atoi(str.mid(3,3)); + const long sotco = atol(str.right(6)); + + TCommessa_string cms(codcms, gruppo, conto, sotco); + + _commessa = cms; + } + +} + + ////////////////////////// + //// TVB_RECSET //// + ////////////////////////// + +TRecnotype TVB_recset::new_rec(const char* buf) +{ + TToken_string str(256,'\t'); //nuovo record tab separator + + if(buf && *buf) + { + bool apici=false; + + for (const char* c = buf; *c ; c++) + { + if (*c == '"') + { + apici = !apici; + } + else + { + if (*c == separator()) + { + if (!apici) + str << str.separator(); + else + str << *c; + } + else + str << *c; + + } + } + } + + const TRecnotype n = TText_recordset::new_rec(str); + + if (n >= 0) + row(n).separator(str.separator()); + + return n; +} + + +TVB_recset::TVB_recset(const char * fileName, const char s) + : TCSV_recordset("CSV(,)") +{ + set_separator(s); + load_file(fileName); +} diff --git a/ps/ps0713lib.h b/ps/ps0713lib.h new file mode 100755 index 000000000..268767396 --- /dev/null +++ b/ps/ps0713lib.h @@ -0,0 +1,64 @@ +#ifndef __PS0713LIB_H +#define __PS0713LIB_H + +#ifndef __RECSET_H +#include +#endif + +#ifndef __TEXTSET_H +#include +#endif + + //////////////////////////////// + //// TCOMMESSA_STRING //// + //////////////////////////////// + +//classe TCommessa_string +class TCommessa_string: public TToken_string +{ +public: + const long idlavoro(); + const int gruppo(); + const int conto(); + const long sotco(); + + TCommessa_string& operator= (const char* key){ set(key); return *this; } + + TCommessa_string(const long idlavoro, const int gruppo, const int conto, const long sotco); + TCommessa_string(const char* key):TToken_string(key){} + TCommessa_string(const TToken_string& key):TToken_string(key){} + TCommessa_string(const TCommessa_string& key):TToken_string(key){} + TCommessa_string():TToken_string(){} +}; + + ///////////////////////// + //// TCOMMESSA //// + ///////////////////////// + +//Classe TCommessa +class TCommessa : public TObject +{ + TString8 _codice; + TCommessa_string _commessa; + +public: + const TString8 codice() const; + const TCommessa_string cmsstr() const; + TCommessa(const char* codcms); +}; + + ////////////////////////// + //// TVB_RECSET //// + ////////////////////////// + +//Classe TVB_recset +class TVB_recset : public TCSV_recordset +{ + protected: + virtual TRecnotype new_rec(const char* buf = NULL); + + public: + TVB_recset(const char* fileName, const char s); +}; + +#endif