campo-sirio/mr/mr0100.cpp
angelo 86da863222 Patch level :
Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
Aggiunta TCalendar_mask in mrplib.
Aggiunta gestione parametri ditta per MRP.


git-svn-id: svn://10.65.10.50/trunk@7149 c028cbd2-c16b-5b4b-a496-9718f37d4682
1998-09-28 07:37:18 +00:00

135 lines
2.8 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
{
TMRP_calendar* _calendar;
protected:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
public:
TMRP_mask(const char* name, int num = 0);
virtual ~TMRP_mask();
};
bool TMRP_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
const TString16 tn = app().get_tabname();
if (tn == "IMP" || tn == "LNP")
{
switch (o.dlg())
{
case F_CODICE:
case F_IMPIANTO:
case F_TYPE:
if (e == fe_modify)
{
TString16 lin, imp;
if (tn == "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);
}
if (_calendar == NULL)
_calendar = new TMRP_calendar(lin, imp);
else
_calendar->set(lin, imp);
TCalendar_field& cf = (TCalendar_field&)field(F_CALENDAR);
cf.set_calendar(_calendar, get_int(F_YEAR));
cf.win().force_update();
}
break;
case F_YEAR:
if (e == fe_init || e == fe_modify)
{
TCalendar_field& cf = (TCalendar_field&)field(F_CALENDAR);
cf.set_calendar(_calendar, get_int(F_YEAR));
if (is_running())
cf.win().force_update();
}
break;
default:
break;
}
}
return TRUE;
}
TMRP_mask::TMRP_mask(const char* name, int num)
: TCalendar_mask(name, num), _calendar(NULL)
{
set_handlers();
}
TMRP_mask::~TMRP_mask()
{
if (_calendar)
delete _calendar;
}
///////////////////////////////////////////////////////////
// TMRPtables
///////////////////////////////////////////////////////////
class TMRPtables : public TTable_application
{
protected:
virtual TString& get_mask_name(TString& name) const;
virtual TMask* set_mask(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)
{
TString name; get_mask_name(name);
m = new TMRP_mask(name);
}
return TTable_application::set_mask(m);
}
int mr0100(int argc, char* argv[])
{
if (argc > 2)
{
TString name;
name << "Tabella " << argv[2];
TMRPtables a;
a.run(argc, argv, name);
}
return 0;
}