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;
|
||||
TFile_cache *tab_cache;
|
||||
TMetachar * metac[MAXMETACH];
|
||||
TMetachar * metac[MAXMETACH];
|
||||
|
||||
static bool sumsign_handler(TMask_field &, KEY); // handler
|
||||
static bool format_handler(TMask_field &, KEY); // handler dei metacaratteri
|
||||
static bool codliv_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 sumsign_handler(TMask_field &, KEY); // handler
|
||||
static bool format_handler(TMask_field &, KEY); // handler dei metacaratteri
|
||||
static bool codliv_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
|
||||
|
||||
|
||||
public:
|
||||
TMask_tabmag(const char * ,const TString16 &);
|
||||
virtual ~TMask_tabmag();
|
||||
TMask_tabmag(const char * ,const TString16 &);
|
||||
virtual ~TMask_tabmag();
|
||||
};
|
||||
|
||||
// costruttore della maschera
|
||||
TMask_tabmag::TMask_tabmag(const char * _maskname,const TString16 &tabname):
|
||||
TMask(_maskname)
|
||||
TMask(_maskname)
|
||||
{
|
||||
aux_tabf=NULL;
|
||||
for (int i=0;i<MAXMETACH;i++)
|
||||
metac[i]=NULL;
|
||||
if (tabname == "CAU")
|
||||
metac[i]=NULL;
|
||||
if (tabname == "CAU")
|
||||
{
|
||||
set_handler(F_SGNGIAC, sumsign_handler);
|
||||
}
|
||||
if (tabname == "FCA") // FORMATO CODICE ARTICOLI
|
||||
{
|
||||
metac[0]=new TMetachar;
|
||||
aux_tabf = new TTable("FCA");
|
||||
set_handler(F_FORMLIV, format_handler);
|
||||
metac[0]=new TMetachar;
|
||||
aux_tabf = new TTable("FCA");
|
||||
set_handler(F_FORMLIV, format_handler);
|
||||
set_handler(F_CODLIV, codliv_handler);
|
||||
}
|
||||
if (tabname == "GCA") // GRUPPI CODICE ARTICOLI
|
||||
{
|
||||
tab_cache = new TDecoder("FCA","S1");
|
||||
tab_cache->fill();
|
||||
// crea i riconoscitori del formato
|
||||
for (int i=1; ((TDecoder *)tab_cache)->decode(i)!="";i++)
|
||||
{
|
||||
metac[i-1]=new TMetachar(((TDecoder *)tab_cache)->decode(i));
|
||||
}
|
||||
tab_cache = new TDecoder("FCA","S1");
|
||||
tab_cache->fill();
|
||||
// crea i riconoscitori del formato
|
||||
for (int i=1; ((TDecoder *)tab_cache)->decode(i)!="";i++)
|
||||
{
|
||||
metac[i-1]=new TMetachar(((TDecoder *)tab_cache)->decode(i));
|
||||
}
|
||||
set_handler(F_CODLIV, codlivgca_handler);
|
||||
set_handler(F_CODGROUP, numform_handler);
|
||||
}
|
||||
if (tabname == "FCG") // FORMATO CODICE GIACENZE
|
||||
{
|
||||
metac[0]=new TMetachar;
|
||||
aux_tabf = new TTable("FCG");
|
||||
set_handler(F_FORMLIV, format_handler);
|
||||
metac[0]=new TMetachar;
|
||||
aux_tabf = new TTable("FCG");
|
||||
set_handler(F_FORMLIV, format_handler);
|
||||
set_handler(F_CODLIV, codliv_handler);
|
||||
}
|
||||
if (tabname == "GCG") // GRUPPI CODICE GIACENZE
|
||||
{
|
||||
tab_cache = new TDecoder("FCG","S1");
|
||||
tab_cache->fill();
|
||||
for (int i=1; ((TDecoder *)tab_cache)->decode(i)!="";i++)
|
||||
{
|
||||
metac[i-1]=new TMetachar(((TDecoder *)tab_cache)->decode(i));
|
||||
}
|
||||
tab_cache = new TDecoder("FCG","S1");
|
||||
tab_cache->fill();
|
||||
for (int i=1; ((TDecoder *)tab_cache)->decode(i)!="";i++)
|
||||
{
|
||||
metac[i-1]=new TMetachar(((TDecoder *)tab_cache)->decode(i));
|
||||
}
|
||||
set_handler(F_CODGROUP, numform_handler);
|
||||
}
|
||||
}
|
||||
|
||||
TMask_tabmag::~TMask_tabmag()
|
||||
{
|
||||
if (aux_tabf!=NULL)
|
||||
delete aux_tabf;
|
||||
if (aux_tabf!=NULL)
|
||||
delete aux_tabf;
|
||||
for (int i=0;i<MAXMETACH;i++) {
|
||||
if (metac[i]!=NULL)
|
||||
delete metac[i];
|
||||
}
|
||||
if (metac[i]!=NULL)
|
||||
delete metac[i];
|
||||
}
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
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;
|
||||
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 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);
|
||||
if (aux_tabf->read()==NOERR)
|
||||
{
|
||||
// esiste il seguente:solo caratteri obbligatori
|
||||
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());
|
||||
return FALSE;
|
||||
}
|
||||
// esiste il seguente:solo caratteri obbligatori
|
||||
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());
|
||||
return FALSE;
|
||||
}
|
||||
} /*else {
|
||||
// ultimo livello: almeno un carattere obbligatorio
|
||||
// ELIMINATO
|
||||
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());
|
||||
return FALSE;
|
||||
}
|
||||
// ultimo livello: almeno un carattere obbligatorio
|
||||
// ELIMINATO
|
||||
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());
|
||||
return FALSE;
|
||||
}
|
||||
}*/
|
||||
// setta il campo con la lunghezza massima della stringa di formato
|
||||
mymask.field(F_LENFORM).set(mymask.metac[0]->maxstrlen(f.get()));
|
||||
// setta il campo con la lunghezza massima della stringa di formato
|
||||
mymask.field(F_LENFORM).set(mymask.metac[0]->maxstrlen(f.get()));
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -152,26 +152,26 @@ bool TMask_tabmag::codliv_handler(TMask_field& f, KEY k)
|
||||
TTable * aux_tabf=mymask.aux_tabf;
|
||||
int codliv=atoi((const char *)f.get());
|
||||
|
||||
if (codliv>1)
|
||||
if (codliv>1)
|
||||
// Non è il primo codice
|
||||
{
|
||||
aux_tabf->zero();
|
||||
aux_tabf->put("CODTAB",codliv-1);
|
||||
if (aux_tabf->read()==NOERR)
|
||||
// esiste un precedente
|
||||
{
|
||||
TString prevformat(aux_tabf->get("S1"));
|
||||
aux_tabf->zero();
|
||||
aux_tabf->put("CODTAB",codliv+1);
|
||||
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");
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
f.error_box("Non si possono inserire salti nel livello del codice");
|
||||
return FALSE;
|
||||
}
|
||||
aux_tabf->zero();
|
||||
aux_tabf->put("CODTAB",codliv-1);
|
||||
if (aux_tabf->read()==NOERR)
|
||||
// esiste un precedente
|
||||
{
|
||||
TString prevformat(aux_tabf->get("S1"));
|
||||
aux_tabf->zero();
|
||||
aux_tabf->put("CODTAB",codliv+1);
|
||||
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");
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
f.error_box("Non si possono inserire salti nel livello del codice");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
@ -185,12 +185,12 @@ bool TMask_tabmag::codlivgca_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
TMask_tabmag & mymask=((TMask_tabmag &)f.mask());
|
||||
|
||||
if (((TDecoder *)mymask.tab_cache)->decode(atoi((const char *)f.get())+1)=="")
|
||||
// non esiste un seguente
|
||||
if (((TDecoder *)mymask.tab_cache)->decode(atoi((const char *)f.get())+1)=="")
|
||||
// non esiste un seguente
|
||||
{
|
||||
f.error_box("Non è possibile definire gruppi per l'ultimo livello di codice");
|
||||
return FALSE;
|
||||
}
|
||||
f.error_box("Non è possibile definire gruppi per l'ultimo livello di codice");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -204,11 +204,11 @@ bool TMask_tabmag::numform_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
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");
|
||||
return FALSE;
|
||||
}
|
||||
f.error_box("Codice non corrispondente al formato previsto");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@ -225,9 +225,9 @@ protected: // TRelation_application
|
||||
virtual bool user_create() ;
|
||||
virtual bool protected_record(TRectype& rec) ;
|
||||
virtual int rewrite(const TMask& m);
|
||||
|
||||
virtual TMask * set_mask(TMask * _m=NULL);
|
||||
|
||||
|
||||
virtual TMask * set_mask(TMask * _m=NULL);
|
||||
|
||||
public:
|
||||
Tab_app_mag();
|
||||
virtual ~Tab_app_mag() {}
|
||||
@ -245,45 +245,45 @@ bool Tab_app_mag::protected_record(TRectype& rec)
|
||||
|
||||
if (!prot)
|
||||
{
|
||||
if (get_tabname()=="FCA" ||get_tabname()=="FCG" )
|
||||
{
|
||||
// non si possono cancellare i livelli intermedi:se non è l'ultimo livello, proteggilo
|
||||
TTable aux_tabf(get_tabname());
|
||||
aux_tabf.put("CODTAB",rec.get_int("CODTAB")+1);
|
||||
if (aux_tabf.read()==NOERR)
|
||||
prot=TRUE;
|
||||
}
|
||||
}
|
||||
if (get_tabname()=="FCA" ||get_tabname()=="FCG" )
|
||||
{
|
||||
// non si possono cancellare i livelli intermedi:se non è l'ultimo livello, proteggilo
|
||||
TTable aux_tabf(get_tabname());
|
||||
aux_tabf.put("CODTAB",rec.get_int("CODTAB")+1);
|
||||
if (aux_tabf.read()==NOERR)
|
||||
prot=TRUE;
|
||||
}
|
||||
}
|
||||
return prot;
|
||||
}
|
||||
|
||||
// alloca/cambia la maschera dell'applicazione
|
||||
TMask * Tab_app_mag::set_mask(TMask * _m)
|
||||
{
|
||||
if (_m != NULL)
|
||||
return Tab_application::set_mask(_m);
|
||||
else
|
||||
return Tab_application::set_mask(new TMask_tabmag((const char *)mask_name(),get_tabname()));
|
||||
if (_m != NULL)
|
||||
return Tab_application::set_mask(_m);
|
||||
else
|
||||
return Tab_application::set_mask(new TMask_tabmag((const char *)mask_name(),get_tabname()));
|
||||
}
|
||||
|
||||
bool Tab_app_mag::user_create()
|
||||
{
|
||||
/*
|
||||
la Tab_application::user_create() apre la maschera TMask in modo automatico
|
||||
basandosi sul parametro passato sulla linea di comando e sulla convenzione
|
||||
nome = "BATB"+parametro;
|
||||
ORA:
|
||||
- questa convenzione cambierà per separare i programmi (e le maschere)
|
||||
dei vari pacchetti
|
||||
In tal caso ridefinire il metodo virtual mask_name()
|
||||
- secondo il nuovo stile, gli handler vanno posti in maschere derivate
|
||||
dalla TMask (TMask_tabmag, TMask_tabcau, ecc), pertanto occorre che
|
||||
la maschera aperta sia del tipo corretto
|
||||
per questo motivo la maschera viene creata dalla user_create()
|
||||
la Tab_application::user_create() apre la maschera TMask in modo automatico
|
||||
basandosi sul parametro passato sulla linea di comando e sulla convenzione
|
||||
nome = "BATB"+parametro;
|
||||
ORA:
|
||||
- questa convenzione cambierà per separare i programmi (e le maschere)
|
||||
dei vari pacchetti
|
||||
In tal caso ridefinire il metodo virtual mask_name()
|
||||
- secondo il nuovo stile, gli handler vanno posti in maschere derivate
|
||||
dalla TMask (TMask_tabmag, TMask_tabcau, ecc), pertanto occorre che
|
||||
la maschera aperta sia del tipo corretto
|
||||
per questo motivo la maschera viene creata dalla user_create()
|
||||
*/
|
||||
|
||||
bool ok = Tab_application::user_create();
|
||||
|
||||
|
||||
if (ok)
|
||||
{
|
||||
//TMask& mask = *set_mask();
|
||||
|
@ -11,10 +11,10 @@
|
||||
|
||||
class TStampa_tabmag : public TApplication
|
||||
{
|
||||
TMask * _mask;
|
||||
TForm * _form;
|
||||
TMask * _mask;
|
||||
TForm * _form;
|
||||
|
||||
void set_print(TString & tabname);
|
||||
void set_print(TString & tabname);
|
||||
protected:
|
||||
virtual bool create();
|
||||
virtual bool destroy();
|
||||
@ -22,55 +22,55 @@ protected:
|
||||
|
||||
void TStampa_tabmag::set_print(TString & tabname)
|
||||
{
|
||||
TString filter;
|
||||
TRectype from_rec(LF_TAB),to_rec(LF_TAB);
|
||||
from_rec.put("COD",tabname);
|
||||
from_rec.put("CODTAB",_mask->get(F_INIZIO1));
|
||||
to_rec.put("COD",tabname);
|
||||
to_rec.put("CODTAB",_mask->get(F_FINE1));
|
||||
if (tabname=="FCA" || tabname=="FCG") {
|
||||
if (*_mask->get(F_INIZIO2))
|
||||
filter << "500@->CODTAB[2,20]>=" << _mask->get(F_INIZIO2);
|
||||
if (filter.not_empty())
|
||||
filter << "&&";
|
||||
if (*_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->cursor()->setregion(from_rec,to_rec);
|
||||
if (filter.not_empty())
|
||||
_form->cursor()->setfilter(filter);
|
||||
TString filter;
|
||||
TRectype from_rec(LF_TAB),to_rec(LF_TAB);
|
||||
from_rec.put("COD",tabname);
|
||||
from_rec.put("CODTAB",_mask->get(F_INIZIO1));
|
||||
to_rec.put("COD",tabname);
|
||||
to_rec.put("CODTAB",_mask->get(F_FINE1));
|
||||
if (tabname=="FCA" || tabname=="FCG") {
|
||||
if (*_mask->get(F_INIZIO2))
|
||||
filter << "500@->CODTAB[2,20]>=" << _mask->get(F_INIZIO2);
|
||||
if (filter.not_empty())
|
||||
filter << "&&";
|
||||
if (*_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->cursor()->setregion(from_rec,to_rec);
|
||||
if (filter.not_empty())
|
||||
_form->cursor()->setfilter(filter);
|
||||
}
|
||||
|
||||
bool TStampa_tabmag::create()
|
||||
{
|
||||
TString16 maskname("bast");
|
||||
TString16 formname("tab_");
|
||||
TString16 tabname(argv(2));
|
||||
TString16 maskname("bast");
|
||||
TString16 formname("tab_");
|
||||
TString16 tabname(argv(2));
|
||||
tabname.upper();
|
||||
|
||||
maskname << tabname;
|
||||
formname << tabname;
|
||||
|
||||
_mask = new TMask(maskname);
|
||||
while ((_mask->run() == K_ENTER)) {
|
||||
_form = new TForm(formname);
|
||||
set_print(tabname);
|
||||
_form->print();
|
||||
delete _form;
|
||||
} // while
|
||||
while ((_mask->run() == K_ENTER)) {
|
||||
_form = new TForm(formname);
|
||||
set_print(tabname);
|
||||
_form->print();
|
||||
delete _form;
|
||||
} // while
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool TStampa_tabmag::destroy()
|
||||
{
|
||||
delete _mask;
|
||||
delete _mask;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int mg0200(int argc, char* argv[])
|
||||
{
|
||||
TStampa_tabmag a;// derivata da Application e con uso di form
|
||||
a.run(argc,argv,"Stampa tabelle di magazzino");
|
||||
return 0;
|
||||
TStampa_tabmag a;// derivata da Application e con uso di form
|
||||
a.run(argc,argv,"Stampa tabelle di magazzino");
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user