2010-10-18 14:08:42 +00:00
|
|
|
|
#include "hacnv100.h"
|
|
|
|
|
#include "hacnv100a.h"
|
|
|
|
|
|
|
|
|
|
#include <applicat.h>
|
|
|
|
|
#include <automask.h>
|
|
|
|
|
#include <defmask.h>
|
|
|
|
|
#include <progind.h>
|
|
|
|
|
#include <reprint.h>
|
|
|
|
|
#include <reputils.h>
|
|
|
|
|
#include <tabutil.h>
|
|
|
|
|
|
|
|
|
|
const char* const APPNAME = TR("Importazione anagrafiche HARDY");
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// THardy_log
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class THardy_log : public TLog_report
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
THardy_log() : TLog_report(APPNAME) {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// THardy_iterator
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
bool THardy_iterator::cancelled() const
|
|
|
|
|
{
|
|
|
|
|
return _pi != NULL && _pi->iscancelled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool THardy_iterator::ok() const
|
|
|
|
|
{
|
|
|
|
|
if (cancelled())
|
|
|
|
|
return _ht->log_cancelled();
|
|
|
|
|
return _rec >= 0 && _rec < _ht->recordset().items();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
THardy_iterator& THardy_iterator::operator=(TRecnotype n)
|
|
|
|
|
{
|
|
|
|
|
if (_pi != NULL)
|
|
|
|
|
_pi->setstatus(n+1);
|
|
|
|
|
_ht->recordset().move_to(_rec = n);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
THardy_iterator& THardy_iterator::operator++()
|
|
|
|
|
{
|
|
|
|
|
return *this = ++_rec;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
THardy_iterator::THardy_iterator(THardy_transfer* ht) : _ht(ht), _pi(NULL)
|
|
|
|
|
{
|
|
|
|
|
const TRecnotype tot = _ht->recordset().items();
|
|
|
|
|
TString title;
|
|
|
|
|
title << _ht->title() << ": " << tot << ' ' << TR("righe");
|
|
|
|
|
if (tot > 1)
|
|
|
|
|
_pi = new TProgind(tot, title, true, true);
|
|
|
|
|
else
|
|
|
|
|
::begin_wait();
|
|
|
|
|
|
|
|
|
|
if (tot > 0)
|
|
|
|
|
_ht->log(title);
|
|
|
|
|
|
|
|
|
|
_rec = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
THardy_iterator::~THardy_iterator()
|
|
|
|
|
{
|
|
|
|
|
if (_pi != NULL)
|
|
|
|
|
delete _pi;
|
|
|
|
|
else
|
|
|
|
|
::end_wait();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Cache tabelle
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TCache_tab : public TCache_th
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual TObject* key2obj(const char* key);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual const TString& decode(const TToken_string& cod_codtab);
|
|
|
|
|
TCache_tab(THardy_transfer* ht) : TCache_th(ht) {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const TString& TCache_tab::decode(const TToken_string& cod_codtab)
|
|
|
|
|
{
|
|
|
|
|
TString4 cod; cod_codtab.get(0, cod);
|
|
|
|
|
if (cod.full())
|
|
|
|
|
{
|
|
|
|
|
const TRectype& rec = *(const TRectype*)objptr(cod_codtab);
|
|
|
|
|
if (!rec.empty())
|
|
|
|
|
{
|
|
|
|
|
const char* field = "CODTAB";
|
|
|
|
|
if (cod == "%TPM" || cod == "%TPP" || cod == "%TPI") // Tipo trasporto e porto
|
|
|
|
|
field = "S6";
|
|
|
|
|
return rec.get(field);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return EMPTY_STRING;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TObject* TCache_tab::key2obj(const char* key)
|
|
|
|
|
{
|
|
|
|
|
TToken_string tok(key);
|
|
|
|
|
TString4 tab = tok.get(); tab.upper();
|
|
|
|
|
TString80 cod = tok.get(); cod.upper();
|
|
|
|
|
|
|
|
|
|
if (tab == "%IVA")
|
|
|
|
|
{
|
|
|
|
|
// Campo non digerisce i codici IVA numerici di un solo carattere
|
|
|
|
|
if (cod.len() < 2 && isdigit(cod[0]))
|
|
|
|
|
cod.right_just(2, '0'); // per cui aggiungo uno 0 iniziale
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TTable table(tab);
|
|
|
|
|
table.put("CODTAB", cod);
|
|
|
|
|
if (table.read() != NOERR)
|
|
|
|
|
{
|
|
|
|
|
table.zero();
|
|
|
|
|
table.put("CODTAB", cod);
|
|
|
|
|
table.put("S0", cod);
|
|
|
|
|
test_write(table);
|
|
|
|
|
}
|
|
|
|
|
return table.curr().dup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// THardy_transfer
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void THardy_transfer::init(const char* title, const char* qry_hdr, THardy_log& log)
|
|
|
|
|
{
|
|
|
|
|
_log = &log;
|
|
|
|
|
_log->reset();
|
|
|
|
|
_log->set_title(title);
|
|
|
|
|
_query_header = qry_hdr;
|
|
|
|
|
_write_enabled = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TString& THardy_transfer::title() const
|
|
|
|
|
{ return _log->title(); }
|
|
|
|
|
|
|
|
|
|
void THardy_transfer::log(const char* msg, int sev) const
|
|
|
|
|
{
|
|
|
|
|
_log->log(sev, msg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TRecordset& THardy_transfer::create_recordset(const char* query)
|
|
|
|
|
{
|
|
|
|
|
if (_recset != NULL)
|
|
|
|
|
{
|
|
|
|
|
delete _recset;
|
|
|
|
|
_recset = NULL;
|
|
|
|
|
}
|
|
|
|
|
if (_outset != NULL)
|
|
|
|
|
{
|
|
|
|
|
_outset->exec("COMMIT TRANS");
|
|
|
|
|
delete _outset;
|
|
|
|
|
_outset = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TString qry = query;
|
|
|
|
|
if (!qry.starts_with("US") && !qry.starts_with("ODBC"))
|
|
|
|
|
qry.insert(query_header());
|
|
|
|
|
_recset = ::create_recordset(qry);
|
|
|
|
|
return *_recset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TRecordset& THardy_transfer::recordset() const
|
|
|
|
|
{
|
|
|
|
|
CHECK(_recset != NULL, "NULL recordset");
|
|
|
|
|
return *_recset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TRecordset& THardy_transfer::recordset()
|
|
|
|
|
{
|
|
|
|
|
CHECK(_recset != NULL, "NULL recordset");
|
|
|
|
|
return *_recset;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long THardy_transfer::odbc_exec(const char* cmd)
|
|
|
|
|
{
|
|
|
|
|
long err = 0;
|
|
|
|
|
if (_write_enabled)
|
|
|
|
|
{
|
|
|
|
|
if (_outset == NULL)
|
|
|
|
|
{
|
|
|
|
|
_outset = new TODBC_recordset(query_header());
|
|
|
|
|
err = _outset->exec("BEGIN TRANS");
|
|
|
|
|
}
|
|
|
|
|
if (err >= 0)
|
|
|
|
|
{
|
|
|
|
|
err = _outset->exec(cmd);
|
|
|
|
|
if (err < 0)
|
|
|
|
|
{
|
|
|
|
|
log("", 0); // Salto una riga
|
|
|
|
|
TParagraph_string msg(cmd, 100);
|
|
|
|
|
FOR_EACH_TOKEN(msg, str)
|
|
|
|
|
log(str, 0); // Riporto tutta la query
|
|
|
|
|
log_error(TR("ERRORE in esecuzione della query."));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TString msg;
|
|
|
|
|
msg << TR("ERRORE di connessione a ") << _outset->dsn() << " : BEGIN TRANS";
|
|
|
|
|
log_error(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool THardy_transfer::log_error(const char* msg)
|
|
|
|
|
{
|
|
|
|
|
log(msg, 2);
|
|
|
|
|
if (_write_enabled)
|
|
|
|
|
{
|
|
|
|
|
_write_enabled = false;
|
|
|
|
|
log("");
|
|
|
|
|
log(TR("LA SCRITTURA SUGLI ARCHIVI VIENE DISABILITATA DA QUESTO MOMENTO IN POI"), 2);
|
|
|
|
|
log("");
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool THardy_transfer::log_cancelled()
|
|
|
|
|
{
|
|
|
|
|
return log_error(TR("Procedura interrotta dall'utente"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool THardy_transfer::test_write(TBaseisamfile& file)
|
|
|
|
|
{
|
|
|
|
|
int err = NOERR;
|
|
|
|
|
if (_write_enabled)
|
|
|
|
|
{
|
|
|
|
|
err = file.write_rewrite();
|
|
|
|
|
if (err != NOERR)
|
|
|
|
|
{
|
|
|
|
|
TString msg;
|
|
|
|
|
TString80 code, desc;
|
|
|
|
|
const int logic = file.num();
|
|
|
|
|
if (logic == LF_TAB || logic == LF_TABCOM || logic == LF_TABMOD)
|
|
|
|
|
{
|
|
|
|
|
code = file.get("CODTAB");
|
|
|
|
|
desc = file.get("S0");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
code = file.curr().build_key(1);
|
|
|
|
|
desc = file.curr().build_key(2);
|
|
|
|
|
}
|
|
|
|
|
msg.format(FR("Errore %d durante la scrittura sul file %d: %s - %s"),
|
|
|
|
|
err, logic, (const char*)code, (const char*)desc);
|
|
|
|
|
log_error(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return err == NOERR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TString& THardy_transfer::get_str(const char* field) const
|
|
|
|
|
{
|
|
|
|
|
return recordset().get(field).as_string();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TString& THardy_transfer::get_real_str(const char* campo) const
|
|
|
|
|
{
|
|
|
|
|
const TVariant& var = recordset().get(campo);
|
|
|
|
|
if (var.is_zero())
|
|
|
|
|
return EMPTY_STRING;
|
|
|
|
|
return var.as_string();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long THardy_transfer::get_long(const char* field) const
|
|
|
|
|
{
|
|
|
|
|
return recordset().get(field).as_int();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TString& THardy_transfer::decode_value(const char* tab, const TString& cod)
|
|
|
|
|
{
|
|
|
|
|
if (cod.full())
|
|
|
|
|
{
|
|
|
|
|
if (_tab == NULL)
|
|
|
|
|
_tab = new TCache_tab(this);
|
|
|
|
|
TToken_string tok; tok.add(tab); tok.add(cod);
|
|
|
|
|
return _tab->decode(tok);
|
|
|
|
|
}
|
|
|
|
|
return EMPTY_STRING;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TString& THardy_transfer::decode_field(const char* tab, const char* field)
|
|
|
|
|
{
|
|
|
|
|
const TString& cod = get_str(field);
|
|
|
|
|
return decode_value(tab, cod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const TString& THardy_transfer::build_insert_query(const char* table, const char* f, const char* v) const
|
|
|
|
|
{
|
|
|
|
|
TString qry(255);
|
|
|
|
|
|
|
|
|
|
qry << "INSERT INTO " << table;
|
|
|
|
|
|
|
|
|
|
TAuto_token_string fields(f);
|
|
|
|
|
TToken_string values(v);
|
|
|
|
|
if (fields.items() > 0)
|
|
|
|
|
{
|
|
|
|
|
qry << " (";
|
|
|
|
|
FOR_EACH_TOKEN(fields, tok)
|
|
|
|
|
qry << tok << ',';
|
|
|
|
|
qry.rtrim(1);
|
|
|
|
|
qry << ')';
|
|
|
|
|
}
|
|
|
|
|
qry << " VALUES (";
|
|
|
|
|
|
|
|
|
|
TString tmp;
|
|
|
|
|
FOR_EACH_TOKEN(values, tok)
|
|
|
|
|
{
|
|
|
|
|
tmp = tok;
|
|
|
|
|
if (tmp.full() && !tmp.starts_with("0") && real::is_natural(tmp))
|
|
|
|
|
qry << tok;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (tmp[0] != '\'')
|
|
|
|
|
{
|
|
|
|
|
for (int i = tmp.len()-1; i >= 0; i--)
|
|
|
|
|
{
|
|
|
|
|
if (tmp[i] == '\'')
|
|
|
|
|
tmp.insert("'", i);
|
|
|
|
|
}
|
|
|
|
|
qry << '\'' << tmp << '\'';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
qry << tmp;
|
|
|
|
|
}
|
|
|
|
|
qry << ',';
|
|
|
|
|
}
|
|
|
|
|
qry.rtrim(1);
|
|
|
|
|
qry << ')';
|
|
|
|
|
|
|
|
|
|
return get_tmp_string() = qry;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
THardy_transfer::THardy_transfer()
|
|
|
|
|
: _log(NULL), _config("hacnv100a.ini"), _recset(NULL), _outset(NULL), _tab(NULL)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
THardy_transfer::~THardy_transfer()
|
|
|
|
|
{
|
|
|
|
|
if (_tab != NULL)
|
|
|
|
|
delete _tab;
|
|
|
|
|
if (_outset != NULL)
|
|
|
|
|
{
|
|
|
|
|
_outset->exec("COMMIT TRANS");
|
|
|
|
|
delete _outset;
|
|
|
|
|
}
|
|
|
|
|
if (_recset != NULL)
|
|
|
|
|
delete _recset;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-20 12:46:31 +00:00
|
|
|
|
void THardy_transfer::aggiorna_record(TRectype& rec, const TString_array& lista_campi)
|
2010-10-18 14:08:42 +00:00
|
|
|
|
{
|
|
|
|
|
TString campo_dest, campo_orig, valore, str;
|
|
|
|
|
|
|
|
|
|
FOR_EACH_ARRAY_ROW(lista_campi,i,row)
|
|
|
|
|
{
|
|
|
|
|
row->get(0, campo_dest);
|
|
|
|
|
row->get(1, campo_orig);
|
|
|
|
|
if (campo_orig.full())
|
|
|
|
|
{
|
2010-10-20 12:46:31 +00:00
|
|
|
|
if (campo_orig[0] == '_')
|
|
|
|
|
{
|
|
|
|
|
TToken_string elabora(campo_orig.mid(1),',');
|
|
|
|
|
const TString& str = elabora.get();
|
|
|
|
|
if (str == "TAB") // formato _TAB, <tabella da leggere>,<valore CODTAB>, <campo da leggere>
|
|
|
|
|
{
|
|
|
|
|
const TString4 tab = elabora.get(); // tabella da leggere
|
|
|
|
|
const TString80 campo = elabora.get();
|
|
|
|
|
const TString16 codtab = get_str(campo);
|
|
|
|
|
const TString80 campotab = elabora.get();
|
|
|
|
|
valore = cache().get(tab, codtab, campotab);
|
|
|
|
|
}
|
|
|
|
|
else if (str == "FISSO")
|
|
|
|
|
valore = elabora.get(); // valore fisso indicato in configurazione
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
valore = get_str(campo_orig);
|
2010-10-18 14:08:42 +00:00
|
|
|
|
rec.put(campo_dest, valore);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-20 12:46:31 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// THardy_pag
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
2010-10-18 14:08:42 +00:00
|
|
|
|
bool THardy_pag::trasferisci()
|
|
|
|
|
{
|
|
|
|
|
TString query =
|
|
|
|
|
"SELECT * "
|
|
|
|
|
"FROM dbo.Pagamenti ";
|
|
|
|
|
TRecordset& recset = create_recordset(query);
|
|
|
|
|
TConfig& ini = config();
|
|
|
|
|
TString_array lista_campi;
|
|
|
|
|
ini.list_variables(lista_campi, true, "CPG", true);
|
|
|
|
|
TTable table("%CPG");
|
|
|
|
|
TRectype& rec = table.curr();
|
|
|
|
|
THardy_iterator hi(this);
|
|
|
|
|
while (++hi)
|
|
|
|
|
{
|
|
|
|
|
rec.zero();
|
|
|
|
|
aggiorna_record(rec, lista_campi);
|
|
|
|
|
test_write(table);
|
|
|
|
|
}
|
|
|
|
|
return write_enabled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// THardy_iva
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
bool THardy_iva::trasferisci()
|
|
|
|
|
{
|
|
|
|
|
TString query =
|
|
|
|
|
"SELECT * "
|
|
|
|
|
"FROM dbo.AliquoteIVA ";
|
|
|
|
|
TRecordset& recset = create_recordset(query);
|
|
|
|
|
TConfig& ini = config();
|
|
|
|
|
TString_array lista_campi;
|
|
|
|
|
ini.list_variables(lista_campi, true, "IVA", true);
|
|
|
|
|
TTable table("%IVA");
|
|
|
|
|
TRectype& rec = table.curr();
|
|
|
|
|
THardy_iterator hi(this);
|
|
|
|
|
while (++hi)
|
|
|
|
|
{
|
|
|
|
|
rec.zero();
|
|
|
|
|
aggiorna_record(rec, lista_campi);
|
|
|
|
|
test_write(table);
|
|
|
|
|
}
|
|
|
|
|
return write_enabled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// THardy_catmerc
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
bool THardy_catmerc::trasferisci()
|
|
|
|
|
{
|
|
|
|
|
TString query =
|
|
|
|
|
"SELECT * "
|
|
|
|
|
"FROM dbo.CategorieMerc ";
|
|
|
|
|
TRecordset& recset = create_recordset(query);
|
|
|
|
|
TConfig& ini = config();
|
|
|
|
|
TString_array lista_campi;
|
|
|
|
|
ini.list_variables(lista_campi, true, "GMC", true);
|
|
|
|
|
TTable table("%GMC");
|
2010-10-20 12:46:31 +00:00
|
|
|
|
TRectype& rec = table.curr();
|
2010-10-18 14:08:42 +00:00
|
|
|
|
THardy_iterator hi(this);
|
|
|
|
|
while (++hi)
|
|
|
|
|
{
|
|
|
|
|
rec.zero();
|
|
|
|
|
aggiorna_record(rec, lista_campi);
|
|
|
|
|
test_write(table);
|
|
|
|
|
}
|
|
|
|
|
return write_enabled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// THardy_catfisc
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
bool THardy_catfisc::trasferisci()
|
|
|
|
|
{
|
|
|
|
|
TString query =
|
|
|
|
|
"SELECT * "
|
|
|
|
|
"FROM dbo.CategorieFisc ";
|
|
|
|
|
TRecordset& recset = create_recordset(query);
|
|
|
|
|
TConfig& ini = config();
|
|
|
|
|
TString_array lista_campi;
|
|
|
|
|
ini.list_variables(lista_campi, true, "ASF", true);
|
|
|
|
|
TTable table("%ASF");
|
|
|
|
|
TRectype& rec = table.curr();
|
|
|
|
|
THardy_iterator hi(this);
|
|
|
|
|
while (++hi)
|
|
|
|
|
{
|
|
|
|
|
rec.zero();
|
|
|
|
|
aggiorna_record(rec, lista_campi);
|
|
|
|
|
test_write(table);
|
|
|
|
|
}
|
|
|
|
|
return write_enabled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// THardy_ban
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
bool THardy_ban::trasferisci()
|
|
|
|
|
{
|
|
|
|
|
bool ok = trasferisci_abi();
|
|
|
|
|
if (ok)
|
|
|
|
|
ok = trasferisci_cab();
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool THardy_ban::trasferisci_abi()
|
|
|
|
|
{
|
|
|
|
|
TString query =
|
|
|
|
|
"SELECT * "
|
|
|
|
|
"FROM dbo.Banche ";
|
|
|
|
|
TRecordset& recset = create_recordset(query);
|
2010-10-20 12:46:31 +00:00
|
|
|
|
TConfig& ini = config();
|
2010-10-18 14:08:42 +00:00
|
|
|
|
TString_array lista_campi;
|
|
|
|
|
ini.list_variables(lista_campi, true, "ABI", true);
|
|
|
|
|
TSystemisamfile table(LF_TABCOM);
|
|
|
|
|
table.open(_lock);
|
|
|
|
|
TRectype& rec = table.curr();
|
|
|
|
|
THardy_iterator hi(this);
|
|
|
|
|
while (++hi)
|
|
|
|
|
{
|
|
|
|
|
TString16 codtab = get_str("IdBanca");
|
|
|
|
|
codtab.lpad(5,'0');
|
|
|
|
|
rec.zero();
|
2010-10-20 12:46:31 +00:00
|
|
|
|
rec.put("COD", "BAN");
|
2010-10-18 14:08:42 +00:00
|
|
|
|
rec.put("CODTAB", codtab);
|
|
|
|
|
aggiorna_record(rec, lista_campi);
|
|
|
|
|
test_write(table);
|
|
|
|
|
}
|
|
|
|
|
table.close();
|
|
|
|
|
return write_enabled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool THardy_ban::trasferisci_cab()
|
|
|
|
|
{
|
|
|
|
|
TString query =
|
|
|
|
|
"SELECT * "
|
|
|
|
|
"FROM dbo.Agenzie ";
|
|
|
|
|
TRecordset& recset = create_recordset(query);
|
|
|
|
|
TConfig& ini = config();
|
|
|
|
|
TString_array lista_campi;
|
|
|
|
|
ini.list_variables(lista_campi, true, "CAB", true);
|
|
|
|
|
TSystemisamfile table(LF_TABCOM);
|
|
|
|
|
table.open(_lock);
|
|
|
|
|
TRectype& rec = table.curr();
|
|
|
|
|
THardy_iterator hi(this);
|
|
|
|
|
while (++hi)
|
|
|
|
|
{
|
|
|
|
|
TString16 codtab = get_str("IdBanca");
|
|
|
|
|
codtab.lpad(5,'0');
|
|
|
|
|
codtab << get_str("Cab");
|
|
|
|
|
rec.zero();
|
|
|
|
|
rec.put("COD", "BAN");
|
|
|
|
|
rec.put("CODTAB", codtab);
|
|
|
|
|
aggiorna_record(rec, lista_campi);
|
|
|
|
|
test_write(table);
|
|
|
|
|
}
|
|
|
|
|
table.close();
|
|
|
|
|
return write_enabled();
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-20 12:46:31 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// THardy_caucont
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
bool THardy_caucont::trasferisci()
|
|
|
|
|
{
|
|
|
|
|
TString query =
|
|
|
|
|
"SELECT * "
|
|
|
|
|
"FROM dbo.CausaliContab ";
|
|
|
|
|
TRecordset& recset = create_recordset(query);
|
|
|
|
|
TConfig& ini = config();
|
|
|
|
|
TString_array lista_campi;
|
|
|
|
|
ini.list_variables(lista_campi, true, "CAUCONT", true);
|
|
|
|
|
TSystemisamfile table(LF_CAUSALI);
|
|
|
|
|
table.open(_lock);
|
|
|
|
|
TRectype& rec = table.curr();
|
|
|
|
|
THardy_iterator hi(this);
|
|
|
|
|
while (++hi)
|
|
|
|
|
{
|
|
|
|
|
rec.zero();
|
|
|
|
|
aggiorna_record(rec, lista_campi);
|
|
|
|
|
test_write(table);
|
|
|
|
|
}
|
|
|
|
|
table.close();
|
|
|
|
|
return write_enabled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// THardy_caumag
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
bool THardy_caumag::trasferisci()
|
|
|
|
|
{
|
|
|
|
|
TString query =
|
|
|
|
|
"SELECT * "
|
|
|
|
|
"FROM dbo.CausaliMagaz ";
|
|
|
|
|
TRecordset& recset = create_recordset(query);
|
|
|
|
|
TConfig& ini = config();
|
|
|
|
|
TString_array lista_campi;
|
|
|
|
|
ini.list_variables(lista_campi, true, "CAUMAG", true);
|
|
|
|
|
TTable table("%CAU");
|
|
|
|
|
TRectype& rec = table.curr();
|
|
|
|
|
THardy_iterator hi(this);
|
|
|
|
|
while (++hi)
|
|
|
|
|
{
|
|
|
|
|
rec.zero();
|
|
|
|
|
aggiorna_record(rec, lista_campi);
|
|
|
|
|
test_write(table);
|
|
|
|
|
}
|
|
|
|
|
return write_enabled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// THardy_um
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
bool THardy_um::trasferisci()
|
|
|
|
|
{
|
|
|
|
|
TString query =
|
|
|
|
|
"SELECT * "
|
|
|
|
|
"FROM dbo.UnitaMisura ";
|
|
|
|
|
TRecordset& recset = create_recordset(query);
|
|
|
|
|
TConfig& ini = config();
|
|
|
|
|
TString_array lista_campi;
|
|
|
|
|
ini.list_variables(lista_campi, true, "UM", true);
|
|
|
|
|
TTable table("%UMS");
|
|
|
|
|
TRectype& rec = table.curr();
|
|
|
|
|
THardy_iterator hi(this);
|
|
|
|
|
while (++hi)
|
|
|
|
|
{
|
|
|
|
|
rec.zero();
|
|
|
|
|
aggiorna_record(rec, lista_campi);
|
|
|
|
|
test_write(table);
|
|
|
|
|
}
|
|
|
|
|
return write_enabled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// THardy_art
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
bool THardy_art::trasferisci()
|
|
|
|
|
{
|
|
|
|
|
TString query =
|
|
|
|
|
"SELECT * "
|
|
|
|
|
"FROM dbo.Articoli ";
|
|
|
|
|
TRecordset& recset = create_recordset(query);
|
|
|
|
|
TConfig& ini = config();
|
|
|
|
|
TString_array lista_campi_anamag, lista_campi_umart;
|
|
|
|
|
ini.list_variables(lista_campi_anamag, true, "ANAMAG", true);
|
|
|
|
|
ini.list_variables(lista_campi_umart, true, "UMART", true);
|
|
|
|
|
TSystemisamfile anamag(LF_ANAMAG);
|
|
|
|
|
anamag.open(_lock);
|
|
|
|
|
TRectype& rec_anamag = anamag.curr();
|
|
|
|
|
TSystemisamfile umart(LF_UMART);
|
|
|
|
|
umart.open(_lock);
|
|
|
|
|
TRectype& rec_umart = umart.curr();
|
|
|
|
|
THardy_iterator hi(this);
|
|
|
|
|
while (++hi)
|
|
|
|
|
{
|
|
|
|
|
aggiorna_record(rec_anamag, lista_campi_anamag);
|
|
|
|
|
test_write(anamag);
|
|
|
|
|
aggiorna_record(rec_umart, lista_campi_umart);
|
|
|
|
|
test_write(umart);
|
|
|
|
|
}
|
|
|
|
|
anamag.close();
|
|
|
|
|
umart.close();
|
|
|
|
|
return write_enabled();
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-18 14:08:42 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TImportazioneHardy_mask
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TImportazioneHardy_mask : public TAutomask
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
|
void serialize(bool bSave);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
void trasferisci();
|
|
|
|
|
|
|
|
|
|
TImportazioneHardy_mask();
|
|
|
|
|
virtual ~TImportazioneHardy_mask();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Funzione di tarsferimento dati da/verso file .ini con lo stesso nome della maschera
|
|
|
|
|
// Andrebbe messo in libreria
|
|
|
|
|
void TImportazioneHardy_mask::serialize(bool bSave)
|
|
|
|
|
{
|
|
|
|
|
TFilename n = source_file(); n.ext("ini"); // Construisce il nome del .ini in base al .msk
|
|
|
|
|
TConfig cfg(n, "Main"); // Crea il file di configurazione
|
|
|
|
|
TString4 id;
|
|
|
|
|
for (int i = fields()-1; i >= 0; i--) // Scandisce tutti i campi della maschera ...
|
|
|
|
|
{
|
|
|
|
|
TMask_field& f = fld(i);
|
|
|
|
|
if (f.active() && f.is_loadable()) // ... selezionando solo quelli editabili
|
|
|
|
|
{
|
|
|
|
|
id.format("%d", f.dlg());
|
|
|
|
|
if (bSave) // A seconda del flag di scrittura ...
|
|
|
|
|
cfg.set(id, f.get()); // ... o scrive sul .ini
|
|
|
|
|
else
|
|
|
|
|
f.set(cfg.get(id)); // ... o legge dal .ini
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TImportazioneHardy_mask::trasferisci()
|
|
|
|
|
{
|
|
|
|
|
TString query_header;
|
|
|
|
|
query_header << "ODBC(" << get(F_DSN) << ',' << get(F_USR) << ',' << get(F_PWD) << ")\n";
|
|
|
|
|
|
|
|
|
|
TReport_book book;
|
|
|
|
|
THardy_log log;
|
|
|
|
|
|
|
|
|
|
bool rep_to_print = false;
|
|
|
|
|
bool go_on = true;
|
|
|
|
|
|
|
|
|
|
if (go_on && get_bool(F_PAG))
|
|
|
|
|
{
|
|
|
|
|
THardy_pag pc;
|
|
|
|
|
pc.init(TR("Condizioni di pagamento"), query_header, log);
|
|
|
|
|
go_on = pc.trasferisci();
|
|
|
|
|
book.add(log);
|
|
|
|
|
rep_to_print = true;
|
|
|
|
|
}
|
|
|
|
|
if (go_on && get_bool(F_IVA))
|
|
|
|
|
{
|
|
|
|
|
THardy_iva pc;
|
|
|
|
|
pc.init(TR("Aliquote IVA"), query_header, log);
|
|
|
|
|
go_on = pc.trasferisci();
|
|
|
|
|
book.add(log);
|
|
|
|
|
rep_to_print = true;
|
|
|
|
|
}
|
|
|
|
|
if (go_on && get_bool(F_CATMERC))
|
|
|
|
|
{
|
|
|
|
|
THardy_catmerc pc;
|
|
|
|
|
pc.init(TR("Categorie merceologiche"), query_header, log);
|
|
|
|
|
go_on = pc.trasferisci();
|
|
|
|
|
book.add(log);
|
|
|
|
|
rep_to_print = true;
|
|
|
|
|
}
|
|
|
|
|
if (go_on && get_bool(F_CATFISC))
|
|
|
|
|
{
|
|
|
|
|
THardy_catfisc pc;
|
|
|
|
|
pc.init(TR("Categorie fiscali"), query_header, log);
|
|
|
|
|
go_on = pc.trasferisci();
|
|
|
|
|
book.add(log);
|
|
|
|
|
rep_to_print = true;
|
|
|
|
|
}
|
|
|
|
|
if (go_on && get_bool(F_BAN))
|
|
|
|
|
{
|
|
|
|
|
THardy_ban pc;
|
|
|
|
|
pc.init(TR("Banche"), query_header, log);
|
2010-10-20 12:46:31 +00:00
|
|
|
|
go_on = pc.trasferisci();
|
|
|
|
|
book.add(log);
|
|
|
|
|
rep_to_print = true;
|
|
|
|
|
}
|
|
|
|
|
if (go_on && get_bool(F_CAUCONT))
|
|
|
|
|
{
|
|
|
|
|
THardy_caucont pc;
|
|
|
|
|
pc.init(TR("Causali contabili"), query_header, log);
|
|
|
|
|
go_on = pc.trasferisci();
|
|
|
|
|
book.add(log);
|
|
|
|
|
rep_to_print = true;
|
|
|
|
|
}
|
|
|
|
|
if (go_on && get_bool(F_CAUMAG))
|
|
|
|
|
{
|
|
|
|
|
THardy_caumag pc;
|
|
|
|
|
pc.init(TR("Causali magazzino"), query_header, log);
|
|
|
|
|
go_on = pc.trasferisci();
|
|
|
|
|
book.add(log);
|
|
|
|
|
rep_to_print = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (go_on && get_bool(F_UM))
|
|
|
|
|
{
|
|
|
|
|
THardy_um pc;
|
|
|
|
|
pc.init(TR("Unit<EFBFBD> di misura"), query_header, log);
|
|
|
|
|
go_on = pc.trasferisci();
|
|
|
|
|
book.add(log);
|
|
|
|
|
rep_to_print = true;
|
|
|
|
|
}
|
|
|
|
|
if (go_on && get_bool(F_ARTICOLI))
|
|
|
|
|
{
|
|
|
|
|
THardy_art pc;
|
|
|
|
|
pc.init(TR("Articoli"), query_header, log);
|
2010-10-18 14:08:42 +00:00
|
|
|
|
go_on = pc.trasferisci();
|
|
|
|
|
book.add(log);
|
|
|
|
|
rep_to_print = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rep_to_print && book.pages() > 0)
|
|
|
|
|
book.preview();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TImportazioneHardy_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
|
|
|
{
|
|
|
|
|
switch (o.dlg())
|
|
|
|
|
{
|
|
|
|
|
case DLG_OK:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
serialize(true);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TImportazioneHardy_mask::TImportazioneHardy_mask() : TAutomask("hacnv100a")
|
|
|
|
|
{
|
|
|
|
|
serialize(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TImportazioneHardy_mask::~TImportazioneHardy_mask()
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TImportazioneHardy
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TImportazioneHardy : public TSkeleton_application
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual void main_loop();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void TImportazioneHardy::main_loop()
|
|
|
|
|
{
|
|
|
|
|
TImportazioneHardy_mask mask;
|
|
|
|
|
while (mask.run() == K_ENTER)
|
|
|
|
|
mask.trasferisci();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int hacnv100(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
TImportazioneHardy ih;
|
|
|
|
|
ih.run(argc, argv, APPNAME);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|