Patch level : 10.0 no patch
Files correlati : Ricompilazione Demo : [ ] Metodo per ordinare le righe documento sort_rows(order); order = campi della chiave (es "-"RDOC_CODART"|"RDOC_DATACONS"|"RDOC_QTA) git-svn-id: svn://10.65.10.50/trunk@19602 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
2e123105ff
commit
5621d7dbf9
@ -949,11 +949,74 @@ void TDocumento::dirty_fields()
|
||||
}
|
||||
}
|
||||
|
||||
static TToken_string * __key;
|
||||
|
||||
HIDDEN int sort_doc_rows(const TObject** r0, const TObject** r1)
|
||||
{
|
||||
TRiga_documento * row0 = (TRiga_documento *) *r0;
|
||||
TRiga_documento * row1 = (TRiga_documento *) *r1;
|
||||
int res = 0;
|
||||
TToken_string & key = * __key;
|
||||
TString val0, val1;
|
||||
|
||||
FOR_EACH_TOKEN(key, fldname)
|
||||
{
|
||||
const int reverse = *fldname == '-' ? -1 : 1;
|
||||
|
||||
if (reverse < 0)
|
||||
fldname++;
|
||||
|
||||
const TFieldref fld(fldname, 0);
|
||||
val0 = fld.read(*row0);
|
||||
val1 = fld.read(*row1);
|
||||
|
||||
switch (row0->type(fld.name()))
|
||||
{
|
||||
case _intfld :
|
||||
case _longfld :
|
||||
case _realfld :
|
||||
case _wordfld :
|
||||
{
|
||||
const real r0 = val0;
|
||||
const real r1 = val1;
|
||||
|
||||
if (r0 != r1)
|
||||
res = (r0 < r1 ? -1 : 1) * reverse;
|
||||
}
|
||||
break;
|
||||
case _datefld :
|
||||
{
|
||||
const TDate d0 = val0;
|
||||
const TDate d1 = val1;
|
||||
|
||||
if (d0 != d1)
|
||||
res = (d0 < d1 ? -1 : 1) * reverse;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (val0 != val1)
|
||||
res = xvt_str_compare_ignoring_case(val0, val1) * reverse;
|
||||
break;
|
||||
}
|
||||
if (res != 0)
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void TDocumento::sort_rows(const char * key)
|
||||
{
|
||||
__key = new TToken_string(key);
|
||||
body().sort(sort_doc_rows);
|
||||
delete __key;
|
||||
__key = NULL;
|
||||
}
|
||||
|
||||
int TDocumento::write_rewrite(TBaseisamfile & f, bool re) const
|
||||
{
|
||||
{
|
||||
TDocumento& myself = *((TDocumento *)this);
|
||||
const bool new_doc = nuovo() || numero() <= 0; // E' nuovo di zecca!
|
||||
|
||||
|
||||
if (new_doc)
|
||||
{
|
||||
char stato_finale = tipo().stato_finale_inserimento();
|
||||
|
Loading…
x
Reference in New Issue
Block a user