Files correlati : fp Commento : - Merge commits - Aggiunta personalizzazione calcoli righe di tipo merce per il fruttivendolo
271 lines
6.8 KiB
C++
271 lines
6.8 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
|
|
{
|
|
fp_settings().set_db_indirizzo(get(F_INDIRIZZO));
|
|
fp_settings().set_db_database(get(F_DATABASE));
|
|
fp_settings().set_db_user(get(F_USER));
|
|
fp_settings().set_db_password(get(F_PASSWORD));
|
|
fp_settings().set_fld_dest(get(F_FLDDEST));
|
|
fp_settings().set_fld_dest_usr(get(F_FLDUSRDEST));
|
|
fp_settings().set_cofi_tras(get(F_COFI));
|
|
fp_settings().set_gest_alleg(get_bool(F_ESPORTAALLEG));
|
|
fp_settings().set_allega_fat(get_bool(F_ESPORTADOC));
|
|
fp_settings().set_f8(get_bool(F_F8));
|
|
TFP_righe_custom().save_sheet(sfield(F_FORMPERS));
|
|
}
|
|
|
|
void TParametri_mask::load_all()
|
|
{
|
|
set(F_INDIRIZZO, fp_settings().get_db_indirizzo());
|
|
set(F_DATABASE, fp_settings().get_db_database());
|
|
set(F_USER, fp_settings().get_db_user());
|
|
set(F_PASSWORD, fp_settings().get_db_password());
|
|
set(F_FLDDEST, fp_settings().get_fld_dest());
|
|
set(F_FLDUSRDEST, fp_settings().get_fld_dest_usr());
|
|
set(F_COFI, fp_settings().get_cofi_tras());
|
|
set(F_ESPORTAALLEG, fp_settings().get_gest_alleg());
|
|
set(F_ESPORTADOC, fp_settings().get_allega_fat());
|
|
set(F_F8, fp_settings().is_f8());
|
|
TFP_righe_custom().load_sheet(sfield(F_FORMPERS));
|
|
}
|
|
|
|
void TParametri_mask::tipi_import() const
|
|
{
|
|
if(yesno_box("Attenzione! Questa procedura riporterà su tutti i documenti il tipo documento SDI della configurazione!\nEventuali modifiche già 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(KEY key)
|
|
{
|
|
switch(key)
|
|
{
|
|
case K_SHIFT + K_F12:
|
|
{
|
|
TMask& m = get_tmp_msk("Password");
|
|
m.add_string(101, 0, "Password ", 1, 1, 15, "*");
|
|
m.field(101).check_type(CHECK_REQUIRED);
|
|
while(m.run() == K_ENTER)
|
|
{
|
|
if (m.get(101) == "sirioFATT99") // Hardcoded password are the best!
|
|
{
|
|
for (int i = F_SETPATCH; i <= F_REBORNDB; i++)
|
|
enable(i);
|
|
break;
|
|
}
|
|
else
|
|
error_box("Password errata");
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
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 É 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 É 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 É 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;
|
|
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;
|
|
} |