Patch level : 10.0 109

Files correlati     :
Ricompilazione Demo : [ ]
Commento           :

Riportata la versione 3.2 1208


git-svn-id: svn://10.65.10.50/trunk@17100 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
alex 2008-08-27 09:20:30 +00:00
parent c485d4bf4d
commit 4f9ea774d6
6 changed files with 367 additions and 154 deletions

View File

@ -1,6 +1,8 @@
#include "dblib.h" #include "dblib.h"
#include <automask.h> #include <automask.h>
#include <date.h>
#include <defmask.h>
#include <execp.h> #include <execp.h>
#include <modaut.h> #include <modaut.h>
#include <progind.h> #include <progind.h>
@ -15,33 +17,6 @@
#include "db0500a.h" #include "db0500a.h"
///////////////////////////////////////////////////////////
// Funzione di richiesta stringa che andra' in libreria
///////////////////////////////////////////////////////////
#include <defmask.h>
bool copy_on_code(const char * oldcode, TString& newcode, int width = 50, const char* flags= "")
{
int maskwidth = width+18;
if (maskwidth < 26)
maskwidth = 26;
if (maskwidth > 78)
maskwidth = 78;
TMask m(TR("Copia codice"), 1, maskwidth, 5);
m.add_string(DLG_USER+1, 0, TR("Vecchio codice "), 1, 1, width, "D", width > 76 ? 76 : width);
m.add_string(DLG_USER, 0, TR("Nuovo codice "), 1, 2, width, flags, width > 76 ? 76 : width);
m.add_button(DLG_OK, 0, "", -12, -1, 10, 2);
m.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2);
m.set(DLG_USER+1, oldcode);
m.set(DLG_USER, newcode);
bool ok = m.run() == K_ENTER;
if (ok)
newcode = m.get(DLG_USER);
return ok;
}
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// TDistinta_app // TDistinta_app
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -141,12 +116,25 @@ class TQuery_mask : public TAutomask
{ {
TDistinta_tree& _tree; TDistinta_tree& _tree;
TToken_string _curr; TToken_string _curr;
TCodart_livelli _livart;
TCodgiac_livelli _livgiac; TCodgiac_livelli _livgiac;
bool redraw_tree(TField_event e); bool redraw_tree(TField_event e);
protected: protected:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
void create_browse1(TEdit_field& kfld, int level, short key_id) const;
bool ask_new_code(const TCodice_articolo& oldcode, TCodice_articolo& newcode) const;
bool are_similar(const TCodice_articolo& oldcode, const TCodice_articolo& newcode) const;
bool generate_subcode(const TCodice_articolo& oldcode, const TCodice_articolo& newcode,
const TCodice_articolo& oldsub, TCodice_articolo& newsub) const;
bool copy_article_rows(const int lfile, const TCodice_articolo& oldcode, const TCodice_articolo& newcode) const;
bool copy_article(const TCodice_articolo& oldcode, const TCodice_articolo& newcode) const;
bool copy_distinct(const TCodice_articolo& oldcode, const TCodice_articolo& newcode, bool recursive);
public: public:
const TToken_string& curr() const { return _curr; } const TToken_string& curr() const { return _curr; }
bool restart_tree(); bool restart_tree();
@ -155,6 +143,273 @@ public:
virtual ~TQuery_mask() { } virtual ~TQuery_mask() { }
}; };
void TQuery_mask::create_browse1(TEdit_field& kfld, int level, short key_id) const
{
TFilename tmp; tmp.temp();
ofstream out(tmp);
out << "USE GCA" << endl; //usa la tabella dei livelli articolo
const short id = key_id + level - 1;
const TString& prompt = _livart.name(level);
const TString& picture = _livart.picture(level);
out << "IN CODTAB[1,1] \"" << level << "\"" << endl;
out << "IN CODTAB[2,0] " << id << endl;
out << "DI \"" << prompt;
const int length = _livart.code_length(level);
if (length > prompt.len())
out << '@' << length;
out << "\" CODTAB[2,0]" << endl;
out << "DI \"" << TR("Descrizione") << "@50\" S0" << endl;
out << "OU " << id << " CODTAB[2,0]" << endl;
if (level == 1)
out << "CH RE" << endl;
else
out << "CH NO" << endl;
out << "EN" << endl;
out.close();
TScanner scan(tmp);
while (scan.pop() != "EN")
kfld.parse_item(scan);
xvt_fsys_removefile(tmp);
}
bool TQuery_mask::ask_new_code(const TCodice_articolo& oldcode, TCodice_articolo& newcode) const
{
if (newcode.blank())
newcode = oldcode;
const int last_level = _livart.last_level();
const int width = last_level > 0 ? _livart.packed_length(last_level)+last_level*3+16 : 38;
TMask m(TR("Copia articolo/distinta"), 1, width, 5);
m.add_static(DLG_NULL, 0, PR("Vecchio codice "), 1, 1);
m.add_static(DLG_NULL, 0, PR("Nuovo codice "), 1, 2);
int tab0 = 16;
if (last_level > 0)
{
for (int i = 1; i <= last_level; i++) //cicla su tutti i livelli del codart abilitati
{
const TString& picture = _livart.picture(i);
for (int y = 0; y < 2; y++)
{
if (y == 1)
{
TString4 flags = "BU";
if (picture[0] == '0')
flags << 'Z';
TEdit_field& kfld = m.add_string(200+i, 0, "", tab0, y+1, picture.len(), flags);
create_browse1(kfld, i, 201);
}
else
m.add_string(100+i, 0, "", tab0, y+1, picture.len(), "D");
}
m.set(100+i, _livart.unpack_grpcode(oldcode, i));
m.set(200+i, _livart.unpack_grpcode(newcode, i));
tab0 += picture.len()+3;
}
}
else
{
m.add_string(101, 0, "", tab0, 1, 20, "D");
m.add_string(201, 0, "", tab0, 2, 20, "U");
m.set(101, oldcode);
m.set(201, newcode);
}
m.add_button(DLG_OK, 0, "", -12, -1, 10, 2);
m.add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2);
if (m.run() == K_ENTER)
{
if (last_level > 0)
_livart.pack_maskgrpcodes(newcode, m, 201, last_level);
else
newcode = m.get(201);
}
return newcode.full() && newcode != oldcode;
}
bool TQuery_mask::copy_article_rows(const int lfile, const TCodice_articolo& oldcode, const TCodice_articolo& newcode) const
{
bool ok = true;
// NRIGA vale per tutte le righe dei file connessi ad ANAMAG: CODCORR, DESLIN e UMART
TRecord_array um(lfile, "NRIGA");
um.renum_key(ANAMAG_CODART, oldcode);
um.read(um.key());
if (um.rows() > 0)
{
um.renum_key(ANAMAG_CODART, newcode);
ok = um.write() == NOERR;
}
return ok;
}
bool TQuery_mask::copy_article(const TCodice_articolo& oldcode, const TCodice_articolo& newcode) const
{
TLocalisamfile anamag(LF_ANAMAG);
anamag.put(ANAMAG_CODART, newcode);
bool ok = anamag.read() != NOERR;
if (ok)
{
anamag.put(ANAMAG_CODART, oldcode);
ok = anamag.read() == NOERR;
if (ok)
{
anamag.put(ANAMAG_CODART, newcode);
ok = anamag.write() == NOERR;
if (ok)
{
copy_article_rows(LF_CODCORR, oldcode, newcode);
copy_article_rows(LF_DESLIN, oldcode, newcode);
copy_article_rows(LF_UMART, oldcode, newcode);
}
}
}
return ok;
}
// Confornta due codici articolo diversi e dice che sono simili
// solo se hanno una parte dei sottocodici uguali
bool TQuery_mask::are_similar(const TCodice_articolo& oldcode,
const TCodice_articolo& newcode) const
{
const int last = _livart.last_level();
if (last <= 1)
return false;
int uguali = 0, diversi = 0;
for (int l = 1; l <= last; l++)
{
const TString oldstr = _livart.unpack_grpcode(oldcode, l);
if (oldstr.empty()) // Ultimo pezzo facoltativo?
break;
const TString newstr = _livart.unpack_grpcode(newcode, l);
if (oldstr == newstr)
uguali++;
else
diversi++;
}
return (diversi > 0) && (uguali > 0); // (uguali*diversi)!=0
}
bool TQuery_mask::generate_subcode(const TCodice_articolo& oldcode,
const TCodice_articolo& newcode,
const TCodice_articolo& oldsub,
TCodice_articolo& newsub) const
{
newsub = oldsub;
const int last = _livart.last_level();
for (int l = 1; l <= last; l++)
{
const TString oldstr = _livart.unpack_grpcode(oldcode, l);
if (oldstr.empty()) // Ultimo pezzo facoltativo?
break;
const TString newstr = _livart.unpack_grpcode(newcode, l);
const TString substr = _livart.unpack_grpcode(oldsub, l);
if (oldstr != newstr && oldstr == substr)
newsub.overwrite(newstr, _livart.code_start(l)-1);
}
return newsub != oldsub;
}
bool TQuery_mask::copy_distinct(const TCodice_articolo& oldcode,
const TCodice_articolo& newcode, bool recursive)
{
bool ok = oldcode.full() && newcode.full() && oldcode != newcode;
if (ok)
{
TLocalisamfile dist(LF_DIST);
dist.put("CODDIST", oldcode);
ok = dist.read() == NOERR;
if (ok)
{
// Se la vecchia distinta corrisponde ad un articolo di magazzino
// anche la nuova avra' il suo nuovo articolo corrispondente
const TRectype& oldartrec = cache().get(LF_ANAMAG, oldcode);
TRectype newartrec = cache().get(LF_ANAMAG, newcode);
if (!oldartrec.empty() && newartrec.empty())
{
copy_article(oldcode, newcode);
cache().discard(LF_ANAMAG, newcode); // Annulla record vuoto in cache
newartrec = cache().get(LF_ANAMAG, newcode);
}
dist.put("CODDIST", newcode);
if (!newartrec.empty())
{
// Copio la descrizione dall'articolo collegato
dist.put("DESCR", newartrec.get("DESCR"));
// Determino l'unita' di misura predefinita
TToken_string umkey;
umkey << newcode << "|1";
const TString& um = cache().get(LF_UMART, umkey, "UM");
dist.put("UM", um);
}
else
{
dist.put("ARTPROD", " ");
const TRectype& lavrec = cache().get("LAV",newcode);
if (!lavrec.empty())
dist.put("DESCR",lavrec.get("S0"));
}
const int err = dist.write();
if (err != NOERR)
{
if (err == _isreinsert)
ok = error_box(FR("La distinta '%s' e' gia' presente"), (const char*)newcode);
else
ok = error_box(FR("Errore %d durante la registrazione della distinta '%s'"), err, (const char*)newcode);
}
}
else
ok = error_box(FR("Il codice '%s' non corrisponde ad una distinta valida"), (const char*)oldcode);
}
if (ok)
{
// copia le righe di distinta
TRecord_array rdist(LF_RDIST, "NRIG");
rdist.renum_key("CODDIST", oldcode);
if (rdist.read(rdist.key()) == NOERR)
{
rdist.renum_key("CODDIST", newcode);
if (recursive)
{
for (int r = rdist.last_row(); r > 0; r = rdist.pred_row(r))
{
TRectype& row = rdist.row(r, false); // Rewriteable row
const char row_type = row.get_char("TIPO");
// Tento rigenerazione del codice solo su articoli e distinte
if (row_type == 'A' || row_type == 'D')
{
const TCodice_articolo oldsub = row.get("CODCOMP");
TCodice_articolo newsub;
if (generate_subcode(oldcode, newcode, oldsub, newsub))
{
row.put("CODCOMP", newsub);
if (row_type == 'A')
copy_article(oldsub, newsub);
else
copy_distinct(oldsub, newsub, recursive);
}
}
}
}
rdist.write();
}
}
return ok;
}
bool TQuery_mask::restart_tree() bool TQuery_mask::restart_tree()
{ {
if (!_tree.restart()) if (!_tree.restart())
@ -271,82 +526,31 @@ bool TQuery_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
if (str.not_empty()) if (str.not_empty())
set(F_CODICEQ, str); set(F_CODICEQ, str);
else else
return FALSE; return false;
} }
break; break;
case F_COPY: case F_COPY:
if (e == fe_button) if (e == fe_button)
{ {
const TString oldcode = get(F_CODICE); const TCodice_articolo oldcode = get(F_CODICE);
if (oldcode.blank()) if (oldcode.blank())
error_box(TR("Selezionare un codice")); error_box(TR("Selezionare un codice"));
TLocalisamfile dist(LF_DIST);
dist.put("CODDIST", oldcode);
if (dist.read() == NOERR)
{
TString newcode;
if (copy_on_code(dist.get("CODDIST"),newcode, 20, "U"))
{
if (newcode.not_empty() && newcode != oldcode)
{
dist.put("CODDIST", newcode);
const TRectype & artrec = cache().get(LF_ANAMAG,newcode);
if (!artrec.empty())
{
dist.put("DESCR",artrec.get("DESCR"));
} else {
dist.put("ARTPROD", " ");
const TRectype & lavrec = cache().get("LAV",newcode);
if (!lavrec.empty())
dist.put("DESCR",lavrec.get("S0"));
}
TString environment=dist.get("PARAMETRI");
const int err = dist.write();
if (err == NOERR)
{
// copia le righe di distinta
TRecord_array rdist(LF_RDIST, "NRIG");
rdist.renum_key("CODDIST", oldcode);
if (rdist.read(rdist.key()) == NOERR)
{
rdist.renum_key("CODDIST", newcode);
rdist.write();
}
// copia le righe delle UM
TRecord_array um(LF_UMART, "NRIGA");
um.renum_key("CODART", newcode);
int err=um.read(um.key()) ;
if (um.rows() == 0)
err = _iskeynotfound;
switch (err)
{
case _isemptyfile:
case _iskeynotfound:
um.renum_key("CODART", oldcode);
if (um.read(um.key()) == NOERR )
{
um.renum_key("CODART", newcode);
um.write();
}
break;
case NOERR:
dist.put("UM", um.row(1).get("UM"));
break;
}
}
else else
{ {
if (err == _isreinsert) TCodice_articolo newcode;
error_box(FR("La distinta '%s' e' gia' stata inserita"), (const char*)newcode); if (ask_new_code(oldcode, newcode))
else {
error_box(FR("Errore %d durante la registrazione della distinta '%s'"), err, (const char*)newcode); bool recursive = are_similar(oldcode, newcode);
if (recursive)
recursive = yesno_box(TR("Si desidera riportare le modifiche al codice anche sui componenti?"));
if (copy_distinct(oldcode, newcode, recursive))
{
set(F_CODICEQ, newcode); // Passa in modifica della nuova disitinta
stop_run(K_ENTER);
} }
} }
} }
} }
else
error_box(FR("Il codice '%s' non corrisponde ad una distinta valida"), (const char*)oldcode);
}
break; break;
case F_EXPLODE: case F_EXPLODE:
if (e == fe_button) if (e == fe_button)
@ -1021,9 +1225,12 @@ bool TDistinta_mask::on_field_event(TOperable_field& o, TField_event e, long jol
} }
break; break;
case DLG_MOV: case DLG_MOV:
if (e == fe_button)
{
if (app().has_module(MGAUT)) if (app().has_module(MGAUT))
{ {
TMask mov("db0500d"); TSheet_field& sf = sfield(F_SHEET);
TMov_mask mov(get(F_CODICE), &sf);
TMagazzini m; TMagazzini m;
if (!m.gestmultimag()) if (!m.gestmultimag())
@ -1052,7 +1259,7 @@ bool TDistinta_mask::on_field_event(TOperable_field& o, TField_event e, long jol
TConfig c(name); TConfig c(name);
c.set_paragraph("Transaction"); c.set_paragraph("Transaction");
c.set("Action", "Insert"); c.set("Action", "Insert");
c.set("Mode", "A"); c.set("Mode", "");
c.set_paragraph(format("%d", LF_MOVMAG)); c.set_paragraph(format("%d", LF_MOVMAG));
c.set(MOVMAG_DATAREG, mov.get(F_DATAREG)); c.set(MOVMAG_DATAREG, mov.get(F_DATAREG));
c.set(MOVMAG_CODCAUS, mov.get(F_CODCAUS)); c.set(MOVMAG_CODCAUS, mov.get(F_CODCAUS));
@ -1067,9 +1274,20 @@ bool TDistinta_mask::on_field_event(TOperable_field& o, TField_event e, long jol
c.set(RMOVMAG_QUANT, mov.get(F_QUANT)); c.set(RMOVMAG_QUANT, mov.get(F_QUANT));
c.set(RMOVMAG_PREZZO, mov.get(F_PREZZOM)); c.set(RMOVMAG_PREZZO, mov.get(F_PREZZOM));
} }
TExternal_app app(format("mg1 -0 -i%s", (const char *)name)); TExternal_app app(format("mg1 -0 -i%s", (const char *)name));
app.run(); app.run();
const real prezzo(mov.get(F_PREZZOV));
TLocalisamfile umart(LF_UMART);
umart.put(UMART_CODART, get(F_CODICE));
umart.put(UMART_NRIGA, 1);
if (umart.read(_isequal, _testandlock) == NOERR)
{
umart.put(UMART_PREZZO, prezzo);
umart.rewrite();
}
}
} }
} }
break; break;

