a29e4b43d4
Files correlati : mr0.exe mr1.exe mr2.exe Ricompilazione Demo : [ ] Commento : Bug 0000135 Implementare la gestione multilingua git-svn-id: svn://10.65.10.50/trunk@12087 c028cbd2-c16b-5b4b-a496-9718f37d4682
333 lines
7.1 KiB
C++
Executable File
333 lines
7.1 KiB
C++
Executable File
#include <tabapp.h>
|
|
|
|
#include "mr0.h"
|
|
#include "mrplib.h"
|
|
|
|
#include "mrtblnp.h"
|
|
|
|
#ifndef TTable_application
|
|
#define TTable_application Tab_application
|
|
#endif
|
|
|
|
TTable_application& app() { return (TTable_application&)main_app(); }
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TMRP_mask
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TMRP_mask : public TCalendar_mask
|
|
{
|
|
protected:
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
public:
|
|
bool init_calendar();
|
|
bool save_calendar() const;
|
|
bool remove_calendar();
|
|
|
|
TMRP_mask(const char* name, int num = 0);
|
|
virtual ~TMRP_mask();
|
|
};
|
|
|
|
bool TMRP_mask::init_calendar()
|
|
{
|
|
bool changed = FALSE;
|
|
TString16 lin, imp;
|
|
if (app().get_tabname() == "LNP")
|
|
{
|
|
switch (get(F_TYPE)[0])
|
|
{
|
|
case 'L': lin = get(F_CODICE); imp = get(F_IMPIANTO); break;
|
|
case 'I': imp = get(F_IMPIANTO); break;
|
|
default : break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (get(F_TYPE) == "I")
|
|
imp = get(F_CODICE);
|
|
}
|
|
|
|
TCalendar_field& cf = (TCalendar_field&)field(F_CALENDAR);
|
|
|
|
if (calendar().linea() != lin || calendar().impianto() != imp)
|
|
{
|
|
if (cf.dirty())
|
|
{
|
|
TString str(80);
|
|
str = TR("Il calendario ");
|
|
switch (calendar().tipo())
|
|
{
|
|
case 'L': str << TR("della linea ") << calendar().linea(); break;
|
|
case 'I': str << TR("del impianto ") << calendar().impianto(); break;
|
|
default : str << TR("standard"); break;
|
|
}
|
|
str << TR(" e' stato modificato:\nsi desidera salvare le modifiche effettuate?");
|
|
if (yesno_box(str))
|
|
calendar().rewrite();
|
|
}
|
|
|
|
calendar().set(lin, imp);
|
|
cf.set_dirty(FALSE);
|
|
changed = TRUE;
|
|
}
|
|
cf.set_calendar(&calendar(), get_int(F_YEAR));
|
|
return changed;
|
|
}
|
|
|
|
bool TMRP_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
{
|
|
const TString& tn = app().get_tabname();
|
|
if (tn == "IMP" || tn == "LNP")
|
|
{
|
|
switch (o.dlg())
|
|
{
|
|
case F_IMPIANTO:
|
|
break;
|
|
case F_CODICE:
|
|
case F_TYPE:
|
|
if (e == fe_modify)
|
|
init_calendar();
|
|
break;
|
|
case F_YEAR:
|
|
if (e == fe_init || e == fe_modify)
|
|
{
|
|
update_calendar(F_CALENDAR, F_YEAR);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool TMRP_mask::save_calendar() const
|
|
{
|
|
TCalendar_field& cf = (TCalendar_field&)field(F_CALENDAR);
|
|
if (cf.dirty())
|
|
calendar().rewrite();
|
|
return TRUE;
|
|
}
|
|
|
|
bool TMRP_mask::remove_calendar()
|
|
{
|
|
const TString& tn = app().get_tabname();
|
|
const char tipo = tn[0];
|
|
if (calendar().tipo() == tipo)
|
|
calendar().remove();
|
|
return TRUE;
|
|
}
|
|
|
|
TMRP_mask::TMRP_mask(const char* name, int num)
|
|
: TCalendar_mask(name, num)
|
|
{
|
|
const TString& tn = app().get_tabname();
|
|
if (tn == "LNP")
|
|
{
|
|
TConfig ini(CONFIG_DITTA, "mr");
|
|
bool gestione_impianti = ini.get_bool("GESTIMPIANTI");
|
|
if (!gestione_impianti)
|
|
{
|
|
disable(F_IMPIANTO);
|
|
disable(F_DESCIMPIANTO);
|
|
}
|
|
}
|
|
}
|
|
|
|
TMRP_mask::~TMRP_mask()
|
|
{
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TMRPtables
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TMRPtables : public TTable_application
|
|
{
|
|
void read_turni(TMask& m);
|
|
void write_turni(const TMask& m);
|
|
protected:
|
|
virtual TString& get_mask_name(TString& name) const;
|
|
virtual TMask* set_mask(TMask* m);
|
|
|
|
virtual int read(TMask& m);
|
|
virtual int write(const TMask& m);
|
|
virtual int rewrite(const TMask& m);
|
|
virtual bool remove();
|
|
|
|
virtual void ini2mask(TConfig& ini, TMask& m, bool query);
|
|
virtual void mask2ini(const TMask& m, TConfig& ini);
|
|
|
|
public:
|
|
void save_calendar(const TMask& m);
|
|
void remove_calendar(const TMask& m);
|
|
};
|
|
|
|
TString& TMRPtables::get_mask_name(TString& name) const
|
|
{
|
|
name = get_tabname();
|
|
name.insert("mrtb", 0);
|
|
return name;
|
|
}
|
|
|
|
TMask* TMRPtables::set_mask(TMask* m)
|
|
{
|
|
if (m == NULL)
|
|
{
|
|
const TString& tn = get_tabname();
|
|
TString name; get_mask_name(name);
|
|
if (tn == "IMP" || tn == "LNP")
|
|
m = new TMRP_mask(name);
|
|
else
|
|
m = new TMask(name);
|
|
}
|
|
return TTable_application::set_mask(m);
|
|
}
|
|
|
|
void TMRPtables::save_calendar(const TMask& m)
|
|
{
|
|
const TString& tn = get_tabname();
|
|
if (tn == "IMP" || tn == "LNP")
|
|
{
|
|
const TMRP_mask& cm = (const TMRP_mask&)m;
|
|
cm.save_calendar();
|
|
}
|
|
}
|
|
|
|
void TMRPtables::remove_calendar(const TMask& m)
|
|
{
|
|
const TString& tn = get_tabname();
|
|
if (tn == "IMP" || tn == "LNP")
|
|
{
|
|
TMRP_mask& cm = (TMRP_mask&)m;
|
|
cm.remove_calendar();
|
|
}
|
|
}
|
|
|
|
void TMRPtables::read_turni(TMask& m)
|
|
{
|
|
TUnita_produttiva up(file().curr());
|
|
for (int t=7; t >=0; t--)
|
|
{
|
|
const id= F_T1HINIZIO+t*5;
|
|
m.set(id,up.ora_inizio_turno(t));
|
|
m.set(id+1,up.min_inizio_turno(t));
|
|
m.set(id+2,up.ore_durata_turno(t));
|
|
m.set(id+3,up.min_durata_turno(t));
|
|
m.set(id+4,up.raw_numpers_turno(t));
|
|
}
|
|
}
|
|
|
|
void TMRPtables::write_turni(const TMask& m)
|
|
{
|
|
TUnita_produttiva & up=(TUnita_produttiva &)file().curr();
|
|
for (int t=0; t < 8; t++)
|
|
{
|
|
const id= F_T1HINIZIO+t*5;
|
|
up.set_inizio_turno(t, m.get_int(id), m.get_int(id+1));
|
|
up.set_durata_turno(t, m.get_int(id+2), m.get_int(id+3));
|
|
up.set_numpers_turno(t, m.get_int(id+4));
|
|
}
|
|
}
|
|
|
|
int TMRPtables::read(TMask& m)
|
|
{
|
|
const int err = TTable_application::read(m);
|
|
if (err == NOERR)
|
|
{
|
|
const TString& tn = get_tabname();
|
|
if (tn == "IMP"||tn == "LNP" )
|
|
{
|
|
read_turni(m);
|
|
}
|
|
}
|
|
return err;
|
|
}
|
|
|
|
int TMRPtables::write(const TMask& m)
|
|
{
|
|
const TString& tn = get_tabname();
|
|
if (tn == "IMP"||tn == "LNP" )
|
|
{
|
|
write_turni(m);
|
|
}
|
|
const int err = TTable_application::write(m);
|
|
if (err == NOERR)
|
|
save_calendar(m);
|
|
return err;
|
|
}
|
|
|
|
int TMRPtables::rewrite(const TMask& m)
|
|
{
|
|
const TString& tn = get_tabname();
|
|
if (tn == "IMP"||tn == "LNP" )
|
|
{
|
|
write_turni(m);
|
|
}
|
|
const int err = TTable_application::rewrite(m);
|
|
if (err == NOERR)
|
|
save_calendar(m);
|
|
return err;
|
|
}
|
|
|
|
bool TMRPtables::remove()
|
|
{
|
|
const bool ok = TTable_application::remove();
|
|
if (ok)
|
|
remove_calendar(curr_mask());
|
|
return ok;
|
|
}
|
|
|
|
void TMRPtables::ini2mask(TConfig& ini, TMask& m, bool query)
|
|
{
|
|
TTable_application::ini2mask(ini, m, query);
|
|
|
|
const TString& tn = get_tabname();
|
|
if (tn == "IMP"||tn == "LNP" )
|
|
{
|
|
TAssoc_array& vars = ini.list_variables("5");
|
|
TRectype& curr = file().curr();
|
|
FOR_EACH_ASSOC_STRING(vars, obj, key, str)
|
|
curr.put(key, str);
|
|
read_turni(m);
|
|
}
|
|
}
|
|
|
|
void TMRPtables::mask2ini(const TMask& m, TConfig& ini)
|
|
{
|
|
TTable_application::mask2ini(m, ini);
|
|
|
|
const TString& tn = get_tabname();
|
|
if (tn == "IMP" || tn == "LNP" )
|
|
{
|
|
write_turni(m);
|
|
const TRectype& curr = file().curr();
|
|
ini.set_paragraph("5");
|
|
for (int i = curr.items()-1; i >= 0; i--)
|
|
{
|
|
const char* fname = curr.fieldname(i);
|
|
const TString& val = curr.get(fname);
|
|
if (!val.blank() && ini.get(fname).empty())
|
|
ini.set(fname, val);
|
|
}
|
|
}
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Main
|
|
///////////////////////////////////////////////////////////
|
|
|
|
int mr0100(int argc, char* argv[])
|
|
{
|
|
if (argc > 2)
|
|
{
|
|
TString name;
|
|
name << TR("Tabella ") << argv[2];
|
|
TMRPtables a;
|
|
a.run(argc, argv, name);
|
|
}
|
|
return 0;
|
|
}
|
|
|