148 lines
3.5 KiB
C++
148 lines
3.5 KiB
C++
|
#include <automask.h>
|
||
|
#include <defmask.h>
|
||
|
#include <relapp.h>
|
||
|
#include <tabutil.h>
|
||
|
|
||
|
#include "fp0.h"
|
||
|
#include "fp0500a.h"
|
||
|
#include "fplib.h"
|
||
|
#include "fpccaus.h"
|
||
|
#include "fpcart.h"
|
||
|
#include "fpcadg.h"
|
||
|
|
||
|
|
||
|
//-------------------------------------------------------------------
|
||
|
// MASCHERA (fp0500a)
|
||
|
//-------------------------------------------------------------------
|
||
|
class TFpcust_mask : public TAutomask
|
||
|
{
|
||
|
protected:
|
||
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
|
||
|
public:
|
||
|
|
||
|
TFpcust_mask();
|
||
|
};
|
||
|
|
||
|
bool TFpcust_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||
|
{
|
||
|
switch (o.dlg())
|
||
|
{
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
TFpcust_mask::TFpcust_mask() : TAutomask("fp0500a")
|
||
|
{
|
||
|
}
|
||
|
|
||
|
|
||
|
//--------------------------------------------------------------
|
||
|
// APPLICAZIONE
|
||
|
//--------------------------------------------------------------
|
||
|
class TFpcust : public TRelation_application
|
||
|
{
|
||
|
TFpcust_mask* _mask{ nullptr };
|
||
|
TRelation* _rel{ nullptr };
|
||
|
TFP_custom* _fpcust{ nullptr };
|
||
|
|
||
|
protected:
|
||
|
int read(TMask& m) override;
|
||
|
int write(const TMask& m) override;
|
||
|
int rewrite(const TMask& m) override;
|
||
|
|
||
|
void load_cust(const TMask& m) const;
|
||
|
|
||
|
bool user_create() override;
|
||
|
bool user_destroy() override;
|
||
|
TMask* get_mask(int mode) override { return _mask; }
|
||
|
bool changing_mask(int mode) override { return false; }
|
||
|
|
||
|
public:
|
||
|
// @cmember Disabilita la verifica del modulo : essendo una anagrafica, va sempre abilitata
|
||
|
bool check_autorization() const override { return true; }
|
||
|
TRelation* get_relation() const override { return static_cast<TRelation*>(_rel); }
|
||
|
};
|
||
|
|
||
|
int TFpcust::read(TMask& m)
|
||
|
{
|
||
|
TRelation_application::read(m);
|
||
|
|
||
|
// Carico tutti gli sheet
|
||
|
TFP_custom& fp_custom = dynamic_cast<TFP_custom&>(get_relation()->lfile().curr());
|
||
|
|
||
|
TSheet_field& sheet_causali = m.sfield(F_CAUSALI);
|
||
|
sheet_causali.destroy();
|
||
|
FOR_EACH_FPCAUS_ROW(fp_custom, r, rcaus)
|
||
|
{
|
||
|
TToken_string& row = sheet_causali.row(-1);
|
||
|
row.add(rcaus->get(FPCCAUS_VALORE), xvtil_cid2index(S_CAUS_VALORE));
|
||
|
}
|
||
|
|
||
|
TSheet_field& sheet_articoli = m.sfield(F_ARTICOLI);
|
||
|
sheet_articoli.destroy();
|
||
|
FOR_EACH_FPART_ROW(fp_custom, r, rart)
|
||
|
{
|
||
|
TToken_string& row = sheet_articoli.row(-1);
|
||
|
row.add(rart->get(FPCART_TIPO), xvtil_cid2index(S_ART_TIPO));
|
||
|
row.add(rart->get(FPCART_VALORE), xvtil_cid2index(S_ART_VALORE));
|
||
|
}
|
||
|
|
||
|
TSheet_field& sheet_adg = m.sfield(F_ADG);
|
||
|
sheet_adg.destroy();
|
||
|
FOR_EACH_FPADG_ROW(fp_custom, r, radg)
|
||
|
{
|
||
|
TToken_string& row = sheet_adg.row(-1);
|
||
|
row.add(radg->get(FPCADG_TIPODATO), xvtil_cid2index(S_ADG_TIPODATO));
|
||
|
row.add(radg->get(FPCADG_RTESTO), xvtil_cid2index(S_ADG_RTESTO));
|
||
|
row.add(radg->get(FPCADG_RNUMERO), xvtil_cid2index(S_ADG_RNUMERO));
|
||
|
row.add(radg->get(FPCADG_RDATA), xvtil_cid2index(S_ADG_RDATA));
|
||
|
}
|
||
|
|
||
|
return NOERR;
|
||
|
}
|
||
|
|
||
|
int TFpcust::write(const TMask& m)
|
||
|
{
|
||
|
load_cust(m);
|
||
|
return TRelation_application::write(m);
|
||
|
}
|
||
|
|
||
|
int TFpcust::rewrite(const TMask& m)
|
||
|
{
|
||
|
load_cust(m);
|
||
|
return TRelation_application::rewrite(m);
|
||
|
}
|
||
|
|
||
|
void TFpcust::load_cust(const TMask& m) const
|
||
|
{
|
||
|
_fpcust->set_codcust(m.get(F_CODICE), false);
|
||
|
_fpcust->autoload(m.sfield(F_CAUSALI), LF_FPCCAUS);
|
||
|
_fpcust->autoload(m.sfield(F_ARTICOLI), LF_FPCART);
|
||
|
_fpcust->autoload(m.sfield(F_ADG), LF_FPCADG);
|
||
|
}
|
||
|
|
||
|
|
||
|
bool TFpcust::user_create()
|
||
|
{
|
||
|
_fpcust = new TFP_custom();
|
||
|
_rel = new TRelation(LF_FPCUST);
|
||
|
_rel->lfile().set_curr(_fpcust);
|
||
|
_mask = new TFpcust_mask;
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
bool TFpcust::user_destroy()
|
||
|
{
|
||
|
delete _mask;
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
int fp0500(int argc, char* argv[])
|
||
|
{
|
||
|
TFpcust a;
|
||
|
a.run(argc, argv, TR("Lettere d'intento"));
|
||
|
return 0;
|
||
|
}
|