Files correlati : velib07 Ricompilazione Demo : [ ] Commento : Riportate le features presenti nel file vereplib.cpp ormai obsoleto git-svn-id: svn://10.65.10.50/trunk@14670 c028cbd2-c16b-5b4b-a496-9718f37d4682
136 lines
3.6 KiB
C++
Executable File
136 lines
3.6 KiB
C++
Executable File
#include "velib07.h"
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TDocument_cache
|
|
///////////////////////////////////////////////////////////
|
|
TObject* TDocument_cache::key2obj(const char* key)
|
|
{
|
|
TToken_string k(key);
|
|
const char provv = *k.get(0);
|
|
const int anno = k.get_int();
|
|
const TString4 codnum= k.get();
|
|
const long ndoc = k.get_long();
|
|
TDocumento* doc = new TDocumento(provv, anno, codnum, ndoc);
|
|
doc->get("IMPONIBILI"); // Bastardata per far funzionare la successiva dirty_fields
|
|
doc->dirty_fields();
|
|
return doc;
|
|
}
|
|
|
|
TDocumento& TDocument_cache::doc(const TRectype& rec)
|
|
{
|
|
TToken_string key;
|
|
key = rec.get(DOC_PROVV);
|
|
key.add(rec.get(DOC_ANNO));
|
|
key.add(rec.get(DOC_CODNUM));
|
|
key.add(rec.get(DOC_NDOC));
|
|
TDocumento& d = *(TDocumento*)objptr(key);
|
|
return d;
|
|
}
|
|
|
|
|
|
TDocument_cache:: TDocument_cache() : TCache(3)
|
|
{
|
|
}
|
|
|
|
TDocument_cache:: ~TDocument_cache()
|
|
{
|
|
}
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TDocument_recordset
|
|
///////////////////////////////////////////////////////////
|
|
|
|
const TVariant& TDocument_recordset::get_field(int num, const char* field) const
|
|
{
|
|
if (*field != '#')
|
|
{
|
|
const int idx = relation()->log2ind(num);
|
|
if (idx < 0)
|
|
return NULL_VARIANT;
|
|
const int logic = num > 0 ? num : relation()->file(idx).num();
|
|
if (logic == LF_DOC || logic == LF_RIGHEDOC)
|
|
{
|
|
const TRectype& rec = relation()->file(idx).curr();
|
|
// Se non e' un campo standard, ma e' calcolato da una formula...
|
|
if (rec.type(field) == _nullfld && strncmp(field, "G1:", 3) != 0)
|
|
{
|
|
const TDocumento& doc = ((TDocument_cache&)_cache).doc(rec);
|
|
TVariant& var = get_tmp_var();
|
|
|
|
if (xvt_str_compare_ignoring_case(field, "SEGNO") == 0)
|
|
{
|
|
var = doc.is_nota_credito() ? -UNO : UNO;
|
|
} else
|
|
if (xvt_str_compare_ignoring_case(field, "IS_COSTO") == 0)
|
|
{
|
|
bool costo = (doc.tipo().is_costo()) || (!doc.tipo().is_ricavo() && doc.get_char(DOC_TIPOCF)=='F');
|
|
var = costo ? UNO : ZERO;
|
|
} else
|
|
if (xvt_str_compare_ignoring_case(field, "IS_RICAVO") == 0)
|
|
{
|
|
bool ricavo = (doc.tipo().is_ricavo()) || (!doc.tipo().is_costo() && doc.get_char(DOC_TIPOCF)=='C');
|
|
var = ricavo ? UNO : ZERO;
|
|
}
|
|
else
|
|
{
|
|
const TFieldref ref(field, logic);
|
|
if (logic == LF_DOC)
|
|
{
|
|
var = ref.read(doc);
|
|
}
|
|
else
|
|
{
|
|
const int nriga = rec.get_int(RDOC_NRIGA);
|
|
if (nriga > 0 && nriga <= doc.rows())
|
|
{
|
|
const TRiga_documento& rdoc = doc[nriga];
|
|
var = ref.read(rdoc);
|
|
}
|
|
else
|
|
var = NULL_VARIANT;
|
|
}
|
|
}
|
|
return var;
|
|
}
|
|
}
|
|
}
|
|
return TISAM_recordset::get_field(num, field);
|
|
}
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TDocument_report
|
|
///////////////////////////////////////////////////////////
|
|
|
|
bool TDocument_report::set_recordset(const TString& query)
|
|
{
|
|
return TReport::set_recordset(new TDocument_recordset(query));
|
|
}
|
|
|
|
bool TDocument_report::load(const char* name)
|
|
{
|
|
const bool ok = TReport::load(name);
|
|
if (ok)
|
|
{
|
|
// Purtroppo il recordset delle sottosezioni deve essere reimpostato a mano
|
|
for (int i = 11; i <= 999; i++)
|
|
{
|
|
TReport_section* sec = find_section('B', i);
|
|
if (sec != NULL)
|
|
{
|
|
TRecordset* recset = sec->recordset();
|
|
if (recset != NULL)
|
|
{
|
|
const TString use = recset->query_text();
|
|
recset = new TDocument_recordset(use);
|
|
sec->set_recordset(recset);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return ok;
|
|
}
|
|
|
|
|