Files correlati : fp0.exe fp0100a.msk Commento : Corretto campo mancante nello sheet note dei parametri
274 lines
6.9 KiB
C++
274 lines
6.9 KiB
C++
#include <confapp.h>
|
||
#include <automask.h>
|
||
#include <sheet.h>
|
||
#include <utility.h>
|
||
#include <urldefid.h> // ID Bottoni
|
||
|
||
#include "fp0.h"
|
||
#include "fp0100a.h"
|
||
#include <tsdb.h>
|
||
#include "recset.h"
|
||
#include "progind.h"
|
||
#include "../ve/velib.h"
|
||
#include "fplib.h"
|
||
|
||
class TParametri_mask : public TAutomask
|
||
{
|
||
private:
|
||
void load_all();
|
||
protected:
|
||
void tipi_import() const;
|
||
static TMask& get_tmp_msk(const char* title);
|
||
virtual bool on_key(KEY key);
|
||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||
|
||
public:
|
||
TParametri_mask(const char* n);
|
||
void save_all() const;
|
||
};
|
||
|
||
TParametri_mask::TParametri_mask(const char * n) : TAutomask(n)
|
||
{
|
||
load_all();
|
||
}
|
||
|
||
void TParametri_mask::save_all() const
|
||
{
|
||
set_db_indirizzo(get(F_INDIRIZZO));
|
||
set_db_database(get(F_DATABASE));
|
||
set_db_user(get(F_USER));
|
||
set_db_password(get(F_PASSWORD));
|
||
set_fld_dest(get(F_FLDDEST));
|
||
set_fld_dest_usr(get(F_FLDUSRDEST));
|
||
set_cofi_tras(get(F_COFI));
|
||
set_gest_alleg(get_bool(F_ESPORTAALLEG));
|
||
set_allega_fat(get_bool(F_ESPORTADOC));
|
||
set_f8(get_bool(F_F8));
|
||
set_check_not_block(get_bool(F_CHECK_NOT_BLOCK));
|
||
set_no_sconti_fatt(get_bool(F_CHECK_NO_SCONTI));
|
||
set_no_export_pronto(get_bool(F_CHECK_NO_EXPORT_PRONTO));
|
||
set_data_start_fatt(get_date(F_STARTFATTEL));
|
||
set_data_start_new_fatt(get_date(F_STARTNEWFATT));
|
||
TFP_righe_custom().save_sheet(sfield(F_FORMPERS));
|
||
TFP_nota_piede_f().save_sheet(sfield(F_NPFSHEET));
|
||
}
|
||
|
||
void TParametri_mask::load_all()
|
||
{
|
||
set(F_INDIRIZZO, get_db_indirizzo());
|
||
set(F_DATABASE, get_db_database());
|
||
set(F_USER, get_db_user());
|
||
set(F_PASSWORD, get_db_password());
|
||
set(F_FLDDEST, get_fld_dest());
|
||
set(F_FLDUSRDEST, get_fld_dest_usr());
|
||
set(F_COFI, get_cofi_tras());
|
||
set(F_ESPORTAALLEG, get_gest_alleg());
|
||
set(F_ESPORTADOC, get_allega_fat());
|
||
set(F_F8, is_f8());
|
||
set(F_CHECK_NOT_BLOCK, get_check_not_block());
|
||
set(F_CHECK_NO_SCONTI, get_no_sconti_fatt());
|
||
set(F_CHECK_NO_EXPORT_PRONTO, get_no_export_pronto());
|
||
TFP_righe_custom().load_sheet(sfield(F_FORMPERS));
|
||
TFP_nota_piede_f().load_sheet(sfield(F_NPFSHEET));
|
||
}
|
||
|
||
void TParametri_mask::tipi_import() const
|
||
{
|
||
if(yesno_box("Attenzione! Questa procedura riporter<65> su tutti i documenti il tipo documento SDI della configurazione!\nEventuali modifiche gi<67> fatte verranno sovrascritte, continuare?"))
|
||
{
|
||
TISAM_recordset tipi("USE %TIP SELECT S12!=''");
|
||
TProgress_monitor p(tipi.items(), "Elaborazione tipi doc");
|
||
for(bool ok = tipi.move_first(); ok; ok = tipi.move_next())
|
||
{
|
||
if (!p.add_status())
|
||
break;
|
||
|
||
TISAM_recordset docs("USE DOC SELECT TIPODOC==#TIPODOC");
|
||
docs.set_var("#TIPODOC", tipi.get("CODTAB"));
|
||
|
||
TString msg = "Elaborazione documenti "; msg << tipi.get("CODTAB");
|
||
TProgress_monitor d(docs.items(), msg);
|
||
for (bool ok = docs.move_first(); ok; ok = docs.move_next())
|
||
{
|
||
if (!d.add_status())
|
||
break;
|
||
TDocumento doc(docs.cursor()->curr());
|
||
doc.put("TIPODOCSDI", tipi.get("S12").as_string());
|
||
if (doc.rewrite() != NOERR)
|
||
fatal_box("ERRORE aggiornamento documenti");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
TMask & TParametri_mask::get_tmp_msk(const char * title)
|
||
{
|
||
static TMask* m;
|
||
// Cancello la maschera se esiste
|
||
delete m;
|
||
m = new TMask(title, 1, 30, 5);
|
||
m->add_button_tool(DLG_OK, "~Conferma", TOOL_OK);
|
||
m->add_button_tool(DLG_CANCEL, "Annulla", TOOL_CANCEL);
|
||
return *m;
|
||
}
|
||
|
||
bool TParametri_mask::on_key(const KEY key)
|
||
{
|
||
if (key == K_SHIFT + K_F12)
|
||
{
|
||
if (run_fp_psw_mask())
|
||
{
|
||
for (int i = F_SETPATCH; i <= F_REBORNDB; i++)
|
||
enable(i);
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
bool TParametri_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||
{
|
||
switch (o.dlg())
|
||
{
|
||
case DLG_ELABORA:
|
||
if (e == fe_button)
|
||
tipi_import();
|
||
break;
|
||
case F_SETPATCH:
|
||
{
|
||
if (e == fe_button)
|
||
{
|
||
TMask & m = get_tmp_msk("Livello patch");
|
||
m.add_string(101, 0, "Versione ", 1, 1, 5, "");
|
||
m.field(101).check_type(CHECK_REQUIRED);
|
||
if (m.run() == K_ENTER)
|
||
{
|
||
TLocalisamfile tabmod(LF_TABMOD);
|
||
tabmod.put("MOD", "FP");
|
||
tabmod.put("COD", "SQL");
|
||
tabmod.put("CODTAB", "VERSION");
|
||
tabmod.put("S0", m.get(101));
|
||
if (tabmod.write_rewrite() == NOERR)
|
||
message_box("Versione impostata!");
|
||
else
|
||
error_box("Errore durante la scrittura del DB Campo");
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
case F_ENPTYTABLE:
|
||
if (e == fe_button)
|
||
{
|
||
if (yesno_box("Sei sicuro di voler svuotare tutte le tabelle del database? Questa procedura NON <20> REVERSIBILE"))
|
||
{
|
||
fp_db().sq_set_exec("EXEC sp_MSforeachtable @command1 = 'TRUNCATE TABLE ? '");
|
||
fp_db().sq_commit();
|
||
message_box("Procedura terminata");
|
||
}
|
||
}
|
||
break;
|
||
case F_DROPTABLE:
|
||
if (e == fe_button)
|
||
{
|
||
if (yesno_box("Sei sicuro di voler cancellare tutte le tabelle del database? Questa procedura NON <20> REVERSIBILE"))
|
||
{
|
||
fp_db().sq_set_exec("EXEC sp_MSforeachtable @command1 = 'DROP TABLE ?'");
|
||
fp_db().sq_commit();
|
||
message_box("Procedura terminata");
|
||
}
|
||
}
|
||
break;
|
||
case F_REBORNDB:
|
||
if (e == fe_button)
|
||
{
|
||
if (yesno_box("Sei sicuro di voler ricreare tutte le tabelle del database? Questa procedura NON <20> REVERSIBILE"))
|
||
{
|
||
fp_db().sq_set_exec("EXEC sp_MSforeachtable @command1 = 'DROP TABLE ?'");
|
||
TLocalisamfile tabmod(LF_TABMOD);
|
||
tabmod.put("MOD", "FP");
|
||
tabmod.put("COD", "SQL");
|
||
tabmod.put("CODTAB", "VERSION");
|
||
tabmod.remove();
|
||
check_tables();
|
||
fp_db().sq_commit();
|
||
message_box("Procedura terminata");
|
||
}
|
||
}
|
||
break;
|
||
case F_ESPORTAALLEG:
|
||
{
|
||
const bool esporta = get_bool(F_ESPORTAALLEG);
|
||
field(F_FLDDEST).check_type(esporta ? CHECK_REQUIRED : CHECK_NONE);
|
||
field(F_FLDUSRDEST).check_type(esporta ? CHECK_REQUIRED : CHECK_NONE);
|
||
field(F_ESPORTADOC).enable(esporta);
|
||
if (e == fe_modify && !esporta)
|
||
{
|
||
set(F_FLDDEST, "");
|
||
set(F_FLDUSRDEST, "");
|
||
set(F_ESPORTADOC, "");
|
||
}
|
||
}
|
||
break;
|
||
case F_STARTFATTEL:
|
||
if (e == fe_init)
|
||
o.set(get_data_start_fatt());
|
||
break;
|
||
case F_STARTNEWFATT:
|
||
if (e == fe_init)
|
||
o.set(get_date_start_new_fatt());
|
||
default:
|
||
break;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
class TParametri_ditta : public TSkeleton_application
|
||
{
|
||
public:
|
||
virtual bool create();
|
||
virtual void main_loop();
|
||
};
|
||
|
||
bool TParametri_ditta::create()
|
||
{
|
||
open_files(LF_DOC, LF_RIGHEDOC, -1);
|
||
return TSkeleton_application::create();
|
||
}
|
||
|
||
void TParametri_ditta::main_loop()
|
||
{
|
||
TParametri_mask pm("fp0100a");
|
||
while (pm.run() == K_ENTER)
|
||
{
|
||
// Testo prima la connessione
|
||
TString
|
||
ip = pm.get(F_INDIRIZZO),
|
||
db = pm.get(F_DATABASE),
|
||
ad,
|
||
usr = pm.get(F_USER),
|
||
psw = pm.get(F_PASSWORD);
|
||
ad << ip << "@" << db;
|
||
|
||
SSimple_query s(ad, usr, psw, TSDB_MSSQL);
|
||
|
||
if (s.sq_is_connect())
|
||
{
|
||
pm.save_all();
|
||
message_box("Dati salvati correttamente!");
|
||
s.sq_disconnect();
|
||
}
|
||
else
|
||
{
|
||
TString msg = "Connessione a database non riuscita!\n";
|
||
msg << s.sq_get_string_error();
|
||
error_box(msg);
|
||
}
|
||
}
|
||
}
|
||
|
||
int fp0100(int argc, char* argv[])
|
||
{
|
||
TParametri_ditta appc;
|
||
appc.run(argc, argv, TR("Configurazione FP"));
|
||
return 0;
|
||
} |