Patch level :
Files correlati : Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/trunk@20379 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
6e4e1bf87e
commit
19eab22e18
@ -31,10 +31,12 @@ protected:
|
|||||||
int carica_rmovana();
|
int carica_rmovana();
|
||||||
bool one_checked() const; //(on_field) controlla se nella colonna dei check ce ne è almeno 1 checkato
|
bool one_checked() const; //(on_field) controlla se nella colonna dei check ce ne è almeno 1 checkato
|
||||||
void check_all(const bool checked); //(on_field) checka-dechecka la colonna dei check
|
void check_all(const bool checked); //(on_field) checka-dechecka la colonna dei check
|
||||||
int find_sister_rows(const int curr_sister, int& first_sister, int& last_sister); //
|
int find_sister_rows(const int curr_sister, int& first_sister, int& last_sister); //(on_field) trova le righe con la stessa chiave della riga corrente
|
||||||
void build_key(int i, TToken_string& key); //
|
void build_key(int i, TToken_string& key); //(find_sister_rows) crea la chiave della riga con cui cercare le sorelle
|
||||||
void aggiorna_saldi_preventivi(TSheet_field& sf_righe, const int curr_riga); //(carica_rmovana) crea i saldi preventivi in base agli importi
|
void aggiorna_saldi_preventivi(TSheet_field& sf_righe, const int curr_riga); //(carica_rmovana()) crea i saldi preventivi in base agli importi
|
||||||
void save_commessa(); //(on_field) salva i cambiamenti di date della commessa esaminata
|
void save_commessa(); //(save()) salva i cambiamenti di date della commessa esaminata
|
||||||
|
void save_sheet(); //(save()) salva i cambiamenti nello sheet
|
||||||
|
bool save(); //(on_field) gestisce l'ordine dei salvataggi
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TVariazione_budget_mask();
|
TVariazione_budget_mask();
|
||||||
@ -134,6 +136,7 @@ bool TVariazione_budget_mask::on_field_event(TOperable_field& o, TField_event e,
|
|||||||
case F_DATAFINECMS:
|
case F_DATAFINECMS:
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//sheet
|
//sheet
|
||||||
case S_CHECK:
|
case S_CHECK:
|
||||||
if (e == fe_modify)
|
if (e == fe_modify)
|
||||||
@ -176,13 +179,15 @@ bool TVariazione_budget_mask::on_field_event(TOperable_field& o, TField_event e,
|
|||||||
_dirty = true;
|
_dirty = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//bottoni
|
//bottoni
|
||||||
case DLG_CANCEL:
|
case DLG_CANCEL:
|
||||||
if (e == fe_button)
|
if (e == fe_button)
|
||||||
{
|
{
|
||||||
if (_dirty)
|
if (_dirty)
|
||||||
{
|
{
|
||||||
//chiede se salvare
|
if (yesno_box("Salvare le modifiche effettuate?"))
|
||||||
|
save();
|
||||||
}
|
}
|
||||||
enable(F_CODCMS);
|
enable(F_CODCMS);
|
||||||
enable(F_DESCRIZ);
|
enable(F_DESCRIZ);
|
||||||
@ -225,25 +230,32 @@ bool TVariazione_budget_mask::on_field_event(TOperable_field& o, TField_event e,
|
|||||||
if (e == fe_button)
|
if (e == fe_button)
|
||||||
{
|
{
|
||||||
TSheet_field& sf_righe = sfield(F_RIGHE);
|
TSheet_field& sf_righe = sfield(F_RIGHE);
|
||||||
//calcola la differenza tra
|
|
||||||
FOR_EACH_SHEET_ROW(sf_righe, i, riga) if (riga->get_char(0) > ' ') //solo le righe checked!!
|
FOR_EACH_SHEET_ROW(sf_righe, i, riga) if (riga->get_char(0) > ' ') //solo le righe checked!!
|
||||||
{
|
{
|
||||||
|
//cerca le sorelle della riga
|
||||||
int first, last;
|
int first, last;
|
||||||
const int sisters = find_sister_rows(i, first, last);
|
const int sisters = find_sister_rows(i, first, last);
|
||||||
|
//calcola lo sbilancio tra i saldi maturati e preventivi: il suo scopo sarà quello di modificare gli importi in modo..
|
||||||
TString80 str_mat = riga->get(_pos_mat);
|
//..da azzerare tale sbilancio
|
||||||
const real mat = real(str_mat);
|
const real mat = real(riga->get(_pos_mat));
|
||||||
TString80 str_prev = riga->get(_pos_prev);
|
const real prev = real(riga->get(_pos_prev));
|
||||||
const real prev = real(str_prev);
|
|
||||||
real sbilancio = mat - prev;
|
real sbilancio = mat - prev;
|
||||||
TString80 str_imp = riga->get(_pos_imp);
|
|
||||||
real imp = real(str_imp);
|
//legge l'importo della riga checkata
|
||||||
|
real imp = real(riga->get(_pos_imp));
|
||||||
|
//1) se la riga non ha sorelle -> modifica l'importo della riga stessa per azzerare lo sbilancio e stop!
|
||||||
|
//2) se lo sbilancio è > 0 oppure se lo sbilancio è < 0 ma più piccolo dell'importo, basta agire sulla riga stessa..
|
||||||
|
//..per azzerare lo sbilancio e stop!
|
||||||
if (sbilancio >= -imp || sisters == 1)
|
if (sbilancio >= -imp || sisters == 1)
|
||||||
{
|
{
|
||||||
imp += sbilancio;
|
imp += sbilancio;
|
||||||
sbilancio = ZERO;
|
sbilancio = ZERO;
|
||||||
riga->add(imp.string(), _pos_imp);
|
riga->add(imp.string(), _pos_imp);
|
||||||
}
|
}
|
||||||
|
//3) se invece ci sono sorelle oppure lo sbilancio è < 0 e più grande dell'importo della riga, allora vanno azzerate le..
|
||||||
|
//..righe sorelle partendo da quella checkata, poi passando all'ultima e risalendo fino a che lo sbilancio non si annulli..
|
||||||
|
//..Insomma una strage di righe che si azzerano
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
riga->add("", _pos_imp);
|
riga->add("", _pos_imp);
|
||||||
@ -260,24 +272,28 @@ bool TVariazione_budget_mask::on_field_event(TOperable_field& o, TField_event e,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
const real k = min(imp, -sbilancio);
|
const real k = min(imp, -sbilancio);
|
||||||
imp += k;
|
if (k > ZERO)
|
||||||
|
{
|
||||||
|
imp -= k;
|
||||||
sbilancio += k;
|
sbilancio += k;
|
||||||
sf_righe.row(j).add(imp.string(), _pos_imp);
|
sf_righe.row(j).add(imp.string(), _pos_imp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//al termine deve aggiornare la colonna con i preventivi
|
//al termine deve aggiornare la colonna con i preventivi
|
||||||
aggiorna_saldi_preventivi(sf_righe, i);
|
aggiorna_saldi_preventivi(sf_righe, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
sf_righe.force_update();
|
sf_righe.force_update();
|
||||||
|
_dirty = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DLG_SAVEREC:
|
case DLG_SAVEREC:
|
||||||
if (e == fe_button && check_fields())
|
if (e == fe_button && check_fields())
|
||||||
{
|
{
|
||||||
save_commessa();
|
const bool saved = save();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -306,6 +322,24 @@ void TVariazione_budget_mask::save_commessa()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TVariazione_budget_mask::save_sheet()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TVariazione_budget_mask::save()
|
||||||
|
{
|
||||||
|
//salva nel ditta.ini la causale sulla maschera
|
||||||
|
TConfig ditta_ini(CONFIG_DITTA, "ps1001");
|
||||||
|
ditta_ini.set("CodCaus", get(F_CODCAUS));
|
||||||
|
//salva le modifiche alle date della commessa
|
||||||
|
save_commessa();
|
||||||
|
//salva lo sheet (è il programma principale)
|
||||||
|
save_sheet();
|
||||||
|
_dirty = false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//controlla sulla colonna delle spunte se almeno una è checkata
|
//controlla sulla colonna delle spunte se almeno una è checkata
|
||||||
bool TVariazione_budget_mask::one_checked() const
|
bool TVariazione_budget_mask::one_checked() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user