Patch level : 2.1 104
Files correlati : ve0.exe Ricompilazione Demo : [ ] Commento : Aggiungere nella mashera di ricerca la ditta la ragione sociale del cliente con ricerca risistemare le colonne nella ricerca per cliente e riferimento (aggiungere totale documento) git-svn-id: svn://10.65.10.50/trunk@12287 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
8a50f74505
commit
dd1d626095
229
include/isam.cpp
229
include/isam.cpp
@ -2025,7 +2025,7 @@ void TSystemisamfile::makelc(TRectype& rec)
|
||||
|
||||
int TSystemisamfile::update(
|
||||
const TTrec& newrec, // @parm Nuovo tracciato record con cui aggiornare il file
|
||||
bool vis) // @parm Indica se visualizzare lo stato dell'operazione
|
||||
bool interactive) // @parm Indica se riportare i campi personalizzati (!interactive
|
||||
|
||||
{
|
||||
CHECK(newrec.len() != 0, "Can't update file with empty field info");
|
||||
@ -2081,7 +2081,7 @@ int TSystemisamfile::update(
|
||||
for (int j = 0; j < oldfields; j++)
|
||||
{
|
||||
def = oldrec.fielddef(j);
|
||||
if (def.get(0)[0] == '_')
|
||||
if (!interactive && (def.get(0)[0] == '_'))
|
||||
{
|
||||
if (newrec.field(def) == FIELDERR)
|
||||
{
|
||||
@ -2092,6 +2092,8 @@ int TSystemisamfile::update(
|
||||
(const char *) def.get(0)))
|
||||
return NOERR;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if (wfields < newfields)
|
||||
@ -3597,7 +3599,17 @@ bool TRectype::edit(int logicnum, const char* alternate_key_fields, const char*
|
||||
void TRecfield::set(int from, int to)
|
||||
{
|
||||
const RecDes* rd = _rec->rec_des();
|
||||
|
||||
_subfield = strchr(_name, ':');
|
||||
if (_subfield != NULL)
|
||||
{
|
||||
*_subfield = '\0';
|
||||
_subfield++;
|
||||
strcat(_subfield, "=");
|
||||
}
|
||||
|
||||
const int nf = findfld(rd, _name);
|
||||
|
||||
if (nf == FIELDERR)
|
||||
{
|
||||
NFCHECK("File n. %d unknown field %s", _rec->num(), _name);
|
||||
@ -3613,16 +3625,30 @@ void TRecfield::set(int from, int to)
|
||||
NFCHECK("Invalid Start %d", from);
|
||||
from = 0;
|
||||
}
|
||||
_p = _rec->string() + rd->Fd[nf].RecOff + from;
|
||||
_p = _rec->string() + rd->Fd[nf].RecOff;
|
||||
_dec = rd->Fd[nf].Dec;
|
||||
_type = (TFieldtypes)rd->Fd[nf].TypeF;
|
||||
if (to >= 0)
|
||||
{
|
||||
CHECK(from <= to && to <= rd->Fd[nf].Len, "Invalid Range");
|
||||
_len = to - from + 1;
|
||||
}
|
||||
else
|
||||
_len = rd->Fd[nf].Len - from;
|
||||
if (_subfield == NULL)
|
||||
{
|
||||
_p += from;
|
||||
if (to >= 0)
|
||||
{
|
||||
CHECK(from <= to && to <= rd->Fd[nf].Len, "Invalid Range");
|
||||
_len = to - from + 1;
|
||||
}
|
||||
else
|
||||
_len = rd->Fd[nf].Len - from;
|
||||
}
|
||||
else
|
||||
{
|
||||
CHECK(_type == _memofld, "You can use Subfields only with Memo");
|
||||
_from = from;
|
||||
_to = to;
|
||||
if (_type == _memofld)
|
||||
_len = 0;
|
||||
else
|
||||
_len = rd->Fd[nf].Len;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3633,11 +3659,44 @@ TRecfield::TRecfield(TRectype& rec, const char* name, int from, int to)
|
||||
set(from, to);
|
||||
}
|
||||
|
||||
void TRecfield::put_subfield(const char* s)
|
||||
{
|
||||
const TString& str = _rec->get(_name);
|
||||
int p = str.find(_subfield);
|
||||
|
||||
if (p == 0 || (p > 0 && str[p - 1] < ' '))
|
||||
{
|
||||
p += strlen(_subfield);
|
||||
|
||||
int e = str.find('\n', p);
|
||||
|
||||
if (_to > 0 && p + _to < e)
|
||||
e = p + _to;
|
||||
p += _from;
|
||||
if (p < e)
|
||||
{
|
||||
TString val(s);
|
||||
|
||||
if (_to > 0)
|
||||
{
|
||||
val.left(e - p + 1);
|
||||
val.rpad(e - p + 1);
|
||||
}
|
||||
TString out = str.left(p);
|
||||
out << val << str.mid(e); // ? e + 1
|
||||
_rec->put(_name, out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int TRecfield::operator =(int i)
|
||||
{
|
||||
char buff[32];
|
||||
sprintf(buff, "%d", i);
|
||||
__putfieldbuff( _len, _dec, _type, buff, _p);
|
||||
if (_subfield == NULL)
|
||||
__putfieldbuff( _len, _dec, _type, buff, _p);
|
||||
else
|
||||
put_subfield(buff);
|
||||
_rec->setempty(FALSE);
|
||||
return i;
|
||||
}
|
||||
@ -3647,7 +3706,10 @@ long TRecfield::operator =(long l)
|
||||
{
|
||||
char buff[32];
|
||||
sprintf(buff, "%ld", l);
|
||||
__putfieldbuff( _len, _dec, _type, buff, _p);
|
||||
if (_subfield == NULL)
|
||||
__putfieldbuff( _len, _dec, _type, buff, _p);
|
||||
else
|
||||
put_subfield(buff);
|
||||
_rec->setempty(FALSE);
|
||||
return l;
|
||||
}
|
||||
@ -3656,7 +3718,10 @@ const real& TRecfield::operator =(const real& r)
|
||||
{
|
||||
char buff[80];
|
||||
strcpy(buff, r.string());
|
||||
__putfieldbuff( _len, _dec, _type, buff, _p);
|
||||
if (_subfield == NULL)
|
||||
__putfieldbuff( _len, _dec, _type, buff, _p);
|
||||
else
|
||||
put_subfield(buff);
|
||||
_rec->setempty(FALSE);
|
||||
return r;
|
||||
}
|
||||
@ -3665,17 +3730,25 @@ const TDate& TRecfield::operator =(const TDate& d)
|
||||
{
|
||||
char buff[16];
|
||||
strcpy(buff, (const char*)d);
|
||||
__putfieldbuff( _len, _dec, _type, buff, _p);
|
||||
if (_subfield == NULL)
|
||||
__putfieldbuff( _len, _dec, _type, buff, _p);
|
||||
else
|
||||
put_subfield(buff);
|
||||
_rec->setempty(FALSE);
|
||||
return d;
|
||||
}
|
||||
|
||||
const char* TRecfield::operator =(const char* s)
|
||||
{
|
||||
if (_type == _memofld)
|
||||
_rec->put(_name, s);
|
||||
else
|
||||
__putfieldbuff( _len, _dec, _type, s, _p);
|
||||
if (_subfield == NULL)
|
||||
{
|
||||
if (_type == _memofld)
|
||||
_rec->put(_name, s);
|
||||
else
|
||||
__putfieldbuff( _len, _dec, _type, s, _p);
|
||||
}
|
||||
else
|
||||
put_subfield(s);
|
||||
_rec->setempty(FALSE);
|
||||
return s;
|
||||
}
|
||||
@ -3697,17 +3770,42 @@ void TRecfield::setptr(TRecnotype r)
|
||||
if (n) *wp += 128;
|
||||
}
|
||||
|
||||
void TRecfield::get_subfield(char* s) const
|
||||
{
|
||||
const TString& str = _rec->get(_name);
|
||||
int p = str.find(_subfield);
|
||||
|
||||
if (p == 0 || (p > 0 && str[p - 1] < ' '))
|
||||
{
|
||||
p += strlen(_subfield);
|
||||
|
||||
int e = str.find('\n', p);
|
||||
|
||||
if (_to > 0 && p + _to < e)
|
||||
e = p + _to;
|
||||
p += _from;
|
||||
if (p < e)
|
||||
strcpy(s, str.sub(p, e));
|
||||
else *s = '\0';
|
||||
}
|
||||
else *s = '\0';
|
||||
}
|
||||
|
||||
TRecfield::operator int() const
|
||||
{
|
||||
char tmp[32];
|
||||
if (_type == _intfld || _type == _intzerofld || _type == _longfld || _type == _longzerofld)
|
||||
{
|
||||
strncpy(tmp, _p, _len);
|
||||
tmp[_len] = '\0';
|
||||
}
|
||||
else
|
||||
__getfieldbuff( _len, _type, _p, tmp);
|
||||
if (_subfield == NULL)
|
||||
{
|
||||
if (_type == _intfld || _type == _intzerofld || _type == _longfld || _type == _longzerofld)
|
||||
{
|
||||
strncpy(tmp, _p, _len);
|
||||
tmp[_len] = '\0';
|
||||
}
|
||||
else
|
||||
__getfieldbuff( _len, _type, _p, tmp);
|
||||
}
|
||||
else
|
||||
get_subfield(tmp);
|
||||
return atoi(tmp);
|
||||
}
|
||||
|
||||
@ -3715,13 +3813,19 @@ TRecfield::operator int() const
|
||||
TRecfield::operator long() const
|
||||
{
|
||||
char tmp[32];
|
||||
if (_type == _longfld || _type == _longzerofld || _type == _intfld || _type == _intzerofld)
|
||||
{
|
||||
strncpy(tmp, _p, _len);
|
||||
tmp[_len] = '\0';
|
||||
}
|
||||
else
|
||||
__getfieldbuff( _len, _type, _p, tmp);
|
||||
|
||||
if (_subfield == NULL)
|
||||
{
|
||||
if (_type == _longfld || _type == _longzerofld || _type == _intfld || _type == _intzerofld)
|
||||
{
|
||||
strncpy(tmp, _p, _len);
|
||||
tmp[_len] = '\0';
|
||||
}
|
||||
else
|
||||
__getfieldbuff( _len, _type, _p, tmp);
|
||||
}
|
||||
else
|
||||
get_subfield(tmp);
|
||||
|
||||
return atol(tmp);
|
||||
}
|
||||
@ -3730,13 +3834,20 @@ TRecfield::operator long() const
|
||||
TRecfield::operator const real() const
|
||||
{
|
||||
char tmp[32];
|
||||
if (_type == _realfld)
|
||||
{
|
||||
strncpy(tmp, _p, _len);
|
||||
tmp[_len] = '\0';
|
||||
}
|
||||
else
|
||||
__getfieldbuff( _len, _type, _p, tmp);
|
||||
|
||||
if (_subfield == NULL)
|
||||
{
|
||||
if (_type == _realfld)
|
||||
{
|
||||
strncpy(tmp, _p, _len);
|
||||
tmp[_len] = '\0';
|
||||
}
|
||||
else
|
||||
__getfieldbuff( _len, _type, _p, tmp);
|
||||
}
|
||||
else
|
||||
get_subfield(tmp);
|
||||
|
||||
real r(tmp);
|
||||
return r;
|
||||
}
|
||||
@ -3745,25 +3856,39 @@ TRecfield::operator const real() const
|
||||
TRecfield::operator TDate() const
|
||||
{
|
||||
char tmp[16];
|
||||
if (_type == _datefld)
|
||||
{
|
||||
strncpy(tmp, _p, 8);
|
||||
tmp[8] = '\0';
|
||||
return TDate(atol(tmp));
|
||||
}
|
||||
__getfieldbuff(_len, _type, _p, tmp);
|
||||
|
||||
if (_subfield == NULL)
|
||||
{
|
||||
if (_type == _datefld)
|
||||
{
|
||||
strncpy(tmp, _p, 8);
|
||||
tmp[8] = '\0';
|
||||
return TDate(atol(tmp));
|
||||
}
|
||||
__getfieldbuff(_len, _type, _p, tmp);
|
||||
}
|
||||
else
|
||||
get_subfield(tmp);
|
||||
|
||||
return TDate(tmp);
|
||||
}
|
||||
|
||||
|
||||
TRecfield::operator const char*() const
|
||||
{
|
||||
if (_type == _memofld)
|
||||
return _rec->get(_name);
|
||||
|
||||
TString& tmp = get_tmp_string(_len);
|
||||
__getfieldbuff(_len, _type, _p, tmp.get_buffer());
|
||||
return tmp;
|
||||
|
||||
if (_subfield == NULL)
|
||||
{
|
||||
if (_type == _memofld)
|
||||
return _rec->get(_name);
|
||||
else
|
||||
__getfieldbuff(_len, _type, _p, tmp.get_buffer());
|
||||
}
|
||||
else
|
||||
get_subfield((char *) (const char *)tmp);
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
@ -3778,4 +3903,4 @@ TRecnotype TRecfield::ptr() const
|
||||
while(wp-- > (unsigned char*) _p)
|
||||
r = (r << 8) + *wp;
|
||||
return n ? -r : r;
|
||||
}
|
||||
}
|
@ -596,7 +596,7 @@ public:
|
||||
// @cmember Calcola lo spazio che il file occuperebbe se venisse esteso a <p eox>
|
||||
long size(TRecnotype eox);
|
||||
// @cmember Esegue la conversione del tracciato record del file
|
||||
int update(const TTrec& newrec, bool vis = TRUE);
|
||||
int update(const TTrec& newrec, bool interactive = FALSE);
|
||||
|
||||
// @cmember Esegue sia <mf TSystemisamfile::packfile> e <mf TSystemisamfile::packindex>
|
||||
int pack(bool vis = FALSE, bool ask = TRUE);
|
||||
@ -762,7 +762,7 @@ class TRecfield : public TObject
|
||||
// @access:(INTERNAL) Private Member
|
||||
{
|
||||
// @cmember:(INTERNAL) Nome del campo
|
||||
char _name[12];
|
||||
char _name[30];
|
||||
// @cmember:(INTERNAL) Puntatore a inizio record
|
||||
TRectype* _rec;
|
||||
// @cmember:(INTERNAL) Puntatore a inizio campo
|
||||
@ -773,9 +773,17 @@ class TRecfield : public TObject
|
||||
byte _dec;
|
||||
// @cmember:(INTERNAL) Tipo del campo
|
||||
TFieldtypes _type;
|
||||
// @cmember:(INTERNAL) Sottocampo (Es. G1:TOTDOC)
|
||||
char * _subfield;
|
||||
// @cmember:(INTERNAL) Da per i sottocampi (Es. G1:TOTDOC[2,3])
|
||||
byte _from;
|
||||
// @cmember:(INTERNAL) A per i sottocampi (Es. G1:TOTDOC[2,3])
|
||||
byte _to;
|
||||
|
||||
// @cmember:(INTERNAL) Setta il campo <p to>-esimo con i valori di <p from>-esimo
|
||||
void set(int from, int to);
|
||||
void get_subfield(char * s) const;
|
||||
void put_subfield(const char * s);
|
||||
|
||||
// @access Public Member
|
||||
public:
|
||||
@ -787,10 +795,8 @@ public:
|
||||
const TDate& operator =(const TDate& d) ;
|
||||
// @cmember Operatore di assegnamento per tipo carattere
|
||||
const char* operator =(const char* s) ;
|
||||
#ifndef FOXPRO
|
||||
// @cmember Operatore di assegnamento per tipo real
|
||||
const real& operator =(const real& r) ;
|
||||
#endif
|
||||
|
||||
// @cmember Operatore di estrazione per tipo intero
|
||||
operator int() const ;
|
||||
@ -800,10 +806,8 @@ public:
|
||||
operator const char*() const ;
|
||||
// @cmember Operatore di estrazione per data
|
||||
operator TDate() const ;
|
||||
#ifndef FOXPRO
|
||||
// @cmember const real | operator const real | | Operatore di estrazione per real
|
||||
operator const real() const ;
|
||||
#endif
|
||||
|
||||
// @cmember Scrive un campo packed. Sarebbe meglio non usare mai campi packed.
|
||||
void setptr(TRecnotype r);
|
||||
|
Loading…
x
Reference in New Issue
Block a user