ce70ce1f2e
Files correlati : batbcaa.msk ve2.exe ve0.exe ve6.exe Ricompilazione Demo : [ ] Commento : PG200010 Il campo descrizione dell'articolo in lingua decodifica la tabella lingue e non permette quindi di inserire la descrizione dell'articolo stesso nella lingua stabilita PG200013 Variando il prezzo in immissione documento DI ACQUISTO non viene implementato il campo ultimo costo nell'anagrafica articoli: probabilmente dipende dall'errore generato (vedi errore n, 200017) che non permette di registrare le variazioni su anagrafiche articoli già inserite. PG200014 Nel caso di contabilizzazione di fatture provenienti da paesi cee il programma in fase di "elabora" segnala che manca il codice della provincia di origine all'interno dell'anagrafica articolo pur essendo detto campo correttamente inserito PG200017 La variazione di un qualsiasi campo all'interno di una anagrafica articoli in fase di registrazione genera un errore "I CODICI DELLE GIACENZE NON POSSONO ESSERE VUOTI" . PG200025 Nel caso di una nota di credito che storna totalmente una fattura emessa o ricevuta (e quindi la partita è chiusa) la procedura giustamnete non trova nulla. Nel caso invece di una nota di credito parziale su fattura con modalità di pagamento ad esempio 30/60/90 la procedura non considera affatto la nota di credito e propone gli importi lordi. Sarebbe utile dallo scadenzario poter chiudere le singole rate saldate dalla nota di credito e gestire il residuo della partita sulla/e rate restanti git-svn-id: svn://10.65.10.50/trunk@11369 c028cbd2-c16b-5b4b-a496-9718f37d4682
1656 lines
52 KiB
C++
Executable File
1656 lines
52 KiB
C++
Executable File
#include <currency.h>
|
|
#include <execp.h>
|
|
#include <modaut.h>
|
|
#include <relapp.h>
|
|
#include <tabutil.h>
|
|
#include <execp.h>
|
|
#include <currency.h>
|
|
#include <urldefid.h>
|
|
#include <utility.h>
|
|
|
|
#include "velib.h"
|
|
#include "ve2400.h"
|
|
|
|
#include "..\cg\cglib01.h"
|
|
#include "..\mg\mglib.h"
|
|
#include "..\mg\stomag.h"
|
|
#include "..\mg\anamag.h"
|
|
#include "..\mg\codcorr.h"
|
|
|
|
// maschera dell'anagrafica di magazzino
|
|
class TMask_anamag: public TMask {
|
|
TRelation * _rel; // relazione principale
|
|
|
|
TCodgiac_livelli * livelli_giac;// oggetto handler per i livelli di giacenza
|
|
TCodart_livelli * livelli_art;// oggetto handler per i livelli di anagraficca
|
|
int last_annogiac;
|
|
int last_annosto;
|
|
|
|
int _type_cod;
|
|
TString16 _ean8_pref;
|
|
TString16 _ean13_pref;
|
|
TString16 _generated_code;
|
|
|
|
TString16 _um_principale;
|
|
TMagazzini *_magazzini;
|
|
TEsercizi_contabili *_esercizi_contabili;
|
|
|
|
static bool handle_codice(TMask_field &, KEY); // handler del campo codice articolo
|
|
static bool handle_livart(TMask_field &, KEY); // handler dei campi codice articolo (livelli)
|
|
static bool handle_anno(TMask_field &, KEY); // handler del campo anno delle giacenze
|
|
static bool handle_stoanno(TMask_field &, KEY); // handler del campo anno delle giacenze
|
|
static bool handle_stoanno_row(TMask_field &, KEY); // handler del campo anno delle giacenze sulle righe
|
|
static bool handle_sheet_um(TMask_field &, KEY); // handler dello sheet delle unità di misura
|
|
static bool notify_sheet_um(TSheet_field & s, int r, KEY k); // notify dello sheet delle unità di misura
|
|
static bool handle_sheet_deslin(TMask_field &, KEY); // handler dello sheet delle descrizioni in lingua
|
|
static bool handle_sheet_cod(TMask_field &, KEY); // handler dello sheet dei codici alternativi
|
|
static bool handle_codcorr(TMask_field &, KEY); // handler dello sheet dei codici alternativi
|
|
static bool notify_sheet_giac(TSheet_field & s, int r, KEY k); // notify delle giacenze
|
|
static bool handle_sheetgiac(TMask_field &, KEY); // handler dello sheet giacenze
|
|
static bool notify_sheet_sto(TSheet_field & s, int r, KEY k); // notify dello storico
|
|
static bool handle_sheetstomag(TMask_field &, KEY); // handler dello sheet storico giacenze
|
|
static bool handle_sheet_um_um(TMask_field &, KEY); // handler del campo UM dello sheet delle unità di misura
|
|
static bool handle_sheet_um_price(TMask_field &, KEY); // handler del campo PREZZO e PREZZO_LORDO dello sheet delle unità di misura
|
|
static bool handle_sheet_giac_codmag(TMask_field &, KEY); // handler
|
|
static bool handle_sheet_giac_valgiac(TMask_field &, KEY); // handler
|
|
static bool handle_sheet_stomag_stoval(TMask_field &, KEY); // handler
|
|
static bool handle_autoinsert_livgiac(TMask_field &, KEY); // handler del campo
|
|
|
|
static void sheetgiac_get(TSheet_field &fld_righe, int item);
|
|
static void sheetgiac_put(TSheet_field &fld_righe, int item);
|
|
static void sheetsto_get(TSheet_field &fld_righe, int item);
|
|
static void sheetsto_put(TSheet_field &fld_righe, int item);
|
|
|
|
void clear_info_sto();
|
|
bool info_sto_dirty();
|
|
int add_totali_storico(TString &codmag);
|
|
bool remove_totali_storico(TString & codmag);
|
|
void update_totali_storico(TString & codmag);
|
|
bool check_totali_storico();
|
|
bool generate_code(int _type = 0);
|
|
|
|
public:
|
|
void update_ordc_ordf();
|
|
void set_parametered_fields();
|
|
void ricalcola_giacenze();
|
|
|
|
TString &generated_code() {return _generated_code;}
|
|
TString16 &um_principale() {return _um_principale;}
|
|
TMagazzini & magazzini() {return *_magazzini;}
|
|
TEsercizi_contabili &esercizi_contabili() {return *_esercizi_contabili;}
|
|
|
|
TMask_anamag(TRelation * rel);
|
|
virtual ~TMask_anamag();
|
|
};
|
|
|
|
// ******************************
|
|
// applicazione
|
|
class TAnagrafica_magazzino : public TRelation_application
|
|
{
|
|
TMask_anamag *_msk; // maschera principale
|
|
TRelation *_rel; // relazione principale di un solo file (anagrafiche di magazzino)
|
|
|
|
protected:
|
|
virtual bool user_create();
|
|
virtual bool user_destroy();
|
|
virtual TMask *get_mask(int) { return _msk; }
|
|
virtual bool changing_mask(int) { return FALSE; }
|
|
virtual void init_query_mode(TMask&);
|
|
virtual void init_insert_mode(TMask&);
|
|
virtual void init_modify_mode(TMask&);
|
|
|
|
virtual void on_firm_change();
|
|
bool search_on_file(const char * key, int file, int nkey, const char * field);
|
|
virtual bool protected_record(TRectype&);
|
|
|
|
virtual int read(TMask& m);
|
|
void load_um(TMask& m);
|
|
virtual bool remove();
|
|
virtual int write(const TMask& m);
|
|
virtual int rewrite(const TMask& m);
|
|
|
|
virtual void ini2sheet(TConfig& ini, TSheet_field &sheet);
|
|
virtual void sheet2ini(TSheet_field &sheet,TConfig& ini);
|
|
|
|
static bool handle_copia(TMask_field &, KEY); // handler della copia articolo
|
|
|
|
public:
|
|
virtual TRelation *get_relation() const { return _rel; }
|
|
// @cmember Disabilita la verifica del modulo : essendo una anagrafica, va sempre abilitata
|
|
virtual bool check_autorization() const {return FALSE;}
|
|
TAnagrafica_magazzino() { _rel = NULL; _msk = NULL;}
|
|
virtual ~TAnagrafica_magazzino() {}
|
|
};
|
|
|
|
inline TAnagrafica_magazzino& app() { return (TAnagrafica_magazzino&) main_app(); }
|
|
|
|
void TMask_anamag::set_parametered_fields()
|
|
{
|
|
// ***************************************************
|
|
// ABILITAZIONI PARAMETRICHE
|
|
|
|
if (livelli_giac)
|
|
delete livelli_giac;
|
|
if (livelli_art)
|
|
delete livelli_art;
|
|
if (_esercizi_contabili)
|
|
delete _esercizi_contabili;
|
|
if (_magazzini)
|
|
delete _magazzini;
|
|
|
|
_esercizi_contabili = new TEsercizi_contabili;
|
|
_magazzini = new TMagazzini;
|
|
|
|
// imposta il puntatore al gestore livelli giacenze
|
|
livelli_giac= new TCodgiac_livelli();
|
|
livelli_art= new TCodart_livelli();
|
|
// imposta il valore dell'anno per le giacenze
|
|
last_annogiac=-1;
|
|
last_annosto=-1;
|
|
|
|
// Abilita la pagina delle giacenze
|
|
const bool gestmag = app().has_module(MGAUT) && magazzini().gestmag();
|
|
|
|
if (gestmag)
|
|
{
|
|
// sheet giacenze
|
|
set_handler(F_ANNO, handle_anno );
|
|
set_handler(F_SHEETGIAC, handle_sheetgiac);
|
|
|
|
TSheet_field& sgiac = sfield(F_SHEETGIAC);
|
|
sgiac.set_notify(notify_sheet_giac);
|
|
sgiac.set_userget(sheetgiac_get);
|
|
sgiac.set_userput(sheetgiac_put);
|
|
sgiac.sheet_mask().set_handler(F_CODMAG, handle_sheet_giac_codmag);
|
|
sgiac.sheet_mask().set_handler(F_VALGIAC, handle_sheet_giac_valgiac);
|
|
// sheet storico
|
|
set_handler(F_SHEETSTOMAG, handle_sheetstomag);
|
|
sfield(F_SHEETSTOMAG).set_notify(notify_sheet_sto);
|
|
sfield(F_SHEETSTOMAG).set_userget(sheetsto_get);
|
|
sfield(F_SHEETSTOMAG).set_userput(sheetsto_put);
|
|
TMask& stomask = sfield(F_SHEETSTOMAG).sheet_mask();
|
|
|
|
stomask.set_handler(F_STOVAL, handle_sheet_stomag_stoval);
|
|
stomask.set_handler(F_STOANNOES, handle_stoanno_row);
|
|
|
|
set_handler(F_STOANNO, handle_stoanno);
|
|
}
|
|
|
|
// setta i campi della maschera per la pagina giacenze
|
|
TSheet_field &fld_stomag= sfield(F_SHEETSTOMAG);
|
|
TSheet_field &fld_giac= sfield(F_SHEETGIAC);
|
|
// disabilita le colonne quando non sono utilizzati i livelli di giacenza
|
|
for (int i=0; i<4; i++)
|
|
{
|
|
livelli_giac->set_sheetcolumn(fld_giac,F_LIV1+i,i+1);
|
|
if (livelli_giac->autoinsert(i+1))
|
|
{
|
|
// codice autoinseribile
|
|
TMask_field & campo_liv=fld_giac.sheet_mask().field(F_LIV1+i);
|
|
campo_liv.check_type(CHECK_SEARCH);
|
|
campo_liv.set_handler(gestmag ? handle_autoinsert_livgiac : NULL);
|
|
}
|
|
}
|
|
|
|
/*
|
|
// disabilita la colonna numero distinte
|
|
if (FALSE)
|
|
{
|
|
fld_giac.delete_column(fld_giac.cid2index(F_NDIST));
|
|
fld_giac.sheet_mask().field(F_NDIST).enable(FALSE);
|
|
}
|
|
*/
|
|
// abilita la gestione delle ubicazioni (manuale/su tabella)
|
|
const bool ubi = gestmag && magazzini().gestubi_man();
|
|
fld_giac.sheet_mask().field(F_UBICAZ).show(!ubi);
|
|
fld_giac.sheet_mask().field(F_UBICAZD).show(!ubi);
|
|
fld_giac.sheet_mask().field(F_UBICAZ2).show(ubi);
|
|
|
|
// abilita la gestione del monomagazzino
|
|
const bool mm = gestmag && magazzini().gestmultimag();
|
|
fld_giac.sheet_mask().field(F_DESMAG).enable(mm);
|
|
fld_giac.enable_column(fld_giac.cid2index(F_CODMAG),mm);
|
|
fld_giac.enable_column(fld_giac.cid2index(F_CODDEP),gestmag && magazzini().gestdep());
|
|
fld_stomag.enable_column(fld_stomag.cid2index(F_STOCODMAG),mm);
|
|
|
|
enable_page(PAGE_GIACENZE,gestmag);
|
|
enable_page(PAGE_STORICO,gestmag);
|
|
|
|
// abilita la visualizzazione dei campi distinti per i livelli articolo
|
|
set_handler(F_CODART, handle_codice);
|
|
if (livelli_art->enabled())
|
|
{
|
|
for (int i=0; i<9; i++)
|
|
field(F_LIVART1+i).hide();
|
|
if (!livelli_art->enabled(2))
|
|
field(F_GCA).hide();
|
|
}
|
|
else
|
|
field(F_GCA).hide();
|
|
}
|
|
|
|
// costruttore della maschera anagrafica di magazzino
|
|
TMask_anamag::TMask_anamag(TRelation * rel) : TMask("ve2400")
|
|
{
|
|
_rel=rel;
|
|
|
|
// sheet unità di misura
|
|
set_handler(F_SHEETUM, handle_sheet_um);
|
|
TSheet_field &f= sfield(F_SHEETUM);
|
|
f.set_notify(notify_sheet_um);
|
|
TMask &fm= f.sheet_mask();
|
|
fm.set_handler(FS_CODUM, handle_sheet_um_um);
|
|
fm.set_handler(FS_PREZZO, handle_sheet_um_price);
|
|
fm.set_handler(FS_PREZZO_LORDO, handle_sheet_um_price);
|
|
|
|
TRecord_array* um = new TRecord_array(LF_UMART, "NRIGA");
|
|
f.set_lines_record(*um);
|
|
|
|
// sheet descrizioni in lingua
|
|
set_handler(F_SHEETDESLIN, handle_sheet_deslin);
|
|
// sheet codici corrispondenti
|
|
set_handler(F_SHEETCOD, handle_sheet_cod);
|
|
TSheet_field &fc= sfield(F_SHEETCOD);
|
|
TMask &fmc = fc.sheet_mask();
|
|
fmc.set_handler(FS_CODARTALT, handle_codcorr);
|
|
|
|
livelli_giac = NULL;
|
|
livelli_art = NULL;
|
|
_esercizi_contabili = NULL;
|
|
_magazzini = NULL;
|
|
|
|
set_parametered_fields();
|
|
|
|
TConfig c(CONFIG_DITTA, "ve");
|
|
bool disable_user_page = TRUE;
|
|
TString80 prompt;
|
|
|
|
for (int i = 1; i <= 10; i++)
|
|
{
|
|
if (c.get_bool("CHK_USER", "ve", i))
|
|
{
|
|
TEditable_field * f = NULL;
|
|
prompt = c.get("PROMPT_USER", "ve", i);
|
|
prompt.rpad(20);
|
|
const char type = c.get_char("TYPE_USER", "ve", i);
|
|
if (type == 'S')
|
|
f = &add_string(F_USER1 + i - 1, PAGE_USER, prompt, 2, 3 + i, c.get_int("LEN_USER", "ve", i));
|
|
else
|
|
if (type == 'N')
|
|
{
|
|
f = &add_number(F_USER1 + i - 1, PAGE_USER, prompt, 2, 3 + i, c.get_int("LEN_USER", "ve", i));
|
|
((TReal_field *) f)->set_decimals(c.get_int("DEC_USER", "ve", i));
|
|
}
|
|
else
|
|
if (type == 'D')
|
|
f = &add_date(F_USER1 + i - 1, PAGE_USER, prompt, 2, 3 + i);
|
|
else
|
|
if (type == 'I')
|
|
f = &add_currency(F_USER1 + i - 1, PAGE_USER, prompt, 2, 3 + i, c.get_int("LEN_USER", "ve", i));
|
|
else
|
|
if (type == 'X')
|
|
f = &add_boolean(F_USER1 + i - 1, PAGE_USER, prompt, 2, 3 + i);
|
|
if (f != NULL)
|
|
f->set_field(format("USER%d", i));
|
|
disable_user_page = FALSE;
|
|
}
|
|
}
|
|
_type_cod = c.get_int("GEN_EAN");
|
|
_ean8_pref = c.get("EAN8");
|
|
_ean13_pref = c.get("EAN13");
|
|
|
|
if (disable_user_page)
|
|
disable_page(PAGE_USER);
|
|
}
|
|
|
|
void TMask_anamag::sheetsto_put(TSheet_field &sheet_sto, int item)
|
|
{
|
|
if (item>1) return;
|
|
TMask_anamag & m=(TMask_anamag & )sheet_sto.mask();
|
|
TRectype & first_rec=sheet_sto.record()->row(1,TRUE);
|
|
first_rec.put(STOMAG_ULTCOS1,m.get_real(F_STOULTCOS1 ));
|
|
first_rec.put(STOMAG_ULTCOS2,m.get_real(F_STOULTCOS2 ));
|
|
first_rec.put(STOMAG_COSTSTD,m.get_real(F_STOCOSTOSTD ));
|
|
first_rec.put(STOMAG_COSTOMEDIO,m.get_real(F_STOCOSTOMEDIO ));
|
|
first_rec.put(STOMAG_CATVEN,m.get(F_STOCATVEN ));
|
|
first_rec.put(STOMAG_CODLISTINO,m.get(F_STOCODLIST));
|
|
first_rec.put(STOMAG_PRZLIST,m.get(F_STOPREZZOLIST ));
|
|
}
|
|
|
|
void TMask_anamag::sheetsto_get(TSheet_field &sheet_sto, int item)
|
|
{
|
|
TMask_anamag & m=(TMask_anamag &) sheet_sto.mask();
|
|
|
|
if (item>1) return;
|
|
TRectype & first_rec=sheet_sto.record()->row(1,TRUE);
|
|
m.set(F_STOULTCOS1, first_rec.get_real(STOMAG_ULTCOS1));
|
|
m.set(F_STOULTCOS2, first_rec.get_real(STOMAG_ULTCOS2 ));
|
|
m.set(F_STOCOSTOSTD, first_rec.get_real( STOMAG_COSTSTD ));
|
|
m.set(F_STOCOSTOMEDIO, first_rec.get_real(STOMAG_COSTOMEDIO));
|
|
m.set(F_STOCATVEN , first_rec.get(STOMAG_CATVEN));
|
|
m.set(F_STOCODLIST , first_rec.get(STOMAG_CODLISTINO));
|
|
m.set(F_STOPREZZOLIST ,first_rec.get(STOMAG_PRZLIST));
|
|
}
|
|
|
|
bool TMask_anamag::info_sto_dirty()
|
|
{
|
|
return
|
|
field(F_STOULTCOS1).focusdirty() ||
|
|
field(F_STOULTCOS2).focusdirty() ||
|
|
field(F_STOCOSTOSTD).focusdirty() ||
|
|
field(F_STOCOSTOMEDIO).focusdirty()||
|
|
field(F_STOCATVEN ).focusdirty()||
|
|
field(F_STOCODLIST).focusdirty()||
|
|
field(F_STOPREZZOLIST).focusdirty();
|
|
}
|
|
|
|
|
|
void TMask_anamag::clear_info_sto()
|
|
{
|
|
reset(F_STOULTCOS1);
|
|
reset(F_STOULTCOS2);
|
|
reset(F_STOCOSTOSTD);
|
|
reset(F_STOCOSTOMEDIO);
|
|
reset(F_STOCATVEN );
|
|
reset(F_STOCODLIST);
|
|
reset(F_STOPREZZOLIST);
|
|
}
|
|
|
|
|
|
TMask_anamag::~TMask_anamag()
|
|
{
|
|
if (livelli_art)
|
|
delete livelli_art;
|
|
if (livelli_giac)
|
|
delete livelli_giac;
|
|
if (_esercizi_contabili)
|
|
delete _esercizi_contabili;
|
|
if (_magazzini)
|
|
delete _magazzini;
|
|
}
|
|
|
|
|
|
bool TMask_anamag::handle_autoinsert_livgiac(TMask_field &fld, KEY k)
|
|
{
|
|
if (k == K_TAB && fld.focusdirty() && !fld.empty())
|
|
{
|
|
TMask_anamag & mask=(TMask_anamag &) fld.mask().get_sheet()->mask();
|
|
const int levnum=fld.dlg()-F_LIV1+1;
|
|
return mask.livelli_giac->autoinsert(levnum, fld);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
// HANDLER DEL CODICE: controlla la corrispondenza al formato previsto
|
|
bool TMask_anamag::generate_code(int type)
|
|
{
|
|
if (type == 0)
|
|
{
|
|
type = _type_cod;
|
|
if (type == 0)
|
|
return FALSE;
|
|
}
|
|
else
|
|
if (_type_cod != 0)
|
|
return FALSE;
|
|
|
|
TString cod(20);
|
|
TLocalisamfile anamag(LF_ANAMAG);
|
|
long progr = 0;
|
|
|
|
if (type == 8)
|
|
{
|
|
if (_ean8_pref.empty())
|
|
return FALSE;
|
|
cod = _ean8_pref;
|
|
cod << "999";
|
|
if (_type_cod != 0)
|
|
{
|
|
anamag.put(ANAMAG_CODART, cod);
|
|
|
|
if (anamag.read(_isgteq) != _isemptyfile)
|
|
{
|
|
cod = anamag.get(ANAMAG_CODART);
|
|
|
|
if (_ean8_pref < cod.left(4))
|
|
{
|
|
anamag.prev();
|
|
cod = anamag.get(ANAMAG_CODART);
|
|
}
|
|
if (_ean8_pref == cod.left(4))
|
|
progr = atol(cod.right(3));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
TLocalisamfile codcorr(LF_CODCORR);
|
|
|
|
codcorr.setkey(2);
|
|
codcorr.put(CODCORR_CODARTALT, cod);
|
|
|
|
if (codcorr.read(_isgteq) != _isemptyfile)
|
|
{
|
|
cod = codcorr.get(CODCORR_CODARTALT);
|
|
|
|
if (_ean8_pref < cod.left(4))
|
|
{
|
|
codcorr.prev();
|
|
cod = codcorr.get(CODCORR_CODARTALT);
|
|
}
|
|
if (_ean8_pref == cod.left(4))
|
|
progr = atol(cod.right(3));
|
|
}
|
|
}
|
|
progr++;
|
|
_generated_code.format("%s%03ld", (const char *)_ean8_pref, progr);
|
|
}
|
|
else
|
|
{
|
|
if (_ean13_pref.empty())
|
|
return FALSE;
|
|
cod = _ean13_pref;
|
|
cod << "999999";
|
|
if (_type_cod != 0)
|
|
{
|
|
anamag.put(ANAMAG_CODART, cod);
|
|
|
|
if (anamag.read(_isgteq) != _isemptyfile)
|
|
{
|
|
cod = anamag.get(ANAMAG_CODART);
|
|
|
|
if (_ean13_pref < cod.left(6))
|
|
{
|
|
anamag.prev();
|
|
cod = anamag.get(ANAMAG_CODART);
|
|
}
|
|
if (_ean13_pref == cod.left(6))
|
|
progr = atol(cod.right(6));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
TLocalisamfile codcorr(LF_CODCORR);
|
|
|
|
codcorr.setkey(2);
|
|
codcorr.put(CODCORR_CODARTALT, cod);
|
|
|
|
if (codcorr.read(_isgteq) != _isemptyfile)
|
|
{
|
|
cod = codcorr.get(CODCORR_CODARTALT);
|
|
|
|
if (_ean13_pref < cod.left(6))
|
|
{
|
|
codcorr.prev();
|
|
cod = codcorr.get(CODCORR_CODARTALT);
|
|
}
|
|
if (_ean13_pref == cod.left(6))
|
|
progr = atol(cod.right(6));
|
|
}
|
|
}
|
|
progr++;
|
|
_generated_code.format("%s%06ld", (const char *)_ean13_pref, progr);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TMask_anamag::handle_codice(TMask_field &fld, KEY k)
|
|
{
|
|
TMask_anamag &mask=(TMask_anamag &)fld.mask();
|
|
|
|
TString codepart;
|
|
if (k == K_TAB && !fld.get().blank() && mask.livelli_art->enabled())
|
|
{
|
|
int l;
|
|
TTable _tabgrp("GCA");
|
|
for (l=1; l<mask.livelli_art->last_level(); l++) {
|
|
codepart="";
|
|
codepart << l << mask.livelli_art->unpack_grpcode(fld.get(),l);
|
|
_tabgrp.zero();
|
|
_tabgrp.put("CODTAB", codepart);
|
|
if (_tabgrp.read()!=NOERR) {
|
|
fld.error_box("'%s' non appartiene a '%s'",(const char *)codepart.mid(1),(const char *)mask.livelli_art->name(l));
|
|
return(FALSE);
|
|
}
|
|
}
|
|
codepart=mask.livelli_art->unpack_grpcode(fld.get(),mask.livelli_art->last_level());
|
|
if (codepart.blank()) {
|
|
fld.error_box("Il codice articolo non può essere vuoto");
|
|
return(FALSE);
|
|
}
|
|
if (!mask.livelli_art->fit_to_format(codepart)) {
|
|
fld.error_box("Il codice articolo non corrisponde al formato previsto \n('%s' ?? '%s')",(const char *)codepart,(const char *)mask.livelli_art->code_format());
|
|
return(FALSE);
|
|
}
|
|
}
|
|
if (k == K_F8)
|
|
{
|
|
if (mask.generate_code())
|
|
{
|
|
fld.set(mask.generated_code());
|
|
mask.stop_run(K_INS);
|
|
}
|
|
}
|
|
return(TRUE);
|
|
}
|
|
|
|
// HANDLER DEL CODICE: controlla la corrispondenza al formato previsto
|
|
bool TMask_anamag::handle_livart(TMask_field &fld, KEY k)
|
|
{
|
|
if (k == K_TAB && fld.focusdirty())
|
|
{
|
|
TMask_anamag & m=(TMask_anamag & )fld.mask();
|
|
TString s(m.field(F_CODART).get());
|
|
m.livelli_art->pack_grpcode(s,fld.get(),fld.dlg()-F_LIVART1+1);
|
|
m.field(F_CODART).set(s);
|
|
if (fld.dlg()-F_LIVART1+1==m.livelli_art->last_level() && fld.get().blank()) {
|
|
|
|
fld.error_box("Il codice articolo non può essere lasciato in bianco");
|
|
return FALSE;
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TMask_anamag::handle_anno(TMask_field &fld, KEY k)
|
|
{
|
|
if (k == K_TAB)
|
|
{
|
|
TMask_anamag &mask=(TMask_anamag &)fld.mask();
|
|
TSheet_field& fld_giac = mask.sfield(F_SHEETGIAC);
|
|
|
|
if (mask.get(F_ANNO).empty() )
|
|
{
|
|
mask.set(F_ANNORIF, mask.esercizi_contabili().last()) ;
|
|
mask.set(F_ANNO, mask.get(F_ANNORIF));
|
|
}
|
|
if (mask.last_annogiac>0 && mask.last_annogiac!=fld.mask().get_int(F_ANNO)) {
|
|
if (fld_giac.dirty() && handle_sheetgiac(fld_giac,K_ENTER)) {
|
|
if (fld.yesno_box("Salvare le righe di giacenza per l'anno %d",mask.last_annogiac )) {
|
|
fld_giac.autosave(*mask._rel);
|
|
fld_giac.record()->rewrite();
|
|
}
|
|
}
|
|
mask.field(F_ANNORIF).set(fld.get());
|
|
// rilegge le giacenze relative a quell'anno ed aggiorna il layout
|
|
fld_giac.record()->read(*fld_giac.putkey(*mask._rel));
|
|
fld_giac.autoload(*mask._rel);
|
|
fld_giac.force_update();
|
|
|
|
mask.update_ordc_ordf(); //chiamata del metodo successivo
|
|
}
|
|
mask.last_annogiac=mask.get_int(F_ANNO);
|
|
}
|
|
return(TRUE);
|
|
}
|
|
|
|
|
|
void TMask_anamag::update_ordc_ordf()
|
|
{
|
|
real ordc,ordf;
|
|
const TDate oggi(TODAY);
|
|
int es_corr = esercizi_contabili().date2esc(oggi); // setta l'esercizio corrente (data come intero)
|
|
int es_pred = esercizi_contabili().pred(es_corr); // " " precedente "
|
|
|
|
TRecord_array arr(LF_MAG, MAG_NRIGA);
|
|
TRectype rec(LF_MAG); // crea un record vuoto di LF_MAG
|
|
|
|
for (int j = 0; j < 2; j++)
|
|
{
|
|
const int anno = j != 0 ? es_pred : es_corr;
|
|
if (anno == get_int(F_ANNORIF))
|
|
{
|
|
TSheet_field &fld_giac = sfield(F_SHEETGIAC);
|
|
const int pos_ordc = fld_giac.cid2index(F_ORDC);
|
|
const int pos_ordf = fld_giac.cid2index(F_ORDF);
|
|
|
|
FOR_EACH_SHEET_ROW(fld_giac,i,row)
|
|
{
|
|
ordc += real (row->get(pos_ordc));
|
|
ordf += real (row->get(pos_ordf));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
rec.put(MAG_ANNOES, anno); // riempio il record campione
|
|
rec.put(MAG_CODART, get(F_CODART));
|
|
arr.read(rec);
|
|
for (int i = arr.last_row(); i > 0; i = arr.pred_row(i))
|
|
{
|
|
ordc += arr[i].get_real(MAG_ORDC);
|
|
ordf += arr[i].get_real(MAG_ORDF);
|
|
}
|
|
}
|
|
}
|
|
|
|
set(F_TOT_ORD_CLI, ordc);
|
|
set(F_TOT_ORD_FOR, ordf);
|
|
}
|
|
|
|
bool TMask_anamag::handle_stoanno(TMask_field &fld, KEY k)
|
|
{
|
|
static bool in_handler = FALSE;
|
|
if (k == K_TAB && fld.focusdirty() && !in_handler)
|
|
{
|
|
in_handler = TRUE;
|
|
TMask_anamag &mask=(TMask_anamag &)fld.mask();
|
|
TSheet_field &fld_stomag= mask.sfield(F_SHEETSTOMAG);
|
|
|
|
if (mask.last_annosto>0 && mask.last_annosto!=fld.mask().get_int(F_STOANNO))
|
|
{
|
|
if ((fld_stomag.dirty() || mask.info_sto_dirty()) &&
|
|
fld_stomag.items()>0 )
|
|
{
|
|
if (fld.yesno_box("Salvare lo storico per l'anno %d",mask.last_annosto) &&
|
|
handle_sheetstomag(fld_stomag,K_ENTER))
|
|
{
|
|
fld_stomag.autosave(*mask._rel);
|
|
fld_stomag.record()->write(TRUE);
|
|
}
|
|
}
|
|
}
|
|
// rilegge lo storico relativo a quell'anno ed aggiorna il layout
|
|
mask.field(F_STOANNORIF).set(fld.get());
|
|
mask.clear_info_sto();
|
|
fld_stomag.record()->read(*fld_stomag.putkey(*mask._rel));
|
|
fld_stomag.autoload(*mask._rel);
|
|
handle_sheetstomag(fld_stomag,K_SPACE);
|
|
fld_stomag.force_update();
|
|
mask.last_annosto=mask.get_int(F_STOANNORIF);
|
|
if (fld.focusdirty())
|
|
TEsercizi_contabili::update();
|
|
in_handler = FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool TMask_anamag::handle_stoanno_row(TMask_field &fld, KEY k)
|
|
{
|
|
if (k == K_TAB && fld.focusdirty())
|
|
TEsercizi_contabili::update();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool TMask_anamag::handle_sheet_um(TMask_field &fld, KEY k)
|
|
{
|
|
TSheet_field &f= (TSheet_field &)fld; // typecast del campo al suo sheet corrispondente
|
|
TMask_anamag & m= (TMask_anamag &)(fld.mask());
|
|
if (k == K_ENTER && !m.query_mode())
|
|
{
|
|
const int items = f.items();
|
|
if (items > 0)
|
|
{
|
|
const char *codum=f.cell(0,f.cid2index(FS_CODUM));
|
|
if (*codum<=' ')
|
|
return error_box("La prima unità di misura deve essere specificata");
|
|
TAssoc_array v; // istanzia l'hash table per il controllo di univocità
|
|
for (int i= 0; i<items; i++)
|
|
{
|
|
const TString16 um(f.cell(i,f.cid2index(FS_CODUM)));
|
|
// aggiunge all'hash table l'elemento della riga corrente e controlla che non esista già
|
|
if (v.add(um))
|
|
return error_box("Le unità di misura devono essere diverse tra loro");
|
|
}
|
|
}
|
|
if (!m.um_principale().blank() && m.um_principale()!=f.cell(0,f.cid2index(FS_CODUM))) {
|
|
for (int i= 0; i<f.items(); i++)
|
|
{
|
|
if (m.um_principale()==f.cell(i,f.cid2index(FS_CODUM)))
|
|
break;
|
|
}
|
|
if (i>=f.items()) {
|
|
return error_box("L'unità di misura '%s' deve essere presente in tabella",(const char *)m.um_principale());
|
|
}
|
|
}
|
|
}
|
|
else if (k==K_SPACE) {
|
|
m.um_principale()=f.cell(0,f.cid2index(FS_CODUM));
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool TMask_anamag::notify_sheet_um(TSheet_field &fld_um, int r, KEY k)
|
|
{
|
|
if (k == K_TAB) {
|
|
fld_um.sheet_mask().enable(DLG_DELREC, r > 0);
|
|
if (r == 0) {
|
|
if (fld_um.items() == 0)
|
|
((TToken_string &)fld_um.row(0)) = "|1"; // aggiunge una riga allo sheet
|
|
else
|
|
((TToken_string &)fld_um.row(0)).add("1",fld_um.cid2index(FS_FCUM)); // forza la prima unita' di misura a 1
|
|
fld_um.disable_cell(0, fld_um.cid2index(FS_FCUM)); // mette in sola lettura il secondo campo della prima riga (il fattore di conversione della prima U.M. è fisso a 1)
|
|
fld_um.force_update(0);
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
bool TMask_anamag::handle_sheet_deslin(TMask_field &fld, KEY k)
|
|
{
|
|
if (k == K_ENTER)
|
|
{
|
|
TSheet_field &f= (TSheet_field &)fld; // typecast del campo al suo sheet corrispondente
|
|
const int items = f.items();
|
|
|
|
if (items > 0)
|
|
{
|
|
TAssoc_array v; // istanzia l'hash table per il controllo di univocità
|
|
|
|
for (int i= 0; i < items; i++)
|
|
{
|
|
const TString16 codlin(f.cell(i,0));
|
|
|
|
if (codlin.blank())
|
|
return error_box("I codici lingua non possono essere vuoti");
|
|
if (v.add(codlin))
|
|
return error_box("I codici lingua devono essere diversi tra loro"); // aggiunge all'hash table l'elemento 0 (primo) della riga corrente e controlla che non esista già
|
|
}
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TMask_anamag::handle_sheet_cod(TMask_field &fld, KEY k)
|
|
{
|
|
if (k==K_ENTER)
|
|
{
|
|
TSheet_field &f= (TSheet_field &)fld; // typecast del campo al suo sheet corrispondente
|
|
const int items = f.items();
|
|
|
|
if (items > 0)
|
|
{
|
|
TMask &m= fld.mask(); // prende la maschere d'origine del campo
|
|
TAssoc_array v; // istanzia l'hash table per il controllo di univocità
|
|
|
|
TString80 codart = m.get(F_CODART);
|
|
v.add(codart); // aggiunge all'hash table il codice articolo originale
|
|
for (int i= 0; i< items; i++)
|
|
{
|
|
codart = f.cell(i,0);
|
|
if (codart.blank())
|
|
return error_box("I codici alternativi non possono essere vuoti");
|
|
if (v.add(codart))
|
|
return error_box("I codici alternativi devono essere diversi tra loro e dal codice dell'articolo"); // aggiunge all'hash table l'elemento 0 (primo) della riga corrente e controlla che non esista già
|
|
}
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TMask_anamag::handle_codcorr(TMask_field &fld, KEY k)
|
|
{
|
|
if (k == K_F8)
|
|
{
|
|
TMask &m = fld.mask(); // prende la maschere d'origine del campo
|
|
TMask_anamag & mask = (TMask_anamag &) m.get_sheet()->mask();
|
|
char val = fld.mask().get(FS_TIPO)[0];
|
|
int type = val == '8' ? 8 : (val == '1' ? 13 : 0);
|
|
|
|
if (type > 0 && mask.generate_code(type))
|
|
fld.set(mask.generated_code());
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TMask_anamag::handle_sheetgiac(TMask_field &fld, KEY k)
|
|
{
|
|
if (k == K_ENTER)
|
|
{
|
|
TSheet_field &f=(TSheet_field &)fld;
|
|
TMask_anamag &m= (TMask_anamag&)f.mask(); // prende la maschere d'origine del campo
|
|
const int items = f.items();
|
|
|
|
if (items > 0 && m.magazzini().gestmultimag())
|
|
{
|
|
TAssoc_array v; // istanzia l'hash table per il controllo di univocità
|
|
|
|
for (int i= 0; i< items; i++)
|
|
{
|
|
TString codgiac;
|
|
m.livelli_giac->pack_grpcode(codgiac, f.cell(i,F_LIV1-FIRST_FIELD),1);
|
|
m.livelli_giac->pack_grpcode(codgiac, f.cell(i,F_LIV2-FIRST_FIELD),2);
|
|
m.livelli_giac->pack_grpcode(codgiac, f.cell(i,F_LIV3-FIRST_FIELD),3);
|
|
m.livelli_giac->pack_grpcode(codgiac, f.cell(i,F_LIV4-FIRST_FIELD),4);
|
|
|
|
codgiac << f.cell(i,F_CODMAG-FIRST_FIELD);
|
|
codgiac << f.cell(i,F_CODDEP-FIRST_FIELD);
|
|
if (codgiac.blank())
|
|
return error_box("I codici delle giacenze non possono essere vuoti");
|
|
// aggiunge all'hash table l'elemento 0 (primo) della riga corrente e controlla che non esista già
|
|
if (v.add(codgiac))
|
|
return error_box("Esistono due righe con lo stesso codice di giacenza");
|
|
if (!notify_sheet_giac(f, i, K_ENTER))
|
|
return FALSE;
|
|
}
|
|
// ordina le righe per livello+codmag
|
|
// f.rows_array().sort();
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
int TMask_anamag::add_totali_storico(TString & codmag)
|
|
{
|
|
TSheet_field &s =(TSheet_field &)field(F_SHEETSTOMAG);
|
|
bool need_rigatotali(TRUE);
|
|
for (int r=0 ; r< s.items() && codmag>=s.cell(r,s.cid2index(F_STOCODMAG)); r++)
|
|
{
|
|
if (*s.cell(r,s.cid2index(F_STOTIPORIGA))==SIMBOLO_TOTALI
|
|
&& codmag==s.cell(r,s.cid2index(F_STOCODMAG)))
|
|
need_rigatotali=FALSE;
|
|
}
|
|
if (need_rigatotali )
|
|
{
|
|
real totq,totval;
|
|
TLocalisamfile mag(LF_MAG);
|
|
mag.setkey(2);
|
|
mag.put(MAG_ANNOES,get(F_STOANNORIF));
|
|
//mag.put(MAG_CODART,get(F_CODART));
|
|
mag.put(MAG_CODMAG,codmag);
|
|
mag.read();
|
|
while (!mag.eof()
|
|
&& get_int(F_STOANNORIF)==mag.get_int(MAG_ANNOES)
|
|
&& strncmp((const char *)codmag,mag.get(MAG_CODMAG),3)==0)
|
|
{
|
|
if (get(F_CODART)==mag.get(MAG_CODART))
|
|
{
|
|
totq+=mag.get_real(MAG_RIM);
|
|
totval+=mag.get_real(MAG_VALRIM);
|
|
}
|
|
mag.next();
|
|
}
|
|
s.insert(r,FALSE);
|
|
s.row(r ).add(SIMBOLO_TOTALI,s.cid2index(F_STOTIPORIGA));
|
|
s.row(r ).add(codmag,s.cid2index(F_STOCODMAG));
|
|
s.row(r ).add("Totale",s.cid2index(F_STOANNOES));
|
|
s.disable_cell(r,-1);
|
|
|
|
s.insert(r+1,FALSE);
|
|
s.row(r+1).add(SIMBOLO_TOTALI,s.cid2index(F_STOTIPORIGA));
|
|
s.row(r+1).add(codmag,s.cid2index(F_STOCODMAG));
|
|
s.row(r+1).add("Rim.in",s.cid2index(F_STOANNOES));
|
|
s.row(r+1).add(totq.string(),s.cid2index(F_STOQUANT));
|
|
s.row(r+1).add(totval.string(),s.cid2index(F_STOVAL));
|
|
s.disable_cell(r+1,-1);
|
|
}
|
|
update_totali_storico(codmag);
|
|
return r;
|
|
}
|
|
|
|
void TMask_anamag::update_totali_storico(TString & codmag)
|
|
{
|
|
TSheet_field &s =(TSheet_field &)field(F_SHEETSTOMAG);
|
|
real tot1,tot2;
|
|
// find first occourrence..
|
|
int i=0 ;
|
|
while (i< s.items() && codmag>s.cell(i,s.cid2index(F_STOCODMAG)))
|
|
i++;
|
|
// ...sum...
|
|
for (; i< s.items() && *s.cell(i,s.cid2index(F_STOTIPORIGA))!=SIMBOLO_TOTALI ; i++)
|
|
{
|
|
tot1+=real(s.cell(i,s.cid2index(F_STOQUANT)));
|
|
tot2+=real(s.cell(i,s.cid2index(F_STOVAL)));
|
|
}
|
|
//... display
|
|
if (i< s.items())
|
|
{
|
|
s.row(i).add(tot1.string(),s.cid2index(F_STOQUANT));
|
|
s.row(i).add(tot2.string(),s.cid2index(F_STOVAL));
|
|
s.force_update(i);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool TMask_anamag::remove_totali_storico(TString & codmag)
|
|
{
|
|
TSheet_field &s =(TSheet_field &)field(F_SHEETSTOMAG);
|
|
|
|
bool found_some(FALSE);
|
|
if (codmag==" ")
|
|
return FALSE;
|
|
|
|
for (int r=0 ;
|
|
!found_some && r< s.items()-1
|
|
&& !(*s.cell(r,s.cid2index(F_STOTIPORIGA))==SIMBOLO_TOTALI
|
|
&& codmag==s.cell(r,s.cid2index(F_STOCODMAG)));
|
|
r++)
|
|
{
|
|
if (*s.cell(r,s.cid2index(F_STOTIPORIGA))!=SIMBOLO_TOTALI
|
|
&& codmag==s.cell(r,s.cid2index(F_STOCODMAG)))
|
|
found_some=TRUE;
|
|
}
|
|
if (!found_some)
|
|
{
|
|
// ultima riga
|
|
s.destroy(r,FALSE);
|
|
s.destroy(r,FALSE);
|
|
}
|
|
return !found_some;
|
|
}
|
|
|
|
|
|
bool TMask_anamag::check_totali_storico()
|
|
{
|
|
TSheet_field &s =(TSheet_field &)field(F_SHEETSTOMAG);
|
|
const int annogiac = get_int(F_ANNO);
|
|
if (annogiac != last_annosto)
|
|
return TRUE;
|
|
for (int r=0 ; r< s.items() ; r++)
|
|
{
|
|
// rintraccia il totale
|
|
for (; r< s.items() && *s.cell(r,s.cid2index(F_STOTIPORIGA))!=SIMBOLO_TOTALI; r++) ;
|
|
real totq1(s.cell(r,s.cid2index(F_STOQUANT))),totq2(s.cell(r+1,s.cid2index(F_STOQUANT)));
|
|
if (totq1!=totq2)
|
|
if (!yesno_box("La somma delle composizioni dello storico \nper il magazzino %s non corrisponde \nalla rimanenza iniziale.\n Proseguo ugualmente ?",
|
|
(const char *)s.cell(r,s.cid2index(F_STOCODMAG))))
|
|
return FALSE;
|
|
real totval1(s.cell(r,s.cid2index(F_STOVAL))),totval2(s.cell(r+1,s.cid2index(F_STOVAL)));
|
|
if (totval1!=totval2)
|
|
return yesno_box("La somma del valore delle composizioni dello storico \n per il magazzino %s non corrisponde \nal valore della rimanenza iniziale.\n Proseguo ugualmente ?",
|
|
(const char *)s.cell(r,s.cid2index(F_STOCODMAG)));
|
|
r++;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
bool TMask_anamag::notify_sheet_giac(TSheet_field &f, int i, KEY k)
|
|
{
|
|
TMask_anamag & m=(TMask_anamag &)f.mask();
|
|
switch (k)
|
|
{
|
|
case (K_ENTER): // fine modifica
|
|
{
|
|
real ck(f.cell(i,f.cid2index(F_RIM)));
|
|
ck+=real(f.cell(i,f.cid2index(F_ACQ)));
|
|
ck+=real(f.cell(i,f.cid2index(F_ENTR)));
|
|
ck-=real(f.cell(i,f.cid2index(F_VEN)));
|
|
ck-=real(f.cell(i,f.cid2index(F_USC)));
|
|
ck-=real(f.cell(i,f.cid2index(F_ACL)));
|
|
ck+=real(f.cell(i,f.cid2index(F_INCL)));
|
|
ck-=real(f.cell(i,f.cid2index(F_INPRODF)));
|
|
ck+=real(f.cell(i,f.cid2index(F_INPRODC)));
|
|
ck-=real(f.cell(i,f.cid2index(F_SCARTI)));
|
|
ck-=real(f.cell(i,f.cid2index(F_GIAC)));
|
|
|
|
if (!ck.is_zero())
|
|
{
|
|
f.error_box("La giacenza deve essere pari a RIM+(ACQ+ENTR)-(VEN+USC)-(ACL-INCL)-(PRODF-PRODC) - SCARTI)");
|
|
return FALSE;
|
|
}
|
|
|
|
m.update_ordc_ordf(); //chiama la funzione che calcola i totali degli ordinati
|
|
}
|
|
break;
|
|
case (K_CTRL + K_INS): // richiesta di inserimento
|
|
case (K_TAB): // modifica
|
|
{
|
|
if (*f.cell(i,f.cid2index(F_CODMAG))<=' ')
|
|
{
|
|
if (m.magazzini().standardmag().not_empty())
|
|
{
|
|
f.row(i).add(m.magazzini().standardmag(),f.cid2index(F_CODMAG));
|
|
f.row(i).add(m.magazzini().standarddep(),f.cid2index(F_CODDEP));
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TMask_anamag::handle_sheet_giac_codmag(TMask_field &f, KEY k)
|
|
{
|
|
if (k==K_TAB && f.dirty())
|
|
{
|
|
TMask& m = f.mask();
|
|
const TRectype& mag = ((TEdit_field&)f).browse()->cursor()->curr();
|
|
const bool gesdep = mag.get_bool("B0");
|
|
|
|
m.enable(F_CODDEP, gesdep);
|
|
m.show(F_DESDEP, gesdep);
|
|
if (gesdep)
|
|
m.field(F_CODDEP).check();
|
|
else
|
|
{
|
|
m.set(F_CODDEP, "");
|
|
m.set(F_DESDEP, "");
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
bool TMask_anamag::handle_sheet_giac_valgiac(TMask_field &f, KEY k)
|
|
{
|
|
if (k==K_TAB && f.dirty())
|
|
{
|
|
TMask& m = f.mask();
|
|
real q=m.get_real(F_RIM)+m.get_real(F_ACQ);
|
|
if (q.is_zero())
|
|
f.set(q.string());
|
|
else
|
|
{
|
|
q=(m.get_real(F_VRIM)+m.get_real(F_VACQ))/q;
|
|
TPrice r(q);
|
|
f.set(r.get_num().string());
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TMask_anamag::handle_sheet_stomag_stoval(TMask_field &f, KEY k)
|
|
{
|
|
if (k==K_TAB && f.dirty())
|
|
{
|
|
TMask& m = f.mask();
|
|
real r1 = m.get_real(F_STOQUANT);
|
|
real r2 = m.get_real(F_STOVALUN);
|
|
|
|
r1 *= r2;
|
|
m.set(F_STOVAL, r1.string());
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TMask_anamag::notify_sheet_sto(TSheet_field &s, int r, KEY k)
|
|
{
|
|
static TString16 oldcodmag,newcodmag,oldanno,newanno;
|
|
TMask_anamag & m=(TMask_anamag &)s.mask();
|
|
bool need_rigatotali=TRUE;
|
|
switch (k)
|
|
{
|
|
case K_DEL:
|
|
if (*s.cell(r,s.cid2index(F_STOTIPORIGA))==SIMBOLO_TOTALI)
|
|
return FALSE;
|
|
break;
|
|
|
|
case (K_CTRL+K_DEL):
|
|
if (m.remove_totali_storico(oldcodmag))
|
|
s.force_update();
|
|
break;
|
|
|
|
case K_TAB: // posizionamento sulla riga
|
|
oldcodmag=s.cell(r,s.cid2index(F_STOCODMAG));
|
|
oldanno=s.cell(r,s.cid2index(F_STOANNOES));
|
|
break;
|
|
|
|
case (K_ENTER): // fine modifica
|
|
|
|
newanno=(s.cell(r,s.cid2index(F_STOANNOES)));
|
|
newcodmag=(s.cell(r,s.cid2index(F_STOCODMAG)));
|
|
|
|
if (m.esercizi_contabili()[atoi(newanno)].inizio() >= m.esercizi_contabili()[m.get_int(F_STOANNO)].inizio())
|
|
{
|
|
s.row(r).add(oldanno,s.cid2index(F_STOANNOES));
|
|
s.error_box("La rimanenza iniziale di un esercizio deve essere composta da parti provenienti da esercizi precedenti");
|
|
return FALSE;
|
|
}
|
|
// modifica
|
|
m.update_totali_storico(newcodmag);
|
|
if (oldcodmag==s.cell(r,s.cid2index(F_STOCODMAG)))
|
|
{
|
|
if (oldanno==s.cell(r,s.cid2index(F_STOANNOES)) )
|
|
break;
|
|
} else {
|
|
m.remove_totali_storico(oldcodmag);
|
|
}
|
|
case (K_CTRL + K_INS ): // fine inserimento
|
|
if (*s.cell(r,s.cid2index(F_STOCODMAG))==' ' && m.magazzini().standardmag().not_empty())
|
|
{
|
|
// new line
|
|
s.row(r).add(m.magazzini().standardmag(),s.cid2index(F_STOCODMAG));
|
|
}
|
|
|
|
newcodmag=(s.cell(r,s.cid2index(F_STOCODMAG)));
|
|
newanno=(s.cell(r,s.cid2index(F_STOANNOES)));
|
|
if (newcodmag != " ")
|
|
{
|
|
// ordina
|
|
while (r< s.items()-1 && (newcodmag > s.cell(r+1,s.cid2index(F_STOCODMAG)) ||
|
|
(newcodmag == s.cell(r+1,s.cid2index(F_STOCODMAG)) &&
|
|
(newanno > s.cell(r+1,s.cid2index(F_STOANNOES)) && *s.cell(r+1,s.cid2index(F_STOTIPORIGA))!=SIMBOLO_TOTALI)) ))
|
|
{
|
|
s.swap_rows(r,r+1);
|
|
r++;
|
|
}
|
|
while (r>0 && (newcodmag < s.cell(r-1,s.cid2index(F_STOCODMAG)) ||
|
|
(newcodmag == s.cell(r-1,s.cid2index(F_STOCODMAG)) &&
|
|
(newanno < s.cell(r-1,s.cid2index(F_STOANNOES)) || *s.cell(r-1,s.cid2index(F_STOTIPORIGA))==SIMBOLO_TOTALI )) ))
|
|
{
|
|
s.swap_rows(r,r-1);
|
|
r--;
|
|
}
|
|
m.add_totali_storico(newcodmag);
|
|
TSheet_field & s_um=(TSheet_field & )s.mask().field(F_SHEETUM);
|
|
s.force_update();
|
|
}
|
|
break;
|
|
|
|
case (K_INS): // richiesta di inserimento
|
|
break;
|
|
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
|
|
bool TMask_anamag::handle_sheetstomag(TMask_field &fld, KEY k)
|
|
{
|
|
TSheet_field & f=(TSheet_field &)fld;
|
|
TMask_anamag &m=(TMask_anamag &) f.mask(); // prende la maschere d'origine del campo
|
|
if (k==K_ENTER)
|
|
{
|
|
const int items = f.items();
|
|
real totrim,totvalrim;
|
|
|
|
if (items > 0)
|
|
{
|
|
if (!m.check_totali_storico())
|
|
return FALSE;
|
|
TAssoc_array v; // istanzia l'hash table per il controllo di univocità
|
|
for (int i= 0; i< items; i++)
|
|
{
|
|
if (*f.cell(i,f.cid2index(F_STOTIPORIGA))!=SIMBOLO_TOTALI)
|
|
{
|
|
TString codmg(f.cell(i,f.cid2index(F_STOCODMAG)));
|
|
TString codeser(f.cell(i,f.cid2index(F_STOANNOES)));
|
|
if (codmg.blank())
|
|
return error_box("Il codice del magazzino non può essere vuoto");
|
|
if (codeser.blank())
|
|
return error_box("I codici degli esercizi non possono essere vuoti");
|
|
// aggiunge all'hash table l'elemento 0 (primo) della riga corrente e controlla che non esista già
|
|
codmg.overwrite(codeser,3);
|
|
if (v.add(codmg))
|
|
return error_box("La composizione delle rimanenze deve far riferimento a esercizi tutti diversi tra loro");
|
|
TLocalisamfile stor_aux(LF_STOMAG);
|
|
|
|
stor_aux.put(STOMAG_CODART,fld.mask().get(F_CODART));
|
|
stor_aux.put(STOMAG_ANNOESRIF,fld.mask().get(F_STOANNO));
|
|
stor_aux.put(STOMAG_ANNOES,codeser);
|
|
|
|
totrim=totrim+(real)f.cell(i,f.cid2index(F_STOQUANT));
|
|
totvalrim=totvalrim+(real)f.cell(i,f.cid2index(F_STOVAL));
|
|
}
|
|
}
|
|
for (i= 0; i< items;)
|
|
{
|
|
if (*f.cell(i,f.cid2index(F_STOTIPORIGA))==SIMBOLO_TOTALI)
|
|
f.rows_array().remove(i,TRUE);
|
|
else
|
|
i++;
|
|
}
|
|
// ordina le righe per ANNO
|
|
//f.rows_array().sort();
|
|
if ( m.get(F_STOANNO)<f.cell(f.items()-1,F_STOANNOES-FIRST_FIELD))
|
|
return error_box("La composizione delle rimanenze non puo' comprendere anni seguenti");
|
|
}
|
|
|
|
} else
|
|
if (k==K_SPACE)
|
|
{
|
|
for (int i=0; i< f.items();)
|
|
{
|
|
TString16 codmag(f.cell(i,f.cid2index(F_STOCODMAG)));
|
|
i=m.add_totali_storico(codmag)+2;
|
|
}
|
|
f.force_update();
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TMask_anamag::handle_sheet_um_um(TMask_field &fld, KEY k)
|
|
{
|
|
if (fld.focusdirty() && k == K_TAB)
|
|
{
|
|
TMask &m = fld.mask(); // prende la maschera d'origine del campo (maschera dello sheet)
|
|
const TString16 curr_um(fld.get()); // prende il contenuto del campo corrente (unità di misura corrente)
|
|
|
|
if (!curr_um.blank()) // se il codice dell'unità di misura è vuoto non viene fatto alcun calcolo
|
|
{
|
|
TSheet_field *f= m.get_sheet(); // prende lo sheet d'origine della maschera del campo
|
|
|
|
CHECK(f != NULL, "Il puntatore allo sheet è nullo");
|
|
if (f->selected() > 0)
|
|
{
|
|
|
|
// ALGORITMO DI PRECALCOLO DEL RAPPORTO DELLE UNITA' DI MISURA NELLO SHEET
|
|
//
|
|
// SHEET:
|
|
// -----
|
|
// riga u.m. f.c.
|
|
// 1) KM 1 -> kilometri (you), riferiti al metro (your) con f.c. 1000 (your_fc)
|
|
// ... ... ...
|
|
// ...) MM X -> millimetri (me), riferiti al metro (my) con f.c. 0,001 (my_fc)
|
|
//
|
|
// se (your==my) allora X=(my_fc/your_fc) ...chiaro, no!? :-)
|
|
|
|
TTable t("%UMS");
|
|
real x; // fattore di conversione dell'unità di misura corrente
|
|
const TString16 first_um(f->row(0).get(0)); // prende l'unità di misura di rapporto (dalla prima linea dello sheet)
|
|
|
|
t.zero();
|
|
t.put("CODTAB", curr_um);
|
|
if (t.read() == NOERR)
|
|
{
|
|
const TString16 rif_um(t.get("S7")); // prende l'unità di misura di riferimento dell'unità di misura corrente
|
|
x = t.get_real("R10"); // prende il suo fattore di conversione
|
|
|
|
if (rif_um != first_um)
|
|
{
|
|
t.zero();
|
|
t.put("CODTAB", first_um);
|
|
if (t.read() == NOERR)
|
|
{
|
|
TString16 rif_first_um(t.get("S7")); // prende l'unità di misura di riferimento dell'unità di misura di rapporto
|
|
real rif_fc_first_um(t.get_real("R10")); // prende il suo fattore di conversione
|
|
rif_fc_first_um = rif_fc_first_um.is_zero() ? 1 : rif_fc_first_um;
|
|
|
|
if (rif_first_um == rif_um)
|
|
{
|
|
x /= rif_fc_first_um; // calcola il rapporto tra i fattori di conversione
|
|
x.round(5); // arrotonda il risultato a 5 decimali
|
|
} else {
|
|
if (rif_first_um == curr_um) {
|
|
x= 1/rif_fc_first_um;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (x == ZERO)
|
|
x = 1.00;
|
|
m.set(FS_FCUM, x); // il risultato viene scritto nel campo del fattore di conversione
|
|
} else {
|
|
TString & um_p=((TMask_anamag &)f->mask()).um_principale();
|
|
if (um_p.blank()) {
|
|
f->mask().set(F_UMPRINCIPALE,curr_um);
|
|
f->mask().set(F_UMPRINCIPALE2,curr_um);
|
|
um_p=curr_um;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TMask_anamag::handle_sheet_um_price(TMask_field &f, KEY k)
|
|
{
|
|
if (f.to_check(k,TRUE))
|
|
{
|
|
TMask& m = f.mask();
|
|
TString codiva= m.get_sheet()->mask().get(F_CODIVA);// recuper il codice IVA dalla maschera principale
|
|
real netto = 0.0;
|
|
real lordo = 0.0;
|
|
TCodiceIVA iva(codiva);
|
|
|
|
if (f.dlg() == FS_PREZZO)
|
|
{
|
|
netto = real(m.get(FS_PREZZO));
|
|
lordo = iva.lordo(netto, AUTO_PRICES_DECIMALS, TCurrency::get_firm_val());
|
|
m.set(FS_PREZZO_LORDO,lordo.string());
|
|
}
|
|
else
|
|
{
|
|
lordo = real(m.get(FS_PREZZO_LORDO));
|
|
real prec_lordo = lordo;
|
|
const real imposta = iva.scorpora(lordo, AUTO_PRICES_DECIMALS, TCurrency::get_firm_val());
|
|
netto = lordo;
|
|
lordo += imposta;
|
|
if (lordo != prec_lordo)
|
|
{
|
|
warning_box("Scorporando l'iva dal prezzo lordo si e' dovuto\n"
|
|
"correggere quest'ultimo a causa di arrotondamenti.");
|
|
m.set(FS_PREZZO_LORDO,lordo.string());
|
|
}
|
|
m.set(FS_PREZZO,netto.string());
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
|
|
void TMask_anamag::sheetgiac_get(TSheet_field &fld_righe, int item)
|
|
{
|
|
TMask_anamag &m=(TMask_anamag &)fld_righe.mask();
|
|
// prende il record della riga corrente dal record array
|
|
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("LIVELLO") ,1),fld_righe.cid2index(F_LIV1) );
|
|
row.add( m.livelli_giac->unpack_grpcode(rec.get("LIVELLO") ,2),fld_righe.cid2index(F_LIV2) );
|
|
row.add( m.livelli_giac->unpack_grpcode(rec.get("LIVELLO") ,3),fld_righe.cid2index(F_LIV3) );
|
|
row.add( m.livelli_giac->unpack_grpcode(rec.get("LIVELLO") ,4),fld_righe.cid2index(F_LIV4) );
|
|
}
|
|
|
|
|
|
// item varies from 1 to items()
|
|
void TMask_anamag::sheetgiac_put(TSheet_field &fld_righe, int item)
|
|
{
|
|
TMask_anamag &m=(TMask_anamag &)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("LIVELLO", packedcode);
|
|
}
|
|
}
|
|
|
|
// Aggiorna il valore delle giacenze in base al cambiamento dell'unità di misura principale
|
|
void TMask_anamag::ricalcola_giacenze()
|
|
{
|
|
real fc(1.0);
|
|
TSheet_field & f=(TSheet_field &)field(F_SHEETUM);
|
|
if (!um_principale().blank() && um_principale()!=f.cell(0,f.cid2index(FS_CODUM))) {
|
|
for (int i= 0; i<f.items(); i++)
|
|
{
|
|
if (um_principale()==f.cell(i,f.cid2index(FS_CODUM)))
|
|
break;
|
|
}
|
|
fc=f.cell(i,f.cid2index(FS_FCUM));
|
|
}
|
|
if (fc != 1.0)
|
|
{
|
|
TLocalisamfile mag(LF_MAG),stomag(LF_STOMAG);
|
|
int annoes=esercizi_contabili().first();
|
|
// ciclo sugli esercizi
|
|
do {
|
|
mag.zero();
|
|
mag.put(MAG_ANNOES,annoes);
|
|
mag.put(MAG_CODART,get(F_CODART));
|
|
mag.read(_isgteq);
|
|
// ciclo per le giacenze di questo esercizio
|
|
while (!mag.eof() && get(F_CODART)==mag.get(MAG_CODART) && annoes==mag.get_int(MAG_ANNOES))
|
|
{
|
|
mag.put(MAG_LIVRIOR,mag.get_real(MAG_LIVRIOR)*fc); // update ..
|
|
mag.put(MAG_LOTTORIOR,mag.get_real(MAG_LOTTORIOR)*fc);
|
|
// saldi
|
|
mag.put(MAG_GIAC,mag.get_real(MAG_GIAC)*fc); // update ..
|
|
mag.put(MAG_ACQ,mag.get_real(MAG_ACQ)*fc);
|
|
mag.put(MAG_ENT,mag.get_real(MAG_ENT)*fc);
|
|
mag.put(MAG_VEN,mag.get_real(MAG_VEN)*fc);
|
|
mag.put(MAG_USC,mag.get_real(MAG_USC)*fc);
|
|
mag.put(MAG_ORDC,mag.get_real(MAG_ORDC)*fc);
|
|
mag.put(MAG_ORDF,mag.get_real(MAG_ORDF)*fc);
|
|
mag.put(MAG_RIM,mag.get_real(MAG_RIM)*fc);
|
|
mag.put(MAG_SCARTI,mag.get_real(MAG_SCARTI)*fc);
|
|
mag.put(MAG_INCL,mag.get_real(MAG_INCL)*fc);
|
|
mag.put(MAG_ACL,mag.get_real(MAG_ACL)*fc);
|
|
mag.put(MAG_PRODCOMP,mag.get_real(MAG_PRODCOMP)*fc);
|
|
mag.put(MAG_PRODFIN,mag.get_real(MAG_PRODFIN)*fc);
|
|
mag.put(MAG_SCORTAMIN,mag.get_real(MAG_SCORTAMIN)*fc);
|
|
// i valori non vanno aggiornati !
|
|
/*mag.put(MAG_VALACQ,mag.get_real(MAG_VALACQ)*fc);
|
|
mag.put(MAG_VALENT,mag.get_real(MAG_VALENT)*fc);
|
|
mag.put(MAG_VALVEN,mag.get_real(MAG_VALVEN)*fc);
|
|
mag.put(MAG_VALUSC,mag.get_real(MAG_VALUSC)*fc);
|
|
mag.put(MAG_VALORDC,mag.get_real(MAG_VALORDC)*fc);
|
|
mag.put(MAG_VALORDF,mag.get_real(MAG_VALORDF)*fc);
|
|
mag.put(MAG_VALRIM,mag.get_real(MAG_VALRIM)*fc);
|
|
mag.put(MAG_VALSCARTI,mag.get_real(MAG_VALSCARTI)*fc); */
|
|
|
|
mag.rewrite();
|
|
mag.next();
|
|
}
|
|
stomag.zero();
|
|
stomag.put(STOMAG_ANNOESRIF,annoes);
|
|
stomag.put(STOMAG_CODART,get(F_CODART));
|
|
stomag.read(_isgteq);
|
|
// ciclo per lo storico di questo esercizio
|
|
while (!stomag.eof() && get(F_CODART)==stomag.get(STOMAG_CODART) && annoes==stomag.get_int(STOMAG_ANNOESRIF))
|
|
{
|
|
stomag.put(STOMAG_QUANT,stomag.get_real(STOMAG_QUANT)*fc); // update ..
|
|
|
|
stomag.rewrite();
|
|
stomag.next();
|
|
}
|
|
} while (annoes=esercizi_contabili().next(annoes));
|
|
}
|
|
return;
|
|
}
|
|
|
|
|
|
void TAnagrafica_magazzino::on_firm_change()
|
|
{
|
|
if (_msk)
|
|
_msk->set_parametered_fields();
|
|
}
|
|
|
|
bool TAnagrafica_magazzino::search_on_file(const char * key, int file, int nkey, const char * field)
|
|
{
|
|
TLocalisamfile f(file);
|
|
|
|
if (f.empty())
|
|
return FALSE;
|
|
else
|
|
{
|
|
f.setkey(nkey);
|
|
f.put(field, key);
|
|
f.read();
|
|
return f.get(field) == key;
|
|
}
|
|
}
|
|
|
|
bool TAnagrafica_magazzino::protected_record(TRectype& rec)
|
|
{
|
|
const TString art(rec.get(ANAMAG_CODART));
|
|
const TRectype & dist = cache().get(LF_DIST, art);
|
|
|
|
if (!dist.empty())
|
|
return TRUE;
|
|
else
|
|
if (search_on_file(art, LF_RDIST, 2, "CODCOMP"))
|
|
return TRUE;
|
|
else
|
|
return search_on_file(art, LF_RMOVMAG, 2, "CODART");
|
|
}
|
|
|
|
bool TAnagrafica_magazzino::user_create()
|
|
{
|
|
open_files(LF_TAB, LF_TABCOM, LF_ANAMAG, LF_MAG, LF_STOMAG,
|
|
LF_UMART, LF_CODCORR, LF_DESLIN, LF_DIST, LF_RDIST, LF_RMOVMAG,
|
|
LF_CLIFO, LF_PCON, 0);
|
|
// crea l'oggetto per i parametri di livello giacenza
|
|
// apre la maschera e dispone gli sheet
|
|
_rel= new TRelation(LF_ANAMAG);
|
|
|
|
_msk= new TMask_anamag(_rel);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool TAnagrafica_magazzino::user_destroy()
|
|
{
|
|
|
|
delete _rel;
|
|
delete _msk;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
int TAnagrafica_magazzino::read(TMask& m)
|
|
{
|
|
int err= TRelation_application::read(m);
|
|
if (err == NOERR)
|
|
{
|
|
// LETTURA SHEET STORICO MAGAZZINO IN AUTOMATICO
|
|
TSheet_field &fld_stomag= m.sfield(F_SHEETSTOMAG);
|
|
fld_stomag.sheet_mask().field(F_STOCODART).set(m.field(F_CODART).get()); // necessario se lo sheet è vuoto
|
|
|
|
// *****************************
|
|
// LETTURA SHEET UNITA' DI MISURA
|
|
load_um(m);
|
|
((TMask_anamag & ) m).update_ordc_ordf(); //chiama la funzione che calcola i totali degli ordinati
|
|
}
|
|
return err;
|
|
}
|
|
|
|
void TAnagrafica_magazzino::load_um(TMask& m)
|
|
{
|
|
// *****************************
|
|
// LETTURA SHEET UNITA' DI MISURA
|
|
TSheet_field &fld_um= m.sfield(F_SHEETUM); // prende lo sheet delle unità di misura
|
|
get_relation()->lfile().put(ANAMAG_CODART,m.get(F_CODART));
|
|
fld_um.record()->read(*fld_um.putkey(*get_relation()));
|
|
fld_um.autoload(*get_relation());
|
|
// else
|
|
// ((TToken_string &)fld_um.row(0)).add("1",fld_um.cid2index(FS_FCUM)); // forza la prima unita' di misura a 1
|
|
// fld_um.disable_cell(0, fld_um.cid2index(FS_FCUM)); // mette in sola lettura il secondo campo della prima riga (il fattore di conversione della prima U.M. è fisso a 1)
|
|
// fld_um.force_update(0); // aggiorna lo stato della riga 0
|
|
TString16 um_principale;
|
|
um_principale=fld_um.cell(0, fld_um.cid2index(FS_CODUM));
|
|
m.set(F_UMPRINCIPALE,um_principale);
|
|
m.set(F_UMPRINCIPALE2,um_principale);
|
|
}
|
|
|
|
bool TAnagrafica_magazzino::remove()
|
|
{
|
|
bool ok = TRelation_application::remove();
|
|
if (ok)
|
|
{
|
|
TMask &m=curr_mask();
|
|
TSheet_field &f= (TSheet_field &)m.field(F_SHEETUM); // prende lo sheet delle unità di misura
|
|
TLocalisamfile distinte(LF_DIST);
|
|
distinte.put("CODDIST",m.get(F_CODART));
|
|
int err=distinte.read();// esiste la distinta ?
|
|
switch(err)
|
|
{
|
|
case _iskeynotfound :
|
|
case _isemptyfile :
|
|
case _iseof:
|
|
ok &= (f.record()->remove() == NOERR);
|
|
break;
|
|
}
|
|
}
|
|
return ok;
|
|
}
|
|
|
|
int TAnagrafica_magazzino::write(const TMask& m)
|
|
{
|
|
int err =TRelation_application::write(m);
|
|
if (err==NOERR)
|
|
{
|
|
TSheet_field &f= (TSheet_field &)m.field(F_SHEETUM); // prende lo sheet delle unità di misura
|
|
err|=f.record()->write(FALSE);
|
|
}
|
|
return err;
|
|
}
|
|
|
|
int TAnagrafica_magazzino::rewrite(const TMask& m)
|
|
{
|
|
int err =TRelation_application::rewrite(m);
|
|
if (err==NOERR)
|
|
{
|
|
TSheet_field& f= m.sfield(F_SHEETUM); // prende lo sheet delle unità di misura
|
|
err|=f.record()->write(TRUE);
|
|
}
|
|
((TMask_anamag &)m).ricalcola_giacenze();
|
|
return err;
|
|
}
|
|
|
|
static bool non_esiste_handler(TMask_field& f, KEY k)
|
|
{
|
|
if (f.to_check(k))
|
|
{
|
|
TLocalisamfile anamag(LF_ANAMAG);
|
|
anamag.put("CODART", f.mask().get(F_CODART));
|
|
if (anamag.read() == NOERR)
|
|
return error_box("Il codice articolo selezionato esiste già");
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TAnagrafica_magazzino::handle_copia(TMask_field &fld, KEY k)
|
|
{
|
|
if (k == K_SPACE)
|
|
{
|
|
TMask ask("ve2400k");
|
|
ask.set_handler(F_CODART, non_esiste_handler);
|
|
if (ask.run() == K_ENTER)
|
|
{
|
|
TMask& m = fld.mask();
|
|
m.set(F_CODART, ask.get(F_CODART), TRUE);
|
|
|
|
m.sfield(F_SHEETGIAC).destroy();
|
|
m.sfield(F_SHEETSTOMAG).destroy();
|
|
|
|
m.load_profile(0, FALSE);
|
|
|
|
m.set_mode(MODE_INS);
|
|
xvt_statbar_set("Inserimento", TRUE);
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
void TAnagrafica_magazzino::init_query_mode(TMask &m)
|
|
{
|
|
m.hide(F_COPY);
|
|
}
|
|
|
|
void TAnagrafica_magazzino::init_insert_mode(TMask &m)
|
|
{
|
|
load_um(m);
|
|
TSheet_field& f = m.sfield(F_SHEETUM);
|
|
if (f.items() == 0)
|
|
f.row(0) = " |1"; // aggiunge una riga allo sheet
|
|
}
|
|
|
|
void TAnagrafica_magazzino::init_modify_mode(TMask &m)
|
|
{
|
|
m.set_handler(F_COPY, handle_copia);
|
|
m.show(F_COPY);
|
|
}
|
|
|
|
void TAnagrafica_magazzino::ini2sheet(TConfig& ini, TSheet_field &sheet)
|
|
{
|
|
switch(sheet.dlg())
|
|
{
|
|
case F_SHEETGIAC:
|
|
case F_SHEETSTOMAG:
|
|
break; // do nothing
|
|
default:
|
|
TRelation_application::ini2sheet(ini, sheet);
|
|
}
|
|
}
|
|
|
|
void TAnagrafica_magazzino::sheet2ini(TSheet_field &sheet,TConfig& ini)
|
|
{
|
|
switch(sheet.dlg())
|
|
{
|
|
case F_SHEETGIAC:
|
|
case F_SHEETSTOMAG:
|
|
break; // do nothing
|
|
default:
|
|
TRelation_application::sheet2ini(sheet, ini);
|
|
}
|
|
}
|
|
|
|
// ************************
|
|
//
|
|
int ve2400(int argc, char* argv[])
|
|
{
|
|
TAnagrafica_magazzino a;
|
|
|
|
a.run(argc, argv, "Anagrafica di magazzino");
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
|