Patch level : 12.0 874

Files correlati     : f9.exe, f90100.sql
Commento            :
- Pulizia codice
- Eliminazione record movimento nella lista di controllo errori (eliminazione da db)
- Cambiato sistema di fetch numero ultima estrazione del giorno
- Cambiato ordinamento visualizzazione pacchetti in ordine decr. di data
- Sistemata query controllo sovrapposizione periodi per definitivo
- Aggiunti messaggi di errore in caso di fallimento creazione/aggiornam. tabelle
This commit is contained in:
Simone Palacino 2019-09-17 11:45:00 +02:00
parent dee23524bc
commit 257f685a70
2 changed files with 45 additions and 38 deletions

View File

@ -101,11 +101,11 @@ bool TEstrai_mask::estrai_handler(TMask_field& f, unsigned short key)
message_box("Estrazione avvenuta con successo!"); message_box("Estrazione avvenuta con successo!");
app().segna_estratti(); app().segna_estratti();
} }
else if (!stato) if (!stato)
{ {
app().segna_in_errore(); app().segna_in_errore();
warning_box("L'estrazione non e' stata completata. Controllare il log degli errori."); warning_box("L'estrazione non e' stata completata. Controllare il log degli errori.");
} }
return true; return true;
} }
@ -226,13 +226,13 @@ void TMonitor_mask::open_win_conf() const
m->run(); m->run();
} }
void TMonitor_mask::fill() void TMonitor_mask::fill() const
{ {
app()._ambiente = ini_get_string(CONFIG_DITTA, PAR_MOD, AMBIENTE_F9); app()._ambiente = ini_get_string(CONFIG_DITTA, PAR_MOD, AMBIENTE_F9);
app()._addr_doc = ini_get_string(CONFIG_DITTA, PAR_MOD, ADDRCART_F9); app()._addr_doc = ini_get_string(CONFIG_DITTA, PAR_MOD, ADDRCART_F9);
TString query; TString query;
query << "SELECT * FROM F9DRD00K ORDER BY " << DRD_TIME << ";"; query << "SELECT * FROM F9DRD00K ORDER BY " << DRD_TIME << " DESC;";
db().sq_set_exec(query, false); db().sq_set_exec(query, false);
TSheet_field& sf = sfield(S_ELAB); TSheet_field& sf = sfield(S_ELAB);
@ -260,19 +260,12 @@ void TMonitor_mask::fill()
row.add(db().sq_get(DRD_UTENTE)); row.add(db().sq_get(DRD_UTENTE));
row.add(TF9_app::traduci_stato(db().sq_get(DRD_STATO))); row.add(TF9_app::traduci_stato(db().sq_get(DRD_STATO)));
row.add(db().sq_get(DRD_DESC)); row.add(db().sq_get(DRD_DESC));
if (TDate(row.get(cid2index(F_DATAESTR))) == today)
{
if (TString(row.get(cid2index(F_PROV_B))) == "X")
app()._last_estr_p = real(TString(row.get(cid2index(F_IDESTR))).ltrim(10)).integer();
else
app()._last_estr_d = real(TString(row.get(cid2index(F_IDESTR))).ltrim(10)).integer();
}
} }
sf.force_update(); sf.force_update();
sf.show(); sf.show();
} }
void TMonitor_mask::delete_pack(bool all) void TMonitor_mask::delete_pack(const bool all) const
{ {
bool flag = false; bool flag = false;
TSheet_field& sf = sfield(S_ELAB); TSheet_field& sf = sfield(S_ELAB);
@ -418,6 +411,13 @@ void TF9_dberr::send()
_insert.cut(0) << "INSERT INTO " F9_ERR " VALUES ()"; _insert.cut(0) << "INSERT INTO " F9_ERR " VALUES ()";
} }
void TF9_dberr::del_err(const TString& id_estr, int numreg)
{
TString query;
query << "DELETE FROM " F9_ERR " WHERE IDESTR = '" << id_estr << "' AND NUMREG = '" << numreg << "';";
db().sq_set_exec(query);
}
char TF9_dberr::get_errori(const TString& id_estr, vector<TToken_string>& movs) char TF9_dberr::get_errori(const TString& id_estr, vector<TToken_string>& movs)
{ {
TString query; TString query;
@ -698,7 +698,7 @@ void TF9_app::edit_wa() const
"INSERT INTO F9WA00K (F9PCSOC, F9PPCDC0) VALUES (" << _ambiente << ", " << _addr_doc << ");"; "INSERT INTO F9WA00K (F9PCSOC, F9PPCDC0) VALUES (" << _ambiente << ", " << _addr_doc << ");";
} }
void TF9_app::export_error_list(bool esclusi) // todo: da ritestare void TF9_app::export_error_list(bool esclusi)
{ {
TF9_dberr dberr; TF9_dberr dberr;
vector<TToken_string>& movs = esclusi ? _esclusi : _movs; vector<TToken_string>& movs = esclusi ? _esclusi : _movs;
@ -747,7 +747,6 @@ void TF9_app::load()
// Prendo tutti i movimenti a partire da una data e li carico tutti fino alla data finale // Prendo tutti i movimenti a partire da una data e li carico tutti fino alla data finale
_movs.clear(); _movs.clear();
for (bool ok = mov.read(); ok && (datareg = mov.get_date(MOV_DATAREG)) >= dataini && datareg <= dataend; ok = mov.next() == NOERR) for (bool ok = mov.read(); ok && (datareg = mov.get_date(MOV_DATAREG)) >= dataini && datareg <= dataend; ok = mov.next() == NOERR)
{ {
if (!progr.add_status()) if (!progr.add_status())
@ -976,10 +975,16 @@ bool TF9_app::is_doc_xml(const TLocalisamfile& mov)
TString TF9_app::next_estr_today(const char tipo) const TString TF9_app::next_estr_today(const char tipo) const
{ {
char estr[] = {0,0,0,0,0,0,0,0,0}; char estr[] = {0,0,0,0,0,0,0,0,0};
if(tipo == 'P') TString query;
sprintf_s(estr, 9, "%08d", _last_estr_p + 1); query << "SELECT TOP 1 " DRD_ID_EST " AS IDESTR\n"
else "FROM " F9_DRD "\n"
sprintf_s(estr, 9, "%08d", _last_estr_d + 1); "WHERE " DRD_ID_EST " LIKE '" << today.date2ansi() << tipo << "%'\n" <<
"ORDER BY " DRD_ID_EST " DESC";
if(!db().sq_set_exec(query))
fatal_box(db().sq_get_text_error());
const int last_estr = real(db().sq_get("IDESTR").ltrim(10)).integer();
sprintf_s(estr, 9, "%08d", last_estr + 1);
return estr; return estr;
} }
@ -989,9 +994,10 @@ bool TF9_app::check_periodo_def(const drd& head)
// Controllo se ci sono estrazioni (definitive) che si sovrappongono di periodo (con lo stesso tipo) e che non siano in stato di errore // Controllo se ci sono estrazioni (definitive) che si sovrappongono di periodo (con lo stesso tipo) e che non siano in stato di errore
// Nel caso di stato di errore e' invece possibile la ri-estrazione // Nel caso di stato di errore e' invece possibile la ri-estrazione
query << "SELECT *\nFROM F9DRD00K\n" << query << "SELECT *\nFROM F9DRD00K\n" <<
"WHERE '" << head.dal.date2ansi() << "' =< " DRD_DATAA " AND '" << head.al.date2ansi() << "' >= " DRD_DATADA " AND " "WHERE " << DRD_DATAA << " >= '" << head.dal.date2ansi() << "' AND " DRD_DATADA " <= '" << head.al.date2ansi() << "' AND "
DRD_FLAG_PD " = 'D' AND\n F9RIDAS <> '" D_GEST_ERR "' AND F9RIDAS <> '" D_WA_ERR "' AND F9RIDAS <> '" D_ERR_SOS "' AND " DRD_TIPODOC " = '" << head.tipo_doc << "';"; DRD_FLAG_PD " = 'D' AND\n " DRD_STATO " <> '" D_GEST_ERR "' AND " DRD_STATO " <> '" D_WA_ERR "' AND " DRD_STATO " <> '" D_ERR_SOS "' AND " DRD_TIPODOC " = '" << head.tipo_doc << "';";
db().sq_set_exec(query); if (!db().sq_set_exec(query))
fatal_box(db().sq_get_text_error());
return db().sq_items() == 0; return db().sq_items() == 0;
} }
@ -1074,7 +1080,7 @@ int TF9_app::estrai()
else if (_head.stato_estr == D_GEST_OK) else if (_head.stato_estr == D_GEST_OK)
{ {
_msk->disable_controllo_err(); _msk->disable_controllo_err();
return estrazione_iva() ? 1 : false; return estrazione_iva() ? 1 : 0;
} }
} }
return -2; return -2;
@ -1229,7 +1235,7 @@ void TF9_app::segna_in_errore() const
db().sq_set_exec(query); db().sq_set_exec(query);
} }
#ifdef DBG
void pulisci_mov() void pulisci_mov()
{ {
TLocalisamfile mov(LF_MOV); TLocalisamfile mov(LF_MOV);
@ -1240,9 +1246,10 @@ void pulisci_mov()
{ {
mov.put(MOV_ELABF9, ""); mov.put(MOV_ELABF9, "");
mov.write(); mov.write();
bool ok = mov.rewrite() == NOERR; mov.rewrite();
}while (mov.next() == NOERR); }while (mov.next() == NOERR);
} }
#endif
void TF9_app::main_loop() void TF9_app::main_loop()
{ {
@ -1273,12 +1280,12 @@ bool TF9_app::create_tables() const
char ver[5] = "0000"; char ver[5] = "0000";
sprintf_s(ver, 5, "%04d", 100); sprintf_s(ver, 5, "%04d", 100);
tabmod.put(TABMOD_TABVER, ver); tabmod.put(TABMOD_TABVER, ver);
tabmod.write(); // todo: controllare tabmod.write();
ok &= tabmod.rewrite() == NOERR; // todo: controllare ok &= tabmod.rewrite() == NOERR;
return ok; return ok;
} }
bool TF9_app::check_tabelle_f9() bool TF9_app::check_tabelle_f9() const
{ {
bool ok = true; bool ok = true;
TString query; TString query;
@ -1553,7 +1560,7 @@ TToken_string* TControllo_mask::selected_fat() const
return nullptr; return nullptr;
} }
void TControllo_mask::associa() void TControllo_mask::associa() // todo: levare gli ultimi residui del vecchio funzionamento del controllo errori
{ {
TToken_string* mov_sel = selected_mov(); TToken_string* mov_sel = selected_mov();
TToken_string* fat_sel = selected_fat(); TToken_string* fat_sel = selected_fat();
@ -1579,6 +1586,7 @@ void TControllo_mask::associa()
++it; ++it;
} }
it->add(" ", 0); it->add(" ", 0);
TF9_dberr::del_err(_id_estr, mov_sel->get_int(cid2index(F_CNUMREG)));
} }
} }

