#include #include #include #include #include #include "in0.h" #include "in0500a.h" #include "inlib01.h" #include /////////////////////////////////////////////////////////// // TImmissione_mask /////////////////////////////////////////////////////////// class TImmissione_mask : public TIntra_mask { protected: virtual short type_field() const { return F_TIPO_MOV; } protected: virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); bool on_sheet_event(TSheet_field& s, TField_event e, int row); bool on_sheet_field_event(TOperable_field& o, TField_event e, long jolly); public: TImmissione_mask(); virtual ~TImmissione_mask() { } }; bool TImmissione_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) { const short id = o.dlg(); switch (id) { case F_NUM_REG: if (e == fe_modify) { if (main_app().has_module(CGAUT)) { const TString& numreg = o.get(); const TRectype& mov = cache().get(LF_MOV, numreg); set(F_NUM_DOC, mov.get(MOV_NUMDOC)); set(F_DATA_DOC, mov.get(MOV_DATADOC)); } } break; case F_TIPO_MOV: if (e == fe_init || e == fe_modify) { TMask& m = sfield(F_RIGHE).sheet_mask(); const bool acq = tipo() == 'A'; m.show(-GR_ACQUISTI, acq); // Mostra i gruppi di campi m.show(-GR_CESSIONI, !acq); // consoni al tipo movimento /* const bool req = frequenza() == 'M'; for (int i = m.fields()-1; i >= 0; i--) { TMask_field& f = m.fld(i); if (f.dlg() <= F_NOMENCLATURA) break; if (f.is_edit()) f.check_type(req ? CHECK_REQUIRED : CHECK_NORMAL); } */ } break; case F_VALUTA: if (e == fe_modify) { TEdit_field& cambio = efield(F_CAMBIO); if (cambio.empty()) { const TRectype& curr = efield(F_VALUTA).browse()->cursor()->curr(); const TString& s = curr.get("S4"); if (s.not_empty()) cambio.set(s); else { const TString& r = curr.get("R0"); cambio.set(r); } } } break; case F_AMM_LIRE: if (e == fe_modify) { TMask& m = o.mask(); if (m.get_real(F_AMM_VALUTA).is_zero()) { TCurrency curr(real(o.get()), "_FIRM"); curr.change_value(get(F_VALUTA), get_real(F_CAMBIO)); m.set(F_AMM_VALUTA, curr.string(), TRUE); } } break; case F_AMM_VALUTA: if (e == fe_modify) { TMask& m = o.mask(); if (m.get_real(F_AMM_LIRE).is_zero()) { TCurrency curr(real(o.get()), get(F_VALUTA), get_real(F_CAMBIO)); curr.change_value("_FIRM"); m.set(F_AMM_LIRE, curr.string(), TRUE); } } break; case F_RIGHE: return on_sheet_event((TSheet_field&)o, e, int(jolly)); case R_RIEPILOGHI: if (e == fe_button) ::genera_riepiloghi(tipo()); break; default: if (id < F_DITTA && jolly == 1) return on_sheet_field_event(o, e, jolly); break; } return TIntra_mask::on_field_event(o, e, jolly); } bool TImmissione_mask::on_sheet_event(TSheet_field& s, TField_event e, int row) { return TRUE; } bool TImmissione_mask::on_sheet_field_event(TOperable_field& o, TField_event e, long jolly) { switch (o.dlg()) { case F_NOMENCLATURA: if (e == fe_modify) { TMask& m = o.mask(); if (!o.empty()) { const TRectype& nom = ((TEdit_field&)o).browse()->cursor()->curr(); if (m.get(F_UMS).empty()) m.set(F_UMS, nom.get("S5"), TRUE); bool req = frequenza() == 'M'; if (req) // Solo la frequenza mensile puo' obbligare { const char obb = nom.get_char("S4"); req = obb == 'E' || obb == tipo(); } m.field(F_UMS).check_type(req ? CHECK_REQUIRED : CHECK_NORMAL); m.field(F_MASSA_UMS).check_type(req ? CHECK_REQUIRED : CHECK_NORMAL); } else { m.set(F_UMS, "", TRUE); } } break; default: break; } return TRUE; } TImmissione_mask::TImmissione_mask() : TIntra_mask("in0500a") { } /////////////////////////////////////////////////////////// // Applicazione principale /////////////////////////////////////////////////////////// class TImmissione_intra : public TRelation_application { TRelation* _rel; TImmissione_mask* _msk; protected: virtual bool user_create(); virtual TRelation* get_relation() const { return _rel; } virtual TMask* get_mask(int) { return _msk; } virtual bool changing_mask(int mode) { return FALSE; } virtual bool user_destroy(); public: }; bool TImmissione_intra::user_create() { open_files(LF_TABCOM, LF_TAB, LF_CLIFO, LF_MOV, LF_INTRA, LF_RINTRA, 0); _rel = new TRelation(LF_INTRA); _msk = new TImmissione_mask; return TRUE; } bool TImmissione_intra::user_destroy() { delete _msk; delete _rel; return TRUE; } int in0500(int argc, char* argv[]) { TImmissione_intra a; a.run(argc, argv, "Movimenti INTRA"); return 0; }