Tab esplosi
git-svn-id: svn://10.65.10.50/trunk@4699 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
0b8f07e996
commit
cfc16a03b7
457
mg/mg1100.cpp
457
mg/mg1100.cpp
@ -18,38 +18,38 @@
|
||||
// maschera dell'applicazione "Gestione interattiva movimenti di magazzino"
|
||||
//
|
||||
class TMask_movmag: public TMask {
|
||||
TMov_mag * mov_mag;
|
||||
TMag_livelli * livelli_giac; // oggetto gestione livelli di giacenza
|
||||
TString price_codart;
|
||||
real price_quant;
|
||||
bool price_proposed;
|
||||
real proposed_price(TString codart, real quant);
|
||||
bool update_rigamov (int r, const char * old_codcaus);
|
||||
TMov_mag * mov_mag;
|
||||
TMag_livelli * livelli_giac; // oggetto gestione livelli di giacenza
|
||||
TString price_codart;
|
||||
real price_quant;
|
||||
bool price_proposed;
|
||||
real proposed_price(TString codart, real quant);
|
||||
bool update_rigamov (int r, const char * old_codcaus);
|
||||
|
||||
static bool notify_righe(TSheet_field & fld_righe, int item, KEY k); // notify delle righe di sheet
|
||||
static bool handle_righe(TMask_field &f, KEY k); // handler delle righe
|
||||
static bool handle_righeprezzo(TMask_field &f, KEY k); // handler del prezzo delle righe
|
||||
static bool handle_codcaus(TMask_field &fld, KEY k); // handler della causale
|
||||
static bool handle_datacomp(TMask_field &, KEY k); // handler del numero di registrazione
|
||||
static void sheetrighe_put(TSheet_field &fld_righe, int item);
|
||||
static void sheetrighe_get(TSheet_field &fld_righe, int item);
|
||||
static bool notify_righe(TSheet_field & fld_righe, int item, KEY k); // notify delle righe di sheet
|
||||
static bool handle_righe(TMask_field &f, KEY k); // handler delle righe
|
||||
static bool handle_righeprezzo(TMask_field &f, KEY k); // handler del prezzo delle righe
|
||||
static bool handle_codcaus(TMask_field &fld, KEY k); // handler della causale
|
||||
static bool handle_datacomp(TMask_field &, KEY k); // handler del numero di registrazione
|
||||
static void sheetrighe_put(TSheet_field &fld_righe, int item);
|
||||
static void sheetrighe_get(TSheet_field &fld_righe, int item);
|
||||
public:
|
||||
TMask_movmag(TMag_livelli *l_m,TMov_mag * m_m);
|
||||
virtual ~TMask_movmag();
|
||||
TMask_movmag(TMag_livelli *l_m,TMov_mag * m_m);
|
||||
virtual ~TMask_movmag();
|
||||
};
|
||||
|
||||
|
||||
// costruttore della maschera anagrafica di magazzino
|
||||
//TMask_movmag::TMask_movmag() :
|
||||
TMask_movmag::TMask_movmag(TMag_livelli *l_m,TMov_mag * m_m)
|
||||
: TMask("mg1100")
|
||||
: TMask("mg1100")
|
||||
{
|
||||
// oggetti dell'applicazione
|
||||
livelli_giac= l_m;
|
||||
mov_mag = m_m;
|
||||
// oggetti dell'applicazione
|
||||
livelli_giac= l_m;
|
||||
mov_mag = m_m;
|
||||
|
||||
// setta handler e notify
|
||||
TSheet_field & ss=(TSheet_field &)field(F_RIGHE);
|
||||
// setta handler e notify
|
||||
TSheet_field & ss=(TSheet_field &)field(F_RIGHE);
|
||||
set_handler(F_DATACOMP, handle_datacomp);
|
||||
set_handler(F_CODCAUS, handle_codcaus);
|
||||
ss.sheet_mask().field(F_PREZZO).set_handler(handle_righeprezzo);
|
||||
@ -59,49 +59,49 @@ TMask_movmag::TMask_movmag(TMag_livelli *l_m,TMov_mag * m_m)
|
||||
ss.set_handler(handle_righe);
|
||||
ss.set_userget(sheetrighe_get);
|
||||
ss.set_userput(sheetrighe_put);
|
||||
ss.set_lines_record(m_m->body());
|
||||
// setta i campi della maschera
|
||||
// per la pagina giacenze
|
||||
TSheet_field &fld_righe= (TSheet_field &)field(F_RIGHE);
|
||||
// disabilita le colonne quando non sono utilizzati i livelli di giacenza
|
||||
if (livelli_giac->enabled(1)) {
|
||||
fld_righe.sheet_mask().field(F_LIV1).show();
|
||||
fld_righe.set_column_header(fld_righe.cid2index(F_LIV1),livelli_giac->name(1));
|
||||
fld_righe.sheet_mask().field(F_LIV1).set_prompt(livelli_giac->name(1));
|
||||
} else {
|
||||
fld_righe.sheet_mask().field(F_LIV1).hide();
|
||||
fld_righe.delete_column(fld_righe.cid2index(F_LIV1));
|
||||
}
|
||||
if (livelli_giac->enabled(2)) {
|
||||
fld_righe.sheet_mask().field(F_LIV2).show();
|
||||
fld_righe.set_column_header(fld_righe.cid2index(F_LIV2),livelli_giac->name(2));
|
||||
fld_righe.sheet_mask().field(F_LIV2).set_prompt(livelli_giac->name(2));
|
||||
} else {
|
||||
fld_righe.sheet_mask().field(F_LIV2).hide();
|
||||
fld_righe.delete_column(fld_righe.cid2index(F_LIV2));
|
||||
}
|
||||
if (livelli_giac->enabled(3)) {
|
||||
fld_righe.sheet_mask().field(F_LIV3).show();
|
||||
fld_righe.set_column_header(fld_righe.cid2index(F_LIV3),livelli_giac->name(3));
|
||||
fld_righe.sheet_mask().field(F_LIV3).set_prompt(livelli_giac->name(3));
|
||||
} else {
|
||||
fld_righe.sheet_mask().field(F_LIV3).hide();
|
||||
fld_righe.delete_column(fld_righe.cid2index(F_LIV3));
|
||||
}
|
||||
if (livelli_giac->enabled(4)) {
|
||||
fld_righe.sheet_mask().field(F_LIV4).show();
|
||||
fld_righe.set_column_header(fld_righe.cid2index(F_LIV4),livelli_giac->name(4));
|
||||
fld_righe.sheet_mask().field(F_LIV4).set_prompt(livelli_giac->name(4));
|
||||
} else {
|
||||
fld_righe.sheet_mask().field(F_LIV4).hide();
|
||||
fld_righe.delete_column(fld_righe.cid2index(F_LIV4));
|
||||
}
|
||||
ss.set_lines_record(m_m->body());
|
||||
// setta i campi della maschera
|
||||
// per la pagina giacenze
|
||||
TSheet_field &fld_righe= (TSheet_field &)field(F_RIGHE);
|
||||
// disabilita le colonne quando non sono utilizzati i livelli di giacenza
|
||||
if (livelli_giac->enabled(1)) {
|
||||
fld_righe.sheet_mask().field(F_LIV1).show();
|
||||
fld_righe.set_column_header(fld_righe.cid2index(F_LIV1),livelli_giac->name(1));
|
||||
fld_righe.sheet_mask().field(F_LIV1).set_prompt(livelli_giac->name(1));
|
||||
} else {
|
||||
fld_righe.sheet_mask().field(F_LIV1).hide();
|
||||
fld_righe.delete_column(fld_righe.cid2index(F_LIV1));
|
||||
}
|
||||
if (livelli_giac->enabled(2)) {
|
||||
fld_righe.sheet_mask().field(F_LIV2).show();
|
||||
fld_righe.set_column_header(fld_righe.cid2index(F_LIV2),livelli_giac->name(2));
|
||||
fld_righe.sheet_mask().field(F_LIV2).set_prompt(livelli_giac->name(2));
|
||||
} else {
|
||||
fld_righe.sheet_mask().field(F_LIV2).hide();
|
||||
fld_righe.delete_column(fld_righe.cid2index(F_LIV2));
|
||||
}
|
||||
if (livelli_giac->enabled(3)) {
|
||||
fld_righe.sheet_mask().field(F_LIV3).show();
|
||||
fld_righe.set_column_header(fld_righe.cid2index(F_LIV3),livelli_giac->name(3));
|
||||
fld_righe.sheet_mask().field(F_LIV3).set_prompt(livelli_giac->name(3));
|
||||
} else {
|
||||
fld_righe.sheet_mask().field(F_LIV3).hide();
|
||||
fld_righe.delete_column(fld_righe.cid2index(F_LIV3));
|
||||
}
|
||||
if (livelli_giac->enabled(4)) {
|
||||
fld_righe.sheet_mask().field(F_LIV4).show();
|
||||
fld_righe.set_column_header(fld_righe.cid2index(F_LIV4),livelli_giac->name(4));
|
||||
fld_righe.sheet_mask().field(F_LIV4).set_prompt(livelli_giac->name(4));
|
||||
} else {
|
||||
fld_righe.sheet_mask().field(F_LIV4).hide();
|
||||
fld_righe.delete_column(fld_righe.cid2index(F_LIV4));
|
||||
}
|
||||
|
||||
TConfig prassid(CONFIG_DITTA, "ve"); // apre il file di configurazione della ditta corrente
|
||||
TConfig prassid(CONFIG_DITTA, "ve"); // apre il file di configurazione della ditta corrente
|
||||
if (prassid.get_bool("GES", NULL, A_LISTINI))
|
||||
field(F_CATVEN).enable(prassid.get_bool("GESLISCV"));
|
||||
else
|
||||
field(F_CATVEN).disable();
|
||||
field(F_CATVEN).enable(prassid.get_bool("GESLISCV"));
|
||||
else
|
||||
field(F_CATVEN).disable();
|
||||
}
|
||||
|
||||
|
||||
@ -115,13 +115,13 @@ void TMask_movmag::sheetrighe_get(TSheet_field &fld_righe, int item)
|
||||
{
|
||||
TMask_movmag &m=(TMask_movmag &)fld_righe.mask();
|
||||
// prende il record della riga corrente dal record array
|
||||
TRectype &rec= fld_righe.record()->row(item, TRUE);
|
||||
TRectype &rec= fld_righe.record()->row(item, TRUE);
|
||||
TToken_string &row= fld_righe.row(item-1);
|
||||
// codici di livello
|
||||
row.add( m.livelli_giac->unpack_grpcode(rec.get("LIVGIAC") ,1),fld_righe.cid2index(F_LIV1) );
|
||||
row.add( m.livelli_giac->unpack_grpcode(rec.get("LIVGIAC") ,2),fld_righe.cid2index(F_LIV2) );
|
||||
row.add( m.livelli_giac->unpack_grpcode(rec.get("LIVGIAC") ,2),fld_righe.cid2index(F_LIV2) );
|
||||
row.add( m.livelli_giac->unpack_grpcode(rec.get("LIVGIAC") ,3),fld_righe.cid2index(F_LIV3) );
|
||||
row.add( m.livelli_giac->unpack_grpcode(rec.get("LIVGIAC") ,4),fld_righe.cid2index(F_LIV4) );
|
||||
row.add( m.livelli_giac->unpack_grpcode(rec.get("LIVGIAC") ,4),fld_righe.cid2index(F_LIV4) );
|
||||
}
|
||||
|
||||
// item varies from 1 to items()
|
||||
@ -130,44 +130,44 @@ void TMask_movmag::sheetrighe_put(TSheet_field &fld_righe, int item)
|
||||
TMask_movmag &m=(TMask_movmag &)fld_righe.mask();
|
||||
TToken_string &row= fld_righe.row(item-1);
|
||||
|
||||
TRectype &recrighe= fld_righe.record()->row(item, TRUE);
|
||||
// codici livello
|
||||
if (m.livelli_giac->enabled()) {
|
||||
TString16 packedcode;
|
||||
m.livelli_giac->pack_grpcode(packedcode,row.get(fld_righe.cid2index(F_LIV1)),1);
|
||||
m.livelli_giac->pack_grpcode(packedcode,row.get(fld_righe.cid2index(F_LIV2)),2);
|
||||
m.livelli_giac->pack_grpcode(packedcode,row.get(fld_righe.cid2index(F_LIV3)),3);
|
||||
m.livelli_giac->pack_grpcode(packedcode,row.get(fld_righe.cid2index(F_LIV4)),4);
|
||||
recrighe.put("LIVGIAC", packedcode);
|
||||
}
|
||||
TRectype &recrighe= fld_righe.record()->row(item, TRUE);
|
||||
// codici livello
|
||||
if (m.livelli_giac->enabled()) {
|
||||
TString16 packedcode;
|
||||
m.livelli_giac->pack_grpcode(packedcode,row.get(fld_righe.cid2index(F_LIV1)),1);
|
||||
m.livelli_giac->pack_grpcode(packedcode,row.get(fld_righe.cid2index(F_LIV2)),2);
|
||||
m.livelli_giac->pack_grpcode(packedcode,row.get(fld_righe.cid2index(F_LIV3)),3);
|
||||
m.livelli_giac->pack_grpcode(packedcode,row.get(fld_righe.cid2index(F_LIV4)),4);
|
||||
recrighe.put("LIVGIAC", packedcode);
|
||||
}
|
||||
}
|
||||
|
||||
bool TMask_movmag::handle_righe(TMask_field &f, KEY k)
|
||||
{
|
||||
if (k == K_ENTER) {
|
||||
TSheet_field & ss=(TSheet_field & )f;
|
||||
for (int i=0; i< ss.items(); i++)
|
||||
{
|
||||
if (ss.cell(i,ss.cid2index(F_CODMAG))==NULL || *ss.cell(i,ss.cid2index(F_CODMAG)) ==' ')
|
||||
{
|
||||
f.error_box("Nella riga %d manca l'indicazione del magazzino ",i+1);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
TSheet_field & ss=(TSheet_field & )f;
|
||||
for (int i=0; i< ss.items(); i++)
|
||||
{
|
||||
if (*ss.cell(i,ss.cid2index(F_CODMAG)) ==' ')
|
||||
{
|
||||
f.error_box("Nella riga %d manca l'indicazione del magazzino ",i+1);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TMask_movmag::notify_righe(TSheet_field & ss, int r, KEY key)
|
||||
{
|
||||
static TString16 old_codcaus;
|
||||
static TString16 old_codcaus;
|
||||
if ( key == K_DEL ) // Cancellazione
|
||||
{
|
||||
if (*ss.cell(r,ss.cid2index( F_AUTOMATICA))=='A')
|
||||
return FALSE; // can't remove auto lines directly
|
||||
if (*ss.cell(r,ss.cid2index( F_AUTOMATICA))==riga_automatica)
|
||||
return FALSE; // can't remove auto lines directly
|
||||
if (r < ss.items()-1)
|
||||
{
|
||||
if (*ss.cell(r+1,ss.cid2index( F_AUTOMATICA))=='A')
|
||||
if (*ss.cell(r+1,ss.cid2index( F_AUTOMATICA))==riga_automatica)
|
||||
{
|
||||
ss.destroy(r + 1);
|
||||
}
|
||||
@ -175,180 +175,176 @@ bool TMask_movmag::notify_righe(TSheet_field & ss, int r, KEY key)
|
||||
|
||||
} else if (key == K_INS) { // Inserimento
|
||||
{
|
||||
if (*ss.cell(r,ss.cid2index( F_AUTOMATICA))=='A')
|
||||
if (*ss.cell(r,ss.cid2index( F_AUTOMATICA))==riga_automatica)
|
||||
return FALSE; // cannot insert between a row and its generated one
|
||||
}
|
||||
|
||||
} else if (key == K_SPACE) {
|
||||
old_codcaus=ss.sheet_mask().get(F_CAUSRIG);
|
||||
old_codcaus=ss.sheet_mask().get(F_CAUSRIG);
|
||||
if (old_codcaus.blank())
|
||||
old_codcaus=ss.mask().get(F_CODCAUS);
|
||||
old_codcaus=ss.mask().get(F_CODCAUS);
|
||||
|
||||
} else if (key == K_ENTER) {
|
||||
TMask_movmag &m=(TMask_movmag &)ss.mask();
|
||||
if (m.update_rigamov(r,old_codcaus))
|
||||
ss.select(r+1);
|
||||
TMask_movmag &m=(TMask_movmag &)ss.mask();
|
||||
if (m.update_rigamov(r,old_codcaus))
|
||||
ss.select(r+1);
|
||||
}
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
bool TMask_movmag::handle_righeprezzo(TMask_field &f, KEY k)
|
||||
{
|
||||
TSheet_field &sh=(TSheet_field &)(*f.mask().get_sheet());
|
||||
TMask_movmag &m=(TMask_movmag &)sh.mask();
|
||||
if (k==K_TAB && f.focusdirty())
|
||||
{
|
||||
m.price_proposed=FALSE;
|
||||
// in caso di nuova linea o prezzo nullo, propone il prezzo in base alla causale
|
||||
if (!f.mask().get(F_QUANT).blank() &&
|
||||
!f.mask().get(F_CODART).blank() &&
|
||||
f.mask().get(F_PREZZO).blank() &&
|
||||
(m.price_proposed==FALSE))
|
||||
{
|
||||
m.price_proposed=TRUE;
|
||||
real prz=m.proposed_price(f.mask().get(F_CODART),
|
||||
f.mask().get_real(F_QUANT));
|
||||
f.mask().set(F_PREZZO,prz);
|
||||
}
|
||||
}
|
||||
TSheet_field &sh=(TSheet_field &)(*f.mask().get_sheet());
|
||||
TMask_movmag &m=(TMask_movmag &)sh.mask();
|
||||
if (k==K_TAB && f.focusdirty())
|
||||
{
|
||||
m.price_proposed=FALSE;
|
||||
// in caso di nuova linea o prezzo nullo, propone il prezzo in base alla causale
|
||||
if (!f.mask().get(F_QUANT).blank() &&
|
||||
!f.mask().get(F_CODART).blank() &&
|
||||
f.mask().get(F_PREZZO).blank() &&
|
||||
(m.price_proposed==FALSE))
|
||||
{
|
||||
m.price_proposed=TRUE;
|
||||
real prz=m.proposed_price(f.mask().get(F_CODART),
|
||||
f.mask().get_real(F_QUANT));
|
||||
f.mask().set(F_PREZZO,prz);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TMask_movmag::update_rigamov (int r, const char * old_codcaus)
|
||||
{
|
||||
TSheet_field & ss=(TSheet_field & )field(F_RIGHE);
|
||||
TCausale_magazzino cau_riga();
|
||||
|
||||
TString16 new_codcaus(ss.cell(r,ss.cid2index(F_CAUSRIG)));
|
||||
if (new_codcaus.blank())
|
||||
new_codcaus=get(F_CODCAUS);
|
||||
TCausale_magazzino oldcau(old_codcaus);
|
||||
TCausale_magazzino cau(new_codcaus);
|
||||
if (*cau.get_collegata()!='\0')
|
||||
{
|
||||
// deve esserci una riga collegata
|
||||
TString16 codmag,coddep;
|
||||
real prezzo(ss.cell(r,ss.cid2index(F_PREZZO)));
|
||||
if (r < ss.items()-1 && *ss.cell(r+1,ss.cid2index( F_AUTOMATICA)) == ' ')
|
||||
{
|
||||
// manca, la inserisco
|
||||
ss.insert(r+1);
|
||||
ss.row(r+1)=ss.row(r);
|
||||
} else {
|
||||
codmag=ss.cell(r+1,ss.cid2index(F_CODMAG));
|
||||
coddep=ss.cell(r+1,ss.cid2index(F_CODDEP));
|
||||
ss.row(r+1)=ss.row(r);
|
||||
}
|
||||
ss.row(r+1).add(prezzo.string(),ss.cid2index(F_PREZZO));
|
||||
ss.row(r+1).add(codmag,ss.cid2index(F_CODMAG));
|
||||
ss.row(r+1).add(coddep,ss.cid2index(F_CODDEP));
|
||||
ss.row(r+1).add(cau.get_collegata(),ss.cid2index(F_CAUSRIG));
|
||||
ss.row(r+1).add("A",ss.cid2index(F_AUTOMATICA));
|
||||
ss.check_row(r+1);
|
||||
ss.force_update(r+1);
|
||||
return TRUE;
|
||||
} else
|
||||
if (*oldcau.get_collegata()!='\0')
|
||||
{
|
||||
// scollega la vecchia riga
|
||||
ss.destroy(r + 1);
|
||||
}
|
||||
return FALSE;
|
||||
TSheet_field & ss=(TSheet_field & )field(F_RIGHE);
|
||||
|
||||
TString16 new_codcaus(ss.cell(r,ss.cid2index(F_CAUSRIG)));
|
||||
if (new_codcaus.blank())
|
||||
new_codcaus=get(F_CODCAUS);
|
||||
TCausale_magazzino oldcau(old_codcaus);
|
||||
TCausale_magazzino cau(new_codcaus);
|
||||
if (*cau.get_collegata()!='\0')
|
||||
{
|
||||
// deve esserci una riga collegata
|
||||
TString16 codmag,coddep;
|
||||
real prezzo(ss.cell(r,ss.cid2index(F_PREZZO)));
|
||||
if (r < ss.items()-1 && *ss.cell(r+1,ss.cid2index( F_AUTOMATICA)) != riga_automatica)
|
||||
{
|
||||
// manca, la inserisco
|
||||
ss.insert(r+1);
|
||||
ss.row(r+1)=ss.row(r);
|
||||
} else {
|
||||
codmag=ss.cell(r+1,ss.cid2index(F_CODMAG));
|
||||
coddep=ss.cell(r+1,ss.cid2index(F_CODDEP));
|
||||
ss.row(r+1)=ss.row(r);
|
||||
}
|
||||
ss.row(r+1).add(prezzo.string(),ss.cid2index(F_PREZZO));
|
||||
ss.row(r+1).add(codmag,ss.cid2index(F_CODMAG));
|
||||
ss.row(r+1).add(coddep,ss.cid2index(F_CODDEP));
|
||||
ss.row(r+1).add(cau.get_collegata(),ss.cid2index(F_CAUSRIG));
|
||||
ss.row(r+1).add(TString(1,riga_automatica),ss.cid2index(F_AUTOMATICA));
|
||||
ss.check_row(r+1);
|
||||
ss.force_update(r+1);
|
||||
return TRUE;
|
||||
} else
|
||||
if (*oldcau.get_collegata()!='\0')
|
||||
{
|
||||
// scollega la vecchia riga
|
||||
ss.destroy(r + 1);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
real TMask_movmag::proposed_price(TString codart,
|
||||
real quant)
|
||||
real quant)
|
||||
{
|
||||
real rv("0");
|
||||
TCausale_magazzino cau(get(F_CODCAUS));
|
||||
TLocalisamfile anamag(LF_ANAMAG);
|
||||
anamag.put("CODART",codart);
|
||||
anamag.read();
|
||||
switch (cau.get_tipoprz()) {
|
||||
// prezzo
|
||||
case 'P': {
|
||||
TLocalisamfile umart(LF_UMART);
|
||||
TConfig cfgditta(CONFIG_DITTA);
|
||||
TCondizione_vendita cv(&cfgditta,&anamag,&umart);
|
||||
|
||||
cv.put_listino(get(F_CODCONDV),get(F_CATVEN));
|
||||
cv.ricerca(codart,quant);
|
||||
rv=cv.get_prezzo();
|
||||
}
|
||||
break;
|
||||
// costo
|
||||
case 'C': {
|
||||
rv=anamag.get_real("ULTCOS1");
|
||||
}
|
||||
break;
|
||||
}
|
||||
return rv;
|
||||
real rv("0");
|
||||
TCausale_magazzino cau(get(F_CODCAUS));
|
||||
TLocalisamfile anamag(LF_ANAMAG);
|
||||
anamag.put("CODART",codart);
|
||||
anamag.read();
|
||||
switch (cau.get_tipoprz()) {
|
||||
// prezzo
|
||||
case 'P': {
|
||||
TLocalisamfile umart(LF_UMART);
|
||||
TConfig cfgditta(CONFIG_DITTA);
|
||||
TCondizione_vendita cv(&cfgditta,&anamag,&umart);
|
||||
|
||||
cv.put_listino(get(F_CODCONDV),get(F_CATVEN));
|
||||
cv.ricerca(codart,quant);
|
||||
rv=cv.get_prezzo();
|
||||
}
|
||||
break;
|
||||
// costo
|
||||
case 'C': {
|
||||
rv=anamag.get_real("ULTCOS1");
|
||||
}
|
||||
break;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
bool TMask_movmag::handle_codcaus(TMask_field &fld, KEY k)
|
||||
{
|
||||
static TString16 old_codcaus;
|
||||
static TString16 old_codcaus;
|
||||
|
||||
if (k == K_TAB && fld.focusdirty() && old_codcaus!="") {
|
||||
// aggiorna le righe di sheet
|
||||
TMask_movmag &m=(TMask_movmag &)fld.mask();
|
||||
TSheet_field & ss=(TSheet_field & )m.field(F_RIGHE);
|
||||
bool added_some;
|
||||
|
||||
for (int i=0; i< ss.items(); i++)
|
||||
{
|
||||
if (*ss.cell(i,ss.cid2index(F_CAUSRIG)) ==' ')
|
||||
// la riga dipende dalla causale movimento
|
||||
added_some &=(m.update_rigamov(i,old_codcaus));
|
||||
}
|
||||
if (added_some)
|
||||
{
|
||||
ss.dirty();
|
||||
ss.set_focus();
|
||||
}
|
||||
}
|
||||
if (k == K_TAB)
|
||||
old_codcaus=fld.get();
|
||||
if (k == K_TAB && fld.focusdirty() && old_codcaus!="") {
|
||||
// aggiorna le righe di sheet
|
||||
TMask_movmag &m=(TMask_movmag &)fld.mask();
|
||||
TSheet_field & ss=(TSheet_field & )m.field(F_RIGHE);
|
||||
bool added_some;
|
||||
|
||||
for (int i=0; i< ss.items(); i++)
|
||||
{
|
||||
if (*ss.cell(i,ss.cid2index(F_CAUSRIG)) ==' ')
|
||||
// la riga dipende dalla causale movimento
|
||||
added_some &=(m.update_rigamov(i,old_codcaus));
|
||||
}
|
||||
if (added_some)
|
||||
{
|
||||
ss.dirty();
|
||||
ss.set_focus();
|
||||
}
|
||||
}
|
||||
if (k == K_TAB)
|
||||
old_codcaus=fld.get();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TMask_movmag::handle_datacomp(TMask_field &fld, KEY k)
|
||||
{
|
||||
if (k == K_TAB && fld.focusdirty())
|
||||
{
|
||||
if (k == K_TAB && fld.focusdirty())
|
||||
{
|
||||
|
||||
int codes=((TMask_movmag &)fld.mask()).mov_mag->codice_esercizio(TDate(fld.get()));
|
||||
if (codes>0)
|
||||
fld.mask().field(F_ANNOES).set(codes);
|
||||
else
|
||||
{
|
||||
fld.error_box("La data indicata non appartiene a nessuno degli esercizi contabili inseriti ") ;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
int codes=((TMask_movmag &)fld.mask()).mov_mag->codice_esercizio(TDate(fld.get()));
|
||||
if (codes>0)
|
||||
fld.mask().field(F_ANNOES).set(codes);
|
||||
else
|
||||
{
|
||||
fld.error_box("La data indicata non appartiene a nessuno degli esercizi contabili inseriti ") ;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
class TApp_movmag: public TRelation_application {
|
||||
TMask_movmag *_msk; // maschera principale
|
||||
TArray used_files;
|
||||
TMask_movmag *_msk; // maschera principale
|
||||
TMag_livelli * _livelli_giac;// oggetto handler per i livelli di giacenza
|
||||
TRelation * _rel; // relazione contenente il file movimenti
|
||||
TLocalisamfile * _rmovmag; // file aperto per utilizzarne il record
|
||||
TRelation * _rel; // relazione contenente il file movimenti
|
||||
|
||||
virtual bool user_create();
|
||||
virtual bool user_destroy();
|
||||
virtual TMask *get_mask(int) { return _msk; }
|
||||
virtual bool changing_mask(int) { return FALSE; }
|
||||
virtual TRelation *get_relation() const { return _rel; }
|
||||
virtual const char *get_next_key();
|
||||
// virtual int read(TMask& m);
|
||||
// virtual bool remove();
|
||||
// virtual int write(const TMask& m);
|
||||
// virtual int rewrite(const TMask& m);
|
||||
virtual const char *get_next_key();
|
||||
|
||||
TString16 _nextcod;
|
||||
TString16 _nextcod;
|
||||
public:
|
||||
TApp_movmag() {};
|
||||
virtual ~TApp_movmag() {};
|
||||
@ -359,26 +355,29 @@ inline TApp_movmag& app() { return (TApp_movmag&) main_app(); }
|
||||
|
||||
bool TApp_movmag::user_create()
|
||||
{
|
||||
|
||||
_rmovmag = new TLocalisamfile(LF_RMOVMAG);
|
||||
used_files.add(new TLocalisamfile(LF_ANAMAG));
|
||||
used_files.add(new TLocalisamfile(LF_UMART));
|
||||
used_files.add(new TLocalisamfile(LF_MOVMAG));
|
||||
used_files.add(new TLocalisamfile(LF_RMOVMAG));
|
||||
used_files.add(new TTable("%CAU"));
|
||||
|
||||
TMov_mag * m_m= new TMov_mag(); // record del movimento di magazzino
|
||||
m_m->enable_autoload(LF_RMOVMAG);
|
||||
|
||||
// gestione giacenza a livelli
|
||||
_livelli_giac= new TMag_livelli("FCG");
|
||||
m_m->enable_autoload(LF_RMOVMAG);
|
||||
|
||||
// gestione giacenza a livelli
|
||||
_livelli_giac= new TMag_livelli("FCG");
|
||||
// maschera specifica con gli handler dei movimenti
|
||||
_msk= new TMask_movmag(_livelli_giac,m_m);
|
||||
// relazione con un solo file (LF_MOVMAG) ma col record Head_Body
|
||||
// relazione con un solo file (LF_MOVMAG) ma col record Head_Body
|
||||
_rel= new TRelation(LF_MOVMAG);
|
||||
_rel->lfile().set_curr(m_m);
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TApp_movmag::user_destroy()
|
||||
{
|
||||
delete _rmovmag;
|
||||
delete _rel;
|
||||
delete _rel;
|
||||
delete _msk;
|
||||
delete _livelli_giac;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user