d3f3c31928
Files correlati : Ricompilazione Demo : [ ] Commento :Inserito controllo max numero pagine e max lunghezza git-svn-id: svn://10.65.10.50/trunk@13051 c028cbd2-c16b-5b4b-a496-9718f37d4682
209 lines
3.8 KiB
C++
Executable File
209 lines
3.8 KiB
C++
Executable File
#include <applicat.h>
|
||
#include <automask.h>
|
||
#include <sheet.h>
|
||
#include <utility.h>
|
||
|
||
#include <doc.h>
|
||
|
||
#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 totlen = 0;
|
||
int items;
|
||
|
||
items = mask().items();
|
||
configfile.remove_all();
|
||
|
||
if (items>_maxelem)
|
||
{
|
||
message_box("Il massimo numero di filtri gestibili <20> pari a %d, pertanto verranno considerate solamente le prime %d righe", _maxelem, _maxelem);
|
||
items=16;
|
||
}
|
||
|
||
for (int i=0;i<items;i++)
|
||
{
|
||
TString currdesc(mask().row(i).get(1));
|
||
configfile.set("Filter", mask().row(i).get(0), NULL, true, i);
|
||
configfile.set("Descr", currdesc, NULL, true, i);
|
||
totlen+=currdesc.len();
|
||
}
|
||
|
||
if (totlen>_maxlen)
|
||
message_box("E' probabile che la lunghezza delle descrizioni inserite ne impedisca la totale visualizzazione sullo schermo");
|
||
|
||
}
|
||
|
||
///////////////////////////////////////////////////////////
|
||
// Main
|
||
///////////////////////////////////////////////////////////
|
||
|
||
int ci0300(int argc, char* argv[])
|
||
{
|
||
TConfigurazioneIndustriale_app a ;
|
||
a.run(argc, argv, TR("Contabilit<EFBFBD> Industriale"));
|
||
return 0;
|
||
}
|
||
|