View File

@ -103,4 +103,7 @@
#define F_PREZZOM 127 #define F_PREZZOM 127
#define F_DESMAG 128 #define F_DESMAG 128
#define F_DESDEP 129 #define F_DESDEP 129
#define F_TIPOVAL 130
#define F_PREZZOV 131
#define F_SCONTO 132
#endif #endif

View File

@ -254,9 +254,7 @@ void TValorizzazione_mask::elabora()
bf.add_line(line); bf.add_line(line);
} }
if (pi.isfinished())
enable(DLG_SAVEREC); enable(DLG_SAVEREC);
vw.goto_top(); vw.goto_top();
} }
@ -331,12 +329,9 @@ void TValorizzazione_mask::salva()
} }
} }
if (pi.isfinished())
{
_valori.destroy(); _valori.destroy();
_risultati.destroy(); _risultati.destroy();
disable(DLG_SAVEREC); disable(DLG_SAVEREC);
}
} }
bool TValorizzazione_mask::on_field_event(TOperable_field& f, TField_event e, long jolly) bool TValorizzazione_mask::on_field_event(TOperable_field& f, TField_event e, long jolly)

View File

@ -1797,12 +1797,13 @@ TLavorazione *TDistinta_tree::find_labor(TRiga_esplosione *l)
// TRiga_esplosione // TRiga_esplosione
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
void TRiga_esplosione::init(const TDistinta_tree& tree, bool vis_ghost, const TRectype * rec) void TRiga_esplosione::init(const TDistinta_tree& tree, bool vis_ghost)
{ {
TCodice_articolo art; tree.curr_code(art); art.trim(); tree.curr_code(_comp); _comp.trim();
tree.father_code(_dist); _dist.trim();
TCodice_um um; tree.curr_um(um); TCodice_um um; tree.curr_um(um);
real val = tree.curr_qta(); real val = tree.curr_qta();
set(art, um, val); set(_comp, um, val);
_last_qta = tree.last_qta(vis_ghost); // Puo' sempre servire anche questa _last_qta = tree.last_qta(vis_ghost); // Puo' sempre servire anche questa
tree.curr_giaclev(_giac); tree.curr_giaclev(_giac);
_tipo = tree.curr_type(); _tipo = tree.curr_type();
@ -1810,10 +1811,6 @@ void TRiga_esplosione::init(const TDistinta_tree& tree, bool vis_ghost, const TR
_mat_base = FALSE; _mat_base = FALSE;
// set path and code // set path and code
tree.curr_id(_path); // path tree.curr_id(_path); // path
if (rec != NULL)
_rdist = new TRectype(*rec);
else
_rdist = NULL;
} }
const char * TRiga_esplosione::father(const char * types) const char * TRiga_esplosione::father(const char * types)

View File

@ -399,11 +399,12 @@ class TRiga_esplosione : public TQuantita
char _tipo; char _tipo;
bool _mat_base; bool _mat_base;
real _last_qta; real _last_qta;
TRectype * _rdist; TCodice_articolo _comp;
TCodice_articolo _dist;
protected: protected:
virtual TObject* dup() const { return new TRiga_esplosione(*this); } virtual TObject* dup() const { return new TRiga_esplosione(*this); }
void init(const TDistinta_tree& tree, bool vis_ghost = FALSE, const TRectype * rec = NULL); void init(const TDistinta_tree& tree, bool vis_ghost = FALSE);
public: public:
const TToken_string& path() const { return _path; } const TToken_string& path() const { return _path; }
@ -420,10 +421,11 @@ public:
// cerca un padre o nonno di uno dei tipi passati // cerca un padre o nonno di uno dei tipi passati
const char * father(const char * types=NULL); const char * father(const char * types=NULL);
const real& last_qta() const { return _last_qta; } const real& last_qta() const { return _last_qta; }
const TRectype * rdist_rec() const { return _rdist;} t const TCodice_articolo & componente() const { return _comp; }
const TCodice_articolo & distinta() const { return _dist;}
TRiga_esplosione(); TRiga_esplosione();
TRiga_esplosione(const TDistinta_tree& tree, bool vis_ghost = false, const TRectype * rec = NULL); TRiga_esplosione(const TDistinta_tree& tree, bool vis_ghost = false);
TRiga_esplosione(const TRiga_esplosione& re); TRiga_esplosione(const TRiga_esplosione& re);
virtual ~TRiga_esplosione() { if (_rdist != NULL) delete _rdist;} virtual ~TRiga_esplosione() { if (_rdist != NULL) delete _rdist;}
}; };

View File

@ -2,8 +2,6 @@
#include <diction.h> #include <diction.h>
#include <relation.h> #include <relation.h>
#include <mov.h>
#include <rmov.h>
#include "../cg/cg2101.h" #include "../cg/cg2101.h"
#include "../cg/cglib02.h" #include "../cg/cglib02.h"