Risolti problemucci in elaborazioni differite per DBService

git-svn-id: svn://10.65.10.50/branches/R_10_00@22788 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2013-01-25 08:45:36 +00:00
parent 7e9f0d51c5
commit 06cfa6bf68
3 changed files with 79 additions and 81 deletions

View File

@ -263,7 +263,7 @@ const TString_array& TTipo_documento::sheet_columns() const
TConfig prof(pn, "SHEET");
for (int i = 0; i < MAX_COLUMNS; i++)
{
const TString& id = prof.get("Col", NULL, i);
const TString& id = prof.get("Col", NULL, i);
if (atoi(id) <= 0)
break;
((TString_array&)_sheet_columns).add(id);
@ -297,10 +297,10 @@ void TTipo_documento::set_defaults(TMask& m) const
{
TFilename pn; profile_name(pn);
TConfig prof(pn, "DEFAULT");
TToken_string s;
for(int i = 0; ; i++)
{
TToken_string s(prof.get("Default", NULL, i));
s = prof.get("Default", NULL, i);
if (s.empty())
break;
const int field = s.get_int();

View File

@ -993,7 +993,6 @@ void TDocumento_mask::cli2mask(bool force_load)
set(F_CODPAG, c.get(CLI_CODPAG));
TToken_string key;
key.add(c.get(CLI_TIPOCF));
key.add(c.get(CLI_CODCF));
key.add("V");
@ -3267,6 +3266,8 @@ bool TElabora_mask::elabora()
TParametri_elaborazione& p = e->params();
set(F_QTA, p.get("QUANTITA"));
}
// Toglie spunta ai documenti selezionati
_tree.toggle_all_nodes();
}
const TString8 num_in = e->codice_numerazione_iniziale();
set(F_CODNUM_ELAB, num_in);

View File

@ -713,16 +713,13 @@ bool codmag_coll_handler( TMask_field& f, KEY key )
return true;
}
void upd_colli_peso_tara(TMask& m, const TString & codart)
{
// const real qta = m.get_real(FR_QTA) * curr_fc; // curr_fc puo' non essere inizializzata e vale -1
// Usando il metodo apposito di TArticolo non si sbaglia micca mai.
// Sarebbe bene sparare (come dice Luca) a curr_fc ovunque copaia
TArticolo & articolo = cached_article(codart);
TArticolo& articolo = cached_article(codart);
const real qta = articolo.convert_to_um(m.get_real(FR_QTA), NULL, m.get(FR_UMQTA));
const real ppcollo = articolo.get_real(ANAMAG_PPCOLLO);
real ncolli = ppcollo.is_zero() ? UNO : qta / ppcollo;
@ -1602,6 +1599,7 @@ bool codart_handler(TMask_field& f, KEY key )
if (key == K_TAB && (f.focusdirty() || row_mask.get(FR_CHECKED).empty()))
{
// cached_article(NULL); // Azzera cache articoli nel caso l'utente abbia cambiato pesi
TCond_vendita & condv = mask.condv();
condv.set_testa(&mask);
@ -1725,7 +1723,7 @@ bool codart_handler(TMask_field& f, KEY key )
else
{
curr_um.cut(0);
curr_fc = 1.0;
curr_fc = UNO;
}
row_mask.set(FR_UMQTA, curr_um);
upd_colli_peso_tara(row_mask, codart);
@ -1783,91 +1781,90 @@ bool codart_handler(TMask_field& f, KEY key )
if (mask.gestione_note_per_articolo())
mask.send_key(K_F8, F_NAR, &sh);
}
}
else
if (key == K_F8 && !row_mask.is_running())
} else
if (key == K_F8 && !row_mask.is_running())
{
const bool explode_db = ini_get_bool(CONFIG_DITTA, "ve", "EXPLODEDB");
if (explode_db && !sh.sheet_mask().is_running())
{
const bool explode_db = ini_get_bool(CONFIG_DITTA, "ve", "EXPLODEDB");
const bool valcomp = ini_get_bool(CONFIG_DITTA, "ve", "VALCOMP");
const bool matbase = ini_get_bool(CONFIG_DITTA, "ve", "TIPOESPL");
const TExplosion_grouping raggart = (TExplosion_grouping) ini_get_int(CONFIG_DITTA, "ve", "RAGGART");
const bool elrorig = ini_get_bool(CONFIG_DITTA, "ve", "ELRORIG");
const int livello = ini_get_int(CONFIG_DITTA, "ve", "LIVESPL");
const int ordin = ini_get_int(CONFIG_DITTA, "ve", "ORDDB");
TDocumento & doc = mask.doc();
TRiga_documento & curr_row = doc[current_doc_row];
const int start_level = curr_row.get_int(RDOC_LEVEL);
if (explode_db && !sh.sheet_mask().is_running())
{
const bool valcomp = ini_get_bool(CONFIG_DITTA, "ve", "VALCOMP");
const bool matbase = ini_get_bool(CONFIG_DITTA, "ve", "TIPOESPL");
const TExplosion_grouping raggart = (TExplosion_grouping) ini_get_int(CONFIG_DITTA, "ve", "RAGGART");
const bool elrorig = ini_get_bool(CONFIG_DITTA, "ve", "ELRORIG");
const int livello = ini_get_int(CONFIG_DITTA, "ve", "LIVESPL");
const int ordin = ini_get_int(CONFIG_DITTA, "ve", "ORDDB");
TDocumento & doc = mask.doc();
TRiga_documento & curr_row = doc[current_doc_row];
const int start_level = curr_row.get_int(RDOC_LEVEL);
sh.update_row(current_doc_row - 1);
curr_row.autosave(sh);
sh.update_row(current_doc_row - 1);
curr_row.autosave(sh);
TDistinta_tree db;
TArray components;
TDistinta_tree db;
TArray components;
db.set_root(curr_row);
db.set_root(curr_row);
const int items = db.explode(components, matbase, raggart, livello, "A", ordin);
if (items > 0)
{
TProgind pi(items, TR("Esplosione in corso..."), false, true);
int row = current_doc_row;
const TString16 tiporiga(curr_row.tipo().codice());
const int items = db.explode(components, matbase, raggart, livello, "A", ordin);
if (items > 0)
{
TProgind pi(items, TR("Esplosione in corso..."), false, true);
int row = current_doc_row;
const TString16 tiporiga(curr_row.tipo().codice());
TString_array& str_arr = sh.rows_array();
TString_array& str_arr = sh.rows_array();
for (int i = components.first(); i < items; i = components.succ(i))
{
pi.addstatus(1L);
TRiga_esplosione & r = (TRiga_esplosione &) components[i];
sh.insert(row, false, true);
TRiga_documento & new_row = doc[row + 1];
for (int i = components.first(); i < items; i = components.succ(i))
TDocumento::copy_data(new_row, curr_row);
new_row.put(RDOC_CODART, r.articolo());
new_row.put(RDOC_CODARTMAG, r.articolo());
new_row.put(RDOC_LIVELLO, r.giacenza());
new_row.zero(RDOC_DESCR);
new_row.zero(RDOC_DESCLUNGA);
new_row.zero(RDOC_DESCEST);
new_row.put(RDOC_CHECKED, "");
new_row.put(RDOC_UMQTA, r.um());
new_row.put(RDOC_GENERATA, "X");
new_row.put(RDOC_QTA, r.val() /* * qta_fin */);
const int level = start_level + r.livello();
new_row.put(RDOC_LEVEL, level);
if (!valcomp)
{
pi.addstatus(1L);
TRiga_esplosione & r = (TRiga_esplosione &) components[i];
sh.insert(row, false, true);
TRiga_documento & new_row = doc[row + 1];
TDocumento::copy_data(new_row, curr_row);
new_row.put(RDOC_CODART, r.articolo());
new_row.put(RDOC_CODARTMAG, r.articolo());
new_row.put(RDOC_LIVELLO, r.giacenza());
new_row.zero(RDOC_DESCR);
new_row.zero(RDOC_DESCLUNGA);
new_row.zero(RDOC_DESCEST);
new_row.put(RDOC_CHECKED, "");
new_row.put(RDOC_UMQTA, r.um());
new_row.put(RDOC_GENERATA, "X");
new_row.put(RDOC_QTA, r.val() /* * qta_fin */);
const int level = start_level + r.livello();
new_row.put(RDOC_LEVEL, level);
if (!valcomp)
{
new_row.zero(RDOC_PREZZO);
sh.row(row).add("0", sh.cid2index(FR_PREZZO));
row_mask.reset(FR_PREZZO);
}
new_row.autoload(sh);
sh.check_row(row);
new_row.autosave(sh); // Da sheet a rdoc
row++;
new_row.zero(RDOC_PREZZO);
sh.row(row).add("0", sh.cid2index(FR_PREZZO));
row_mask.reset(FR_PREZZO);
}
if (elrorig)
{
doc.destroy_row(current_doc_row, true);
sh.destroy(current_doc_row - 1, false);
row--;
}
else
if (valcomp)
{
curr_row.zero(RDOC_PREZZO);
curr_row.autoload(sh);
}
sh.force_update();
sh.post_select(current_doc_row - 1);
sh.update_mask(current_doc_row - 1);
new_row.autoload(sh);
sh.check_row(row);
new_row.autosave(sh); // Da sheet a rdoc
row++;
}
if (elrorig)
{
doc.destroy_row(current_doc_row, true);
sh.destroy(current_doc_row - 1, false);
row--;
}
else
if (valcomp)
{
curr_row.zero(RDOC_PREZZO);
curr_row.autoload(sh);
}
sh.force_update();
sh.post_select(current_doc_row - 1);
sh.update_mask(current_doc_row - 1);
}
mask.update_giacenza();
}
mask.update_giacenza();
}
return true;
}