diff --git a/src/f9/f90200.cpp b/src/f9/f90200.cpp new file mode 100644 index 000000000..596028b5a --- /dev/null +++ b/src/f9/f90200.cpp @@ -0,0 +1,110 @@ +#include "f90.h" +#include "applicat.h" +#include "automask.h" +#include "f90200a.h" +#include "tsdb.h" +#include "../fp/fplib.h" +#include "f901tab.h" +#include "f9lib.h" + +/////////////////////////////////////////////////////////////// +// TConfigurazione_sostitutiva_msk +/////////////////////////////////////////////////////////////// + +class TConfigurazione_sostitutiva_msk : public TAutomask +{ + + bool on_field_event(TOperable_field& o, TField_event e, long jolly) override; + bool on_key(KEY key) override; + +public: + + TConfigurazione_sostitutiva_msk() : TAutomask("f90200a") { } +}; + +bool TConfigurazione_sostitutiva_msk::on_field_event(TOperable_field& o, TField_event e, long jolly) +{ + switch(o.dlg()) + { + case DLG_OK: + if (e == fe_button) + bool simo = true; + break; + } + return true; +} + +bool TConfigurazione_sostitutiva_msk::on_key(KEY key) +{ + if (key == K_DEL) + { + TSheet_field& sf = sfield(S_CLASSDOC); + sf.hide(); + int row = sf.selected(); + TString_array& arr = sf.rows_array(); + arr.destroy(row, true); + sf.force_update(); + sf.show(); + } + return TAutomask::on_key(key); +} + + +/////////////////////////////////////////////////////////////// +// TConfigurazione_sostitutiva_app +/////////////////////////////////////////////////////////////// + +class TConfigurazione_sostitutiva_app : public TSkeleton_application +{ + TString _log; + void add_error_log(TString& query); + void main_loop() override; + +public: + + TConfigurazione_sostitutiva_app() { } +}; + + +void TConfigurazione_sostitutiva_app::add_error_log(TString& query) +{ + _log << "\n" << query << "\n" << db().sq_get_text_error() << "\n" << db().sq_get_string_error(); +} + +void TConfigurazione_sostitutiva_app::main_loop() +{ + TConfigurazione_sostitutiva_msk msk; + while(msk.run() == K_ENTER) + { + TSheet_field& sf = msk.sfield(S_CLASSDOC); + TString query; + FOR_EACH_SHEET_ROW(sf, nr, row) + { + TString where_s; + where_s << ""; + query << "IF EXIST (SELECT * FROM " F9_DRT " WHERE " << where_s << ")\n" + " UPDATE " F9_DRT " SET \n" + " WHERE " << where_s << ";\n" + "ELSE" + " INSERT INTO " F9_DRT " ( ) \n" + " VALUES ();\n"; + } + bool ok = db().sq_set_exec(query, false); + ok &= db().sq_commit(); + if (false) + { + add_error_log(query); + ofstream fout; + fout.open("f9.config.error.txt"); + fout << _log << "\n"; + error_box("Errore nel salvataggio dei dati. Controllare file di errore f9.config.error.txt"); + } + } +} + +int f90200(int argc, char* argv[]) +{ + TConfigurazione_sostitutiva_app app; + app.run(argc, argv, TR("Configurazione Archiviazione Sostitutiva")); + return 0; +}