Patch level : 12.0 no-patch

Files correlati     : f90.exe f90100a.msk f90200a.msk
Commento            :
- F9 ARCHIVIAZIONE SOSTITUTIVA:
- Modificata funzione apertura maschere secondarie.
- Spostati caricamento da ini nel costruttore dell'applicazione.
- Aggiunto caricamento e salvataggio tabella cat. doc. su ini
- Corretto salvataggio su db delle categorie doc.
- Aggiunto controllo spelling nome categorie solo lettere maiuscole e "_"
- Aggiunto pulsante elimina
This commit is contained in:
Simone Palacino 2020-04-06 19:25:21 +02:00
parent c393381689
commit 64919101a4
7 changed files with 215 additions and 72 deletions

View File

@ -4,4 +4,4 @@
int f90100(int argc, char* argv[]);
int f90200(int argc, char* argv[]);
#endif
#endif // __F90_H

View File

@ -29,10 +29,10 @@
TMask& descr_msk()
{
static TMask* m = nullptr;
static std::unique_ptr<TMask> m = nullptr;
if (m == nullptr)
{
m = new TMask("Estrazione", 1, 60, 5);
m = std::make_unique<TMask>("Estrazione", 1, 60, 5);
m->add_button_tool(DLG_OK, "Conferma", TOOL_OK);
m->add_groupbox(DES_GROUP, 0, "Inserire descrizione estrazione:", 1, 0, 59, 3, "");
m->add_string(DES_TEXT, 0, "Descrizione", 4, 1, 250, "", 40);
@ -40,42 +40,38 @@ TMask& descr_msk()
return *m;
}
// Doppio puntatore perche' cosi' sono sicuro di puntare alla stessa cosa che sta puntando la variabile
// statica all'interno di questa funzione.
// Vale anche per la inclusi_mask()
TMask** esclusi_mask()
TMask& esclusi_mask()
{
static TMask* _esclusi_mask = nullptr;
static unique_ptr<TMask> _esclusi_mask = nullptr;
if (_esclusi_mask == nullptr)
{
_esclusi_mask = new TMask("f90100c.msk");
_esclusi_mask = std::make_unique<TMask>("f90100c.msk");
TMask& m = *_esclusi_mask;
((TSheet_field&)m.field(S_ESCL)).set_notify(TF9_app::select_escl_notify); // Handler dello sheet per selezione singola
m.set_handler(DLG_FINDREC, TF9_app::controllo_escl_handler); // Bottone per aprire maschera di controllo movimenti
m.set_handler(B_ESTRAI, TF9_app::estrai_escl_handler); // Bottone estrai
m.set_handler(DLG_FINDREC, TF9_app::controllo_escl_handler); // Bottone per aprire maschera di controllo movimenti
m.set_handler(B_ESTRAI, TF9_app::estrai_escl_handler); // Bottone estrai
TMask& sheet_m = ((TSheet_field&)m.field(S_ESCL)).sheet_mask(); // Maschera dei campi dello sheet
sheet_m.set_handler(DLG_USER, TF9_app::mov_handler_escl); // Bottone collega movimento
m.field(DLG_FINDREC).disable();
}
return &_esclusi_mask;
return *_esclusi_mask;
}
TMask** inclusi_mask()
TMask& inclusi_mask()
{
static TMask* _inclusi_mask = nullptr;
static std::unique_ptr<TMask> _inclusi_mask = nullptr;
if (_inclusi_mask == nullptr)
{
_inclusi_mask = new TMask("f90100d.msk");
_inclusi_mask = std::make_unique<TMask>("f90100d.msk");
TMask& m = *_inclusi_mask;
((TSheet_field&)m.field(S_ESCL)).set_notify(TF9_app::select_escl_notify); // Handler dello sheet per selezione singola
TMask& sheet_m = ((TSheet_field&)m.field(S_ESCL)).sheet_mask(); // Maschera dei campi dello sheet
sheet_m.set_handler(DLG_USER, TF9_app::mov_handler); // Bottone collega movimento
}
return &_inclusi_mask;
return *_inclusi_mask;
}
const TString& recset_get_string(const TRecordset& rec, const char* field, const int zero_filled)
@ -307,9 +303,6 @@ void TMonitor_mask::delete_pack(const bool all) const
void TMonitor_mask::fill() const
{
f9_app()._config.ambiente = ini_get_string(CONFIG_DITTA, PAR_MOD, AMBIENTE_F9);
f9_app()._config.addr_doc = ini_get_string(CONFIG_DITTA, PAR_MOD, ADDRCART_F9);
TString query;
query << "SELECT * FROM F9DRD00K ORDER BY " << DRD_TIME << " DESC;";
fp_db().sq_set_exec(query, false);
@ -389,7 +382,7 @@ bool TMonitor_mask::on_key(const KEY key)
void TMonitor_mask::open_mostra_estrazione() const
{
TMask& msk = **inclusi_mask();
TMask& msk = inclusi_mask();
//fill
TSheet_field& sf = msk.sfield(S_ESCL);
sf.destroy();
@ -1010,7 +1003,7 @@ void TF9_app::open_esclusi()
// Esclusi mask ////////////////////////////////
fill_esclusi();
while ((*esclusi_mask())->run() == K_ENTER)
while (esclusi_mask().run() == K_ENTER)
{
}
@ -1019,7 +1012,7 @@ void TF9_app::open_esclusi()
void TF9_app::fill_esclusi()
{
vector<TToken_string>& esclusi = f9_app()._esclusi_vect;
TSheet_field& sf = (*esclusi_mask())->sfield(S_ESCL);
TSheet_field& sf = esclusi_mask().sfield(S_ESCL);
sf.hide();
sf.destroy();
for (auto it = esclusi.begin(); it != esclusi.end(); ++it)
@ -1050,10 +1043,10 @@ movimento_t TF9_app::escl2mov(TToken_string* row)
bool TF9_app::estrai_escl_handler(TMask_field&, KEY key)
{
TMask* msk = *esclusi_mask();
TMask& msk = esclusi_mask();
TF9_app& a = f9_app();
vector<TToken_string>& _esclusi = a._esclusi_vect;
TSheet_field& sf = msk->sfield(S_ESCL);
TSheet_field& sf = msk.sfield(S_ESCL);
descr_msk().run();
const TString descr = descr_msk().get(DES_TEXT);
@ -1090,7 +1083,7 @@ bool TF9_app::estrai_escl_handler(TMask_field&, KEY key)
bool TF9_app::mov_handler(TMask_field& f, KEY key)
{
TSheet_field& sf = (*inclusi_mask())->sfield(S_ESCL);
TSheet_field& sf = inclusi_mask().sfield(S_ESCL);
TToken_string& row = sf.row(sf.selected());
TRectype mov(LF_MOV);
mov.put(MOV_NUMREG, row.get(sf.cid2index(F_NUMREG)));
@ -1099,7 +1092,7 @@ bool TF9_app::mov_handler(TMask_field& f, KEY key)
bool TF9_app::mov_handler_escl(TMask_field& f, KEY key)
{
TSheet_field& sf = (*esclusi_mask())->sfield(S_ESCL);
TSheet_field& sf = esclusi_mask().sfield(S_ESCL);
TToken_string& row = sf.row(sf.selected());
TRectype mov(LF_MOV);
mov.put(MOV_NUMREG, row.get(sf.cid2index(F_NUMREG)));
@ -1121,7 +1114,7 @@ int TF9_app::estrai()
const bool flagpro = is_provviso();
// Vero e proprio oggetto estrazione
_estrazione = make_shared<TEstrazione>(
_estrazione = make_unique<TEstrazione>(
get_ambiente(), // Codice ambiente
flagpro, // Flag prov.
tipodoc, // Tipo doc.

View File

@ -59,7 +59,7 @@ class TF9_app : public TSkeleton_application
char _flagprov_escl;
TString _log;
shared_ptr<TEstrazione> _estrazione;
unique_ptr<TEstrazione> _estrazione;
TEstrazione* _estr_escluso;
TDate get_dataini() const { return _estr_msk->get_date(ES_DATAINI); }
@ -127,7 +127,10 @@ public:
bool check_table() const;
TF9_app() : _config({ "", "", false, false }), _estr_msk(nullptr), _msk(nullptr), _mov_escl("", '|'),
_tipodoc_escl('A'), _flagprov_escl('P'), _estrazione(nullptr), _estr_escluso(nullptr)
{ }
{
_config.ambiente = ini_get_string(CONFIG_DITTA, PAR_MOD, AMBIENTE_F9);
_config.addr_doc = ini_get_string(CONFIG_DITTA, PAR_MOD, ADDRCART_F9);
}
};
TF9_app& f9_app();

View File

@ -94,10 +94,10 @@
#define DRT_CODSOC "F9TCSOC" // A(10) [K] - COD.SOCIETŔ
#define DRT_CATDOC "F9TCADO" // A(10) [K] - Categoria documento
#define DRT_DESCR "F9TDES" // A(30) - Descrizione documento
#define DRT_DESCR "F9TDDES" // A(30) - Descrizione documento
#define DRT_CLASSO "F9TCLDC" // A(10) - classe documentale sostitutiva
#define DRT_CAUSSO "F9TCSOS" // A(6) - causale per sostitutiva(TD01…)
#define DRT_CAUSCON "F9TCAU" // A(6) - causale contabile
#define DRT_CAUSCON "F9TCCAU" // A(6) - causale contabile
#define DRT_TIPOCAU "F9TTCAU" // A(6) - tipo causale contabile
#define DRT_TIMOMOV "F9TTMOV" // A(6) - tipo movimento contabile
#define DRT_OPCEE "F9TFCEE" // A(6) - operatore CEE

View File

@ -8,33 +8,55 @@
#include "f90100.h"
///////////////////////////////////////////////////////////////
// TConfigurazione_sostitutiva_msk
// TF9_categorie_doc_msk
///////////////////////////////////////////////////////////////
class TConfigurazione_sostitutiva_msk : public TAutomask
class TF9_categorie_doc_msk : public TAutomask
{
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
bool on_key(KEY key) override;
public:
void check_spell() const;
void load_table() const;
void salva_tabella() const;
TConfigurazione_sostitutiva_msk() : TAutomask("f90200a") { }
public:
TF9_categorie_doc_msk() : TAutomask("f90200a") { load_table(); }
};
bool TConfigurazione_sostitutiva_msk::on_field_event(TOperable_field& o, TField_event e, long jolly)
bool TF9_categorie_doc_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;
salva_tabella();
break;
case B_DELETE:
if (e == fe_button)
{
TSheet_field& sf = sfield(S_CLASSDOC);
sf.hide();
FOR_EACH_SHEET_ROW(sf, nr, row)
{
if (row->starts_with("X"))
{
sf.destroy(nr);
--nr;
}
}
sf.show();
}
break;
}
/*if(o.dlg() >= F_SELCLASS && o.dlg() <= F_OPERCEE && (e == fe_init || e == fe_modify) && jolly >= 1)
{
return true;
}*/
return true;
}
bool TConfigurazione_sostitutiva_msk::on_key(KEY key)
bool TF9_categorie_doc_msk::on_key(KEY key)
{
if (key == K_DEL)
{
@ -49,62 +71,146 @@ bool TConfigurazione_sostitutiva_msk::on_key(KEY key)
return TAutomask::on_key(key);
}
void TF9_categorie_doc_msk::check_spell() const
{
TSheet_field& sf = sfield(S_CLASSDOC);
FOR_EACH_SHEET_ROW(sf, nr, row)
{
TString start;
TString catdoc = start = row->get(F_CATDOC - 101);
catdoc.trim();
catdoc.upper();
std::string ss = (const char*)catdoc;
for (size_t i = 0; i < ss.size(); ++i)
{
if (!(ss[i] >= 'A' && ss[i] <= 'Z' || ss[i] >= '0' && ss[i] <= '9' || ss[i] == '_'))
ss.erase(i--, 1);
}
catdoc = ss.c_str();
row->add(catdoc, 1);
if (catdoc != start)
sf.force_update();
}
}
void TF9_categorie_doc_msk::load_table() const
{
TSheet_field& sf = sfield(S_CLASSDOC);
sf.hide();
sf.destroy();
int idx = 0;
while (true)
{
const TString& appo = ini_get_string(CONFIG_DITTA, "F9", "CATDOC", "", idx++);
if (appo == "STOP" || appo.empty()) /* STOP: Riga terminatrice */
break;
TToken_string& row = sf.row(-1);
row = appo;
}
sf.show();
sf.force_update();
}
void TF9_categorie_doc_msk::salva_tabella() const
{
check_spell();
int idx = 0;
TString iget = "start";
while (iget != "STOP" && !iget.empty())
{
iget = ini_get_string(CONFIG_DITTA, "F9", "CATDOC", "", idx);
ini_remove(CONFIG_DITTA, "F9", "CATDOC", idx++);
}
idx = 0;
TSheet_field& sf = sfield(S_CLASSDOC);
FOR_EACH_SHEET_ROW(sf, nr, row)
{
if(!((TString*)row)->empty())
ini_set_string(CONFIG_DITTA, "F9", "CATDOC", *row, idx++);
}
ini_set_string(CONFIG_DITTA, "F9", "CATDOC", "STOP", idx); // Riga terminatrice
// Reload
load_table();
}
///////////////////////////////////////////////////////////////
// TConfigurazione_sostitutiva_app
// TF9_categorie_doc
///////////////////////////////////////////////////////////////
class TConfigurazione_sostitutiva_app : public TSkeleton_application
class TF9_categorie_doc : public TSkeleton_application
{
TString _log;
void add_error_log(TString& query);
void main_loop() override;
public:
TConfigurazione_sostitutiva_app() { }
TF9_categorie_doc() = default;
};
void TConfigurazione_sostitutiva_app::add_error_log(TString& query)
void TF9_categorie_doc::add_error_log(TString& query)
{
_log << "\n" << query << "\n" << fp_db().sq_get_text_error() << "\n" << fp_db().sq_get_string_error();
}
void TConfigurazione_sostitutiva_app::main_loop()
void TF9_categorie_doc::main_loop()
{
TConfigurazione_sostitutiva_msk msk;
TF9_categorie_doc_msk msk;
while(msk.run() == K_ENTER)
{
TSheet_field& sf = msk.sfield(S_CLASSDOC);
TString query;
FOR_EACH_SHEET_ROW(sf, nr, row)
query << "TRUNCATE TABLE " F9_DRT ";\n";
bool ok = fp_db().sq_set_exec(query, false) && fp_db().sq_commit();
if (ok)
{
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";
FOR_EACH_SHEET_ROW(sf, nr, row)
{
query.cut(0);
query << "INSERT INTO " F9_DRT "("
DRT_CODSOC ", "
DRT_CATDOC ", "
DRT_DESCR ", "
DRT_CLASSO ", "
DRT_CAUSSO ", "
DRT_CAUSCON ", "
DRT_TIPOCAU ", "
DRT_TIMOMOV ", "
DRT_OPCEE ")\nVALUES('" <<
ini_get_string(CONFIG_DITTA, PAR_MOD, AMBIENTE_F9) << "', '" <<
row->get(1) << "', '" <<
row->get(2) << "', '" <<
row->get(3) << "', '" <<
row->get(4) << "', '" <<
row->get(5) << "', '" <<
row->get(6) << "', '" <<
row->get(7) << "', '" <<
row->get(8) << "');\n";
ok &= fp_db().sq_set_exec(query, false) && fp_db().sq_commit();
if (!ok)
break;
}
}
bool ok = fp_db().sq_set_exec(query, false);
ok &= fp_db().sq_commit();
if (false)
if (!ok)
{
add_error_log(query);
ofstream fout;
fout.open("f9.config.error.txt");
fout.open("f9.catdoc.dberror.txt");
fout << _log << "\n";
error_box("Errore nel salvataggio dei dati. Controllare file di errore f9.config.error.txt");
error_box("Errore nel salvataggio dei dati.\nControllare file di errore f9.catdoc.dberror.txt");
}
}
}
int f90200(int argc, char* argv[])
int f90200(const int argc, char* argv[])
{
TConfigurazione_sostitutiva_app app;
app.run(argc, argv, TR("Configurazione Archiviazione Sostitutiva"));
TF9_categorie_doc app;
app.run(argc, argv, TR("Configurazione Categorie Documentali."));
return 0;
}

View File

@ -1,3 +1,5 @@
#define B_DELETE 401
#define S_CLASSDOC 201
#define F_SELCLASS 101

View File

@ -4,11 +4,50 @@ TOOLBAR "topbar" 0 0 0 2
BUTTON DLG_OK 2 2
BEGIN
PROMPT 1 1 "Registra"
PROMPT 1 1 "Regi~stra"
PICTURE TOOL_SAVEREC
END
#include "helpbar.h"
BUTTON B_DELETE 2 2
BEGIN
PROMPT 1 1 "Eli~mina"
PICTURE TOOL_DELREC
END
BUTTON DLG_NULL 2 2
BEGIN
PROMPT -1 1 ""
PICTURE 0
END
BUTTON DLG_INFO 2 2
BEGIN
PROMPT 1 1 "Info"
MESSAGE EXIT,K_F2
PICTURE TOOL_INFO
END
BUTTON DLG_HELP 2 2
BEGIN
PROMPT 2 1 "Help"
MESSAGE EXIT,K_F1
PICTURE TOOL_HELP
END
BUTTON DLG_NULL 2 2
BEGIN
PROMPT -1 0 ""
PICTURE 0
END
BUTTON DLG_CANCEL 2 2
BEGIN
PROMPT 3 1 "Annulla"
MESSAGE EXIT,K_ESC
PICTURE TOOL_CANCEL
END
ENDPAGE
PAGE "Classi Documentali" 0 2 0 0
@ -38,12 +77,12 @@ BEGIN
PROMPT 1 1 "Seleziona"
END
STRING F_CATDOC 5
STRING F_CATDOC 10
BEGIN
PROMPT 0 0 "Categoria Documento"
END
STRING F_DESCRDOC 5
STRING F_DESCRDOC 30
BEGIN
PROMPT 0 0 "Descrizione Documento"
END
@ -70,22 +109,22 @@ BEGIN
ITEM "TD20|TD20 Autofattura"
END
STRING F_CAUSCONT 5
STRING F_CAUSCONT 6
BEGIN
PROMPT 0 0 "Causale Contabile"
END
STRING F_TIPOCAUSCONT 5
STRING F_TIPOCAUSCONT 6
BEGIN
PROMPT 0 0 "Tipo Causale Contabile"
END
STRING F_TIPOMOVCONT 5
STRING F_TIPOMOVCONT 6
BEGIN
PROMPT 0 0 "Tipo Movimento Contabile"
END
STRING F_OPERCEE 5
STRING F_OPERCEE 6
BEGIN
PROMPT 0 0 "Operatore CEE"
END