Files correlati : Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/trunk@19757 c028cbd2-c16b-5b4b-a496-9718f37d4682
290 lines
6.9 KiB
C++
Executable File
290 lines
6.9 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <automask.h>
|
|
#include <execp.h>
|
|
#include <progind.h>
|
|
#include <reputils.h>
|
|
#include <utility.h>
|
|
#include <relation.h>
|
|
#include <reprint.h>
|
|
#include <textset.h>
|
|
|
|
#include "tabutil.h"
|
|
|
|
#include "pe0001.h"
|
|
#include "pe0001100a.h"
|
|
|
|
#include <causali.h>
|
|
#include <clifo.h>
|
|
#include <mov.h>
|
|
#include <rmoviva.h>
|
|
|
|
class TErogazioni_wincard : public TAS400_recordset
|
|
{
|
|
const TVariant& get_field(const TAS400_column_info& fi) const;
|
|
|
|
public:
|
|
TErogazioni_wincard(const char* query = "");
|
|
virtual ~TErogazioni_wincard() { }
|
|
};
|
|
|
|
|
|
TErogazioni_wincard::TErogazioni_wincard(const char* query)
|
|
: TAS400_recordset(TString("AS400(269,0,0)\n") << query)
|
|
{
|
|
create_field("Impianto", 0, 8);
|
|
create_field("Cliente", 8, 3);
|
|
create_field("Filler01", 11, 14);
|
|
create_field("Schede", 25, 5, _intfld);
|
|
create_field("Data", 30, 8, _datefld);
|
|
create_field("Ora", 38, 8);
|
|
create_field("Pompa", 46, 2);
|
|
create_field("Prodotto", 48, 15);
|
|
create_field("Volume", 63, 15, _realfld);
|
|
create_field("Importo", 78, 15, _realfld);
|
|
create_field("Prezzo", 93, 15, _realfld);
|
|
create_field("Note", 108, 20);
|
|
create_field("Ins.Manuale", 128, 1);
|
|
create_field("Num. Buono", 129, 10, _realfld);
|
|
create_field("DataStampa", 139, 8, _datefld);
|
|
create_field("OraStampa", 147, 8);
|
|
create_field("Fller02", 155, 1);
|
|
create_field("Contatore", 156, 10, _realfld);
|
|
create_field("Num. Fattura", 166, 10, _realfld);
|
|
create_field("Sconto", 176, 15, _realfld);
|
|
create_field("Mess Inc.", 191, 4);
|
|
create_field("ID", 195, 10, _realfld);
|
|
create_field("Ora Registrazione", 205, 8);
|
|
create_field("Venduto", 213, 1);
|
|
create_field("Temperatura", 214, 15, _realfld);
|
|
create_field("Densitŕ", 229, 15, _realfld);
|
|
create_field("Fatt54b", 244, 15, _realfld);
|
|
create_field("Data", 259, 8, _datefld);
|
|
}
|
|
|
|
const TVariant& TErogazioni_wincard::get_field(const TAS400_column_info& ci) const
|
|
{
|
|
if (ci._type == _datefld)
|
|
{
|
|
TVariant & var = get_tmp_var();
|
|
const TRecnotype n = current_row();
|
|
if (n >= 0 && n < items())
|
|
{
|
|
const TString& str = row(n).mid(ci._pos, ci._width);
|
|
long ansi = 20000000L + atoi(str.right(2)) * 10000 + atoi(str.mid(3,2)) * 100 + atoi(str.left(2));
|
|
|
|
if (ansi > 20510000L)
|
|
ansi -= 1000000L;
|
|
var = TDate(ansi);
|
|
}
|
|
|
|
return var;
|
|
}
|
|
else
|
|
if (ci._type == _realfld)
|
|
{
|
|
TVariant & var = get_tmp_var();
|
|
const TRecnotype n = current_row();
|
|
if (n >= 0 && n < items())
|
|
{
|
|
const TString& str = row(n).mid(ci._pos, ci._width);
|
|
|
|
var = real(real::ita2eng(str));
|
|
}
|
|
|
|
return var;
|
|
}
|
|
return TAS400_recordset::get_field(ci);
|
|
}
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TAutomask
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TImportaFat_mask : public TAutomask
|
|
{
|
|
protected:
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
public:
|
|
TImportaFat_mask();
|
|
};
|
|
|
|
TImportaFat_mask::TImportaFat_mask() :TAutomask ("pe0001100a")
|
|
{
|
|
}
|
|
|
|
bool TImportaFat_mask::on_field_event(TOperable_field& f, TField_event e, long jolly)
|
|
{
|
|
switch (f.dlg())
|
|
{
|
|
//giochetto per avere la lista dei files validi nella directory di trasferimento!
|
|
case F_NAME:
|
|
if (e == fe_button)
|
|
{
|
|
TArray_sheet as(-1, -1, 72, 20, TR("Selezione file"),
|
|
"File@32");
|
|
TFilename path = get(F_PATH);
|
|
path.add("*.csv"); //files delle testate
|
|
list_files(path, as.rows_array());
|
|
TFilename name;
|
|
FOR_EACH_ARRAY_ROW(as.rows_array(), i, row)
|
|
{
|
|
name = *row;
|
|
*row = name.name();
|
|
}
|
|
if (as.run() == K_ENTER)
|
|
{
|
|
f.set(as.row(as.selected()));
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
///////////////////////////////////////////////
|
|
//// CLASSI DERIVATE PER IMPORTAZIONE DATI ////
|
|
///////////////////////////////////////////////
|
|
|
|
/////////////////////////////////////////////////////////////
|
|
// Recordset specifici per i dati da trasferire
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
//Piano dei conti
|
|
class TImporta_fatt_recordset : public TCSV_recordset
|
|
{
|
|
public:
|
|
TImporta_fatt_recordset(const char * fileName);
|
|
};
|
|
|
|
TImporta_fatt_recordset::TImporta_fatt_recordset(const char * fileName)
|
|
: TCSV_recordset("CSV(\",\")")
|
|
{
|
|
load_file(fileName);
|
|
}
|
|
|
|
///////////////////////////////////////
|
|
// TSkeleton_application
|
|
///////////////////////////////////////
|
|
class TFattCSV : public TSkeleton_application
|
|
{
|
|
virtual bool check_autorization() const {return false;}
|
|
virtual const char * extra_modules() const {return "ve";}
|
|
|
|
TImportaFat_mask* _msk;
|
|
TConfig* _configfile;
|
|
|
|
|
|
//protected:
|
|
|
|
|
|
public:
|
|
virtual bool create();
|
|
virtual bool destroy();
|
|
virtual void main_loop();
|
|
bool transfer(const TFilename& file);
|
|
|
|
TFattCSV() {};
|
|
};
|
|
|
|
bool TFattCSV::transfer(const TFilename& file)
|
|
{
|
|
TImporta_fatt_recordset s(file);
|
|
|
|
TProgind pi(s.items(),"Importazione fatture in corso ...",true,true);
|
|
|
|
_configfile->set_paragraph("Transaction"); //setto il paragrafo [Transaction] del file ini
|
|
|
|
_configfile->set("Action","INSERT");
|
|
_configfile->set("Mode","AUTO");
|
|
|
|
_configfile->set_paragraph("23"); //setto il paragrafo [23] del file ini (testata)
|
|
|
|
_configfile->set(MOV_TIPO,"F");
|
|
_configfile->set(MOV_CODCF, _msk->get(F_CODCF));
|
|
|
|
_configfile->set(MOV_CODCAUS, _msk->get(F_CODCAU));
|
|
|
|
_configfile->set(MOV_DATAREG, _msk->get(F_DATAREG));
|
|
|
|
|
|
int nriga = 1;
|
|
|
|
for (bool ok=s.move_first();ok;ok=s.move_next())
|
|
{
|
|
if (!pi.addstatus(1))
|
|
break;
|
|
|
|
TString8 paragraph;
|
|
paragraph.format("%d,%d",LF_RMOVIVA,nriga++);
|
|
_configfile->set_paragraph(paragraph);
|
|
|
|
TString16 codcom = s.get(0).as_string();
|
|
real imp = s.get(1).as_real();
|
|
|
|
_configfile->set(RMI_IMPONIBILE,imp.string());
|
|
_configfile->set(RMI_CODIVA,_msk->get(F_CODIVA));
|
|
_configfile->set(RMI_CODCMS,codcom);
|
|
|
|
}
|
|
|
|
_configfile->set_paragraph("Transaction");
|
|
|
|
return true;
|
|
}
|
|
|
|
const char* nomeini = "pe0001100fatt.ini";
|
|
|
|
bool TFattCSV::create()
|
|
{
|
|
xvt_fsys_removefile(nomeini);
|
|
_configfile = new TConfig(nomeini);
|
|
|
|
_msk = new TImportaFat_mask();
|
|
|
|
return TSkeleton_application::create();
|
|
}
|
|
|
|
bool TFattCSV::destroy()
|
|
{
|
|
delete _msk;
|
|
delete _configfile;
|
|
return TApplication::destroy();
|
|
}
|
|
|
|
void TFattCSV::main_loop()
|
|
{
|
|
KEY tasto;
|
|
tasto = _msk->run();
|
|
if (tasto == K_ENTER)
|
|
{
|
|
|
|
//genero il nome del file da caricare
|
|
TFilename name = _msk->get(F_PATH);
|
|
name.add(_msk->get(F_NAME));
|
|
if (transfer(name))
|
|
{
|
|
|
|
TString app;
|
|
app << "cg2 -0 -i" << nomeini;
|
|
TExternal_app primanota(app);
|
|
primanota.run();
|
|
|
|
message_box(TR("Importazione fatture completata"));
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
TFattCSV& app() { return (TFattCSV&) main_app(); }
|
|
|
|
|
|
int pe0001100 (int argc, char* argv[])
|
|
{
|
|
TFattCSV main_app;
|
|
main_app.run(argc, argv, TR("Importazione Fatture"));
|
|
return true;
|
|
} |