diff --git a/ci/ci0.cpp b/ci/ci0.cpp index 1a72b64c9..6b57d2f36 100755 --- a/ci/ci0.cpp +++ b/ci/ci0.cpp @@ -10,7 +10,7 @@ int main(int argc, char** argv) // ci0200(argc,argv); // stampa tabelle break; case 2: - // ci0300(argc,argv); // parametri configurazione Contabilita' Industriale + ci0300(argc,argv); // parametri configurazione Contabilita' Industriale break; case 3: ci0400(argc,argv); // Immssione documenti diff --git a/ci/ci0300.cpp b/ci/ci0300.cpp new file mode 100755 index 000000000..3248dff18 --- /dev/null +++ b/ci/ci0300.cpp @@ -0,0 +1,196 @@ +#include +#include +#include +#include + +#include + +#include "ci0.h" +#include "cilib.h" +#include "ci0300.h" + +/////////////////////////////////////////////////////////// +// TConfigurazioneIndustriale_mask +/////////////////////////////////////////////////////////// + +void TConfigurazioneIndustriale_mask::add_element(TToken_string& t, long selrow) +{ + if (selrow<-1) + return; + + if (selrow>items()-1) + selrow = -1; + + rows_array().add(t,selrow); + force_update(); + +} + +void TConfigurazioneIndustriale_mask::add_element(long selrow) +{ + if (selrow<-1) + return; + + if (selrow>items()-1) + selrow = -1; + + sheet().insert(selrow, true, true); + force_update(); + +} + +void TConfigurazioneIndustriale_mask::delete_element(long selrow) +{ + TToken_string t(40); + + if (items()<1) + return; + + if (selrow<0) + return; + + if (selrow>items()-1) + return; + + rows_array().destroy(selrow); + force_update(); + +} + +void TConfigurazioneIndustriale_mask::moveup_element(long selrow) +{ + if (items()<=1) + return; + + if (selrow<=0) + return; + + if (selrow>items()-1) + return; + + rows_array().swap(selrow,selrow-1); + sheet().force_update(); + sheet().select(selrow-1); + +} + +void TConfigurazioneIndustriale_mask::movedown_element(long selrow) +{ + if (items()<=1) + return; + + if (selrow<0) + return; + + if (selrow>=items()-1) + return; + + rows_array().swap(selrow,selrow+1); + sheet().force_update(); + sheet().select(selrow+1); + +} + +bool TConfigurazioneIndustriale_mask::on_field_event(TOperable_field& o, TField_event e, long jolly) +{ + switch (o.dlg()) + { + case F_MOVEUP: + moveup_element(sheet().selected()); + break; + case F_MOVEDN: + movedown_element(sheet().selected()); + break; + default: + break; + } + + return true; +} + +/////////////////////////////////////////////////////////// +// TConfigurazioneIndustriale_app +/////////////////////////////////////////////////////////// + +// Overrides + +bool TConfigurazioneIndustriale_app::create() +{ + _mask = new TConfigurazioneIndustriale_mask(); + + file_to_sheet(); + + return TSkeleton_application::create(); +} + +bool TConfigurazioneIndustriale_app::destroy() +{ + delete _mask; + + return TSkeleton_application::destroy(); +} + +void TConfigurazioneIndustriale_app::main_loop() +{ + KEY exitval; + + while ((exitval=_mask->run()) != K_QUIT) + { + + switch(exitval) + { + case K_ESC: + return; + default: + break; + } + } + + sheet_to_file(); +} + +// Conversione Array <-> File + +void TConfigurazioneIndustriale_app::file_to_sheet() +{ + TConfig configfile(CONFIG_DITTA, "ci"); + int item = 0; + + while (configfile.exist("Descr",item)) + { + TToken_string t; + t.add(configfile.get("Filter", NULL,item, "F01")); + t.add(configfile.get("Descr", NULL,item, "Fatture")); + mask().add_element(t); + item++; + } + +} + +void TConfigurazioneIndustriale_app::sheet_to_file() +{ + TConfig configfile(CONFIG_DITTA, "ci"); + int items; + + items = mask().items(); + configfile.remove_all(); + + for (int i=0;i