d39b1114a5
Files correlati : Ricompilazione Demo : [ ] Commento : Aggiunta traduzione all intra git-svn-id: svn://10.65.10.50/trunk@11204 c028cbd2-c16b-5b4b-a496-9718f37d4682
262 lines
6.8 KiB
C++
Executable File
262 lines
6.8 KiB
C++
Executable File
#include <recarray.h>
|
||
#include <relapp.h>
|
||
|
||
#include "in0.h"
|
||
#include "in0600a.h"
|
||
#include "inlib01.h"
|
||
|
||
class TRiepiloghi_mask : public TIntra_mask
|
||
{
|
||
protected:
|
||
virtual short type_field() const;
|
||
virtual short period_field() const;
|
||
virtual int anno() const { return get_int(F_ANNO); }
|
||
|
||
protected:
|
||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||
|
||
public:
|
||
TRiepiloghi_mask();
|
||
virtual ~TRiepiloghi_mask() { }
|
||
};
|
||
|
||
short TRiepiloghi_mask::type_field() const
|
||
{ return F_TIPO; }
|
||
|
||
short TRiepiloghi_mask::period_field() const
|
||
{ return F_PERIODO_M; }
|
||
|
||
bool TRiepiloghi_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||
{
|
||
switch (o.dlg())
|
||
{
|
||
case F_TIPO:
|
||
{
|
||
TString key ; key << main_app().get_firm();
|
||
const bool req = frequenza() == 'M' && !cache().get(LF_NDITTE, key).get_bool("NONOBBSTAT");
|
||
CheckType chk = req ? CHECK_REQUIRED : CHECK_NORMAL;
|
||
|
||
field(F_VALORE_STAT).check_type(chk);
|
||
field(F_CONSEGNA).check_type(chk);
|
||
field(F_TRASPORTO).check_type(chk);
|
||
|
||
chk = frequenza() == 'M' ? CHECK_REQUIRED : CHECK_NORMAL;
|
||
field(F_PAESE).check_type(chk);
|
||
field(F_PAESE_ORIG).check_type(chk);
|
||
field(F_PROV).check_type(chk);
|
||
}
|
||
break;
|
||
case F_NOMENCLATURA1:
|
||
case F_NOMENCLATURA2:
|
||
case F_NOMENCLATURA3:
|
||
if (e == fe_close && !query_mode())
|
||
{
|
||
if (frequenza() != 'A')
|
||
{
|
||
TString16 key; key << get(F_NOMENCLATURA1) << get(F_NOMENCLATURA2) << get(F_NOMENCLATURA3);
|
||
if (key.empty())
|
||
return error_box(TR("La nomenclatura combinata e' obbligatoria"));
|
||
}
|
||
}
|
||
else
|
||
if (e == fe_init || e == fe_modify)
|
||
{
|
||
TString16 key; key << get(F_NOMENCLATURA1) << get(F_NOMENCLATURA2) << get(F_NOMENCLATURA3);
|
||
const TRectype& nom = cache().get("%NOC", key);
|
||
set(F_UMS, nom.get("S5"));
|
||
bool req = frequenza() == 'M';
|
||
if (req) // Solo la frequenza mensile puo' obbligare
|
||
{
|
||
const char obb = nom.get_char("S4");
|
||
req = obb == 'E' || obb == tipo();
|
||
}
|
||
field(F_MASSA_UMS).check_type(req ? CHECK_REQUIRED : CHECK_NORMAL);
|
||
}
|
||
break;
|
||
case F_VALORE_STAT:
|
||
if (e == fe_init)
|
||
{
|
||
bool req = frequenza() == 'M';
|
||
if (req)
|
||
{
|
||
TString16 key ; key << main_app().get_firm();
|
||
req = !cache().get(LF_NDITTE, key).get_bool("NONOBBSTAT");
|
||
}
|
||
const CheckType chk = req ? CHECK_REQUIRED : CHECK_NORMAL;
|
||
field(F_VALORE_STAT).check_type(chk);
|
||
field(F_CONSEGNA).check_type(chk);
|
||
field(F_TRASPORTO).check_type(chk);
|
||
}
|
||
break;
|
||
case F_PARTITA_IVA:
|
||
if (e == fe_modify)
|
||
{
|
||
const TRectype& curr = efield(F_PARTITA_IVA).browse()->cursor()->curr();
|
||
TString16 codval = curr.get("VALINTRA");
|
||
|
||
if (codval.empty())
|
||
codval = curr.get("CODVAL");
|
||
|
||
set(F_VALUTA, codval);
|
||
}
|
||
break;
|
||
case F_NATURA_TRANS:
|
||
if (e == fe_modify || e == fe_init)
|
||
o.check();
|
||
break;
|
||
case F_VALUTA:
|
||
if (e == fe_modify || e == fe_init)
|
||
{
|
||
const bool tv = is_true_value(o.get());
|
||
if (!tv) o.reset();
|
||
TEdit_field& av = efield(F_AMM_VALUTA);
|
||
av.check_type(tv ? CHECK_REQUIRED : CHECK_NORMAL);
|
||
}
|
||
break;
|
||
case F_RIEPILOGHI:
|
||
if (e == fe_button)
|
||
::genera_riepiloghi(tipo(), anno());
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
return TIntra_mask::on_field_event(o, e, jolly);
|
||
}
|
||
|
||
TRiepiloghi_mask::TRiepiloghi_mask()
|
||
: TIntra_mask("in0600a")
|
||
{
|
||
// first_focus(F_NUM_RIG);
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// Applicazione principale
|
||
///////////////////////////////////////////////////////////
|
||
|
||
class TRiepiloghi_intra : public TRelation_application
|
||
{
|
||
TRelation* _rel;
|
||
TRiepiloghi_mask* _msk;
|
||
|
||
protected:
|
||
virtual bool user_create();
|
||
virtual TRelation* get_relation() const { return _rel; }
|
||
virtual TMask* get_mask(int) { return _msk; }
|
||
virtual int write(const TMask& m);
|
||
virtual bool changing_mask(int mode) { return FALSE; }
|
||
virtual bool user_destroy();
|
||
virtual bool get_next_key(TToken_string& k);
|
||
virtual void init_query_mode(TMask& m);
|
||
virtual void init_insert_mode(TMask& m);
|
||
virtual void init_modify_mode(TMask& m);
|
||
virtual bool save_and_new() const { return TRUE; };
|
||
virtual void check_existent_disk(const TMask& m);
|
||
public:
|
||
};
|
||
|
||
bool TRiepiloghi_intra::user_create()
|
||
{
|
||
open_files(LF_TABCOM, LF_TAB, LF_CLIFO,
|
||
LF_INTRA, LF_RINTRA, LF_RIEPRETT, 0);
|
||
_rel = new TRelation(LF_RIEPRETT);
|
||
_msk = new TRiepiloghi_mask;
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
bool TRiepiloghi_intra::user_destroy()
|
||
{
|
||
delete _msk;
|
||
delete _rel;
|
||
return TRUE;
|
||
}
|
||
|
||
bool TRiepiloghi_intra::get_next_key(TToken_string& k)
|
||
{
|
||
if (_msk->get(F_ANNO).empty() || _msk->get(F_PARTITA_IVA).empty())
|
||
return FALSE;
|
||
|
||
_msk->autosave(*_rel);
|
||
TRectype filter(_rel->curr());
|
||
filter.zero("NUMRIG");
|
||
|
||
TCursor cur(_rel, "", 1, &filter, &filter);
|
||
const long r = cur.items();
|
||
long num_rig = 1;
|
||
if (r > 0)
|
||
{
|
||
cur = r-1;
|
||
num_rig = cur.curr().get_long("NUMRIG")+1;
|
||
}
|
||
|
||
k.cut(0); k.add(F_NUM_RIG); k.add(num_rig);
|
||
return TRUE;
|
||
}
|
||
|
||
void TRiepiloghi_intra::init_insert_mode(TMask& m)
|
||
{
|
||
check_existent_disk(m);
|
||
m.enable(F_VALUTA);
|
||
}
|
||
|
||
void TRiepiloghi_intra::init_modify_mode(TMask& m)
|
||
{
|
||
check_existent_disk(m);
|
||
m.enable(F_VALUTA);
|
||
}
|
||
|
||
int TRiepiloghi_intra::write(const TMask& m)
|
||
{
|
||
_rel->curr().put("FREQUENZA", ((TRiepiloghi_mask &) m).frequenza(m.get_int(F_ANNO)));
|
||
return TRelation_application::write(m);
|
||
}
|
||
void TRiepiloghi_intra::init_query_mode(TMask& m)
|
||
{
|
||
TEdit_field& numrig = m.efield(F_NUM_RIG);
|
||
TCursor& cur = *numrig.browse()->cursor();
|
||
if (cur.items() > 0L)
|
||
cur.last_item();
|
||
const TRectype& curr = cur.curr();
|
||
m.set(F_ANNO, curr.get("ANNO"));
|
||
m.set(F_TIPO, curr.get("TIPO"), TRUE);
|
||
if (m.field(F_PERIODO_M).shown())
|
||
m.set(F_PERIODO_M, curr.get("PERIODO"));
|
||
else
|
||
if (m.field(F_PERIODO_T).shown())
|
||
m.set(F_PERIODO_T, curr.get("PERIODO"));
|
||
else
|
||
if (m.field(F_PERIODO_A).shown())
|
||
m.set(F_PERIODO_A, curr.get("PERIODO"));
|
||
m.disable(F_VALUTA);
|
||
}
|
||
|
||
void TRiepiloghi_intra::check_existent_disk(const TMask& m)
|
||
{
|
||
int anno = m.get_int(F_ANNO);
|
||
int periodo = 0;
|
||
if (m.field(F_PERIODO_M).shown())
|
||
periodo = m.get_int(F_PERIODO_M);
|
||
else
|
||
if (m.field(F_PERIODO_T).shown())
|
||
periodo = m.get_int(F_PERIODO_M);
|
||
else
|
||
if (m.field(F_PERIODO_A).shown())
|
||
periodo = m.get_int(F_PERIODO_A);
|
||
char tipo = m.get(F_TIPO)[0];
|
||
|
||
TString str;
|
||
str.format("%c%4d%02d",tipo,anno,periodo);
|
||
|
||
const TRectype& ird = cache().get("IRD",str);
|
||
if (!ird.empty())
|
||
warning_box(FR("E' gi<67> stato generato il dischetto per il periodo %d dell'anno %d"), periodo,anno);
|
||
|
||
}
|
||
|
||
int in0600(int argc, char* argv[])
|
||
{
|
||
TRiepiloghi_intra a;
|
||
a.run(argc, argv, TR("Riepiloghi INTRA"));
|
||
return 0;
|
||
}
|