// gestione tabelle di modulo hardy #include #include #include #include #include "halib.h" #include "hatbatt.h" #include "hatbcau.h" #include "hatbcel.h" /////////////////////////////////////////////////////////// // Maschera generica di gestione tabelle hardy /////////////////////////////////////////////////////////// class THA_table_mask : public TAutomask { protected: virtual bool on_field_event(TOperable_field &o, TField_event e, long jolly); public: THA_table_mask(const char* name) : TAutomask(name) {} }; bool THA_table_mask::on_field_event(TOperable_field &o, TField_event e, long jolly) { return true; } /////////////////////////////////////////////////////////// // Applicazione generica di gestione tabelle hardy /////////////////////////////////////////////////////////// // applicazione per la gestione delle tabelle di lavanderia class THA_table_app : public TTable_module_application { protected: // TRelation_application virtual bool protected_record(TRectype& record); virtual void init_query_mode(TMask& m); virtual void init_query_insert_mode(TMask& m); virtual void init_insert_mode(TMask& m); virtual void init_modify_mode(TMask& m); virtual bool get_next_key(TToken_string& key); }; bool THA_table_app::get_next_key(TToken_string& key) { //casino per la tabella attrezzature "&ATT" const TString4 name = get_relation()->file(0).name(); if (name == "ATT") { const TString& codart = curr_mask().get(F_CODART); if (codart.full()) { const TString& codtab = get_next_att_key(codart); //riempie la token_string con i dati richiesti key.add(F_CODART); key.add(codart); key.add(F_PROGRESSIVO); key.add(codtab.mid(5)); } return true; } return TTable_module_application::get_next_key(key); } bool THA_table_app::protected_record(TRectype& record) { const TString4 name = get_relation()->file(0).name(); //tabella delle attrezzature //non si puņ eliminare una attrezzatura se la medesima ha una storia! rispettiamo gli anziani! if (name == "ATT") { //controlla che l'attrezzatura non abbia record nella tabella della storia attrezzature TString query; query << "USE &HIS"; query << "\nFROM CODTAB=#CODATTR"; query << "\nTO CODTAB=#CODATTR"; const TString codattr = record.get("CODTAB"); TISAM_recordset attr_recset(query); attr_recset.set_var("#CODATTR", codattr); const long items = attr_recset.items(); return items > 0; } return true; } void THA_table_app::init_insert_mode(TMask& m) { const TString4 name = get_relation()->file(0).name(); if (name == "ATT") { m.hide(-2); m.show(-1); } } void THA_table_app::init_modify_mode(TMask& m) { const TString4 name = get_relation()->file(0).name(); if (name == "ATT") { m.hide(-2); m.show(-1); } } void THA_table_app::init_query_mode(TMask& m) { const TString4 name = get_relation()->file(0).name(); if (name == "CEL") { m.hide(F_CODCLI1); m.show(F_CODCLI); } if (name == "ATT") //inizialmente vedo il gruppo 2 di SEARCH e non quello 1 di NEW { m.hide(-1); m.show(-2); } } void THA_table_app::init_query_insert_mode(TMask& m) { const TString4 name = get_relation()->file(0).name(); if (name == "CEL") { m.hide(F_CODCLI); m.show(F_CODCLI1); } if (name == "ATT") { m.hide(-2); //in caso di 'nuovo' vedo il gruppo di NEW m.show(-1); } } int ha0100(int argc, char* argv[]) { THA_table_app a; a.run(argc, argv, TR("Tabella Caffe' Hardy")); return 0; }