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>
|
|
|
|
|
|
2010-10-28 13:27:37 +00:00
|
|
|
|
#include <pconti.h>
|
|
|
|
|
#include <clifo.h>
|
2010-10-29 13:19:54 +00:00
|
|
|
|
#include "..\pr\agenti.h"
|
2010-10-28 13:27:37 +00:00
|
|
|
|
|
2010-10-18 14:08:42 +00:00
|
|
|
|
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] == '_')
|
|
|
|
|
{
|
2010-10-29 13:19:54 +00:00
|
|
|
|
if (campo_orig.starts_with("_FISSO")) // valore fisso indicato in configurazione
|
2010-10-28 13:27:37 +00:00
|
|
|
|
{
|
2010-10-29 13:19:54 +00:00
|
|
|
|
valore = campo_orig.after(',');
|
|
|
|
|
valore.trim();
|
|
|
|
|
} else
|
|
|
|
|
if (campo_orig.starts_with("_STREXPR")) // formato _STREXPR, espressione
|
2010-10-28 13:27:37 +00:00
|
|
|
|
{
|
|
|
|
|
TExpression expr(campo_orig.after(','), _strexpr);
|
|
|
|
|
for (int v = 0; v < expr.numvar(); v++)
|
|
|
|
|
{
|
|
|
|
|
const char* varname = expr.varname(v);
|
|
|
|
|
expr.setvar(v, get_str(varname));
|
|
|
|
|
}
|
|
|
|
|
valore = expr.as_string();
|
|
|
|
|
valore.trim();
|
2010-10-29 13:19:54 +00:00
|
|
|
|
} else
|
|
|
|
|
if (campo_orig.starts_with("_TAB")) // formato _TAB,<tabella da leggere>,<valore CODTAB>, <campo da leggere>
|
|
|
|
|
{
|
|
|
|
|
TToken_string elabora(campo_orig, ',');
|
|
|
|
|
const TString4 tab = elabora.get(1); // tabella da leggere
|
|
|
|
|
const TString16 codtab = get_str(elabora.get());
|
|
|
|
|
const TString16 campotab = elabora.get();
|
|
|
|
|
valore = cache().get(tab, codtab, campotab);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (campo_orig.starts_with("_TRADUCI"))
|
|
|
|
|
{
|
|
|
|
|
const TString80 campo = campo_orig.after(',');
|
|
|
|
|
const TString80 contenuto = get_str(campo);
|
|
|
|
|
TConfig& ini = config();
|
|
|
|
|
valore = ini.get(contenuto,campo);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
valore.cut(0);
|
2010-10-20 12:46:31 +00:00
|
|
|
|
}
|
|
|
|
|
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);
|
2010-10-28 13:27:37 +00:00
|
|
|
|
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-28 13:27:37 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// THardy_conti
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
bool THardy_pcon::trasferisci()
|
|
|
|
|
{
|
|
|
|
|
if (trasferisci_gruppi())
|
|
|
|
|
if (trasferisci_conti())
|
|
|
|
|
return trasferisci_sottoconti();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool THardy_pcon::trasferisci_gruppi()
|
|
|
|
|
{
|
|
|
|
|
TString query =
|
|
|
|
|
"SELECT * "
|
|
|
|
|
"FROM dbo.Mastri "
|
|
|
|
|
"WHERE Livello=2";
|
|
|
|
|
|
|
|
|
|
TRecordset& recset = create_recordset(query);
|
|
|
|
|
TConfig& ini = config();
|
|
|
|
|
|
|
|
|
|
TString_array lista_campi;
|
|
|
|
|
ini.list_variables(lista_campi, true, "MASTRI", true);
|
|
|
|
|
|
|
|
|
|
TSystemisamfile pcon(LF_PCON);
|
|
|
|
|
pcon.open(_lock);
|
|
|
|
|
TRectype& rec = pcon.curr();
|
|
|
|
|
THardy_iterator hi(this);
|
|
|
|
|
while (++hi)
|
|
|
|
|
{
|
|
|
|
|
// costruisco la chiave gr.co.sc
|
|
|
|
|
const TString16 key = get_str("IdMastro");
|
|
|
|
|
const TString& gruppo = key.mid(0,2);
|
|
|
|
|
rec.zero();
|
|
|
|
|
rec.put(PCN_GRUPPO, gruppo);
|
|
|
|
|
aggiorna_record(rec, lista_campi);
|
|
|
|
|
test_write(pcon);
|
|
|
|
|
}
|
|
|
|
|
pcon.close();
|
|
|
|
|
return write_enabled();
|
|
|
|
|
}
|
|
|
|
|
bool THardy_pcon::trasferisci_conti()
|
|
|
|
|
{
|
|
|
|
|
TString query =
|
|
|
|
|
"SELECT * "
|
|
|
|
|
"FROM dbo.Mastri "
|
|
|
|
|
"WHERE Livello=1";
|
|
|
|
|
|
|
|
|
|
TRecordset& recset = create_recordset(query);
|
|
|
|
|
TConfig& ini = config();
|
|
|
|
|
|
|
|
|
|
TString_array lista_campi_pcon;
|
|
|
|
|
ini.list_variables(lista_campi_pcon, true, "MASTRI", true);
|
|
|
|
|
const TString& esclusi = ini.get("PCON", "PARAMETRI");
|
|
|
|
|
|
|
|
|
|
TSystemisamfile pcon(LF_PCON);
|
|
|
|
|
pcon.open(_lock);
|
|
|
|
|
TRectype& rec_pcon = pcon.curr();
|
|
|
|
|
THardy_iterator hi(this);
|
|
|
|
|
while (++hi)
|
|
|
|
|
{
|
|
|
|
|
// costruisco la chiave gr.co
|
|
|
|
|
const TString16 key = get_str("IdMastro");
|
|
|
|
|
const int gr = atoi(key.mid(0,2));
|
|
|
|
|
int co = atoi(key.mid(2,2));
|
|
|
|
|
const int so = atoi(key.mid(4,3));
|
|
|
|
|
if ((gr != 0) && (co != 0))
|
|
|
|
|
{
|
|
|
|
|
if (esclusi.find(key.mid(0,2))>=0)
|
|
|
|
|
co = co*10+so;
|
|
|
|
|
rec_pcon.zero();
|
|
|
|
|
rec_pcon.put(PCN_GRUPPO, gr);
|
|
|
|
|
rec_pcon.put(PCN_CONTO, co);
|
|
|
|
|
aggiorna_record(rec_pcon, lista_campi_pcon);
|
|
|
|
|
test_write(pcon);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pcon.close();
|
|
|
|
|
return write_enabled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool THardy_pcon::trasferisci_sottoconti()
|
|
|
|
|
{
|
|
|
|
|
TString query =
|
|
|
|
|
"SELECT * "
|
|
|
|
|
"FROM dbo.Conti ";
|
|
|
|
|
|
|
|
|
|
TRecordset& recset = create_recordset(query);
|
|
|
|
|
TConfig& ini = config();
|
|
|
|
|
|
|
|
|
|
TString_array lista_campi_pcon, lista_cf;
|
|
|
|
|
ini.list_variables(lista_campi_pcon, true, "CONTI", true);
|
|
|
|
|
const TString& esclusi = ini.get("PCON", "PARAMETRI");
|
|
|
|
|
|
|
|
|
|
TSystemisamfile pcon(LF_PCON);
|
|
|
|
|
pcon.open(_lock);
|
|
|
|
|
TRectype& rec_pcon = pcon.curr();
|
|
|
|
|
THardy_iterator hi(this);
|
|
|
|
|
while (++hi)
|
|
|
|
|
{
|
|
|
|
|
// costruisco la chiave gr.co.sc
|
|
|
|
|
const TString16 key = get_str("IdConto");
|
|
|
|
|
const int gr = atoi(key.mid(1,2));
|
|
|
|
|
const int co = atoi(key.mid(3,2));
|
|
|
|
|
const int so = atoi(key.mid(5,3));
|
|
|
|
|
|
|
|
|
|
rec_pcon.zero();
|
|
|
|
|
rec_pcon.put(PCN_GRUPPO, gr);
|
|
|
|
|
|
|
|
|
|
if ((gr != 0) && (co != 0) && (so!= 0))
|
|
|
|
|
{
|
|
|
|
|
if (esclusi.find(key.mid(1,2))>=0)
|
|
|
|
|
rec_pcon.put(PCN_CONTO, co*10+so);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rec_pcon.put(PCN_CONTO, co);
|
|
|
|
|
rec_pcon.put(PCN_SOTTOCONTO, so);
|
|
|
|
|
}
|
|
|
|
|
aggiorna_record(rec_pcon, lista_campi_pcon);
|
|
|
|
|
test_write(pcon);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
pcon.close();
|
|
|
|
|
return write_enabled();
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-29 07:55:05 +00:00
|
|
|
|
long THardy_clienti::get_codcf(const TString &key)
|
|
|
|
|
{
|
|
|
|
|
long codcf = 0;
|
|
|
|
|
const char first = key[0];
|
|
|
|
|
long cod_hardy = atoi(key.mid(3,6));
|
|
|
|
|
switch (first)
|
|
|
|
|
{
|
|
|
|
|
case 'H':
|
|
|
|
|
{
|
|
|
|
|
codcf = 130000+cod_hardy;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 'P':
|
|
|
|
|
{
|
|
|
|
|
codcf = 140000+cod_hardy;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case '0':
|
|
|
|
|
{
|
|
|
|
|
const char second = key[1];
|
|
|
|
|
if (second == '1')
|
|
|
|
|
codcf = 120000+cod_hardy;
|
|
|
|
|
else if (second == '0')
|
|
|
|
|
{
|
|
|
|
|
const char third = key[2];
|
|
|
|
|
if (third == '4')
|
|
|
|
|
codcf = 110000+cod_hardy;
|
|
|
|
|
else if (third == '3')
|
|
|
|
|
codcf = 100000+cod_hardy;
|
|
|
|
|
else if (third == '2')
|
|
|
|
|
codcf = 200000+cod_hardy;
|
|
|
|
|
else
|
|
|
|
|
codcf = cod_hardy;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
codcf = cod_hardy;
|
|
|
|
|
}
|
2010-10-29 13:19:54 +00:00
|
|
|
|
if (codcf > 999999)
|
|
|
|
|
codcf = 0;
|
2010-10-29 07:55:05 +00:00
|
|
|
|
return codcf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool THardy_clienti::trasferisci()
|
|
|
|
|
{
|
|
|
|
|
TString query =
|
|
|
|
|
"SELECT * "
|
|
|
|
|
"FROM dbo.Clienti ";
|
|
|
|
|
|
|
|
|
|
TRecordset& recset = create_recordset(query);
|
|
|
|
|
TConfig& ini = config();
|
|
|
|
|
|
|
|
|
|
TString_array lista_campi;
|
|
|
|
|
ini.list_variables(lista_campi, true, "CLIENTI", true);
|
|
|
|
|
|
|
|
|
|
TSystemisamfile clienti(LF_CLIFO);
|
|
|
|
|
clienti.open(_lock);
|
|
|
|
|
TRectype& rec = clienti.curr();
|
|
|
|
|
THardy_iterator hi(this);
|
|
|
|
|
while (++hi)
|
|
|
|
|
{
|
|
|
|
|
// costruisco la chiave
|
|
|
|
|
const TString16 key = get_str("IdConto");
|
|
|
|
|
long codcf = get_codcf(key);
|
2010-10-29 13:19:54 +00:00
|
|
|
|
if (codcf > 0)
|
|
|
|
|
{
|
|
|
|
|
rec.zero();
|
|
|
|
|
rec.put(CLI_TIPOCF, "C");
|
|
|
|
|
rec.put(CLI_CODCF, codcf);
|
|
|
|
|
// ricerca comune
|
|
|
|
|
const TString8 cap = get_str("IdCap"); //cap
|
|
|
|
|
TString80 loc = get_str("Localita"); //localit<69>
|
|
|
|
|
const TString8 com = cap2comune(cap,loc); //codice comune
|
|
|
|
|
const TString8 stato = get_str("IdNazione"); //stato
|
|
|
|
|
|
|
|
|
|
rec.put(CLI_CAPCF, cap);
|
|
|
|
|
if (com.full() && !com.blank())
|
|
|
|
|
{
|
|
|
|
|
rec.put(CLI_COMCF, com); //se riesce la CAP2COMUNE, inserisco il codice comune
|
|
|
|
|
loc = "";
|
|
|
|
|
rec.put(CLI_LOCCF, loc);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rec.put(CLI_COMCF, com);
|
|
|
|
|
if (stato != "IT" && !stato.blank()) //altrimenti metto tutto nella localit<69>, eventualmente concatenando lo stato
|
|
|
|
|
loc << " - " << stato;
|
|
|
|
|
rec.put(CLI_LOCCF, loc);
|
|
|
|
|
}
|
|
|
|
|
aggiorna_record(rec, lista_campi);
|
|
|
|
|
test_write(clienti);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TString msg;
|
|
|
|
|
msg << TR("Impossibile determinare il codice del cliente") << " '" << key << '\'';
|
|
|
|
|
log(msg);
|
|
|
|
|
}
|
2010-10-29 07:55:05 +00:00
|
|
|
|
}
|
|
|
|
|
clienti.close();
|
|
|
|
|
return write_enabled();
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-29 13:19:54 +00:00
|
|
|
|
long THardy_fornitori::get_codcf(const TString &key)
|
|
|
|
|
{
|
|
|
|
|
long codcf = atoi(key.mid(3,6));
|
|
|
|
|
return codcf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool THardy_fornitori::trasferisci()
|
|
|
|
|
{
|
|
|
|
|
TString query =
|
|
|
|
|
"SELECT * "
|
|
|
|
|
"FROM dbo.Fornitori ";
|
|
|
|
|
|
|
|
|
|
TRecordset& recset = create_recordset(query);
|
|
|
|
|
TConfig& ini = config();
|
|
|
|
|
|
|
|
|
|
TString_array lista_campi;
|
|
|
|
|
ini.list_variables(lista_campi, true, "FORNITORI", true);
|
|
|
|
|
|
|
|
|
|
TSystemisamfile clienti(LF_CLIFO);
|
|
|
|
|
clienti.open(_lock);
|
|
|
|
|
TRectype& rec = clienti.curr();
|
|
|
|
|
THardy_iterator hi(this);
|
|
|
|
|
while (++hi)
|
|
|
|
|
{
|
|
|
|
|
const TString16 key = get_str("IdConto");
|
|
|
|
|
long codcf = get_codcf(key);
|
|
|
|
|
if (codcf > 0)
|
|
|
|
|
{
|
|
|
|
|
rec.zero();
|
|
|
|
|
rec.put(CLI_TIPOCF, "F");
|
|
|
|
|
rec.put(CLI_CODCF, codcf);
|
|
|
|
|
// ricerca comune
|
|
|
|
|
const TString8 cap = get_str("IdCap"); //cap
|
|
|
|
|
TString80 loc = get_str("Localita"); //localit<69>
|
|
|
|
|
const TString8 com = cap2comune(cap,loc); //codice comune
|
|
|
|
|
const TString8 stato = get_str("IdNazione"); //stato
|
|
|
|
|
|
|
|
|
|
rec.put(CLI_CAPCF, cap);
|
|
|
|
|
if (com.full() && !com.blank())
|
|
|
|
|
{
|
|
|
|
|
rec.put(CLI_COMCF, com); //se riesce la CAP2COMUNE, inserisco il codice comune
|
|
|
|
|
loc = "";
|
|
|
|
|
rec.put(CLI_LOCCF, loc);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rec.put(CLI_COMCF, com);
|
|
|
|
|
if (stato != "IT" && !stato.blank()) //altrimenti metto tutto nella localit<69>, eventualmente concatenando lo stato
|
|
|
|
|
loc << " - " << stato;
|
|
|
|
|
rec.put(CLI_LOCCF, loc);
|
|
|
|
|
}
|
|
|
|
|
aggiorna_record(rec, lista_campi);
|
|
|
|
|
test_write(clienti);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TString msg;
|
|
|
|
|
msg << TR("Impossibile determinare il codice del fornitore") << " '" << key << '\'';
|
|
|
|
|
log(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
clienti.close();
|
|
|
|
|
return write_enabled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TString& THardy_agenti::get_codage(const TString& key)
|
|
|
|
|
{
|
|
|
|
|
TString16 codage(key);
|
|
|
|
|
return codage.right_just(5,'0');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool THardy_agenti::trasferisci()
|
|
|
|
|
{
|
|
|
|
|
TString query =
|
|
|
|
|
"SELECT * "
|
|
|
|
|
"FROM dbo.Agenti ";
|
|
|
|
|
|
|
|
|
|
TRecordset& recset = create_recordset(query);
|
|
|
|
|
TConfig& ini = config();
|
|
|
|
|
|
|
|
|
|
TString_array lista_campi;
|
|
|
|
|
ini.list_variables(lista_campi, true, "AGENTI", true);
|
|
|
|
|
|
|
|
|
|
TSystemisamfile agenti(LF_AGENTI);
|
|
|
|
|
agenti.open(_lock);
|
|
|
|
|
TRectype& rec = agenti.curr();
|
|
|
|
|
THardy_iterator hi(this);
|
|
|
|
|
while (++hi)
|
|
|
|
|
{
|
|
|
|
|
const TString16 key = get_str("IdAgente");
|
|
|
|
|
TString8 codage = get_codage(key);
|
|
|
|
|
if (codage > 0)
|
|
|
|
|
{
|
|
|
|
|
rec.zero();
|
|
|
|
|
rec.put(AGE_CODAGE, codage);
|
|
|
|
|
aggiorna_record(rec, lista_campi);
|
|
|
|
|
test_write(agenti);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TString msg;
|
|
|
|
|
msg << TR("Impossibile determinare il codice dell'agente") << " '" << key << '\'';
|
|
|
|
|
log(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
agenti.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;
|
|
|
|
|
}
|
2010-10-28 13:27:37 +00:00
|
|
|
|
if (go_on && get_bool(F_PCON))
|
|
|
|
|
{
|
|
|
|
|
THardy_pcon pc;
|
|
|
|
|
pc.init(TR("Piano dei conti"), query_header, log);
|
|
|
|
|
go_on = pc.trasferisci();
|
|
|
|
|
book.add(log);
|
|
|
|
|
rep_to_print = true;
|
|
|
|
|
}
|
|
|
|
|
if (go_on && get_bool(F_CLI))
|
|
|
|
|
{
|
|
|
|
|
THardy_clienti pc;
|
|
|
|
|
pc.init(TR("Clienti"), query_header, log);
|
2010-10-29 13:19:54 +00:00
|
|
|
|
go_on = pc.trasferisci();
|
|
|
|
|
book.add(log);
|
|
|
|
|
rep_to_print = true;
|
|
|
|
|
}
|
|
|
|
|
if (go_on && get_bool(F_FOR))
|
|
|
|
|
{
|
|
|
|
|
THardy_fornitori pc;
|
|
|
|
|
pc.init(TR("Fornitori"), query_header, log);
|
|
|
|
|
go_on = pc.trasferisci();
|
|
|
|
|
book.add(log);
|
|
|
|
|
rep_to_print = true;
|
|
|
|
|
}
|
|
|
|
|
if (go_on && get_bool(F_AGENTI))
|
|
|
|
|
{
|
|
|
|
|
THardy_agenti pc;
|
|
|
|
|
pc.init(TR("Agenti"), query_header, log);
|
2010-10-28 13:27:37 +00:00
|
|
|
|
go_on = pc.trasferisci();
|
|
|
|
|
book.add(log);
|
|
|
|
|
rep_to_print = true;
|
|
|
|
|
}
|
2010-10-18 14:08:42 +00:00
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|