2010-12-06 11:49:38 +00:00
|
|
|
|
#include "halib.h"
|
|
|
|
|
#include "hacnvlib.h"
|
|
|
|
|
#include "hacnv200a.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("Conversione movimenti");
|
|
|
|
|
|
2010-12-07 14:53:18 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Movimenti
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class THardy_movimenti : public THardy_transfer
|
|
|
|
|
{
|
|
|
|
|
int _anno;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual bool trasferisci();
|
|
|
|
|
THardy_movimenti(int anno);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
THardy_movimenti::THardy_movimenti(int anno) : _anno(anno)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool THardy_movimenti::trasferisci()
|
|
|
|
|
{
|
|
|
|
|
TString query =
|
|
|
|
|
"SELECT * "
|
|
|
|
|
"FROM dbo.MovContabiliT "
|
|
|
|
|
"WHERE Esercizio=";
|
|
|
|
|
query << _anno;
|
|
|
|
|
|
|
|
|
|
TRecordset& recset = create_recordset(query);
|
|
|
|
|
TConfig& ini = config();
|
|
|
|
|
|
|
|
|
|
TString_array lista_campi;
|
|
|
|
|
ini.list_variables(lista_campi, true, "MOV", true);
|
|
|
|
|
|
|
|
|
|
TFilename outdir("C:");
|
|
|
|
|
TConfig* conf = NULL;
|
|
|
|
|
int nrigac = 1;
|
|
|
|
|
int nrigai = 1;
|
|
|
|
|
long ntran = 1L;
|
|
|
|
|
|
|
|
|
|
THardy_iterator hi(this);
|
|
|
|
|
while (++hi)
|
|
|
|
|
{
|
|
|
|
|
if (conf != NULL)
|
|
|
|
|
delete conf;
|
|
|
|
|
conf = NULL;
|
|
|
|
|
TFilename temp(outdir);
|
|
|
|
|
|
|
|
|
|
temp.format("%05ld", ntran++);
|
|
|
|
|
temp.ext("ini");
|
|
|
|
|
if (temp.exist())
|
|
|
|
|
temp.fremove();
|
|
|
|
|
conf = new TConfig(temp);
|
|
|
|
|
conf->set_paragraph("Transaction");
|
|
|
|
|
conf->set("Action","INSERT");
|
|
|
|
|
conf->set("Mode", "AUTO");
|
|
|
|
|
|
|
|
|
|
conf->set_paragraph("23"); // testata movimento
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
const TString& key = get_str("IdConto");
|
|
|
|
|
const long codcf = 0;//key2forn(key);
|
|
|
|
|
if (codcf > 0)
|
|
|
|
|
{
|
|
|
|
|
rec.zero();
|
|
|
|
|
rec.put(CLI_TIPOCF, "F");
|
|
|
|
|
rec.put(CLI_CODCF, codcf);
|
|
|
|
|
|
|
|
|
|
// contropartita
|
|
|
|
|
const TString16 key = get_str("IdContropartita");
|
|
|
|
|
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.put(CLI_GRUPPORIC, gr);
|
|
|
|
|
rec.put(CLI_CONTORIC, co);
|
|
|
|
|
rec.put(CLI_SOTTOCRIC, so);
|
|
|
|
|
|
|
|
|
|
// ricerca comune
|
|
|
|
|
const TString8 cap = get_str("IdCap"); //cap
|
|
|
|
|
TString80 loc = get_str("Localita"); //localit<69>
|
|
|
|
|
const TString4 com = cap2comune(cap,loc); //codice comune
|
|
|
|
|
const TString4 stato = get_str("IdNazione"); //stato
|
|
|
|
|
|
|
|
|
|
rec.put(CLI_CAPCF, cap);
|
|
|
|
|
if (com.full())
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return write_enabled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-12-06 11:49:38 +00:00
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TConvMovimentiHardy_mask
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TConvMovimentiHardy_mask : public TAutomask
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
|
void serialize(bool bSave);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
void trasferisci();
|
|
|
|
|
|
|
|
|
|
TConvMovimentiHardy_mask();
|
|
|
|
|
virtual ~TConvMovimentiHardy_mask();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Funzione di tarsferimento dati da/verso file .ini con lo stesso nome della maschera
|
|
|
|
|
// Andrebbe messo in libreria
|
|
|
|
|
void TConvMovimentiHardy_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 TConvMovimentiHardy_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;
|
|
|
|
|
|
2010-12-07 14:53:18 +00:00
|
|
|
|
const int anno = get_int(F_ANNO);
|
|
|
|
|
if (go_on && (anno!=0))
|
2010-12-06 11:49:38 +00:00
|
|
|
|
{
|
2010-12-07 14:53:18 +00:00
|
|
|
|
THardy_movimenti pc(anno);
|
|
|
|
|
pc.init(TR("Movimenti contabili"), query_header, log);
|
|
|
|
|
go_on = pc.trasferisci();
|
|
|
|
|
book.add(log);
|
|
|
|
|
rep_to_print = true;
|
2010-12-06 11:49:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rep_to_print && book.pages() > 0)
|
|
|
|
|
book.preview();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TConvMovimentiHardy_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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TConvMovimentiHardy_mask::TConvMovimentiHardy_mask() : TAutomask("hacnv200a")
|
|
|
|
|
{
|
|
|
|
|
serialize(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TConvMovimentiHardy_mask::~TConvMovimentiHardy_mask()
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TConvMovimentiHardy
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TConvMovimentiHardy : public TSkeleton_application
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual void main_loop();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void TConvMovimentiHardy::main_loop()
|
|
|
|
|
{
|
|
|
|
|
TConvMovimentiHardy_mask mask;
|
|
|
|
|
while (mask.run() == K_ENTER)
|
|
|
|
|
mask.trasferisci();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int hacnv200(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
TConvMovimentiHardy ih;
|
|
|
|
|
ih.run(argc, argv, APPNAME);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|