Supporto per TRecord_array con chiave su CODTAB[a,b]
git-svn-id: svn://10.65.10.50/branches/R_10_00@22761 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
886efa8b82
commit
885a21a2d1
@ -876,8 +876,10 @@ XI_OBJ* TControl::find_operable(XI_OBJ* container, bool forward, bool normal) co
|
|||||||
XI_OBJ* obj = child[c];
|
XI_OBJ* obj = child[c];
|
||||||
switch (obj->type)
|
switch (obj->type)
|
||||||
{
|
{
|
||||||
case XIT_LIST:
|
|
||||||
case XIT_BTN:
|
case XIT_BTN:
|
||||||
|
if (obj->v.btn->type == XIBT_BUTTON_CHECKBOX)
|
||||||
|
break;
|
||||||
|
case XIT_LIST:
|
||||||
case XIT_FIELD:
|
case XIT_FIELD:
|
||||||
if (normal && obj->cid > 0)
|
if (normal && obj->cid > 0)
|
||||||
found = obj;
|
found = obj;
|
||||||
@ -1655,7 +1657,8 @@ void TButton_control::create(WINDOW win, short cid,
|
|||||||
xi_dequeue();
|
xi_dequeue();
|
||||||
xi_tree_free(def);
|
xi_tree_free(def);
|
||||||
|
|
||||||
update_tab_cid();
|
if (wc != WC_CHECKBUTTON) // Annullo fastidiosa gestione tab per i checkbutton
|
||||||
|
update_tab_cid();
|
||||||
}
|
}
|
||||||
|
|
||||||
int TButton_control::button_type() const
|
int TButton_control::button_type() const
|
||||||
|
@ -108,36 +108,39 @@ void TDowJones::flush()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TDowJones::test_cache()
|
void TDowJones::test_cache()
|
||||||
{
|
{
|
||||||
// Controllo se e' cambiata la ditta
|
if (prefix_valid())
|
||||||
const long newfirm = prefix().get_codditta();
|
|
||||||
if (newfirm != _codditta)
|
|
||||||
{
|
{
|
||||||
_codditta = newfirm;
|
// Controllo se e' cambiata la ditta
|
||||||
_firm_val = prefix().firm().codice_valuta();
|
const long newfirm = prefix().get_codditta();
|
||||||
}
|
if (newfirm != _codditta)
|
||||||
|
|
||||||
if (_euro_val.empty())
|
|
||||||
{
|
|
||||||
fill();
|
|
||||||
FOR_EACH_ASSOC_OBJECT(_cache, hash, key, obj) if (*key)
|
|
||||||
{
|
{
|
||||||
const TExchangeData& data = *(const TExchangeData*)obj;
|
_codditta = newfirm;
|
||||||
if (data._is_euro && _euro_val.empty())
|
_firm_val = prefix().firm().codice_valuta();
|
||||||
_euro_val = key;
|
}
|
||||||
|
if (_euro_val.empty())
|
||||||
|
{
|
||||||
|
fill();
|
||||||
|
FOR_EACH_ASSOC_OBJECT(_cache, hash, key, obj) if (*key)
|
||||||
|
{
|
||||||
|
const TExchangeData& data = *(const TExchangeData*)obj;
|
||||||
|
if (data._is_euro && _euro_val.empty())
|
||||||
|
_euro_val = key;
|
||||||
|
}
|
||||||
|
_firm_val = prefix().firm().codice_valuta();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_euro_val.empty()) // Si son dimenticati dell'EURO?
|
|
||||||
{
|
|
||||||
TExchangeData* euro = new TExchangeData;
|
|
||||||
euro->_chg = UNO; euro->_dec = euro->_dec_prices = 2;
|
|
||||||
euro->_is_euro = true;
|
|
||||||
_euro_val = "EUR";
|
|
||||||
_cache.add(_euro_val, euro);
|
|
||||||
}
|
|
||||||
|
|
||||||
_firm_val = prefix().firm().codice_valuta();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_euro_val.empty()) // Si son dimenticati dell'EURO?
|
||||||
|
{
|
||||||
|
TExchangeData* euro = new TExchangeData;
|
||||||
|
euro->_chg = UNO; euro->_dec = euro->_dec_prices = 2;
|
||||||
|
euro->_is_euro = true;
|
||||||
|
_euro_val = "EUR";
|
||||||
|
_cache.add(_euro_val, euro);
|
||||||
|
}
|
||||||
|
if (_firm_val.empty())
|
||||||
|
_firm_val = _euro_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* TDowJones::expand_value(const char* val)
|
const char* TDowJones::expand_value(const char* val)
|
||||||
@ -165,7 +168,9 @@ const char* TDowJones::expand_value(const char* val)
|
|||||||
const TDowJones::TExchangeData& TDowJones::get(const char* val)
|
const TDowJones::TExchangeData& TDowJones::get(const char* val)
|
||||||
{
|
{
|
||||||
test_cache();
|
test_cache();
|
||||||
return (const TExchangeData&)query(expand_value(val));
|
if (prefix_valid())
|
||||||
|
return (const TExchangeData&)query(expand_value(val));
|
||||||
|
return *(const TExchangeData*)_cache.first_item();
|
||||||
}
|
}
|
||||||
|
|
||||||
const TString& TDowJones::get_firm_val()
|
const TString& TDowJones::get_firm_val()
|
||||||
@ -205,7 +210,7 @@ real TDowJones::exchange(const real& num, // Importo da convertire
|
|||||||
real to = tochg;
|
real to = tochg;
|
||||||
if (to <= ZERO) to = datato._chg;
|
if (to <= ZERO) to = datato._chg;
|
||||||
|
|
||||||
n = n * to / fr; // Nuovo modo
|
n = n * to / fr; // Nuovo modo
|
||||||
if (price == 0 || price == 1) // Arrotonda solo in caso normale
|
if (price == 0 || price == 1) // Arrotonda solo in caso normale
|
||||||
n.round(price ? datato._dec_prices : datato._dec);
|
n.round(price ? datato._dec_prices : datato._dec);
|
||||||
}
|
}
|
||||||
@ -337,7 +342,6 @@ int TCurrency::get_euro_dec(bool price)
|
|||||||
return DowJones.get_dec(get_euro_val(), price);
|
return DowJones.get_dec(get_euro_val(), price);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TCurrency::force_firm_val(const char* val)
|
void TCurrency::force_firm_val(const char* val)
|
||||||
{
|
{
|
||||||
DowJones.force_firm_val(val);
|
DowJones.force_firm_val(val);
|
||||||
|
@ -84,6 +84,7 @@
|
|||||||
#define DOC_TIPOCFFATT "TIPOCFFATT"
|
#define DOC_TIPOCFFATT "TIPOCFFATT"
|
||||||
#define DOC_CODCFFATT "CODCFFATT"
|
#define DOC_CODCFFATT "CODCFFATT"
|
||||||
#define DOC_LIQDIFF "LIQDIFF"
|
#define DOC_LIQDIFF "LIQDIFF"
|
||||||
|
#define DOC_IVAXCASSA "IVAXCASSA"
|
||||||
#define DOC_DATACOMP "DATACOMP"
|
#define DOC_DATACOMP "DATACOMP"
|
||||||
#define DOC_DATAFCOMP "DATAFCOMP"
|
#define DOC_DATAFCOMP "DATAFCOMP"
|
||||||
#define DOC_CUP "CUP"
|
#define DOC_CUP "CUP"
|
||||||
|
@ -3874,7 +3874,16 @@ int TRectype::remove(TBaseisamfile& f) const
|
|||||||
|
|
||||||
void TRectype::renum_key(const char* field, const char* val)
|
void TRectype::renum_key(const char* field, const char* val)
|
||||||
{
|
{
|
||||||
put(field, val);
|
if (strchr(field, '[') != NULL) // Accept CODTAB[6,10]
|
||||||
|
{
|
||||||
|
const TFieldref fref(field, 0);
|
||||||
|
TString80 str = val;
|
||||||
|
if (real::is_natural(val))
|
||||||
|
str.right_just(fref.len(*this), '0');
|
||||||
|
fref.write(str, *this);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
put(field, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Certified 99%
|
// Certified 99%
|
||||||
|
@ -2790,7 +2790,6 @@ bool TSheet_field::parse_item(TScanner& scanner)
|
|||||||
|
|
||||||
void TSheet_field::parse_input(TScanner& scanner)
|
void TSheet_field::parse_input(TScanner& scanner)
|
||||||
{
|
{
|
||||||
|
|
||||||
const char* s = scanner.pop();
|
const char* s = scanner.pop();
|
||||||
_file_k_names.add(s);
|
_file_k_names.add(s);
|
||||||
|
|
||||||
@ -2800,7 +2799,6 @@ void TSheet_field::parse_input(TScanner& scanner)
|
|||||||
scanner.push();
|
scanner.push();
|
||||||
TString& str = scanner.line();
|
TString& str = scanner.line();
|
||||||
_file_k_ids.add(str);
|
_file_k_ids.add(str);
|
||||||
|
|
||||||
}
|
}
|
||||||
else // Field on the mask
|
else // Field on the mask
|
||||||
{
|
{
|
||||||
@ -2810,9 +2808,7 @@ void TSheet_field::parse_input(TScanner& scanner)
|
|||||||
else scanner.push();
|
else scanner.push();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Certified 100%
|
// Certified 100%
|
||||||
void TSheet_field::create(WINDOW parent)
|
void TSheet_field::create(WINDOW parent)
|
||||||
{
|
{
|
||||||
@ -3486,13 +3482,22 @@ TRectype* TSheet_field::putkey(const TRelation& r)
|
|||||||
_sheetfile->zero();
|
_sheetfile->zero();
|
||||||
_file_k_ids.restart();
|
_file_k_ids.restart();
|
||||||
for (TString16 dbfieldname = _file_k_names.get(0);
|
for (TString16 dbfieldname = _file_k_names.get(0);
|
||||||
dbfieldname.not_empty();
|
dbfieldname.full();
|
||||||
dbfieldname = _file_k_names.get())
|
dbfieldname = _file_k_names.get())
|
||||||
{
|
{
|
||||||
TMask_field& f= mask().field(_file_k_ids.get_int());
|
TString80 id = _file_k_ids.get();
|
||||||
if (mask().edit_mode())
|
if (id[0] == '"')
|
||||||
((TLoadable_field&)f).autoload(r); // Molto probabilmente inutile!
|
{
|
||||||
_sheetfile->put(dbfieldname, f.get());
|
id.strip("\"");
|
||||||
|
_sheetfile->curr().renum_key(dbfieldname, id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TMask_field& f = mask().field(atoi(id));
|
||||||
|
if (mask().edit_mode())
|
||||||
|
((TLoadable_field&)f).autoload(r); // Molto probabilmente inutile!
|
||||||
|
_sheetfile->curr().renum_key(dbfieldname, f.get());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return &_sheetfile->curr();
|
return &_sheetfile->curr();
|
||||||
}
|
}
|
||||||
@ -3581,22 +3586,34 @@ bool TSheet_field::autosave(TRelation& rel)
|
|||||||
if (mask().insert_mode())
|
if (mask().insert_mode())
|
||||||
{
|
{
|
||||||
// rinumera la chiave
|
// rinumera la chiave
|
||||||
TString dbfieldname;
|
_file_k_ids.restart();
|
||||||
TMask_field * f;
|
for (TString16 dbfieldname = _file_k_names.get(0);
|
||||||
restart_key();
|
dbfieldname.full();
|
||||||
while ((f = get_key(dbfieldname)))
|
dbfieldname = _file_k_names.get())
|
||||||
_linee_rec->renum_key(dbfieldname, f->get());
|
{
|
||||||
|
TString80 id = _file_k_ids.get();
|
||||||
|
if (id[0] == '"')
|
||||||
|
{
|
||||||
|
id.strip("\"");
|
||||||
|
_linee_rec->renum_key(dbfieldname, id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const TMask_field& f = mask().field(atoi(id));
|
||||||
|
_linee_rec->renum_key(dbfieldname, f.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// *******
|
// *******
|
||||||
// trasferisce le linee dallo sheet al record array (ignorando righe vuote alla fine)
|
// trasferisce le linee dallo sheet al record array (ignorando righe vuote alla fine)
|
||||||
int i= items();
|
int i = items();
|
||||||
while (i >= 1 && row(i-1).empty_items())
|
while (i > 0 && row(i-1).empty_items())
|
||||||
i--;
|
i--;
|
||||||
for (; i >= 1; i--)
|
for (; i > 0; i--)
|
||||||
{
|
{
|
||||||
TRectype &rec = _linee_rec->row(i, true);
|
TRectype &rec = _linee_rec->row(i, true);
|
||||||
autosave_line(i,rec);
|
autosave_line(i,rec); // autosave_line parte da 1 :-(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return _enable_autoload;
|
return _enable_autoload;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <dongle.h>
|
#include <dongle.h>
|
||||||
#include <prefix.h>
|
#include <prefix.h>
|
||||||
#include <recarray.h>
|
#include <recarray.h>
|
||||||
|
#include <relation.h>
|
||||||
#include <tabmod.h>
|
#include <tabmod.h>
|
||||||
#include <tabutil.h>
|
#include <tabutil.h>
|
||||||
|
|
||||||
@ -47,7 +48,7 @@ TRecord_array::TRecord_array(const TRecord_array& a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Questo si che e' il costruttore dei miei sogni
|
// Questo si che e' il costruttore dei miei sogni
|
||||||
// Senza cavolate come numfield o necessita' di interi record come chiave!
|
// Senza cavolate come numfield o necessità di interi record come chiave!
|
||||||
TRecord_array::TRecord_array(const char* keytok, int logicnum, int first)
|
TRecord_array::TRecord_array(const char* keytok, int logicnum, int first)
|
||||||
: _file(logicnum), _offset(first - 1)
|
: _file(logicnum), _offset(first - 1)
|
||||||
{
|
{
|
||||||
@ -100,6 +101,14 @@ void TRecord_array::set_key(TRectype* r)
|
|||||||
renum_key(rf.Name, val);
|
renum_key(rf.Name, val);
|
||||||
CHECKS(i > 0 || val.full(), "First key field can't be empty: ", rf.Name);
|
CHECKS(i > 0 || val.full(), "First key field can't be empty: ", rf.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_num.find('[') > 0)
|
||||||
|
{
|
||||||
|
const TFieldref field(_num, 0);
|
||||||
|
val = r->get(field.name());
|
||||||
|
val.cut(field.from());
|
||||||
|
renum_key(field.name(), val);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +205,15 @@ void TRecord_array::sort(COMPARE_FUNCTION sort_func)
|
|||||||
int TRecord_array::rec2row(const TRectype& r) const
|
int TRecord_array::rec2row(const TRectype& r) const
|
||||||
{
|
{
|
||||||
CHECK(r.num() == _file, "Incompatible record");
|
CHECK(r.num() == _file, "Incompatible record");
|
||||||
const int n = r.get_int(_num) - _offset; // Non e' detto che sia un int!
|
int n = 0;
|
||||||
|
if (_num.find('[') > 0)
|
||||||
|
{
|
||||||
|
const TFieldref fref(_num, 0);
|
||||||
|
n = atoi(fref.read(r));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
n = r.get_int(_num); // Non e' detto che sia un int!
|
||||||
|
n -= _offset;
|
||||||
CHECKD(n >= 0 && n < 30000, "Bad line number in record ", n + _offset);
|
CHECKD(n >= 0 && n < 30000, "Bad line number in record ", n + _offset);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -302,7 +319,13 @@ void TRecord_array::destroy_rows()
|
|||||||
bool TRecord_array::good(
|
bool TRecord_array::good(
|
||||||
const TRectype& rec) const // @parm Record di cui confrontare i campi
|
const TRectype& rec) const // @parm Record di cui confrontare i campi
|
||||||
{
|
{
|
||||||
const bool yes = key().same_key(rec, 1, 1);
|
bool yes = key().same_key(rec, 1, 1);
|
||||||
|
if (yes && _num.find('[') > 0)
|
||||||
|
{
|
||||||
|
const TFieldref fref(_num, 0);
|
||||||
|
const char* codtab = fref.name();
|
||||||
|
yes = rec.get(codtab).starts_with(key().get(codtab));
|
||||||
|
}
|
||||||
return yes;
|
return yes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,7 +333,11 @@ int TRecord_array::read(TRectype* filter)
|
|||||||
{
|
{
|
||||||
CHECK(filter != NULL, "You can't specify NULL as filter ");
|
CHECK(filter != NULL, "You can't specify NULL as filter ");
|
||||||
CHECKD(filter->num() == _file, "Bad key record ", filter->num());
|
CHECKD(filter->num() == _file, "Bad key record ", filter->num());
|
||||||
CHECKS(filter->get(_num).empty(), "You can't specify in the filter the field ", (const char*)_num);
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
const TFieldref fref(_num, 0);
|
||||||
|
CHECKS(*fref.read(*filter) < ' ', "You can't specify in the filter the field ", (const char*)_num);
|
||||||
|
#endif
|
||||||
|
|
||||||
_data.destroy();
|
_data.destroy();
|
||||||
set_key(filter);
|
set_key(filter);
|
||||||
@ -360,10 +387,14 @@ int TRecord_array::remove_from(TIsamfile& f, int pos) const
|
|||||||
TRectype* rec = (TRectype*)key().dup();
|
TRectype* rec = (TRectype*)key().dup();
|
||||||
CHECK(!rec->empty(), "Can't use empty key");
|
CHECK(!rec->empty(), "Can't use empty key");
|
||||||
|
|
||||||
rec->put(_num, pos);
|
TString16 n; n << pos;
|
||||||
|
rec->renum_key(_num, n);
|
||||||
|
|
||||||
|
const TFieldref fref(_num, 0);
|
||||||
|
|
||||||
for (int e = rec->read(f, _isgteq); e == NOERR && good(*rec); e = rec->next(f))
|
for (int e = rec->read(f, _isgteq); e == NOERR && good(*rec); e = rec->next(f))
|
||||||
{
|
{
|
||||||
const int found = rec->get_int(_num);
|
const int found = atoi(fref.read(*rec));
|
||||||
if (found >= pos)
|
if (found >= pos)
|
||||||
{
|
{
|
||||||
err = rec->remove(f);
|
err = rec->remove(f);
|
||||||
@ -434,11 +465,13 @@ int TRecord_array::write(bool re) const
|
|||||||
{
|
{
|
||||||
TRectype* rec = (TRectype*)key().dup();
|
TRectype* rec = (TRectype*)key().dup();
|
||||||
CHECK(!rec->empty(), "TRecord_array has an empty key");
|
CHECK(!rec->empty(), "TRecord_array has an empty key");
|
||||||
rec->put(_num, pos);
|
TString16 n; n << pos;
|
||||||
|
rec->renum_key(_num, n);
|
||||||
err = rec->read(f, _isgteq);
|
err = rec->read(f, _isgteq);
|
||||||
if (err == NOERR && good(*rec)) // Cerca una riga >= pos sul file
|
if (err == NOERR && good(*rec)) // Cerca una riga >= pos sul file
|
||||||
{
|
{
|
||||||
last_on_file = rec->get_int(_num);
|
const TFieldref fref(_num, 0);
|
||||||
|
last_on_file = atoi(fref.read(*rec));
|
||||||
if (last_on_file == pos) // La riga c'era ma ora non piu'
|
if (last_on_file == pos) // La riga c'era ma ora non piu'
|
||||||
{
|
{
|
||||||
err = (rec->remove(f)); // Cancello il record indesiderato
|
err = (rec->remove(f)); // Cancello il record indesiderato
|
||||||
|
@ -85,7 +85,7 @@ const TToken_string& TRecordset::sheet_head() const
|
|||||||
case _intfld:
|
case _intfld:
|
||||||
case _longfld: head << 'R'; break;
|
case _longfld: head << 'R'; break;
|
||||||
case _datefld: head << 'D'; break;
|
case _datefld: head << 'D'; break;
|
||||||
case _realfld: head << 'V'; break;
|
case _realfld: head << (ci._width > 7 ? 'V' : 'R'); break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,18 +134,9 @@ TString::~TString()
|
|||||||
|
|
||||||
char TString::shift(int n)
|
char TString::shift(int n)
|
||||||
{
|
{
|
||||||
CHECK(n>0,"Scorrimento a destra delle stringhe non ancora supportato");
|
CHECK(n>0 && n<=len(),"Errore di scorrimento");
|
||||||
CHECK(n<_size,"Errore di scorrimento");
|
const char r=*(_str+n-1);
|
||||||
char r=*(_str+n-1);
|
strcpy(_str, _str+n);
|
||||||
if (n)
|
|
||||||
{
|
|
||||||
char *c=_str;
|
|
||||||
while (*c)
|
|
||||||
{
|
|
||||||
*(c)=*(c+n);
|
|
||||||
c++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user