2010-05-18 14:42:41 +00:00
|
|
|
#include "ps0713lib.h"
|
|
|
|
|
|
|
|
////////////////////////////////
|
|
|
|
//// TCOMMESSA_STRING ////
|
|
|
|
////////////////////////////////
|
|
|
|
|
|
|
|
//IDLAVORO: metodo che restituisce l'Idlavoro
|
2010-05-26 08:37:03 +00:00
|
|
|
const TString16 TCommessa_string::idlavoro()
|
2010-05-18 14:42:41 +00:00
|
|
|
{
|
2010-05-26 08:37:03 +00:00
|
|
|
return get(0);
|
2010-05-18 14:42:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//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
|
2010-05-26 08:37:03 +00:00
|
|
|
TCommessa_string::TCommessa_string(const char* idlavoro, const int gruppo, const int conto, const long sotco)
|
2010-05-18 14:42:41 +00:00
|
|
|
{
|
|
|
|
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();
|
|
|
|
|
2010-05-26 08:37:03 +00:00
|
|
|
const TString16 codcms = rip.get("CODCMS").as_string();
|
2010-05-18 14:42:41 +00:00
|
|
|
|
|
|
|
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();
|
2010-05-18 14:48:53 +00:00
|
|
|
const int gruppo = atoi(str.left(3)) > 0 ? atoi(str.left(3)) : 0;
|
|
|
|
const int conto = atoi(str.mid(3,3)) > 0 ? atoi(str.mid(3,3)) : 0;
|
|
|
|
const long sotco = atol(str.right(6)) > 0L ? atol(str.right(6)) : 0L;
|
2010-05-18 14:42:41 +00:00
|
|
|
|
|
|
|
TCommessa_string cms(codcms, gruppo, conto, sotco);
|
|
|
|
|
|
|
|
_commessa = cms;
|
|
|
|
}
|
2010-05-18 14:48:53 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
TCommessa_string cms(0L, 0, 0, 0L);
|
|
|
|
_commessa = cms;
|
|
|
|
}
|
2010-05-18 14:42:41 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////
|
|
|
|
//// 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);
|
|
|
|
}
|