Patch level : 10.1002

Files correlati     : ve0.exe
Ricompilazione Demo : [ ]
Commento            :

Aggiunta una funzione per ordinare le righe di un documento che ordina le righe a blocchi in ordine di codice, i blocchi sono delimitiati da righe senza codice (descrizioni).
 Per attivarla bisogna aggiungere un bottone con id 43 alla maschera.


git-svn-id: svn://10.65.10.50/branches/R_10_00@22143 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2011-05-20 14:36:10 +00:00
parent de583099ef
commit 213cb02697
2 changed files with 40 additions and 0 deletions

View File

@ -1011,6 +1011,7 @@ public:
static bool datacambio_handler( TMask_field& f, KEY key );
static bool codval_handler( TMask_field& f, KEY key );
static bool confirm_handler( TMask_field& f, KEY key );
static bool sort_row_handler( TMask_field& f, KEY key );
static bool ss_notify(TSheet_field& ss, int r, KEY key);
static bool ss_handler(TMask_field& f, KEY key);
virtual void user_set_handler( short fieldid, int index);

View File

@ -161,6 +161,9 @@ TDocumento_mask::TDocumento_mask(const char* td)
set_handler( DLG_PREVIEW, print_handler );
set_handler( DLG_EMAIL, print_handler );
set_handler( DLG_CONFERMA, confirm_handler );
if (id2pos(DLG_SORT) > 0)
set_handler( DLG_SORT, sort_row_handler );
const TString_array& handlers = tdoc.handlers();
FOR_EACH_ARRAY_ROW(handlers, r, riga)
@ -4177,6 +4180,42 @@ bool TDocumento_mask::confirm_handler( TMask_field& f, KEY key )
}
return ok;
}
static int row_compare(TSheet_field& s, int r1, int r2)
{
for (int i = r1 + 1; i < r2; i++)
if (s.row(i).get(s.cid2index(FR_CODART))[0] == '\0')
return -1;
const char* c1 = s.row(r1).get(s.cid2index(FR_CODART));
const char* c2 = s.row(r2).get(s.cid2index(FR_CODART));
if (c1 && *c1 && c2 && *c2)
return strcmp(c1, c2);
return r1 - r2;
}
bool TDocumento_mask::sort_row_handler( TMask_field& f, KEY key )
{
if (key == K_SPACE)
{
TSheet_field & sheet = f.mask().sfield(F_SHEET);
TString_array saved_rows = sheet.rows_array();
const int nrows = sheet.items();
sheet.sort(row_compare);
if (nrows == sheet.items())
sheet.force_update();
else
{
sheet.rows_array() = saved_rows;
sheet.force_update();
return message_box("L'ordinamento non ha avuto un esito positivo");
}
}
return true;
}
void TDocumento_mask::sel_color()
{