View File

@ -70,8 +70,6 @@ class TF9_app : public TSkeleton_application
int _tot_movs; int _tot_movs;
TString _ambiente; // Codice ambiente (codsoc) TString _ambiente; // Codice ambiente (codsoc)
TString _addr_doc; // Indirizzo documenti cartacei TString _addr_doc; // Indirizzo documenti cartacei
int _last_estr_p;
int _last_estr_d;
char _tipodoc_escl; char _tipodoc_escl;
char _flagprov_escl; char _flagprov_escl;
@ -139,12 +137,12 @@ public:
// Controllo e aggiornamento tabelle F9 // Controllo e aggiornamento tabelle F9
bool create_tables() const; // Creazione tabelle F9 bool create_tables() const; // Creazione tabelle F9
bool check_tabelle_f9(); // Controllo esistenza delle tabelle e in caso le crea bool check_tabelle_f9() const; // Controllo esistenza delle tabelle e in caso le crea
bool aggiorna_tab_f9(int version) const; // Aggiorna modifiche alle tabelle F9 come descritto in cima al file .cpp bool aggiorna_tab_f9(int version) const; // Aggiorna modifiche alle tabelle F9 come descritto in cima al file .cpp
bool check_tab_version() const; // Controllo della versione e in caso aggiorna le tabelle bool check_tab_version() const; // Controllo della versione e in caso aggiorna le tabelle
bool check_table() const; bool check_table() const;
TF9_app() : _estr_msk(nullptr), _msk(nullptr), _mov_escl("", '|'), _tot_movs(0), _ambiente(""), _addr_doc(""), TF9_app() : _estr_msk(nullptr), _msk(nullptr), _mov_escl("", '|'), _tot_movs(0), _ambiente(""), _addr_doc(""),
_last_estr_p(0), _last_estr_d(0), _tipodoc_escl('A'), _flagprov_escl('P') { } _tipodoc_escl('A'), _flagprov_escl('P') { }
}; };
TF9_app& app(); TF9_app& app();
@ -162,9 +160,9 @@ class TMonitor_mask : public TAutomask
static void open_win_estr(); static void open_win_estr();
void open_win_conf() const; void open_win_conf() const;
void fill(); void fill() const;
void delete_pack(bool all = false); void delete_pack(bool all = false) const;
void sel() const; void sel() const;
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override; bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
@ -185,7 +183,7 @@ class TControllo_mask : public TAutomask
bool _sel_esclusi; bool _sel_esclusi;
bool _is_escluso; bool _is_escluso;
TString _id_estr; TString _id_estr;
char _tipo_doc_err; char _tipo_doc_err{};
vector<TToken_string>& import_error_list(); vector<TToken_string>& import_error_list();
void fill(); void fill();
@ -220,6 +218,7 @@ public:
void add(long num); void add(long num);
void add() { add_str("NULL"); } void add() { add_str("NULL"); }
void send(); void send();
static void del_err(const TString& id_estr, int get_int);
static char get_errori(const TString& id_estr, vector<TToken_string>& movs); static char get_errori(const TString& id_estr, vector<TToken_string>& movs);
TF9_dberr(); TF9_dberr();
}; };