Patch level : 10.0

Files correlati     : db0.exe
Ricompilazione Demo : [ ]
Commento            :
Corretta gestione unita' di misura principale delle distinte virtuali


git-svn-id: svn://10.65.10.50/trunk@19179 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2009-08-03 15:09:14 +00:00
parent 8b374eaf78
commit 4db0d08f66

@ -952,6 +952,7 @@ class TDistinta_mask : public TAutomask
TString _numdoc;
TDate _datadoc;
private:
void set_um_rif(int row);
bool on_distsheet_event(TOperable_field& o, TField_event e, long jolly);
@ -1005,7 +1006,7 @@ void TDistinta_mask::load_um()
{
// *****************************
// LETTURA SHEET UNITA' DI MISURA
TSheet_field &units= (TSheet_field &)field(F_UNITA); // prende lo sheet delle unità di misura
TSheet_field& units= (TSheet_field &)field(F_UNITA); // prende lo sheet delle unità di misura
const char tree_type=_tree.get_type(get(F_CODICE));
if (!app().is_transaction())
@ -1027,21 +1028,33 @@ void TDistinta_mask::load_um()
units.enable_column(units.cid2index(FU_DESC),virtuale);
units.enable_column(units.cid2index(FU_FC),virtuale);
units.enable_column(units.cid2index(FU_PREZZO),virtuale);
if (units.items()==0)
units.row(0) << get(F_UM) << "|1"; // aggiunge una riga allo sheet
if (units.items()==1)
const TString& main_um = get(F_UM);
if (main_um.full())
{
set(F_UM,units.cell(0,units.cid2index(FU_UM)));
set(F_UMART1ST,get(F_UM));
}
TString16 um;
FOR_EACH_SHEET_ROW_BACK(units, u, urow)
{
urow->get(units.cid2index(FU_UM), um);
if (!um.blank() && um == get(F_UM))
if (units.empty())
units.row(0) << main_um << "|1"; // aggiunge una riga allo sheet
const int idx_um = units.cid2index(FU_UM);
TString4 um;
FOR_EACH_SHEET_ROW_BACK(units, u, urow)
{
set_um_rif(u);
break;
urow->get(idx_um, um);
if (um.full() && um == main_um)
{
set_um_rif(u);
break;
}
}
}
else
{
if (!units.empty())
{
const TString4 um = units.cell(0,units.cid2index(FU_UM));
set(F_UM, um);
set(F_UMART1ST, um);
set_um_rif(0);
}
}
}
@ -1080,60 +1093,34 @@ void TDistinta_mask::set_um_rif(int row)
const int chk = sht.cid2index(FU_RIF);
const int fc = sht.cid2index(FU_FC);
const int cod = sht.cid2index(FU_UM);
TToken_string& first = sht.row(row);
first.add("X", chk);
set(F_UM, first.get(cod), TRUE);
set(F_FCUMART, first.get(fc), TRUE);
sht.force_update(row);
FOR_EACH_SHEET_ROW(sht, r, priga)
{
if (r == row)
{
priga->add("X", chk);
set(F_UM, priga->get(cod), TRUE);
set(F_FCUMART, priga->get(fc), TRUE);
}
else
priga->add("", chk);
}
sht.force_update();
}
bool TDistinta_mask::on_unitsheet_event(TOperable_field& o, TField_event e, long jolly)
{
static bool was_checked = FALSE;
TSheet_field& sht = (TSheet_field&)o;
const int chk = sht.cid2index(FU_RIF);
TSheet_field& sht = sfield(F_UNITA);
switch(e)
{
case se_query_modify:
sht.sheet_mask().enable(DLG_DELREC, jolly > 0L);
was_checked = *sht.cell(int(jolly), chk) > ' ';
sht.sheet_mask().enable(DLG_DELREC, get_bool(F_VIRTUALE) && sht.items()>1);
break;
case se_query_del:
return get_bool(F_VIRTUALE) && jolly > 0L; // Impedisce di cancellare l'unita' di misura base
case se_notify_del:
if (was_checked)
set_um_rif(0);
break;
return get_bool(F_VIRTUALE) && sht.items()>1; // Impedisce di cancellare l'unita' di misura base
case se_notify_modify:
{
const bool is_checked = *sht.cell(int(jolly), chk) > ' ';
if (is_checked != was_checked)
{
if (was_checked)
set_um_rif(0);
else
{
FOR_EACH_SHEET_ROW(sht, r, row)
{
if (r == jolly)
set_um_rif(r);
else
{
if (*row->get(chk) > ' ')
{
row->add(" ", chk);
sht.force_update(r);
}
}
}
}
was_checked = is_checked;
}
if (jolly == 0L)
set(F_UMART1ST,sht.cell(0,sht.cid2index(FU_UM)));
}
if (jolly == 0)
set(F_UMART1ST,sht.cell(0,sht.cid2index(FU_UM)));
break;
case se_query_add:
if (!get_bool(F_VIRTUALE))
@ -1148,12 +1135,25 @@ bool TDistinta_mask::on_unitsheet_event(TOperable_field& o, TField_event e, long
}
break;
case fe_close:
if (sht.items() == 0 || *sht.cell(0,0)<=' ')
if (sht.empty() || *sht.cell(0,0) <= ' ')
return sht.error_box(TR("E' necessario specificare l'unita' di misura principale"));
else
{
const int fc = sht.cid2index(FU_RIF);
int r;
for (r = sht.items()-1; r > 0; r--)
if (*sht.cell(r, fc) > ' ')
break;
set_um_rif(r);
}
break;
case fe_modify:
if (o.dlg() == FU_RIF && o.get().full())
set_um_rif(sht.selected());
break;
default: break;
}
return TRUE;
return true;
}
bool TDistinta_mask::on_distsheet_event(TOperable_field& o, TField_event e, long jolly)
@ -1605,7 +1605,7 @@ bool TDistinta_mask::on_field_event(TOperable_field& o, TField_event e, long jol
}
}
break;
case F_UNITA:
case F_UNITA:
return on_unitsheet_event(o, e, jolly);
case F_SHEET:
return on_distsheet_event(o, e, jolly);
@ -1615,6 +1615,7 @@ case F_UNITA:
switch (jolly)
{
case 1 : return on_distsheet_event(o, e, jolly);
case 2 : return on_unitsheet_event(o, e, jolly);
case 3 : return on_parmsheet_event(o, e, jolly);
default: break;
}