Patch level : 10.0

Files correlati     : ps1001300a.msk ps1001.exe
Ricompilazione Demo : [ ]
Commento            :
Migliorata gestione abilitazione bottoni di salvataggio e modifica


git-svn-id: svn://10.65.10.50/trunk@20424 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2010-05-04 14:06:27 +00:00
parent 6ffa82ad5d
commit 28bc6659d7
4 changed files with 111 additions and 129 deletions

View File

@ -7,12 +7,10 @@ int main(int argc, char** argv)
int n = argc > 1 ? atoi(argv[1]+1) : 0;
switch(n)
{
case 0: ps1001100(argc, argv); break; //Importazione movimento di analitica da righe in *.csv (DINAMICA)
case 1: ps1001200(argc, argv); break; //Importazione di N movimenti analitici di preventivo in *.csv (CRPA e DINAMICA)
case 2: ps1001300(argc,argv); break; //Gestione budget (CRPA e DINAMICA)
default:
ps1001100(argc, argv); break;
case 0: ps1001100(argc, argv); break; //Importazione movimento di analitica da righe in *.csv (DINAMICA)
case 1: ps1001200(argc, argv); break; //Importazione di N movimenti analitici di preventivo in *.csv (CRPA e DINAMICA)
case 2: ps1001300(argc, argv); break; //Gestione budget (CRPA e DINAMICA)
default: ps1001100(argc, argv); break;
}
exit(0);
return 0;
}

View File

