Esplosione tab
git-svn-id: svn://10.65.10.50/trunk@4711 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
ec1d41e5d7
commit
094ba28327
214
mg/mg0100.cpp
214
mg/mg0100.cpp
@ -19,77 +19,77 @@ class TMask_tabmag : public TMask
|
|||||||
{
|
{
|
||||||
TTable *aux_tabf;
|
TTable *aux_tabf;
|
||||||
TFile_cache *tab_cache;
|
TFile_cache *tab_cache;
|
||||||
TMetachar * metac[MAXMETACH];
|
TMetachar * metac[MAXMETACH];
|
||||||
|
|
||||||
static bool sumsign_handler(TMask_field &, KEY); // handler
|
static bool sumsign_handler(TMask_field &, KEY); // handler
|
||||||
static bool format_handler(TMask_field &, KEY); // handler dei metacaratteri
|
static bool format_handler(TMask_field &, KEY); // handler dei metacaratteri
|
||||||
static bool codliv_handler(TMask_field &, KEY); // handler del numero formato
|
static bool codliv_handler(TMask_field &, KEY); // handler del numero formato
|
||||||
static bool numform_handler(TMask_field &, KEY); // handler del numero formato
|
static bool numform_handler(TMask_field &, KEY); // handler del numero formato
|
||||||
static bool codlivgca_handler(TMask_field &, KEY); // handler del numero formato
|
static bool codlivgca_handler(TMask_field &, KEY); // handler del numero formato
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TMask_tabmag(const char * ,const TString16 &);
|
TMask_tabmag(const char * ,const TString16 &);
|
||||||
virtual ~TMask_tabmag();
|
virtual ~TMask_tabmag();
|
||||||
};
|
};
|
||||||
|
|
||||||
// costruttore della maschera
|
// costruttore della maschera
|
||||||
TMask_tabmag::TMask_tabmag(const char * _maskname,const TString16 &tabname):
|
TMask_tabmag::TMask_tabmag(const char * _maskname,const TString16 &tabname):
|
||||||
TMask(_maskname)
|
TMask(_maskname)
|
||||||
{
|
{
|
||||||
aux_tabf=NULL;
|
aux_tabf=NULL;
|
||||||
for (int i=0;i<MAXMETACH;i++)
|
for (int i=0;i<MAXMETACH;i++)
|
||||||
metac[i]=NULL;
|
metac[i]=NULL;
|
||||||
if (tabname == "CAU")
|
if (tabname == "CAU")
|
||||||
{
|
{
|
||||||
set_handler(F_SGNGIAC, sumsign_handler);
|
set_handler(F_SGNGIAC, sumsign_handler);
|
||||||
}
|
}
|
||||||
if (tabname == "FCA") // FORMATO CODICE ARTICOLI
|
if (tabname == "FCA") // FORMATO CODICE ARTICOLI
|
||||||
{
|
{
|
||||||
metac[0]=new TMetachar;
|
metac[0]=new TMetachar;
|
||||||
aux_tabf = new TTable("FCA");
|
aux_tabf = new TTable("FCA");
|
||||||
set_handler(F_FORMLIV, format_handler);
|
set_handler(F_FORMLIV, format_handler);
|
||||||
set_handler(F_CODLIV, codliv_handler);
|
set_handler(F_CODLIV, codliv_handler);
|
||||||
}
|
}
|
||||||
if (tabname == "GCA") // GRUPPI CODICE ARTICOLI
|
if (tabname == "GCA") // GRUPPI CODICE ARTICOLI
|
||||||
{
|
{
|
||||||
tab_cache = new TDecoder("FCA","S1");
|
tab_cache = new TDecoder("FCA","S1");
|
||||||
tab_cache->fill();
|
tab_cache->fill();
|
||||||
// crea i riconoscitori del formato
|
// crea i riconoscitori del formato
|
||||||
for (int i=1; ((TDecoder *)tab_cache)->decode(i)!="";i++)
|
for (int i=1; ((TDecoder *)tab_cache)->decode(i)!="";i++)
|
||||||
{
|
{
|
||||||
metac[i-1]=new TMetachar(((TDecoder *)tab_cache)->decode(i));
|
metac[i-1]=new TMetachar(((TDecoder *)tab_cache)->decode(i));
|
||||||
}
|
}
|
||||||
set_handler(F_CODLIV, codlivgca_handler);
|
set_handler(F_CODLIV, codlivgca_handler);
|
||||||
set_handler(F_CODGROUP, numform_handler);
|
set_handler(F_CODGROUP, numform_handler);
|
||||||
}
|
}
|
||||||
if (tabname == "FCG") // FORMATO CODICE GIACENZE
|
if (tabname == "FCG") // FORMATO CODICE GIACENZE
|
||||||
{
|
{
|
||||||
metac[0]=new TMetachar;
|
metac[0]=new TMetachar;
|
||||||
aux_tabf = new TTable("FCG");
|
aux_tabf = new TTable("FCG");
|
||||||
set_handler(F_FORMLIV, format_handler);
|
set_handler(F_FORMLIV, format_handler);
|
||||||
set_handler(F_CODLIV, codliv_handler);
|
set_handler(F_CODLIV, codliv_handler);
|
||||||
}
|
}
|
||||||
if (tabname == "GCG") // GRUPPI CODICE GIACENZE
|
if (tabname == "GCG") // GRUPPI CODICE GIACENZE
|
||||||
{
|
{
|
||||||
tab_cache = new TDecoder("FCG","S1");
|
tab_cache = new TDecoder("FCG","S1");
|
||||||
tab_cache->fill();
|
tab_cache->fill();
|
||||||
for (int i=1; ((TDecoder *)tab_cache)->decode(i)!="";i++)
|
for (int i=1; ((TDecoder *)tab_cache)->decode(i)!="";i++)
|
||||||
{
|
{
|
||||||
metac[i-1]=new TMetachar(((TDecoder *)tab_cache)->decode(i));
|
metac[i-1]=new TMetachar(((TDecoder *)tab_cache)->decode(i));
|
||||||
}
|
}
|
||||||
set_handler(F_CODGROUP, numform_handler);
|
set_handler(F_CODGROUP, numform_handler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TMask_tabmag::~TMask_tabmag()
|
TMask_tabmag::~TMask_tabmag()
|
||||||
{
|
{
|
||||||
if (aux_tabf!=NULL)
|
if (aux_tabf!=NULL)
|
||||||
delete aux_tabf;
|
delete aux_tabf;
|
||||||
for (int i=0;i<MAXMETACH;i++) {
|
for (int i=0;i<MAXMETACH;i++) {
|
||||||
if (metac[i]!=NULL)
|
if (metac[i]!=NULL)
|
||||||
delete metac[i];
|
delete metac[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// tabella causali: handler della somma segni
|
// tabella causali: handler della somma segni
|
||||||
@ -99,8 +99,8 @@ bool TMask_tabmag::sumsign_handler(TMask_field& f, KEY k)
|
|||||||
{
|
{
|
||||||
if (f.mask().get_int(F_SUMSIGN)!=0)
|
if (f.mask().get_int(F_SUMSIGN)!=0)
|
||||||
{
|
{
|
||||||
f.error_box("La somma dei segni \n((GIAC-RIM)-(ACQ+ENTR)+(VEN+USC)+(ACL-INCL)+(PRODF-PRODC) + SCARTI) \ndeve essere uguale a zero");
|
f.error_box("La somma dei segni \n((GIAC-RIM)-(ACQ+ENTR)+(VEN+USC)+(ACL-INCL)+(PRODF-PRODC) + SCARTI) \ndeve essere uguale a zero");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -122,23 +122,23 @@ bool TMask_tabmag::format_handler(TMask_field& f, KEY k)
|
|||||||
aux_tabf->put("CODTAB",mymask.get_int(F_CODLIV)+1);
|
aux_tabf->put("CODTAB",mymask.get_int(F_CODLIV)+1);
|
||||||
if (aux_tabf->read()==NOERR)
|
if (aux_tabf->read()==NOERR)
|
||||||
{
|
{
|
||||||
// esiste il seguente:solo caratteri obbligatori
|
// esiste il seguente:solo caratteri obbligatori
|
||||||
if (mymask.metac[0]->has_opzchars(s))
|
if (mymask.metac[0]->has_opzchars(s))
|
||||||
{
|
{
|
||||||
f.error_box("I caratteri di formato opzionali ('%s') sono consentiti solo per l'ultimo livello",mymask.metac[0]->opz_chars());
|
f.error_box("I caratteri di formato opzionali ('%s') sono consentiti solo per l'ultimo livello",mymask.metac[0]->opz_chars());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
} /*else {
|
} /*else {
|
||||||
// ultimo livello: almeno un carattere obbligatorio
|
// ultimo livello: almeno un carattere obbligatorio
|
||||||
// ELIMINATO
|
// ELIMINATO
|
||||||
if (!mymask.metac[0]->has_mandchars(s))
|
if (!mymask.metac[0]->has_mandchars(s))
|
||||||
{
|
{
|
||||||
f.error_box("Il codice dell'ultimo livello deve includere almeno un carattere obbligatorio (letterali o '%s') ",mymask.metac[0]->mand_chars());
|
f.error_box("Il codice dell'ultimo livello deve includere almeno un carattere obbligatorio (letterali o '%s') ",mymask.metac[0]->mand_chars());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
// setta il campo con la lunghezza massima della stringa di formato
|
// setta il campo con la lunghezza massima della stringa di formato
|
||||||
mymask.field(F_LENFORM).set(mymask.metac[0]->maxstrlen(f.get()));
|
mymask.field(F_LENFORM).set(mymask.metac[0]->maxstrlen(f.get()));
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -152,26 +152,26 @@ bool TMask_tabmag::codliv_handler(TMask_field& f, KEY k)
|
|||||||
TTable * aux_tabf=mymask.aux_tabf;
|
TTable * aux_tabf=mymask.aux_tabf;
|
||||||
int codliv=atoi((const char *)f.get());
|
int codliv=atoi((const char *)f.get());
|
||||||
|
|
||||||
if (codliv>1)
|
if (codliv>1)
|
||||||
// Non è il primo codice
|
// Non è il primo codice
|
||||||
{
|
{
|
||||||
aux_tabf->zero();
|
aux_tabf->zero();
|
||||||
aux_tabf->put("CODTAB",codliv-1);
|
aux_tabf->put("CODTAB",codliv-1);
|
||||||
if (aux_tabf->read()==NOERR)
|
if (aux_tabf->read()==NOERR)
|
||||||
// esiste un precedente
|
// esiste un precedente
|
||||||
{
|
{
|
||||||
TString prevformat(aux_tabf->get("S1"));
|
TString prevformat(aux_tabf->get("S1"));
|
||||||
aux_tabf->zero();
|
aux_tabf->zero();
|
||||||
aux_tabf->put("CODTAB",codliv+1);
|
aux_tabf->put("CODTAB",codliv+1);
|
||||||
if (aux_tabf->read()!=NOERR && mymask.metac[0]->has_opzchars(prevformat))
|
if (aux_tabf->read()!=NOERR && mymask.metac[0]->has_opzchars(prevformat))
|
||||||
{
|
{
|
||||||
f.error_box("Il livello precedente include caratteri opzionali nel formato\ne non puo' divenire un livello intermedio");
|
f.error_box("Il livello precedente include caratteri opzionali nel formato\ne non puo' divenire un livello intermedio");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
f.error_box("Non si possono inserire salti nel livello del codice");
|
f.error_box("Non si possono inserire salti nel livello del codice");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -185,12 +185,12 @@ bool TMask_tabmag::codlivgca_handler(TMask_field& f, KEY k)
|
|||||||
{
|
{
|
||||||
TMask_tabmag & mymask=((TMask_tabmag &)f.mask());
|
TMask_tabmag & mymask=((TMask_tabmag &)f.mask());
|
||||||
|
|
||||||
if (((TDecoder *)mymask.tab_cache)->decode(atoi((const char *)f.get())+1)=="")
|
if (((TDecoder *)mymask.tab_cache)->decode(atoi((const char *)f.get())+1)=="")
|
||||||
// non esiste un seguente
|
// non esiste un seguente
|
||||||
{
|
{
|
||||||
f.error_box("Non è possibile definire gruppi per l'ultimo livello di codice");
|
f.error_box("Non è possibile definire gruppi per l'ultimo livello di codice");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -204,11 +204,11 @@ bool TMask_tabmag::numform_handler(TMask_field& f, KEY k)
|
|||||||
{
|
{
|
||||||
TMask_tabmag & mymask=((TMask_tabmag &)f.mask());
|
TMask_tabmag & mymask=((TMask_tabmag &)f.mask());
|
||||||
|
|
||||||
if (!(mymask.metac[mymask.get_int(F_CODLIV)-1])->recognized(f.get()))
|
if (!(mymask.metac[mymask.get_int(F_CODLIV)-1])->recognized(f.get()))
|
||||||
{
|
{
|
||||||
f.error_box("Codice non corrispondente al formato previsto");
|
f.error_box("Codice non corrispondente al formato previsto");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -225,9 +225,9 @@ protected: // TRelation_application
|
|||||||
virtual bool user_create() ;
|
virtual bool user_create() ;
|
||||||
virtual bool protected_record(TRectype& rec) ;
|
virtual bool protected_record(TRectype& rec) ;
|
||||||
virtual int rewrite(const TMask& m);
|
virtual int rewrite(const TMask& m);
|
||||||
|
|
||||||
virtual TMask * set_mask(TMask * _m=NULL);
|
virtual TMask * set_mask(TMask * _m=NULL);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Tab_app_mag();
|
Tab_app_mag();
|
||||||
virtual ~Tab_app_mag() {}
|
virtual ~Tab_app_mag() {}
|
||||||
@ -245,45 +245,45 @@ bool Tab_app_mag::protected_record(TRectype& rec)
|
|||||||
|
|
||||||
if (!prot)
|
if (!prot)
|
||||||
{
|
{
|
||||||
if (get_tabname()=="FCA" ||get_tabname()=="FCG" )
|
if (get_tabname()=="FCA" ||get_tabname()=="FCG" )
|
||||||
{
|
{
|
||||||
// non si possono cancellare i livelli intermedi:se non è l'ultimo livello, proteggilo
|
// non si possono cancellare i livelli intermedi:se non è l'ultimo livello, proteggilo
|
||||||
TTable aux_tabf(get_tabname());
|
TTable aux_tabf(get_tabname());
|
||||||
aux_tabf.put("CODTAB",rec.get_int("CODTAB")+1);
|
aux_tabf.put("CODTAB",rec.get_int("CODTAB")+1);
|
||||||
if (aux_tabf.read()==NOERR)
|
if (aux_tabf.read()==NOERR)
|
||||||
prot=TRUE;
|
prot=TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return prot;
|
return prot;
|
||||||
}
|
}
|
||||||
|
|
||||||
// alloca/cambia la maschera dell'applicazione
|
// alloca/cambia la maschera dell'applicazione
|
||||||
TMask * Tab_app_mag::set_mask(TMask * _m)
|
TMask * Tab_app_mag::set_mask(TMask * _m)
|
||||||
{
|
{
|
||||||
if (_m != NULL)
|
if (_m != NULL)
|
||||||
return Tab_application::set_mask(_m);
|
return Tab_application::set_mask(_m);
|
||||||
else
|
else
|
||||||
return Tab_application::set_mask(new TMask_tabmag((const char *)mask_name(),get_tabname()));
|
return Tab_application::set_mask(new TMask_tabmag((const char *)mask_name(),get_tabname()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Tab_app_mag::user_create()
|
bool Tab_app_mag::user_create()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
la Tab_application::user_create() apre la maschera TMask in modo automatico
|
la Tab_application::user_create() apre la maschera TMask in modo automatico
|
||||||
basandosi sul parametro passato sulla linea di comando e sulla convenzione
|
basandosi sul parametro passato sulla linea di comando e sulla convenzione
|
||||||
nome = "BATB"+parametro;
|
nome = "BATB"+parametro;
|
||||||
ORA:
|
ORA:
|
||||||
- questa convenzione cambierà per separare i programmi (e le maschere)
|
- questa convenzione cambierà per separare i programmi (e le maschere)
|
||||||
dei vari pacchetti
|
dei vari pacchetti
|
||||||
In tal caso ridefinire il metodo virtual mask_name()
|
In tal caso ridefinire il metodo virtual mask_name()
|
||||||
- secondo il nuovo stile, gli handler vanno posti in maschere derivate
|
- secondo il nuovo stile, gli handler vanno posti in maschere derivate
|
||||||
dalla TMask (TMask_tabmag, TMask_tabcau, ecc), pertanto occorre che
|
dalla TMask (TMask_tabmag, TMask_tabcau, ecc), pertanto occorre che
|
||||||
la maschera aperta sia del tipo corretto
|
la maschera aperta sia del tipo corretto
|
||||||
per questo motivo la maschera viene creata dalla user_create()
|
per questo motivo la maschera viene creata dalla user_create()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool ok = Tab_application::user_create();
|
bool ok = Tab_application::user_create();
|
||||||
|
|
||||||
if (ok)
|
if (ok)
|
||||||
{
|
{
|
||||||
//TMask& mask = *set_mask();
|
//TMask& mask = *set_mask();
|
||||||
|
@ -11,10 +11,10 @@
|
|||||||
|
|
||||||
class TStampa_tabmag : public TApplication
|
class TStampa_tabmag : public TApplication
|
||||||
{
|
{
|
||||||
TMask * _mask;
|
TMask * _mask;
|
||||||
TForm * _form;
|
TForm * _form;
|
||||||
|
|
||||||
void set_print(TString & tabname);
|
void set_print(TString & tabname);
|
||||||
protected:
|
protected:
|
||||||
virtual bool create();
|
virtual bool create();
|
||||||
virtual bool destroy();
|
virtual bool destroy();
|
||||||
@ -22,55 +22,55 @@ protected:
|
|||||||
|
|
||||||
void TStampa_tabmag::set_print(TString & tabname)
|
void TStampa_tabmag::set_print(TString & tabname)
|
||||||
{
|
{
|
||||||
TString filter;
|
TString filter;
|
||||||
TRectype from_rec(LF_TAB),to_rec(LF_TAB);
|
TRectype from_rec(LF_TAB),to_rec(LF_TAB);
|
||||||
from_rec.put("COD",tabname);
|
from_rec.put("COD",tabname);
|
||||||
from_rec.put("CODTAB",_mask->get(F_INIZIO1));
|
from_rec.put("CODTAB",_mask->get(F_INIZIO1));
|
||||||
to_rec.put("COD",tabname);
|
to_rec.put("COD",tabname);
|
||||||
to_rec.put("CODTAB",_mask->get(F_FINE1));
|
to_rec.put("CODTAB",_mask->get(F_FINE1));
|
||||||
if (tabname=="FCA" || tabname=="FCG") {
|
if (tabname=="FCA" || tabname=="FCG") {
|
||||||
if (*_mask->get(F_INIZIO2))
|
if (*_mask->get(F_INIZIO2))
|
||||||
filter << "500@->CODTAB[2,20]>=" << _mask->get(F_INIZIO2);
|
filter << "500@->CODTAB[2,20]>=" << _mask->get(F_INIZIO2);
|
||||||
if (filter.not_empty())
|
if (filter.not_empty())
|
||||||
filter << "&&";
|
filter << "&&";
|
||||||
if (*_mask->get(F_FINE2))
|
if (*_mask->get(F_FINE2))
|
||||||
filter << "500@->CODTAB[2,20]<=" << _mask->get(F_FINE2);
|
filter << "500@->CODTAB[2,20]<=" << _mask->get(F_FINE2);
|
||||||
_form->find_field('B',odd_page,"GRUPPI").show(_mask->get_bool(F_DETTAGLIO));
|
_form->find_field('B',odd_page,"GRUPPI").show(_mask->get_bool(F_DETTAGLIO));
|
||||||
}
|
}
|
||||||
_form->cursor()->setregion(from_rec,to_rec);
|
_form->cursor()->setregion(from_rec,to_rec);
|
||||||
if (filter.not_empty())
|
if (filter.not_empty())
|
||||||
_form->cursor()->setfilter(filter);
|
_form->cursor()->setfilter(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TStampa_tabmag::create()
|
bool TStampa_tabmag::create()
|
||||||
{
|
{
|
||||||
TString16 maskname("bast");
|
TString16 maskname("bast");
|
||||||
TString16 formname("tab_");
|
TString16 formname("tab_");
|
||||||
TString16 tabname(argv(2));
|
TString16 tabname(argv(2));
|
||||||
tabname.upper();
|
tabname.upper();
|
||||||
|
|
||||||
maskname << tabname;
|
maskname << tabname;
|
||||||
formname << tabname;
|
formname << tabname;
|
||||||
|
|
||||||
_mask = new TMask(maskname);
|
_mask = new TMask(maskname);
|
||||||
while ((_mask->run() == K_ENTER)) {
|
while ((_mask->run() == K_ENTER)) {
|
||||||
_form = new TForm(formname);
|
_form = new TForm(formname);
|
||||||
set_print(tabname);
|
set_print(tabname);
|
||||||
_form->print();
|
_form->print();
|
||||||
delete _form;
|
delete _form;
|
||||||
} // while
|
} // while
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TStampa_tabmag::destroy()
|
bool TStampa_tabmag::destroy()
|
||||||
{
|
{
|
||||||
delete _mask;
|
delete _mask;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mg0200(int argc, char* argv[])
|
int mg0200(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
TStampa_tabmag a;// derivata da Application e con uso di form
|
TStampa_tabmag a;// derivata da Application e con uso di form
|
||||||
a.run(argc,argv,"Stampa tabelle di magazzino");
|
a.run(argc,argv,"Stampa tabelle di magazzino");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user