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:
parent
8b374eaf78
commit
4db0d08f66
109
db/db0500.cpp
109
db/db0500.cpp
@ -952,6 +952,7 @@ class TDistinta_mask : public TAutomask
|
|||||||
TString _numdoc;
|
TString _numdoc;
|
||||||
TDate _datadoc;
|
TDate _datadoc;
|
||||||
|
|
||||||
|
private:
|
||||||
void set_um_rif(int row);
|
void set_um_rif(int row);
|
||||||
|
|
||||||
bool on_distsheet_event(TOperable_field& o, TField_event e, long jolly);
|
bool on_distsheet_event(TOperable_field& o, TField_event e, long jolly);
|
||||||
@ -1027,24 +1028,36 @@ void TDistinta_mask::load_um()
|
|||||||
units.enable_column(units.cid2index(FU_DESC),virtuale);
|
units.enable_column(units.cid2index(FU_DESC),virtuale);
|
||||||
units.enable_column(units.cid2index(FU_FC),virtuale);
|
units.enable_column(units.cid2index(FU_FC),virtuale);
|
||||||
units.enable_column(units.cid2index(FU_PREZZO),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
|
const TString& main_um = get(F_UM);
|
||||||
if (units.items()==1)
|
if (main_um.full())
|
||||||
{
|
{
|
||||||
set(F_UM,units.cell(0,units.cid2index(FU_UM)));
|
if (units.empty())
|
||||||
set(F_UMART1ST,get(F_UM));
|
units.row(0) << main_um << "|1"; // aggiunge una riga allo sheet
|
||||||
}
|
|
||||||
TString16 um;
|
const int idx_um = units.cid2index(FU_UM);
|
||||||
|
TString4 um;
|
||||||
FOR_EACH_SHEET_ROW_BACK(units, u, urow)
|
FOR_EACH_SHEET_ROW_BACK(units, u, urow)
|
||||||
{
|
{
|
||||||
urow->get(units.cid2index(FU_UM), um);
|
urow->get(idx_um, um);
|
||||||
if (!um.blank() && um == get(F_UM))
|
if (um.full() && um == main_um)
|
||||||
{
|
{
|
||||||
set_um_rif(u);
|
set_um_rif(u);
|
||||||
break;
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TDistinta_mask::test_row(const TToken_string& row)
|
bool TDistinta_mask::test_row(const TToken_string& row)
|
||||||
@ -1080,60 +1093,34 @@ void TDistinta_mask::set_um_rif(int row)
|
|||||||
const int chk = sht.cid2index(FU_RIF);
|
const int chk = sht.cid2index(FU_RIF);
|
||||||
const int fc = sht.cid2index(FU_FC);
|
const int fc = sht.cid2index(FU_FC);
|
||||||
const int cod = sht.cid2index(FU_UM);
|
const int cod = sht.cid2index(FU_UM);
|
||||||
TToken_string& first = sht.row(row);
|
|
||||||
first.add("X", chk);
|
FOR_EACH_SHEET_ROW(sht, r, priga)
|
||||||
set(F_UM, first.get(cod), TRUE);
|
{
|
||||||
set(F_FCUMART, first.get(fc), TRUE);
|
if (r == row)
|
||||||
sht.force_update(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)
|
bool TDistinta_mask::on_unitsheet_event(TOperable_field& o, TField_event e, long jolly)
|
||||||
{
|
{
|
||||||
static bool was_checked = FALSE;
|
TSheet_field& sht = sfield(F_UNITA);
|
||||||
|
|
||||||
TSheet_field& sht = (TSheet_field&)o;
|
|
||||||
const int chk = sht.cid2index(FU_RIF);
|
|
||||||
|
|
||||||
switch(e)
|
switch(e)
|
||||||
{
|
{
|
||||||
case se_query_modify:
|
case se_query_modify:
|
||||||
sht.sheet_mask().enable(DLG_DELREC, jolly > 0L);
|
sht.sheet_mask().enable(DLG_DELREC, get_bool(F_VIRTUALE) && sht.items()>1);
|
||||||
was_checked = *sht.cell(int(jolly), chk) > ' ';
|
|
||||||
break;
|
break;
|
||||||
case se_query_del:
|
case se_query_del:
|
||||||
return get_bool(F_VIRTUALE) && jolly > 0L; // Impedisce di cancellare l'unita' di misura base
|
return get_bool(F_VIRTUALE) && sht.items()>1; // Impedisce di cancellare l'unita' di misura base
|
||||||
case se_notify_del:
|
|
||||||
if (was_checked)
|
|
||||||
set_um_rif(0);
|
|
||||||
break;
|
|
||||||
case se_notify_modify:
|
case se_notify_modify:
|
||||||
{
|
if (jolly == 0)
|
||||||
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)));
|
set(F_UMART1ST,sht.cell(0,sht.cid2index(FU_UM)));
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case se_query_add:
|
case se_query_add:
|
||||||
if (!get_bool(F_VIRTUALE))
|
if (!get_bool(F_VIRTUALE))
|
||||||
@ -1148,12 +1135,25 @@ bool TDistinta_mask::on_unitsheet_event(TOperable_field& o, TField_event e, long
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case fe_close:
|
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"));
|
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;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TDistinta_mask::on_distsheet_event(TOperable_field& o, TField_event e, long jolly)
|
bool TDistinta_mask::on_distsheet_event(TOperable_field& o, TField_event e, long jolly)
|
||||||
@ -1615,6 +1615,7 @@ case F_UNITA:
|
|||||||
switch (jolly)
|
switch (jolly)
|
||||||
{
|
{
|
||||||
case 1 : return on_distsheet_event(o, e, 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);
|
case 3 : return on_parmsheet_event(o, e, jolly);
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user