@ -456,7 +456,7 @@ void TBudget_Import::elabora_input(const TFilename& file, TLog_report& log)
//..e gli elementi sono array con le righe del file di input (con la stessa key ma fase\conto etc. diversi)
while (_trasfile->read(curr) == NOERR)
{
pi.setstatus(_trasfile->read_file()->tellg());
pi.setstatus((size_t)_trasfile->read_file()->tellg());
codcms = curr.get(0);
codcms.replace('_', '/');

View File

@ -3,7 +3,6 @@
#include <config.h>
#include <defmask.h>
#include <progind.h>
#include <recarray.h>
#include <textset.h>
#include "../ca/calib01.h"
@ -19,7 +18,7 @@
// Metodi static di ordinamento
///////////////////////////////////
//ordina per numreg/numrig (long+int) oppure per numreg/datacomp/autofcomp/datafcomp
static int compare_by_numrig(TSheet_field & s, int r1, int r2)
static int compare_by_numrig(TSheet_field& s, int r1, int r2)
{
TToken_string& s1 = s.row(r1);
TToken_string& s2 = s.row(r2);
@ -29,7 +28,6 @@ static int compare_by_numrig(TSheet_field & s, int r1, int r2)
const long b11 = s1.get_long(numreg_pos);
const long b21 = s2.get_long(numreg_pos);
int cmp = b11 - b21;
if (cmp == 0)
{
@ -102,6 +100,7 @@ class TVariazione_budget_mask : public TAutomask
protected:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
void set_status(bool edit);
int load(); //(costruttore e on_field) carica i dati per riempire lo sheet
@ -127,11 +126,11 @@ public:
~TVariazione_budget_mask();
};
TVariazione_budget_mask::TVariazione_budget_mask() :TAutomask ("ps1001300a")
TVariazione_budget_mask::TVariazione_budget_mask() : TAutomask ("ps1001300a")
{
//carica la causale che trova nel ditta.ini
TConfig ditta_ini(CONFIG_DITTA, "ps1001");
set(F_CODCAUS, ditta_ini.get("CodCaus"));
set(F_CODCAUS, ditta_ini.get("CodCaus"), 0x3);
//setta le posizioni dei campi dello sheet
TSheet_field& sf_righe = sfield(F_RIGHE);
@ -163,7 +162,7 @@ TVariazione_budget_mask::~TVariazione_budget_mask()
void TVariazione_budget_mask::build_key(int i, TToken_string& key)
{
TSheet_field& sf_righe = sfield(F_RIGHE);
TToken_string curr_riga = sf_righe.row(i);
TToken_string& curr_riga = sf_righe.row(i);
//chiave della riga sorella originale
key.cut(0);
key.add(curr_riga.get(_pos_cdc));
@ -175,7 +174,7 @@ void TVariazione_budget_mask::build_key(int i, TToken_string& key)
void TVariazione_budget_mask::build_key_by_numreg(int i, TToken_string& key)
{
TSheet_field& sf_righe = sfield(F_RIGHE);
TToken_string curr_riga = sf_righe.row(i);
TToken_string& curr_riga = sf_righe.row(i);
//chiave della riga sorella originale
key.cut(0);
key.add(curr_riga.get(_pos_numreg));
@ -202,33 +201,33 @@ int TVariazione_budget_mask::find_sister_rows(const int curr_sister, int& first_
TToken_string key_iesima;
for (int i = curr_sister - 1; i >= 0; i--)
{
if (by_numreg)
build_key_by_numreg(i, key_iesima);
else
build_key(i, key_iesima);
for (int i = curr_sister - 1; i >= 0; i--)
{
if (by_numreg)
build_key_by_numreg(i, key_iesima);
else
build_key(i, key_iesima);
if (key == key_iesima)
first_sister = i;
else
break;
}
if (key == key_iesima)
first_sister = i;
else
break;
}
TSheet_field& sf_righe = sfield(F_RIGHE);
const long items = sf_righe.items();
for (int i = curr_sister + 1; i < items; i++)
{
if (by_numreg)
build_key_by_numreg(i, key_iesima);
else
build_key(i, key_iesima);
TSheet_field& sf_righe = sfield(F_RIGHE);
const long items = sf_righe.items();
for (int i = curr_sister + 1; i < items; i++)
{
if (by_numreg)
build_key_by_numreg(i, key_iesima);
else
build_key(i, key_iesima);
if (key == key_iesima)
last_sister = i;
else
break;
}
if (key == key_iesima)
last_sister = i;
else
break;
}
return last_sister - first_sister + 1;
}
@ -237,30 +236,49 @@ int TVariazione_budget_mask::find_sister_rows(const int curr_sister, int& first_
void TVariazione_budget_mask::sistema_date_cms(TDate& datainicms, TDate& datafinecms)
{
datainicms = get_date(F_DATAINICMS);
datafinecms = get_date(F_DATAPRORCMS);
if (!datafinecms.ok())
const bool pro = get_bool(F_PROROGATA);
if (pro)
datafinecms = get_date(F_DATAPRORCMS);
if (!pro || !datafinecms.ok())
datafinecms = get_date(F_DATAFINECMS);
}
void TVariazione_budget_mask::set_status(bool edit)
{
enable(-3, edit);
enable(DLG_CANCEL, edit);
enable(DLG_QUIT, !edit);
enable(F_CODCMS, !edit);
enable(F_DESCRIZ, !edit);
xvtil_statbar_set(edit ? TR("Modifica") : TR("Selezione"));
}
bool TVariazione_budget_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
switch (o.dlg())
{
//maschera
case F_CODCMS:
if (e == fe_modify)
{
bool e = load() == 0;
o.enable(e);
enable(F_DESCRIZ, e);
}
if (e == fe_init)
set_status(false);
if (e == fe_modify)
set_status(!o.empty() && load() > 0);
break;
case F_DATAINICMS:
case F_DATAFINECMS:
_dirty = true;
break;
//sheet
//sheet
case F_RIGHE:
switch (e)
{
case se_query_add: return field(DLG_CANCEL).enabled();
case se_query_del: return false;
default: break;
}
break;
case S_CHECK:
if (e == fe_modify)
{
@ -282,13 +300,12 @@ bool TVariazione_budget_mask::on_field_event(TOperable_field& o, TField_event e,
const TDate datacomp = o.get();
if (datacomp < datainicms || (datafinecms.ok() && datacomp > datafinecms))
return error_box("La data competenza deve rientrare nella durata della commessa!");
_dirty = true;
}
_dirty = true;
break;
case S_DATAFCOMP:
if (e == fe_modify)
{
const TDate datafcomp = o.get();
if (datafcomp.ok())
{
@ -313,7 +330,6 @@ bool TVariazione_budget_mask::on_field_event(TOperable_field& o, TField_event e,
_dirty = true;
}
break;
case S_SO:
if (e == fe_init)
{
@ -354,24 +370,20 @@ bool TVariazione_budget_mask::on_field_event(TOperable_field& o, TField_event e,
case DLG_CANCEL:
if (e == fe_button && jolly == 0) //jolly serve per specificare che è il DLG_CANCEL della maschera principale
{
if (_dirty)
if (_dirty && yesno_box("Salvare le modifiche effettuate?"))
{
if (yesno_box("Salvare le modifiche effettuate?"))
if (!save()) //attenzione! se la save non riesce si deve fermare senza resettare le modifiche!
return false;
//attenzione! se la save non riesce si deve fermare senza resettare le modifiche!
if (!check_fields() || !save())
return false;
}
enable(F_CODCMS);
enable(F_DESCRIZ);
sfield(F_RIGHE).destroy();
set_status(false);
return false;
}
break;
case DLG_CHECKALL:
if (e == fe_button)
{
check_all(!one_checked());
}
break;
case DLG_TODATAINI:
if (e == fe_button)
@ -380,7 +392,7 @@ bool TVariazione_budget_mask::on_field_event(TOperable_field& o, TField_event e,
TSheet_field& sf_righe = sfield(F_RIGHE);
FOR_EACH_SHEET_ROW(sf_righe, i, riga) if (riga->get_char(0) > ' ') //solo le righe checked!!
riga->add(datainicms, _pos_datacomp);
_dirty = true;
sf_righe.force_update();
}
break;
@ -393,7 +405,7 @@ bool TVariazione_budget_mask::on_field_event(TOperable_field& o, TField_event e,
TSheet_field& sf_righe = sfield(F_RIGHE);
FOR_EACH_SHEET_ROW(sf_righe, i, riga) if (riga->get_char(0) > ' ') //solo le righe checked!!
riga->add(datafinecms, _pos_datafcomp);
_dirty = true;
sf_righe.force_update();
}
break;
@ -456,16 +468,13 @@ bool TVariazione_budget_mask::on_field_event(TOperable_field& o, TField_event e,
//al termine deve aggiornare la colonna con i preventivi
aggiorna_saldi_preventivi(sf_righe, i);
}
sf_righe.force_update();
_dirty = true;
sf_righe.force_update();
}
break;
case DLG_SAVEREC:
if (e == fe_button && check_fields())
{
const bool saved = save();
}
save();
break;
default:
break;
@ -484,10 +493,10 @@ bool TVariazione_budget_mask::save_commessa()
int err = commesse.read(_isequal, _lock);
if (err == NOERR)
{
commesse.put(COMMESSE_DATAINIZIO, get_date(F_DATAINICMS));
commesse.put(COMMESSE_DATAFINE, get_date(F_DATAFINECMS));
commesse.put(COMMESSE_PROROGA, get_bool(F_PROROGATA));
commesse.put(COMMESSE_DATAPROR, get_date(F_DATAPRORCMS));
commesse.put(COMMESSE_DATAINIZIO, get(F_DATAINICMS));
commesse.put(COMMESSE_DATAFINE, get(F_DATAFINECMS));
commesse.put(COMMESSE_PROROGA, get_bool(F_PROROGATA));
commesse.put(COMMESSE_DATAPROR, get(F_DATAPRORCMS));
//solo la rewrite perchè la commessa ovviamente esiste già
err = commesse.rewrite();
}
@ -658,10 +667,8 @@ bool TVariazione_budget_mask::save_sheet()
FOR_EACH_SHEET_ROW(sf_righe, r, riga)
{
const long numreg = sf_righe.row(r).get_long(_pos_numreg);
if (numreg > 0)
r = modifica_movana(numreg, sf_righe, r);
} //FOR_EACH_SHEET_ROW(...
//riordina lo sheet per chiave numreg; in questo modo le righe senza numreg vanno all'inizio e vengono..
@ -679,11 +686,10 @@ bool TVariazione_budget_mask::save_sheet()
break;
n = crea_movana(sf_righe, n);
} //FOR_EACH_SHEET_ROW(sf_righe,n...
//le righe vanno rimesse in ordine di chiave cdc/fase/conto
load();
set_status(load() > 0);
return true;
}
@ -705,7 +711,6 @@ bool TVariazione_budget_mask::save()
bool TVariazione_budget_mask::one_checked() const
{
TSheet_field& sf_righe = sfield(F_RIGHE);
FOR_EACH_SHEET_ROW(sf_righe, i, riga)
{
if (riga->get_char(0) > ' ')
@ -762,11 +767,11 @@ int TVariazione_budget_mask::load()
query << "TO CODCMS=#CODCMS\n";
//instanzio un TISAM_recordset sulle rmovana
TISAM_recordset rmovana(query);
const TString cms = get(F_CODCMS);
const TString& cms = get(F_CODCMS);
rmovana.set_var("#CODCMS", cms);
const long rmovana_items = rmovana.items();
TProgind pi(rmovana_items, "Generazione righe in corso...", true, true);
TProgind pi(rmovana_items, TR("Caricamento righe..."), true, true);
//recupero sheet e realtiva mashera di riga
TSheet_field& sf_righe = sfield(F_RIGHE);
@ -842,10 +847,8 @@ int TVariazione_budget_mask::load()
{
//solo le righe a saldo preventivo nullo vanno considerate
const TString& str_saldo_prev = riga->get(_pos_prev);
if (str_saldo_prev == "")
{
if (str_saldo_prev.blank())
aggiorna_saldi_preventivi(sf_righe, i);
}
}
//e poi aggiorna il video!
@ -862,38 +865,16 @@ int TVariazione_budget_mask::load()
///////////////////////////////////////
class TVariazione_budget : public TSkeleton_application
{
virtual bool check_autorization() const { return false; }
virtual const char * extra_modules() const { return "ca"; }
TVariazione_budget_mask* _msk;
protected:
public:
virtual bool create();
virtual bool destroy();
virtual bool check_autorization() const { return false; }
virtual const char* extra_modules() const { return "ca"; }
virtual void main_loop();
TVariazione_budget() {};
};
bool TVariazione_budget::create()
{
_msk = new TVariazione_budget_mask();
return TSkeleton_application::create();
}
bool TVariazione_budget::destroy()
{
delete _msk;
return TApplication::destroy();
}
void TVariazione_budget::main_loop()
{
KEY tasto;
tasto = _msk->run();
TVariazione_budget_mask msk;
msk.run();
}
int ps1001300 (int argc, char* argv[])
@ -901,4 +882,4 @@ int ps1001300 (int argc, char* argv[])
TVariazione_budget main_app;
main_app.run(argc, argv, TR("Gestione budget per commessa"));
return true;
}
}

View File

@ -6,6 +6,7 @@ BUTTON DLG_SAVEREC 2 2
BEGIN
PROMPT 1 1 "~Salva"
PICTURE TOOL_SAVEREC
GROUP 3
END
BUTTON DLG_NULL 4 2
@ -18,6 +19,7 @@ BUTTON DLG_CHECKALL 2 2
BEGIN
PROMPT 3 1 "~Tutti"
PICTURE TOOL_MULTISEL
GROUP 3
END
BUTTON DLG_NULL
@ -30,24 +32,21 @@ BUTTON DLG_TODATAINI
BEGIN
PROMPT 5 1 "All.~Ini"
PICTURE TOOL_TODATAINI
GROUP 3
END
BUTTON DLG_TODATAFIN
BEGIN
PROMPT 6 1 "All.~Fin"
PICTURE TOOL_TODATAFIN
GROUP 3
END
BUTTON DLG_TOMATURATO
BEGIN
PROMPT 7 1 "All.~Mat"
PICTURE TOOL_TOCALC
END
BUTTON DLG_NULL
BEGIN
PROMPT 8 1 ""
PICTURE 0
GROUP 3
END
#include <cancelbar.h>
@ -91,24 +90,28 @@ END
DATE F_DATAINICMS
BEGIN
PROMPT 1 2 "Inizio "
GROUP 3
END
DATE F_DATAFINECMS
BEGIN
PROMPT 22 2 "Fine "
GROUP 3
END
BOOL F_PROROGATA
BEGIN
PROMPT 43 2 "Prorogata"
MESSAGE FALSE CLEAR,F_DATAPRORCMS
MESSAGE TRUE ENABLE,F_DATAPRORCMS
MESSAGE FALSE HIDE,F_DATAPRORCMS
MESSAGE TRUE SHOW,F_DATAPRORCMS
GROUP 3
END
DATE F_DATAPRORCMS
BEGIN
PROMPT 57 2 "Proroga "
CHECKTYPE REQUIRED
GROUP 3
END
GROUPBOX DLG_NULL 78 3
@ -126,7 +129,7 @@ END
STRINGA F_CODCAUS 3
BEGIN
PROMPT 24 5 "Causale "
USE LF_CAUSALI SELECT MOVIND!=''
USE LF_CAUSALI SELECT MOVIND!=""
INPUT CODCAUS F_CODCAUS
DISPLAY "Codice" CODCAUS
DISPLAY "Descrizione@50" DESCR
@ -147,9 +150,9 @@ BEGIN
CHECKTYPE REQUIRED
END
TEXT -1
TEXT DLG_NULL
BEGIN
PROMPT 0 7 "@bRighe movimenti di budget"
PROMPT -11 7 "@bRighe movimenti di budget"
END
SPREADSHEET F_RIGHE
@ -177,52 +180,52 @@ ENDPAGE
PAGE "Istruzioni " 0 2 0 0
TEXT -1
TEXT DLG_NULL
BEGIN
PROMPT 1 1 "_ Le date della commessa possono essere modificate."
END
TEXT -1
TEXT DLG_NULL
BEGIN
PROMPT 1 2 "_ I pulsanti All.Ini, All.Fin, All.Mat hanno effetto solo sulle righe il cui primo campo è spuntato"
END
TEXT -1
TEXT DLG_NULL
BEGIN
PROMPT 1 3 "_ All.Ini (Allinea all'Inizio) allinea le date di competenza alla data inizio commessa"
END
TEXT -1
TEXT DLG_NULL
BEGIN
PROMPT 1 4 "_ All.Fin (Allinea alla Fine) allinea le date di fine competenza alla data fine commessa"
END
TEXT -1
TEXT DLG_NULL
BEGIN
PROMPT 1 5 "_ All.Mat (Allinea al Maturato) modifica gli importi in modo da portare il Preventivo al valore del Maturato"
END
TEXT -1
TEXT DLG_NULL
BEGIN
PROMPT 1 6 "_ E' possibile modificare manualmente gli importi sulle righe, il Preventivo viene ricalcolato di conseguenza"
END
TEXT -1
TEXT DLG_NULL
BEGIN
PROMPT 1 7 "_ In fase di registrazione vengono eliminate le righe ad importo nullo (azzerare quindi l'importo se si"
END
TEXT -1
TEXT DLG_NULL
BEGIN
PROMPT 1 8 " desidera rimuovere una riga)."
END
TEXT -1
TEXT DLG_NULL
BEGIN
PROMPT 1 9 "_ In fase di registrazione le nuove righe vengono assegnate a nuovi movimenti analitici preventivi"
END
TEXT -1
TEXT DLG_NULL
BEGIN
PROMPT 1 10 "_ Il pulsante Tutti spunta le righe, una per ogni chiave Sede/Fase/Conto"
END