126 lines
3.2 KiB
C++
126 lines
3.2 KiB
C++
|
#include <confapp.h>
|
|||
|
#include <automask.h>
|
|||
|
#include <sheet.h>
|
|||
|
#include <utility.h>
|
|||
|
|
|||
|
#include "fp0.h"
|
|||
|
#include "fp0100a.h"
|
|||
|
#include <tsdb.h>
|
|||
|
#include "recset.h"
|
|||
|
#include "progind.h"
|
|||
|
#include "../ve/velib.h"
|
|||
|
|
|||
|
class TParametri_mask : public TAutomask
|
|||
|
{
|
|||
|
protected:
|
|||
|
void tipi_import();
|
|||
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|||
|
|
|||
|
public:
|
|||
|
TParametri_mask(const char* n);
|
|||
|
};
|
|||
|
|
|||
|
TParametri_mask::TParametri_mask(const char * n) : TAutomask(n)
|
|||
|
{
|
|||
|
set(F_INDIRIZZO, ini_get_string(CONFIG_DITTA, "fp", "ip"));
|
|||
|
set(F_DATABASE, ini_get_string(CONFIG_DITTA, "fp", "db"));
|
|||
|
set(F_USER, ini_get_string(CONFIG_DITTA, "fp", "usr"));
|
|||
|
set(F_PASSWORD, decode(ini_get_string(CONFIG_DITTA, "fp", "psw") ));
|
|||
|
set(F_FLDDEST, ini_get_string(CONFIG_DITTA, "fp", "flddest"));
|
|||
|
set(F_FLDUSRDEST, ini_get_string(CONFIG_DITTA, "fp", "fldusrdest"));
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
void TParametri_mask::tipi_import()
|
|||
|
{
|
|||
|
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");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
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();
|
|||
|
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())
|
|||
|
{
|
|||
|
|
|||
|
ini_set_string(CONFIG_DITTA, "fp", "ip", ip);
|
|||
|
ini_set_string(CONFIG_DITTA, "fp", "db", db);
|
|||
|
ini_set_string(CONFIG_DITTA, "fp", "usr", usr);
|
|||
|
ini_set_string(CONFIG_DITTA, "fp", "psw", encode(psw));
|
|||
|
ini_set_string(CONFIG_DITTA, "fp", "flddest", pm.get(F_FLDDEST));
|
|||
|
ini_set_string(CONFIG_DITTA, "fp", "fldusrdest", pm.get(F_FLDUSRDEST));
|
|||
|
message_box("Dati salvati correttamente!");
|
|||
|
}
|
|||
|
else
|
|||
|
error_box("Connessione a database non riuscita!");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
int fp0100(int argc, char* argv[])
|
|||
|
{
|
|||
|
TParametri_ditta appc;
|
|||
|
appc.run(argc, argv, TR("Configurazione FP"));
|
|||
|
return 0;
|
|||
|
}
|