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@22148 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
d3d6dfb730
commit
ad20a83164
@ -4180,18 +4180,23 @@ bool TDocumento_mask::confirm_handler( TMask_field& f, KEY key )
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
static int row_compare(TSheet_field& s, int r1, int r2)
|
||||
|
||||
static int row_compare(const TObject** obj1, const TObject** obj2)
|
||||
{
|
||||
TRiga_documento & row1 = (TRiga_documento & ) **obj1;
|
||||
TRiga_documento & row2 = (TRiga_documento & ) **obj2;
|
||||
const TDocumento & doc = row1.doc();
|
||||
const int r1 = row1.get_int(RDOC_NRIGA);
|
||||
const int r2 = row2.get_int(RDOC_NRIGA);
|
||||
for (int i = r1 + 1; i < r2; i++)
|
||||
if (s.row(i).get(s.cid2index(FR_CODART))[0] == '\0')
|
||||
if (doc[i].get(RDOC_CODART).blank())
|
||||
return -1;
|
||||
|
||||
const char* c1 = s.row(r1).get(s.cid2index(FR_CODART));
|
||||
const char* c2 = s.row(r2).get(s.cid2index(FR_CODART));
|
||||
const TString80 c1 = row1.get(RDOC_CODART);
|
||||
const TString & c2 = row2.get(RDOC_CODART);
|
||||
|
||||
if (c1 && *c1 && c2 && *c2)
|
||||
return strcmp(c1, c2);
|
||||
|
||||
if (c1.full() && c2.full())
|
||||
return strcmp((const char *) c1, (const char *) c2);
|
||||
return r1 - r2;
|
||||
}
|
||||
|
||||
@ -4200,16 +4205,22 @@ 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();
|
||||
TDocumento_mask & m = (TDocumento_mask &) f.mask();
|
||||
TDocumento & doc = m.doc();
|
||||
TRecord_array saved_rows = doc.body();
|
||||
TRecord_array & rows = doc.body();
|
||||
const int nrows = doc.physical_rows();
|
||||
|
||||
sheet.sort(row_compare);
|
||||
if (nrows == sheet.items())
|
||||
rows.sort(row_compare);
|
||||
if (nrows == doc.physical_rows())
|
||||
{
|
||||
for (int r = 1; r <= nrows; r++)
|
||||
doc[r].autoload(sheet);
|
||||
sheet.force_update();
|
||||
}
|
||||
else
|
||||
{
|
||||
sheet.rows_array() = saved_rows;
|
||||
sheet.force_update();
|
||||
rows = saved_rows;
|
||||
return message_box("L'ordinamento non ha avuto un esito positivo");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user