91 lines
1.7 KiB
C++
91 lines
1.7 KiB
C++
|
// **************************************
|
|||
|
// **************************************
|
|||
|
// **************************************
|
|||
|
// *** classi per la libreria
|
|||
|
// ***
|
|||
|
//*****
|
|||
|
#include <diction.h>
|
|||
|
#include <tabutil.h>
|
|||
|
#include "mglib.h"
|
|||
|
|
|||
|
|
|||
|
// ************************************************
|
|||
|
// TEMP!!!!!!!!!!!!!!!!
|
|||
|
|
|||
|
TRegistro_std::TRegistro_std(const char* cod, int year) : TRectype(LF_TAB)
|
|||
|
{
|
|||
|
if (!read(cod, year))
|
|||
|
fatal_box(TR("Il codice richiesto non <20> stato trovato nei registri"));
|
|||
|
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");
|
|||
|
if (rewrite)
|
|||
|
err = reg.rewrite_write(*this);
|
|||
|
else
|
|||
|
err = reg.write(*this);
|
|||
|
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;
|
|||
|
}
|
|||
|
|
|||
|
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);
|
|||
|
}
|