Patch level : 10.0 332
Files correlati : pe0.exe Ricompilazione Demo : [ ] Commento Preventivazione gestione k git-svn-id: svn://10.65.10.50/trunk@19035 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
13f128d254
commit
f4c9155fcc
211
pe/pe0400.cpp
211
pe/pe0400.cpp
@ -62,7 +62,7 @@ public:
|
|||||||
virtual void user_set_row_handler(TMask& rm, short field, int index);
|
virtual void user_set_row_handler(TMask& rm, short field, int index);
|
||||||
|
|
||||||
void update_prezzo_vendita(TMask & row_mask);
|
void update_prezzo_vendita(TMask & row_mask);
|
||||||
|
void update_costi_ricavi(int row = -1, bool update_sheet = false);
|
||||||
|
|
||||||
virtual TVariable_mask * riga_mask(int numriga);
|
virtual TVariable_mask * riga_mask(int numriga);
|
||||||
virtual void doc2mask(bool reload_clifo = true, bool force_load = false, bool update = true);
|
virtual void doc2mask(bool reload_clifo = true, bool force_load = false, bool update = true);
|
||||||
@ -127,6 +127,88 @@ void TGestione_preventivo_msk:: on_idle()
|
|||||||
//magico metodo per settare, al cambio riga dello sheet, il focus sul campo desiderato (il campo in questione è..
|
//magico metodo per settare, al cambio riga dello sheet, il focus sul campo desiderato (il campo in questione è..
|
||||||
//..definito nella on_idle(); ricordarsi la set_notify() nel costruttore della maschera senno' viene eseguito l'ss_notify()..
|
//..definito nella on_idle(); ricordarsi la set_notify() nel costruttore della maschera senno' viene eseguito l'ss_notify()..
|
||||||
//..standard e non questo qui ridefinito. Allah!
|
//..standard e non questo qui ridefinito. Allah!
|
||||||
|
|
||||||
|
void TGestione_preventivo_msk::update_costi_ricavi(int nrow, bool update_sheet)
|
||||||
|
{
|
||||||
|
TDocumento & d = doc();
|
||||||
|
const int rows = d.physical_rows();
|
||||||
|
TArray valori;
|
||||||
|
TArray costi;
|
||||||
|
TSheet_field & sh = sfield(F_SHEET);
|
||||||
|
bool all = nrow < 0;
|
||||||
|
|
||||||
|
if (all)
|
||||||
|
nrow = rows;
|
||||||
|
else
|
||||||
|
d[nrow].autosave(sh);
|
||||||
|
|
||||||
|
const int cur_level = d[nrow].get_int(RDOC_LEVEL);
|
||||||
|
|
||||||
|
while (nrow < rows && cur_level <= d[nrow + 1].get_int(RDOC_LEVEL))
|
||||||
|
nrow++;
|
||||||
|
for (int i = nrow; i > 0; i--)
|
||||||
|
{
|
||||||
|
TRiga_documento & row = (TRiga_documento &)d[i];
|
||||||
|
const int level = row.get_int(RDOC_LEVEL);
|
||||||
|
|
||||||
|
if (i == rows || level >= doc()[i + 1].get_int(RDOC_LEVEL))
|
||||||
|
{
|
||||||
|
const real importo = row.importo(true, false);
|
||||||
|
|
||||||
|
row.put(RDOC_VALV, importo);
|
||||||
|
for (int i = level - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
real * r = (real *) valori.objptr(i);
|
||||||
|
|
||||||
|
if (r == NULL)
|
||||||
|
{
|
||||||
|
r = new real;
|
||||||
|
valori.add(r, i);
|
||||||
|
}
|
||||||
|
*r += importo;
|
||||||
|
}
|
||||||
|
|
||||||
|
const real costo = row.get_real(RDOC_QTA) * row.get_real(RDOC_COSTO);
|
||||||
|
|
||||||
|
row.put(RDOC_VALC, costo);
|
||||||
|
for (int i = level - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
real * r = (real *) costi.objptr(i);
|
||||||
|
|
||||||
|
if (r == NULL)
|
||||||
|
{
|
||||||
|
r = new real;
|
||||||
|
costi.add(r, i);
|
||||||
|
}
|
||||||
|
*r += costo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
real * r = (real *) valori.objptr(level);
|
||||||
|
|
||||||
|
if (r != NULL)
|
||||||
|
{
|
||||||
|
row.put(RDOC_VALV, *r);
|
||||||
|
*r = ZERO;
|
||||||
|
}
|
||||||
|
r = (real *) costi.objptr(level);
|
||||||
|
if (r != NULL)
|
||||||
|
{
|
||||||
|
row.put(RDOC_VALC, *r);
|
||||||
|
*r = ZERO;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (update_sheet)
|
||||||
|
{
|
||||||
|
row.autoload(sh);
|
||||||
|
sh.check_row(i - 1);
|
||||||
|
sh.force_update(i - 1);
|
||||||
|
}
|
||||||
|
if (!all && level <= 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
bool TGestione_preventivo_msk::ss_notify(TSheet_field& ss, int r, KEY key)
|
bool TGestione_preventivo_msk::ss_notify(TSheet_field& ss, int r, KEY key)
|
||||||
{
|
{
|
||||||
TGestione_preventivo_msk& mask = (TGestione_preventivo_msk&) ss.mask();
|
TGestione_preventivo_msk& mask = (TGestione_preventivo_msk&) ss.mask();
|
||||||
@ -230,6 +312,11 @@ bool TGestione_preventivo_msk::ss_notify(TSheet_field& ss, int r, KEY key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case K_CTRL + K_DEL: // Cancellazione
|
||||||
|
mask.update_costi_ricavi(-1, true);
|
||||||
|
break;
|
||||||
|
case K_ENTER: // Uscita con modifiche
|
||||||
|
mask.update_costi_ricavi(r + 1, true);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -873,82 +960,30 @@ TMask* TGestione_preventivo_app::get_mask( int mode )
|
|||||||
//ridefinisco il metodo write delle TMotore_application
|
//ridefinisco il metodo write delle TMotore_application
|
||||||
int TGestione_preventivo_app::write( const TMask& m )
|
int TGestione_preventivo_app::write( const TMask& m )
|
||||||
{
|
{
|
||||||
TDocumento& doc = ((TDocumento_mask&) m).doc();
|
TGestione_preventivo_msk & mask = (TGestione_preventivo_msk &) m;
|
||||||
|
TDocumento& doc = mask.doc();
|
||||||
|
const int rows = doc.physical_rows();
|
||||||
const TString k = doc.get(DOC_K);
|
const TString k = doc.get(DOC_K);
|
||||||
int max_level = 0;
|
int max_level = 0;
|
||||||
const int rows = doc.physical_rows();
|
|
||||||
TArray valori;
|
TArray valori;
|
||||||
TArray costi;
|
TArray costi;
|
||||||
|
|
||||||
for (int r = 1; r <= rows; r++)
|
|
||||||
{
|
|
||||||
const int level = doc[r].get_int(RDOC_LEVEL);
|
|
||||||
|
|
||||||
if (max_level < level)
|
|
||||||
max_level = level;
|
|
||||||
}
|
|
||||||
for (int i = rows ; i > 0; i--)
|
for (int i = rows ; i > 0; i--)
|
||||||
{
|
{
|
||||||
TRiga_documento & row = (TRiga_documento &)doc[i];
|
TRiga_documento & row = (TRiga_documento &)doc[i];
|
||||||
const int level = row.get_int(RDOC_LEVEL);
|
const int level = row.get_int(RDOC_LEVEL);
|
||||||
|
|
||||||
if (level == max_level && row.get(RDOC_K).blank())
|
|
||||||
row.put(RDOC_K, k);
|
|
||||||
if (i == rows || level >= doc[i + 1].get_int(RDOC_LEVEL))
|
if (i == rows || level >= doc[i + 1].get_int(RDOC_LEVEL))
|
||||||
{
|
row.put(RDOC_K, k);
|
||||||
const real importo = row.importo(true, false);
|
|
||||||
|
|
||||||
row.put(RDOC_VALV, importo);
|
|
||||||
for (int i = level - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
real * r = (real *) valori.objptr(i);
|
|
||||||
|
|
||||||
if (r == NULL)
|
|
||||||
{
|
|
||||||
r = new real;
|
|
||||||
valori.add(r, i);
|
|
||||||
}
|
|
||||||
*r += importo;
|
|
||||||
}
|
|
||||||
|
|
||||||
const real costo = row.get_real(RDOC_QTA) * row.get_real(RDOC_COSTO);
|
|
||||||
|
|
||||||
row.put(RDOC_VALC, costo);
|
|
||||||
for (int i = level - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
real * r = (real *) costi.objptr(i);
|
|
||||||
|
|
||||||
if (r == NULL)
|
|
||||||
{
|
|
||||||
r = new real;
|
|
||||||
costi.add(r, i);
|
|
||||||
}
|
|
||||||
*r += costo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
real * r = (real *) valori.objptr(level);
|
|
||||||
|
|
||||||
if (r != NULL)
|
|
||||||
{
|
|
||||||
row.put(RDOC_VALV, *r);
|
|
||||||
*r = ZERO;
|
|
||||||
}
|
|
||||||
r = (real *) costi.objptr(level);
|
|
||||||
if (r != NULL)
|
|
||||||
{
|
|
||||||
row.put(RDOC_VALC, *r);
|
|
||||||
*r = ZERO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
mask.update_costi_ricavi();
|
||||||
return TMotore_application::write(m);
|
return TMotore_application::write(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
//ridefinisco il metodo rewrite delle TMotore_application
|
//ridefinisco il metodo rewrite delle TMotore_application
|
||||||
int TGestione_preventivo_app::rewrite( const TMask& m )
|
int TGestione_preventivo_app::rewrite( const TMask& m )
|
||||||
{
|
{
|
||||||
|
TGestione_preventivo_msk & mask = (TGestione_preventivo_msk &) m;
|
||||||
TDocumento& doc = ((TDocumento_mask&) m).doc();
|
TDocumento& doc = ((TDocumento_mask&) m).doc();
|
||||||
const TString k = doc.get(DOC_K);
|
const TString k = doc.get(DOC_K);
|
||||||
int max_level = 0;
|
int max_level = 0;
|
||||||
@ -956,69 +991,15 @@ int TGestione_preventivo_app::rewrite( const TMask& m )
|
|||||||
TArray valori;
|
TArray valori;
|
||||||
TArray costi;
|
TArray costi;
|
||||||
|
|
||||||
for (int r = 1; r <= rows; r++)
|
|
||||||
{
|
|
||||||
const int level = doc[r].get_int(RDOC_LEVEL);
|
|
||||||
|
|
||||||
if (max_level < level)
|
|
||||||
max_level = level;
|
|
||||||
}
|
|
||||||
for (int i = rows ; i > 0; i--)
|
for (int i = rows ; i > 0; i--)
|
||||||
{
|
{
|
||||||
TRiga_documento & row = (TRiga_documento &)doc[i];
|
TRiga_documento & row = (TRiga_documento &)doc[i];
|
||||||
const int level = row.get_int(RDOC_LEVEL);
|
const int level = row.get_int(RDOC_LEVEL);
|
||||||
|
|
||||||
if (level == max_level && row.get(RDOC_K).blank())
|
|
||||||
row.put(RDOC_K, k);
|
|
||||||
if (i == rows || level >= doc[i + 1].get_int(RDOC_LEVEL))
|
if (i == rows || level >= doc[i + 1].get_int(RDOC_LEVEL))
|
||||||
{
|
row.put(RDOC_K, k);
|
||||||
const real importo = row.importo(true, false);
|
|
||||||
|
|
||||||
row.put(RDOC_VALV, importo);
|
|
||||||
for (int i = level - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
real * r = (real *) valori.objptr(i);
|
|
||||||
|
|
||||||
if (r == NULL)
|
|
||||||
{
|
|
||||||
r = new real;
|
|
||||||
valori.add(r, i);
|
|
||||||
}
|
|
||||||
*r += importo;
|
|
||||||
}
|
|
||||||
|
|
||||||
const real costo = row.get_real(RDOC_QTA) * row.get_real(RDOC_COSTO);
|
|
||||||
|
|
||||||
row.put(RDOC_VALC, costo);
|
|
||||||
for (int i = level - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
real * r = (real *) costi.objptr(i);
|
|
||||||
|
|
||||||
if (r == NULL)
|
|
||||||
{
|
|
||||||
r = new real;
|
|
||||||
costi.add(r, i);
|
|
||||||
}
|
|
||||||
*r += costo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
real * r = (real *) valori.objptr(level);
|
|
||||||
|
|
||||||
if (r != NULL)
|
|
||||||
{
|
|
||||||
row.put(RDOC_VALV, *r);
|
|
||||||
*r = ZERO;
|
|
||||||
}
|
|
||||||
r = (real *) costi.objptr(level);
|
|
||||||
if (r != NULL)
|
|
||||||
{
|
|
||||||
row.put(RDOC_VALC, *r);
|
|
||||||
*r = ZERO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
mask.update_costi_ricavi();
|
||||||
return TMotore_application::rewrite(m);
|
return TMotore_application::rewrite(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user