7a2b3f956e
git-svn-id: svn://10.65.10.50/branches/R_10_00@23046 c028cbd2-c16b-5b4b-a496-9718f37d4682
684 lines
17 KiB
C++
Executable File
684 lines
17 KiB
C++
Executable File
#include <defmask.h>
|
|
#include <diction.h>
|
|
|
|
#include "../cg/cglib01.h"
|
|
#include "scselect.h"
|
|
#include <pconti.h>
|
|
|
|
static bool sc_filter_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_SPACE)
|
|
{
|
|
TCursor_sheet& cs = (TCursor_sheet&)f.mask();
|
|
TCursor& c = *cs.cursor();
|
|
|
|
TString expr; // Espressione di filtro complessiva
|
|
if (f.get().full()) // Filtro attivato!
|
|
{
|
|
const short id = f.dlg()-500;
|
|
TString e = f.mask().get(id); // Espressione regolare
|
|
e.strip("\"'"); // Tolgo caratteri che potrebbero dare problemi
|
|
if (e.full())
|
|
{
|
|
expr = (c.file().num() == LF_CLIFO) ? CLI_RAGSOC : PCN_DESCR;
|
|
expr << "?=\"" << e << '"';
|
|
expr.upper();
|
|
}
|
|
if (expr.empty())
|
|
f.reset();
|
|
}
|
|
c.freeze(false);
|
|
c.setfilter(expr, true);
|
|
c.freeze(true);
|
|
cs.force_update();
|
|
cs.post_select(0);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
static bool sc_ragsoc_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_TAB && f.focusdirty())
|
|
{
|
|
TMask_field& chk = f.mask().field(f.dlg()+500);
|
|
if (f.get().starts_with("*"))
|
|
chk.set("X");
|
|
if (chk.get().full())
|
|
sc_filter_handler(chk, K_SPACE);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
TSelection_mask::TSelection_mask(const char* name)
|
|
: TMask(name), _who('C'), _key(1), _clifo_rel(NULL), _pdc_rel(NULL),
|
|
_cli_cur_k1(NULL), _cli_cur_k2(NULL), _for_cur_k1(NULL), _for_cur_k2(NULL),
|
|
_pdc_cur_k1(NULL), _pdc_cur_k2(NULL)
|
|
{
|
|
// crea relazioni, cursori e cursor_sheets
|
|
_clifo_rel = new TRelation(LF_CLIFO);
|
|
|
|
TRectype filter(LF_CLIFO);
|
|
filter.put(CLI_TIPOCF, "C");
|
|
_cli_cur_k1 = new TCursor(_clifo_rel, "", 1, &filter, &filter);
|
|
_cli_cur_k2 = new TCursor(_clifo_rel, "", 2, &filter, &filter);
|
|
|
|
_cli_sh_k1 = new TCursor_sheet(_cli_cur_k1, " |CODCF|RAGSOC|PAIV", TR("Selezione cliente per codice"),
|
|
HR("@1|Codice|Ragione Sociale@50|Partita IVA"),0,1);
|
|
_cli_sh_k2 = new TCursor_sheet(_cli_cur_k2, " |RAGSOC|CODCF|PAIV", TR("Selezione cliente per ragione sociale"),
|
|
"@1|Ragione Sociale@50|Codice|Partita IVA",0,1);
|
|
_cli_sh_k2->add_string(SC_CLIFO, 0, PR("Ragione sociale "), 1, 0, 50, "").set_handler(sc_ragsoc_handler);
|
|
_cli_sh_k2->add_checkbutton(SC_CLIFO+500, 0, "", 68, 0, 2, 1, "", 10112, 10113).set_handler(sc_filter_handler);
|
|
|
|
if (id2pos(SC_CLIFO) >= 0)
|
|
{
|
|
filter.put(CLI_TIPOCF, "F");
|
|
_for_cur_k1 = new TCursor(_clifo_rel, "", 1, &filter, &filter);
|
|
_for_cur_k2 = new TCursor(_clifo_rel, "", 2, &filter, &filter);
|
|
_for_sh_k1 = new TCursor_sheet(_for_cur_k1, " |CODCF|RAGSOC|PAIV", TR("Selezione fornitore per codice"),
|
|
HR("@1|Codice|Ragione Sociale@50|Partita IVA"),0,1);
|
|
_for_sh_k2 = new TCursor_sheet(_for_cur_k2, " |RAGSOC|CODCF|PAIV", TR("Selezione fornitore per ragione sociale"),
|
|
"@1|Ragione Sociale@50|Codice|Partita IVA",0,1);
|
|
_for_sh_k2->add_string(SC_CLIFO, 0, PR("Ragione sociale "), 1, 0, 50, "").set_handler(sc_ragsoc_handler);
|
|
_for_sh_k2->add_checkbutton(SC_CLIFO+500, 0, "", 68, 0, 2, 1, "", 10112, 10113).set_handler(sc_filter_handler);
|
|
}
|
|
else
|
|
{
|
|
_for_cur_k1 = NULL;
|
|
_for_cur_k2 = NULL;
|
|
_for_sh_k1 = NULL;
|
|
_for_sh_k2 = NULL;
|
|
}
|
|
|
|
if (id2pos(SC_CLIFO) >= 0 && TToken_string(lfield(SC_CLIFO).get_codes()).items()>2)
|
|
{
|
|
_pdc_rel = new TRelation(LF_PCON);
|
|
TRectype& filter = _pdc_rel->curr();
|
|
_pdc_cur_k1 = new TCursor(_pdc_rel, "", 1, &filter, &filter);
|
|
_pdc_cur_k2 = new TCursor(_pdc_rel, "", 2, &filter, &filter);
|
|
_pdc_sh_k1 = new TCursor_sheet(_pdc_cur_k1, " |GRUPPO|CONTO|SOTTOCONTO|DESCR", "Selezione conti per codice",
|
|
"@1|Gruppo|Conto|Sottoconto|Descrizione@50",0,1);
|
|
_pdc_sh_k2 = new TCursor_sheet(_pdc_cur_k2, " |DESCR|GRUPPO|CONTO|SOTTOCONTO", "Selezione conti per descrizione",
|
|
"@1|Descrizione@50|Gruppo|Conto|Sottoconto",0,1);
|
|
_pdc_sh_k2->add_string(SC_CLIFO, 0, PR("Descrizione "), 1, 0, 50, "").set_handler(sc_ragsoc_handler);
|
|
_pdc_sh_k2->add_checkbutton(SC_CLIFO+500, 0, "", 68, 0, 2, 1, "", 10112, 10113).set_handler(sc_filter_handler);
|
|
}
|
|
else
|
|
{
|
|
_pdc_rel = NULL;
|
|
_pdc_cur_k1 = NULL;
|
|
_pdc_cur_k2 = NULL;
|
|
_pdc_sh_k1 = NULL;
|
|
_pdc_sh_k2 = NULL;
|
|
}
|
|
|
|
set_handler(SC_CLIFO, rclifo_handler);
|
|
set_handler(SC_SORTCF, rsortcf_handler);
|
|
set_handler(SC_SELECT, bselect_handler);
|
|
set_handler(SC_RESET, breset_handler);
|
|
set_handler(SC_CFCODFR, ffrom_handler);
|
|
set_handler(SC_CFCODTO, fto_handler);
|
|
set_handler(SC_CFDESFR, fdfrom_handler);
|
|
set_handler(SC_CFDESTO, fdto_handler);
|
|
}
|
|
|
|
TSelection_mask::~TSelection_mask()
|
|
{
|
|
if (_pdc_sh_k1 != NULL)
|
|
{
|
|
delete _pdc_sh_k2;
|
|
delete _pdc_sh_k1;
|
|
delete _pdc_cur_k2;
|
|
delete _pdc_cur_k1;
|
|
delete _pdc_rel;
|
|
}
|
|
|
|
if (_for_sh_k1 != NULL)
|
|
{
|
|
delete _for_sh_k2;
|
|
delete _for_sh_k1;
|
|
delete _for_cur_k2;
|
|
delete _for_cur_k1;
|
|
}
|
|
|
|
delete _cli_sh_k2;
|
|
delete _cli_sh_k1;
|
|
delete _cli_cur_k2;
|
|
delete _cli_cur_k1;
|
|
|
|
delete _clifo_rel;
|
|
}
|
|
|
|
bool TSelection_mask::stop_run(KEY k)
|
|
{
|
|
const bool ok = TMask::stop_run(k);
|
|
if (ok && k != K_QUIT)
|
|
update_assoc();
|
|
return ok;
|
|
}
|
|
|
|
void TSelection_mask::set_handler(short fld_id, CONTROL_HANDLER handler)
|
|
{
|
|
const int pos = id2pos(fld_id);
|
|
if (pos >= 0)
|
|
fld(pos).set_handler(handler);
|
|
}
|
|
|
|
TCursor_sheet& TSelection_mask::cur_sheet() const
|
|
{
|
|
TCursor_sheet* cs = NULL;
|
|
switch (get_who())
|
|
{
|
|
case 'C': cs = get_key() == 1 ? _cli_sh_k1 : _cli_sh_k2; break;
|
|
case 'F': cs = get_key() == 1 ? _for_sh_k1 : _for_sh_k2; break;
|
|
default : cs = get_key() == 1 ? _pdc_sh_k1 : _pdc_sh_k2; break;
|
|
}
|
|
CHECK(cs, "Can't use a NULL TCursor_sheet");
|
|
return *cs;
|
|
}
|
|
|
|
void TSelection_mask::reset_sheets()
|
|
{
|
|
_cli_sh_k1->uncheck(-1);
|
|
_cli_sh_k2->uncheck(-1);
|
|
if (_for_sh_k1)
|
|
{
|
|
_for_sh_k1->uncheck(-1);
|
|
_for_sh_k2->uncheck(-1);
|
|
}
|
|
if (_pdc_sh_k1)
|
|
{
|
|
_pdc_sh_k1->uncheck(-1);
|
|
_pdc_sh_k2->uncheck(-1);
|
|
}
|
|
reset(SC_CFCODFR);
|
|
reset(SC_CFCODTO);
|
|
reset(SC_CFDESFR);
|
|
reset(SC_CFDESTO);
|
|
reset(SC_NSEL);
|
|
}
|
|
|
|
|
|
// Seleziona tutti i clienti con codice compreso tra due estremi
|
|
void TSelection_mask::select_clifo_range(long from, long to)
|
|
{
|
|
TWait_cursor hourglass;
|
|
TCursor_sheet& c = cur_sheet();
|
|
const long items = c.items();
|
|
const int key = get_key();
|
|
|
|
TCursor* crs = c.cursor();
|
|
if (to == 0 && items)
|
|
to = c.row(items-1).get_long(key);
|
|
|
|
if (from > to) // Controlla limiti
|
|
{
|
|
long tmp = to;
|
|
to = from;
|
|
from = tmp;
|
|
}
|
|
long last = 0;
|
|
long firs = 0;
|
|
|
|
TRectype& rec = crs->file().curr();
|
|
rec.zero();
|
|
rec.put(CLI_TIPOCF,get_who());
|
|
rec.put(CLI_CODCF,from);
|
|
|
|
const TRecnotype start = crs->read(_isgteq);
|
|
firs = rec.get_long(CLI_CODCF);
|
|
rec.zero();
|
|
rec.put(CLI_TIPOCF,get_who());
|
|
rec.put(CLI_CODCF,to);
|
|
TRectype recx(rec);
|
|
TRecnotype end = crs->read(_isgteq);
|
|
if (rec > recx)
|
|
{
|
|
end--;
|
|
(*crs)-=1;
|
|
}
|
|
last = rec.get_long(CLI_CODCF);
|
|
c.uncheck(-1);
|
|
for (long i = start; i <= end; i++)
|
|
c.check(i);
|
|
if (get(SC_CFCODFR).not_empty())
|
|
set(SC_CFCODFR, firs);
|
|
if (get(SC_CFCODTO).not_empty())
|
|
set(SC_CFCODTO, last);
|
|
|
|
set(SC_NSEL, c.checked());
|
|
}
|
|
|
|
void TSelection_mask::select_des_clifo_range(const TString& from, const TString & to)
|
|
{
|
|
TWait_cursor hourglass;
|
|
TCursor_sheet& c = cur_sheet();
|
|
const long items = c.items();
|
|
const int key = get_key();
|
|
CHECK(key == 2, "La chiave deve essere la 2");
|
|
TString s_from(from), s_to(to);
|
|
|
|
if (s_to.empty() && items)
|
|
s_to = c.row(items-1).get(1);
|
|
s_from.upper();
|
|
s_to.upper();
|
|
|
|
if (s_from > s_to) // Controlla limiti
|
|
{
|
|
s_to = from;
|
|
s_from = to;// ripristina i valori originali (!upper)
|
|
set(SC_CFDESFR, to);
|
|
set(SC_CFDESTO, from);
|
|
}
|
|
else
|
|
{
|
|
if (to.not_empty()) s_to = to;
|
|
s_from = from; // ripristina i valori originali (!upper)
|
|
}
|
|
|
|
TString last;
|
|
TString firs;
|
|
|
|
const char who = get_who();
|
|
TCursor* crs = c.cursor();
|
|
TRectype& rec = crs->file().curr();
|
|
rec.zero();
|
|
if (who >= 'C')
|
|
{
|
|
rec.put(CLI_TIPOCF, who);
|
|
rec.put(CLI_RAGSOC, s_from);
|
|
}
|
|
else
|
|
rec.put(PCN_DESCR, s_from);
|
|
const TRecnotype start = crs->read(_isgteq);
|
|
firs = rec.get(who >= 'C' ? CLI_RAGSOC : PCN_DESCR);
|
|
rec.zero();
|
|
if (who >= 'C')
|
|
{
|
|
rec.put(CLI_TIPOCF, who);
|
|
rec.put(CLI_RAGSOC, s_to);
|
|
}
|
|
else
|
|
rec.put(PCN_DESCR, s_to);
|
|
|
|
TRectype recx(rec);
|
|
TRecnotype end = crs->read(_isgteq);
|
|
if (rec > recx)
|
|
{
|
|
end--;
|
|
(*crs)-=1;
|
|
}
|
|
last = rec.get(who >= 'C' ? CLI_RAGSOC : PCN_DESCR);
|
|
c.uncheck(-1);
|
|
for (long i = start; i <= end; i++)
|
|
c.check(i);
|
|
if (get(SC_CFDESFR).not_empty())
|
|
set(SC_CFDESFR, firs);
|
|
if (get(SC_CFDESTO).not_empty())
|
|
set(SC_CFDESTO, last);
|
|
set(SC_NSEL, c.checked());
|
|
}
|
|
|
|
// Cerca il primo e l'ultimo cliente selezionati
|
|
void TSelection_mask::set_clifo_limits()
|
|
{
|
|
TWait_cursor hourglass;
|
|
long from = 0, to = 0;
|
|
|
|
TCursor_sheet& c = cur_sheet();
|
|
const long items = c.items();
|
|
const int key = get_key();
|
|
long first = -1, last = -1;
|
|
|
|
for (long i = 0; i < items; i++)
|
|
if (c.checked(i))
|
|
{
|
|
if (first == -1)
|
|
first = i;
|
|
}
|
|
if (first != -1) //Optimization... If nothing was found previously skip this test.
|
|
for (long j = (items-1); j >= 0 ; j--)
|
|
if (c.checked(j))
|
|
if (last == -1)
|
|
{
|
|
last = j;
|
|
break;
|
|
}
|
|
if (first!= -1 && last != -1) // Something selected?
|
|
{
|
|
TToken_string fitem(c.row(first));
|
|
TToken_string litem(c.row(last));
|
|
from = fitem.get_long(key);
|
|
to = litem.get_long(key);
|
|
if (from>to)
|
|
{
|
|
long t = to;
|
|
to=from;
|
|
from=t;
|
|
}
|
|
}
|
|
set(SC_CFCODFR, from);
|
|
set(SC_CFCODTO, to);
|
|
set(SC_NSEL, c.checked());
|
|
}
|
|
|
|
void TSelection_mask::set_des_clifo_limits()
|
|
{
|
|
TWait_cursor hourglass;
|
|
long first=-1, last=-1;
|
|
TString from,to;
|
|
TCursor_sheet& c = cur_sheet();
|
|
const long items = c.items();
|
|
const int key = get_key();
|
|
CHECK(key == 2, "La chiave deve essere la 2");
|
|
|
|
for (long i = 0; i < items; i++)
|
|
if (c.checked(i))
|
|
{
|
|
if (first == -1)
|
|
first = i;
|
|
}
|
|
if (first != -1)
|
|
for (long j = (items-1); j >= 0 ; j--)
|
|
if (c.checked(j))
|
|
if (last == -1)
|
|
{
|
|
last = j;
|
|
break;
|
|
}
|
|
if (first!= -1 && last != -1)
|
|
{
|
|
TToken_string fitem(c.row(first));
|
|
TToken_string litem(c.row(last));
|
|
from = fitem.get(1);
|
|
to = litem.get(1);
|
|
if (from>to)
|
|
{
|
|
TString temp(to);
|
|
to=from;
|
|
from=temp;
|
|
}
|
|
}
|
|
set(SC_CFDESFR, from);
|
|
set(SC_CFDESTO, to);
|
|
set(SC_NSEL, c.checked());
|
|
}
|
|
|
|
// handlers
|
|
|
|
bool TSelection_mask::ffrom_handler(TMask_field& f, KEY k)
|
|
{
|
|
TSelection_mask& m = (TSelection_mask&)f.mask();
|
|
|
|
if (k == K_TAB && f.focusdirty())
|
|
{
|
|
const long cod1 = atol(f.get());
|
|
const long cod2 = m.get_long(SC_CFCODTO);
|
|
m.select_clifo_range(cod1, cod2);
|
|
}
|
|
else
|
|
if (k == K_F9)
|
|
{
|
|
TCursor_sheet& c = m.cur_sheet();
|
|
c.cursor()->curr().put(CLI_CODCF, f.get());
|
|
c.cursor()->read();
|
|
c.disable_check();
|
|
c.disable(DLG_USER);
|
|
if (c.run() == K_ENTER)
|
|
{
|
|
TToken_string& t = c.row(c.selected());
|
|
const long cod1 = t.get_long(m.get_key());
|
|
const long cod2 = m.get_long(SC_CFCODTO);
|
|
m.set(SC_CFCODFR, cod1);
|
|
m.select_clifo_range(cod1, cod2);
|
|
}
|
|
c.enable(DLG_USER);
|
|
c.enable_check();
|
|
}
|
|
|
|
|
|
return true;
|
|
}
|
|
|
|
bool TSelection_mask::fto_handler(TMask_field& f, KEY k)
|
|
{
|
|
TSelection_mask& m = (TSelection_mask&)f.mask();
|
|
|
|
if (k == K_TAB && f.focusdirty())
|
|
{
|
|
const long cod1 = m.get_long(SC_CFCODFR);
|
|
const long cod2 = atol(f.get());
|
|
m.select_clifo_range(cod1, cod2);
|
|
}
|
|
else
|
|
if (k == K_F9)
|
|
{
|
|
TCursor_sheet& c = m.cur_sheet();
|
|
c.cursor()->curr().put(CLI_CODCF, f.get());
|
|
c.cursor()->read();
|
|
c.disable_check();
|
|
c.disable(DLG_USER);
|
|
if (c.run() == K_ENTER)
|
|
{
|
|
TToken_string& t = c.row(c.selected());
|
|
const long cod2 = t.get_long(m.get_key());
|
|
const long cod1 = m.get_long(SC_CFCODFR);
|
|
m.set(SC_CFCODTO, cod2);
|
|
m.select_clifo_range(cod1, cod2);
|
|
}
|
|
c.enable(DLG_USER);
|
|
c.enable_check();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool TSelection_mask::fdfrom_handler(TMask_field& f, KEY k)
|
|
{
|
|
TSelection_mask& m = (TSelection_mask&)f.mask();
|
|
|
|
if (k == K_TAB && f.focusdirty())
|
|
{
|
|
const TString des1(f.get());
|
|
const TString des2(m.get(SC_CFDESTO));
|
|
m.select_des_clifo_range(des1, des2);
|
|
}
|
|
else
|
|
if (k == K_F9)
|
|
{
|
|
TCursor_sheet& c = m.cur_sheet();
|
|
const char* fld = m.get_who() >= 'C' ? CLI_RAGSOC : PCN_DESCR;
|
|
const TString& value = f.get();
|
|
c.cursor()->curr().put(fld, value);
|
|
c.cursor()->read();
|
|
c.set(SC_CLIFO, value, 0x3);
|
|
c.disable_check();
|
|
c.disable(DLG_USER);
|
|
if (c.run() == K_ENTER)
|
|
{
|
|
TToken_string& t = c.row(c.selected());
|
|
const TString des1(t.get(1));
|
|
const TString des2 = m.get(SC_CFDESTO);
|
|
m.set(SC_CFDESFR, des1);
|
|
m.select_des_clifo_range(des1, des2);
|
|
}
|
|
c.enable(DLG_USER);
|
|
c.enable_check();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
bool TSelection_mask::fdto_handler(TMask_field& f, KEY k)
|
|
{
|
|
TSelection_mask& m = (TSelection_mask&)f.mask();
|
|
|
|
if (k == K_TAB && f.focusdirty())
|
|
{
|
|
const TString des2(f.get());
|
|
const TString des1(m.get(SC_CFDESFR));
|
|
m.select_des_clifo_range(des1, des2);
|
|
}
|
|
else
|
|
if (k == K_F9)
|
|
{
|
|
TCursor_sheet& c = m.cur_sheet();
|
|
const char* fld = m.get_who() >= 'C' ? CLI_RAGSOC : PCN_DESCR;
|
|
const TString& value = f.get();
|
|
c.cursor()->curr().put(fld, value);
|
|
c.cursor()->read();
|
|
c.set(SC_CLIFO, value, 0x3);
|
|
c.disable_check();
|
|
c.disable(DLG_USER);
|
|
if (c.run() == K_ENTER)
|
|
{
|
|
TToken_string& t = c.row(c.selected());
|
|
const TString des1(m.get(SC_CFDESFR));
|
|
const TString des2(t.get(1));
|
|
m.set(SC_CFDESTO, des2);
|
|
m.select_des_clifo_range(des1, des2);
|
|
}
|
|
c.enable(DLG_USER);
|
|
c.enable_check();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool TSelection_mask::breset_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_SPACE)
|
|
{
|
|
TSelection_mask& m = (TSelection_mask&)f.mask();
|
|
m.reset_sheets();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool TSelection_mask::bselect_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_SPACE)
|
|
{
|
|
TSelection_mask& m = (TSelection_mask&)f.mask();
|
|
TCursor_sheet& c = m.cur_sheet();
|
|
c.enable_check();
|
|
c.run();
|
|
if (m.get_key() == 2)
|
|
m.set_des_clifo_limits();
|
|
else
|
|
m.set_clifo_limits();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool TSelection_mask::rclifo_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_SPACE)
|
|
{
|
|
TSelection_mask& m = (TSelection_mask&)f.mask();
|
|
m.set_who(f.get()[0]);
|
|
m.reset_sheets();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool TSelection_mask::rsortcf_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (k == K_SPACE)
|
|
{
|
|
TSelection_mask& m = (TSelection_mask&)f.mask();
|
|
m.set_key(atoi(f.get()));
|
|
m.reset_sheets();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void TSelection_mask::update_assoc()
|
|
{
|
|
_assoc.destroy();
|
|
_all_selected = false;
|
|
|
|
TCursor_sheet& cs = cur_sheet(); // Sheet di selezione (CLI/FO/PCON)
|
|
const long checked = cs.checked();
|
|
if (checked == 0L || checked == cs.items())
|
|
_all_selected =true;
|
|
else
|
|
{
|
|
const int first = get_key();
|
|
const char who = get_who();
|
|
TString16 key;
|
|
|
|
for (long i = cs.items()-1; i >= 0; i--) if (cs.checked(i))
|
|
{
|
|
TToken_string& row = cs.row(i);
|
|
if (who == 'C' || who == 'F')
|
|
{
|
|
key.format("000000%06ld", row.get_long(first));
|
|
}
|
|
else
|
|
{
|
|
const TBill b(row, first, 0x0);
|
|
key.format("%03d%03d%06ld",
|
|
b.gruppo(), b.conto(), b.sottoconto());
|
|
}
|
|
_assoc.add(key, NULL);
|
|
}
|
|
}
|
|
}
|
|
|
|
bool TSelection_mask::selected(const TBill& b) const
|
|
{
|
|
bool ok = _all_selected;
|
|
if (!ok)
|
|
{
|
|
TString16 key;
|
|
key.format("%03d%03d%06ld",
|
|
b.gruppo(), b.conto(), b.sottoconto());
|
|
ok = _assoc.is_key(key);
|
|
}
|
|
return ok;
|
|
}
|
|
|
|
bool TSelection_mask::selected(int g, int c, long s) const
|
|
{
|
|
bool ok = _all_selected;
|
|
if (!ok)
|
|
{
|
|
TString16 key;
|
|
key.format("%03d%03d%06ld", g, c, s);
|
|
ok = _assoc.is_key(key);
|
|
}
|
|
return ok;
|
|
}
|
|
|
|
TRecnotype TSelection_mask::get_clifo_range(long& first, long& last) const
|
|
{
|
|
first = last = 0L;
|
|
TRecnotype items = 0;
|
|
if (get_who() >= 'C')
|
|
{
|
|
if (_all_selected)
|
|
{
|
|
TCursor& c = *cur_sheet().cursor(); // Sheet di selezione (CLI/FO/PCON)
|
|
items = c.items();
|
|
if (items > 0)
|
|
{
|
|
c = 0L; first = c.curr().get_long(CLI_CODCF);
|
|
c = c.items()-1L; last = c.curr().get_long(CLI_CODCF);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
TAssoc_array& ass = (TAssoc_array&)_assoc; // Trick the compiler
|
|
FOR_EACH_ASSOC_OBJECT(ass, obj, key, item)
|
|
{
|
|
const TFixed_string gcs(key);
|
|
const long codcf = atol(gcs.right(6));
|
|
if (first == 0 || codcf < first)
|
|
first = codcf;
|
|
if (last == 0 || codcf > last)
|
|
last = codcf;
|
|
items++;
|
|
}
|
|
}
|
|
}
|
|
return items;
|
|
}
|