1997-06-06 16:36:35 +00:00
|
|
|
|
// **************************************
|
|
|
|
|
// **************************************
|
|
|
|
|
// **************************************
|
|
|
|
|
// *** classi per la libreria
|
|
|
|
|
// ***
|
|
|
|
|
//*****
|
2004-05-18 10:44:57 +00:00
|
|
|
|
#include <diction.h>
|
1997-07-07 10:19:36 +00:00
|
|
|
|
#include <tabutil.h>
|
1997-06-06 16:36:35 +00:00
|
|
|
|
#include "mglib.h"
|
|
|
|
|
|
2004-05-18 10:44:57 +00:00
|
|
|
|
|
1997-06-06 16:36:35 +00:00
|
|
|
|
// ************************************************
|
|
|
|
|
// TEMP!!!!!!!!!!!!!!!!
|
|
|
|
|
|
|
|
|
|
TRegistro_std::TRegistro_std(const char* cod, int year) : TRectype(LF_TAB)
|
|
|
|
|
{
|
|
|
|
|
if (!read(cod, year))
|
2004-05-18 10:44:57 +00:00
|
|
|
|
fatal_box(TR("Il codice richiesto non <20> stato trovato nei registri"));
|
1997-06-06 16:36:35 +00:00
|
|
|
|
TTable itl("%ITL");
|
|
|
|
|
itl.put("CODTAB",cod_intest());
|
|
|
|
|
itl.read();
|
|
|
|
|
_intest=itl.get("S0");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TRegistro_std::read(const char* cod, int year)
|
|
|
|
|
{
|
|
|
|
|
if (year <= 0)
|
|
|
|
|
{
|
|
|
|
|
const TDate oggi(TODAY);
|
|
|
|
|
year = oggi.year();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int err = ~NOERR;
|
|
|
|
|
|
|
|
|
|
TTable reg("REG");
|
|
|
|
|
reg.setkey(1);
|
|
|
|
|
if (cod && *cod > ' ')
|
|
|
|
|
{
|
|
|
|
|
TString16 chiave; chiave.format("%04d%s", year, cod);
|
|
|
|
|
reg.put("CODTAB", chiave);
|
|
|
|
|
err = reg.read();
|
|
|
|
|
}
|
|
|
|
|
*((TRectype *)this) = reg.curr();
|
|
|
|
|
|
|
|
|
|
return err == NOERR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TRegistro_std::write(bool rewrite) const
|
|
|
|
|
{
|
|
|
|
|
int err = ~NOERR;
|
|
|
|
|
TTable reg("REG");
|
|
|
|
|
|
|
|
|
|
reg.set_curr((TRectype *)this);
|
1997-07-07 10:18:20 +00:00
|
|
|
|
if (rewrite)
|
|
|
|
|
err = reg.rewrite();
|
|
|
|
|
else
|
|
|
|
|
err = reg.write();
|
1997-06-06 16:36:35 +00:00
|
|
|
|
return err == NOERR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int TRegistro_std::year() const
|
|
|
|
|
{
|
|
|
|
|
TString16 anno(get("CODTAB"));
|
|
|
|
|
anno.cut(4);
|
|
|
|
|
return atoi(anno);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const TString& TRegistro_std::code() const
|
|
|
|
|
{
|
|
|
|
|
return get("CODTAB").mid(4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TString TRegistro_std::intest() const
|
|
|
|
|
{
|
|
|
|
|
return _intest;
|
|
|
|
|
}
|
1997-10-15 14:47:23 +00:00
|
|
|
|
|
|
|
|
|
int TRegistro_std::lock()
|
|
|
|
|
{
|
|
|
|
|
TTable reg("REG");
|
|
|
|
|
reg.put("CODTAB",this->get("CODTAB"));
|
|
|
|
|
return reg.read(_lock);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int TRegistro_std::unlock()
|
|
|
|
|
{
|
|
|
|
|
TTable reg("REG");
|
|
|
|
|
reg.put("CODTAB",this->get("CODTAB"));
|
|
|
|
|
return reg.read(_unlock);
|
2004-05-18 10:44:57 +00:00
|
|
|
|
}
|