Patch level : 10.0 710
Files correlati : tc0.exe Ricompilazione Demo : [ ] Commento Convesrione ditte Teamsystem git-svn-id: svn://10.65.10.50/trunk@20375 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
873b32e0fc
commit
44b806405e
413
tc/tc0900.cpp
413
tc/tc0900.cpp
@ -4,34 +4,91 @@
|
||||
#include <applicat.h>
|
||||
#include <automask.h>
|
||||
#include <config.h>
|
||||
#include <defmask.h>
|
||||
#include <lffiles.h>
|
||||
#include <progind.h>
|
||||
#include <relation.h>
|
||||
#include <reprint.h>
|
||||
#include <reputils.h>
|
||||
#include <tabutil.h>
|
||||
#include <urldefid.h>
|
||||
#include <utility.h>
|
||||
#include <statbar.h>
|
||||
|
||||
#include <clifo.h>
|
||||
#include <causali.h>
|
||||
#include <pconti.h>
|
||||
#include "tc0701.h"
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TSel_sheet
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TSel_sheet : public TArray_sheet
|
||||
{
|
||||
public:
|
||||
TSel_sheet();
|
||||
};
|
||||
|
||||
TSel_sheet::TSel_sheet()
|
||||
: TArray_sheet(-1, -1, -4, -4, TR("Selezione files"),
|
||||
HR("@1|N.@5|Nome@20|EOD@7|EOX@7|Lunghezza|Descrizione@43|Flags@7"), 0x8)
|
||||
{
|
||||
|
||||
add_button(-1, "", 0, 1); // Separatore
|
||||
add_button(DLG_INFO, TR("Info"), K_F2, BMP_INFO);
|
||||
add_button(DLG_HELP, TR("Help"), K_F1, BMP_HELP);
|
||||
xvt_toolbar_set_last_tool(toolbar(), DLG_QUIT);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// TConvert_mask
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TConvert_mask : public TAutomask
|
||||
{
|
||||
TSel_sheet* _selsheet;
|
||||
short _log2row[500];
|
||||
|
||||
private:
|
||||
void serialize(bool bSave);
|
||||
protected:
|
||||
bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||
public:
|
||||
TConvert_mask();
|
||||
TSel_sheet& selsheet() { CHECK(_selsheet != NULL, TR("NULL selection mask")); return *_selsheet;}
|
||||
const bool to_convert(int logicnum) const { return _selsheet->checked(_log2row[logicnum]);}
|
||||
const bool converted(int logicnum) const { return !to_convert(logicnum);}
|
||||
void set_to_convert(int logicnum) { _selsheet->check(_log2row[logicnum]);}
|
||||
void set_converted(int logicnum) { _selsheet->check(_log2row[logicnum], false);}
|
||||
void build_sheet();
|
||||
void add_sheet_row(int logicnum);
|
||||
|
||||
TConvert_mask();
|
||||
virtual ~TConvert_mask();
|
||||
};
|
||||
|
||||
const long TGm2ricl(char & t, int gr, int co)
|
||||
{
|
||||
long codricl = 0;
|
||||
|
||||
if (gr > 0)
|
||||
{
|
||||
TLocalisamfile riclpdc(LF_RICLPDC);
|
||||
|
||||
riclpdc.put("TIPORIC", "TSCONTI");
|
||||
riclpdc.put("GRUPPO", gr);
|
||||
riclpdc.put("CONTO", co);
|
||||
if (riclpdc.read(_isgteq) == NOERR && riclpdc.get_int("GRUPPO") == gr)
|
||||
{
|
||||
if (co == 0)
|
||||
codricl = atol(riclpdc.get("CODICE").sleft(2)) * 100000L;
|
||||
else
|
||||
codricl = atol(riclpdc.get("CODICE").sleft(4)) * 1000;
|
||||
}
|
||||
}
|
||||
return codricl;
|
||||
}
|
||||
|
||||
enum TConv_funcs { _conti, _tabella, _clifor, _contanal } ;
|
||||
|
||||
class TField_info : public TObject
|
||||
@ -53,26 +110,34 @@ public:
|
||||
|
||||
class TConvert_archives : public TSkeleton_application
|
||||
{
|
||||
TTSRiclassifica_cache* _tabelle;
|
||||
TLog_report _log;
|
||||
TTSRiclassifica_cache * _tabelle;
|
||||
TLog_report * _log;
|
||||
long _offsetcli;
|
||||
long _offsetfor;
|
||||
TConvert_mask * _m;
|
||||
TFilename _srcdir;
|
||||
TFilename _dstdir;
|
||||
bool _tabcomconverted;
|
||||
bool _tabconverted;
|
||||
|
||||
virtual bool create();
|
||||
virtual bool destroy();
|
||||
void convert(bool comtables);
|
||||
const TString & scod2ricl(const char* tab, const TString& cod);
|
||||
const long bill2ricl(char t, int gr, int co, long so) { return TSbill2ricl(t, gr, co, so); }
|
||||
const long gm2ricl(char t, int gr, int co) { return TGm2ricl(t, gr, co); }
|
||||
bool convert_clifo(char t, long & codcf);
|
||||
bool convert_field(TRectype & rec, TField_info & finfo);
|
||||
bool convert_field(TRectype & rec, TField_info & finfo, TString & msg);
|
||||
void convert_file(int logicnum, TArray & fieldlist);
|
||||
void convert_table(const char * tablename, TArray & fieldlist);
|
||||
void convert_table(const char * tablename, TArray & fieldlist, bool first = false);
|
||||
bool copy_file(const TFilename& src, const TFilename& dst, const int preflen) const;
|
||||
void save_or_restore_file(int logicnum);
|
||||
|
||||
protected:
|
||||
virtual void main_loop();
|
||||
|
||||
public:
|
||||
TConvert_archives() : _log("Conversione Archivi CAMPO"), _offsetcli(0L), _offsetfor(0L) {}
|
||||
TConvert_archives() : _offsetcli(0L), _offsetfor(0L) {}
|
||||
};
|
||||
|
||||
TConvert_archives& app() { return (TConvert_archives&)main_app(); }
|
||||
@ -84,15 +149,111 @@ TConvert_archives& app() { return (TConvert_archives&)main_app(); }
|
||||
TConvert_mask::TConvert_mask() : TAutomask("tc0900a")
|
||||
{
|
||||
serialize(false);
|
||||
_selsheet = new TSel_sheet;
|
||||
build_sheet();
|
||||
}
|
||||
|
||||
void TConvert_mask::add_sheet_row(int logicnum)
|
||||
{
|
||||
TToken_string riga;
|
||||
TDir cdir;
|
||||
|
||||
cdir.get(logicnum, _nolock, _nordir, _sysdirop);
|
||||
riga = " ";
|
||||
riga.add(logicnum);
|
||||
riga.add(cdir.name());
|
||||
riga.add(cdir.eod());
|
||||
riga.add(cdir.eox());
|
||||
riga.add((int)cdir.len());
|
||||
riga.add(cdir.des());
|
||||
riga.add(cdir.flags());
|
||||
const int row = _selsheet->add(riga);
|
||||
_log2row[logicnum]= row;
|
||||
}
|
||||
|
||||
void TConvert_mask::build_sheet()
|
||||
{
|
||||
_selsheet->destroy();
|
||||
add_sheet_row(LF_TABCOM);
|
||||
add_sheet_row(LF_TAB);
|
||||
add_sheet_row(LF_NDITTE);
|
||||
add_sheet_row(LF_INDSP);
|
||||
add_sheet_row(LF_CFVEN);
|
||||
add_sheet_row(LF_PCON);
|
||||
add_sheet_row(LF_CLIFO);
|
||||
add_sheet_row(LF_SALDI);
|
||||
add_sheet_row(LF_ALLEG);
|
||||
add_sheet_row(LF_MOV);
|
||||
add_sheet_row(LF_RMOV);
|
||||
add_sheet_row(LF_RMOVIVA);
|
||||
add_sheet_row(LF_CAUSALI);
|
||||
add_sheet_row(LF_RCAUSALI);
|
||||
add_sheet_row(LF_PARTITE);
|
||||
add_sheet_row(LF_SCADENZE);
|
||||
add_sheet_row(LF_PAGSCA);
|
||||
add_sheet_row(LF_EFFETTI);
|
||||
add_sheet_row(LF_CESS);
|
||||
add_sheet_row(LF_DOC);
|
||||
add_sheet_row(LF_RIGHEDOC);
|
||||
add_sheet_row(LF_ANAMAG);
|
||||
add_sheet_row(LF_CONDV);
|
||||
add_sheet_row(LF_RCONDV);
|
||||
add_sheet_row(LF_TABREG);
|
||||
add_sheet_row(LF_MOVANA);
|
||||
add_sheet_row(LF_RMOVANA);
|
||||
add_sheet_row(LF_MOVMAG);
|
||||
add_sheet_row(LF_AGENTI);
|
||||
add_sheet_row(LF_PROVV);
|
||||
add_sheet_row(LF_INTRA);
|
||||
add_sheet_row(LF_RIEPRETT);
|
||||
add_sheet_row(LF_CESPI);
|
||||
add_sheet_row(LF_COLLCES);
|
||||
add_sheet_row(LF_RIP);
|
||||
add_sheet_row(LF_RRIP);
|
||||
add_sheet_row(LF_SALDANA);
|
||||
add_sheet_row(LF_LETINT);
|
||||
add_sheet_row(LF_PANAPDC);
|
||||
add_sheet_row(LF_RICLPDC);
|
||||
add_sheet_row(LF_CLIFOGIAC);
|
||||
|
||||
const int rows = _selsheet->items();
|
||||
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
TToken_string & row = _selsheet->row(i);
|
||||
const int logicnum = row.get_int(1);
|
||||
|
||||
_selsheet->check(i, ini_get_bool(CONFIG_DITTA, "tc", "file2conv", true, i));
|
||||
}
|
||||
}
|
||||
|
||||
TConvert_mask::~TConvert_mask()
|
||||
{
|
||||
const int rows = _selsheet->items();
|
||||
|
||||
for (int i = 0; i < rows; i++)
|
||||
{
|
||||
TToken_string & row = _selsheet->row(i);
|
||||
const int logicnum = row.get_int(1);
|
||||
|
||||
ini_set_bool(CONFIG_DITTA, "tc", "file2conv", _selsheet->checked(i), i);
|
||||
}
|
||||
delete _selsheet;
|
||||
serialize(true);
|
||||
}
|
||||
|
||||
bool TConvert_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 DLG_SELECT:
|
||||
if (e == fe_button)
|
||||
_selsheet->run();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -145,12 +306,14 @@ bool TConvert_archives::create()
|
||||
firstfor = 1;
|
||||
_offsetcli -= firstfor;
|
||||
}
|
||||
_log = new TLog_report("Conversione Archivi CAMPO");
|
||||
return TSkeleton_application::create();
|
||||
}
|
||||
|
||||
bool TConvert_archives::destroy()
|
||||
{
|
||||
delete _tabelle;
|
||||
delete _log;
|
||||
return TSkeleton_application::destroy();
|
||||
}
|
||||
|
||||
@ -167,10 +330,13 @@ bool TConvert_archives::convert_clifo(char t, long & codcf)
|
||||
bool converted = false;
|
||||
|
||||
if (codcf >= 1000000L)
|
||||
{
|
||||
codcf -= t == 'C' ? _offsetcli : _offsetfor;
|
||||
converted = true;
|
||||
}
|
||||
return converted;
|
||||
}
|
||||
bool TConvert_archives::convert_field(TRectype & rec, TField_info & finfo)
|
||||
bool TConvert_archives::convert_field(TRectype & rec, TField_info & finfo, TString & msg)
|
||||
{
|
||||
bool converted = false;
|
||||
if (finfo.fieldname().full())
|
||||
@ -186,6 +352,8 @@ bool TConvert_archives::convert_field(TRectype & rec, TField_info & finfo)
|
||||
if (ftipo && *ftipo)
|
||||
t = rec.get(ftipo)[0];
|
||||
int gr = rec.get_int(fname.get());
|
||||
if (gr == 0)
|
||||
return true;
|
||||
int co = rec.get_int(fname.get());
|
||||
if (t == 'X')
|
||||
{
|
||||
@ -198,9 +366,12 @@ bool TConvert_archives::convert_field(TRectype & rec, TField_info & finfo)
|
||||
const char * fso = fname.get();
|
||||
long so = 0L;
|
||||
if (fso && *fso)
|
||||
rec.get_long(fso);
|
||||
so = rec.get_long(fso);
|
||||
long ricl = bill2ricl(t, gr, co, so);
|
||||
|
||||
if (ricl == 0 && so == 0)
|
||||
ricl = gm2ricl(t, gr, co);
|
||||
|
||||
if (ricl > 0)
|
||||
{
|
||||
so = ricl % 1000;
|
||||
@ -209,7 +380,7 @@ bool TConvert_archives::convert_field(TRectype & rec, TField_info & finfo)
|
||||
if (t <= ' ' || convert_clifo(t, so))
|
||||
rec.put(fso, so);
|
||||
}
|
||||
if (rec.num() == LF_PCON)
|
||||
if (rec.num() == LF_PCON && so != 0)
|
||||
{
|
||||
const TRectype & tab = cache().get("&TCO", format("&07ld", ricl));
|
||||
if (!tab.empty())
|
||||
@ -224,55 +395,50 @@ bool TConvert_archives::convert_field(TRectype & rec, TField_info & finfo)
|
||||
}
|
||||
else
|
||||
{
|
||||
TString msg; msg.format(FR("Campi %s - %s - %s : valore %d - &d - &ld decodifica assente"),
|
||||
(const char *) fname.get(1),
|
||||
(const char *) fname.get(2),
|
||||
(const char *) fname.get(3),
|
||||
gr, co, so);
|
||||
_log.log(2, msg);
|
||||
if (msg.full())
|
||||
_log->log(0, msg);
|
||||
msg.format(FR("Campi %s - %s - %s : valore %d - %d - %ld decodifica assente"),
|
||||
(const char *) fname.get(1),
|
||||
(const char *) fname.get(2),
|
||||
(const char *) fname.get(3),
|
||||
gr, co, so);
|
||||
_log->log(2, msg);
|
||||
msg.cut(0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case _tabella :
|
||||
{
|
||||
const bool s3 = fname == "S3[1,4]";
|
||||
const TFieldref fr(fname, 0);
|
||||
const bool subsc = fname == "S3[1,4]";
|
||||
|
||||
const bool reg = finfo.table() == "REG";
|
||||
const bool rpg = finfo.table() == "%RPG";
|
||||
|
||||
TString val = rec.get(s3 ? "S3" : fname);
|
||||
TString val = fr.read(rec);
|
||||
|
||||
if (s3 || rpg)
|
||||
if (val.blank())
|
||||
return true;
|
||||
|
||||
if (reg)
|
||||
{
|
||||
TString4 v = val.left(4);
|
||||
TString4 v = val.mid(4);
|
||||
|
||||
scod2ricl(finfo.table(), v);
|
||||
v = scod2ricl(finfo.table(), v);
|
||||
if (v.full())
|
||||
val.overwrite(v, 0, 4);
|
||||
{
|
||||
val = val.left(4);
|
||||
val << v;
|
||||
}
|
||||
else
|
||||
val.cut(0);
|
||||
}
|
||||
else
|
||||
if (reg)
|
||||
{
|
||||
TString4 v = val.mid(4);
|
||||
|
||||
scod2ricl(finfo.table(), v);
|
||||
if (v.full())
|
||||
{
|
||||
val = val.left(4);
|
||||
val << v;
|
||||
}
|
||||
else
|
||||
val.cut(0);
|
||||
}
|
||||
else
|
||||
scod2ricl(finfo.table(), val);
|
||||
val = scod2ricl(finfo.table(), val);
|
||||
|
||||
if (val.full())
|
||||
{
|
||||
rec.put(fname, val);
|
||||
fr.write(val, rec);
|
||||
converted = true;
|
||||
}
|
||||
if (finfo.TStable().full())
|
||||
{
|
||||
const TRectype & tab = cache().get(finfo.TStable(), val);
|
||||
@ -280,15 +446,19 @@ bool TConvert_archives::convert_field(TRectype & rec, TField_info & finfo)
|
||||
if (!tab.empty())
|
||||
{
|
||||
if (rec.num() == LF_CAUSALI)
|
||||
rec.put(CAU_DESCR, tab.get("S0"));
|
||||
rec.put(CAU_DESCR, tab.get("S0"));
|
||||
else
|
||||
rec.put("S0", tab.get("S0"));
|
||||
rec.put("S0", tab.get("S0"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TString msg; msg.format(FR("Campo %s : valore %s decodifica assente"), (const char *) fname, (const char *) val);
|
||||
_log.log(2, msg);
|
||||
if (msg.full())
|
||||
_log->log(0, msg);
|
||||
TString msg; msg.format(FR("Campo %s : valore %s decodifica assente"), (const char *) fname, fr.read(rec));
|
||||
_log->log(2, msg);
|
||||
msg.cut(0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -302,16 +472,19 @@ bool TConvert_archives::convert_field(TRectype & rec, TField_info & finfo)
|
||||
t = rec.get(ftipo)[0];
|
||||
const TString & fcod = fname.get(1);
|
||||
long codcf = rec.get_long(fcod);
|
||||
const long oldcf = codcf;
|
||||
converted = convert_clifo(t, codcf);
|
||||
|
||||
if (converted)
|
||||
if (codcf == 0L)
|
||||
return true;
|
||||
const long oldcf = codcf;
|
||||
converted = true;
|
||||
|
||||
if (convert_clifo(t, codcf))
|
||||
{
|
||||
rec.put(fcod, codcf);
|
||||
if (rec.num() == LF_CLIFO)
|
||||
{
|
||||
TString msg; msg.format(FR("Convertito il cliente %ld in %ld"), oldcf, codcf);
|
||||
_log.log(0, msg);
|
||||
_log->log(0, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -320,6 +493,10 @@ bool TConvert_archives::convert_field(TRectype & rec, TField_info & finfo)
|
||||
{
|
||||
TString val = rec.get(fname);
|
||||
int gr = atoi(val.left(3));
|
||||
|
||||
if (gr == 0)
|
||||
return true;
|
||||
|
||||
int co = atoi(val.mid(3,3));
|
||||
long so = atol(val.mid(6,6));
|
||||
char t = ' ';
|
||||
@ -343,36 +520,88 @@ bool TConvert_archives::convert_field(TRectype & rec, TField_info & finfo)
|
||||
return converted;
|
||||
}
|
||||
|
||||
bool TConvert_archives::copy_file(const TFilename& src, const TFilename& dst, const int preflen) const
|
||||
{
|
||||
// Crea la cartella di destinazione se necessario
|
||||
TFilename dstfile(dst);
|
||||
TFilename fname = src.mid(preflen);
|
||||
|
||||
dstfile << fname;
|
||||
const char* dstdir = dstfile.path();
|
||||
|
||||
if (*dstdir && !xvt_fsys_mkdir(dstdir))
|
||||
return error_box(FR("Impossibile creare la cartella %s"), dst.path());
|
||||
|
||||
// Copia veramente il file
|
||||
return ::fcopy(src, dstfile);
|
||||
}
|
||||
|
||||
|
||||
void TConvert_archives::save_or_restore_file(int logicnum)
|
||||
{
|
||||
TFilename dst(_dstdir);
|
||||
TFilename fn(prefix().get_filename(logicnum));
|
||||
TString_array res;
|
||||
|
||||
fn = fn.mid(_srcdir.len());
|
||||
dst << fn << ".dbf";
|
||||
if (fexist(dst))
|
||||
{
|
||||
dst.ext("*");
|
||||
list_files(dst, res);
|
||||
|
||||
FOR_EACH_ARRAY_ROW(res, r, str)
|
||||
copy_file(*str, _srcdir, _dstdir.len());
|
||||
}
|
||||
else
|
||||
{
|
||||
TFilename src(_srcdir);
|
||||
|
||||
src << fn;
|
||||
src.ext("*");
|
||||
list_files(src, res);
|
||||
|
||||
FOR_EACH_ARRAY_ROW(res, r, str)
|
||||
copy_file(*str, _dstdir, _srcdir.len());
|
||||
}
|
||||
}
|
||||
|
||||
void TConvert_archives::convert_file(int logicnum, TArray & fieldlist)
|
||||
{
|
||||
if (_m->converted(logicnum))
|
||||
return;
|
||||
TLocalisamfile f(logicnum);
|
||||
TRectype rec(f.curr());
|
||||
TCursor c(new TRelation(logicnum));
|
||||
TRectype rec(c.curr());
|
||||
TRectype old(rec);
|
||||
TString key;
|
||||
TString msg;
|
||||
|
||||
msg.format(FR("Conversione file %d - %s"), logicnum, f.description());
|
||||
_log.log(0, msg);
|
||||
TProgind p(f.items(), msg);
|
||||
for (int err = f.first(); !p.iscancelled() && err == NOERR; err = f.next())
|
||||
|
||||
save_or_restore_file(logicnum);
|
||||
_log->log(0, msg);
|
||||
const int items = c.items();
|
||||
TProgind p(items, msg);
|
||||
c.freeze();
|
||||
for (c = 0L; !p.iscancelled() && c.pos() < items; ++c)
|
||||
{
|
||||
p.addstatus(1L);
|
||||
bool converted = false;
|
||||
|
||||
rec = f.curr();
|
||||
rec = c.curr();
|
||||
key = rec.key();
|
||||
msg.format(FR("Record %ld - Chiave %s"), f.recno(), (const char *) key);
|
||||
_log.log(0, msg);
|
||||
msg.format(FR("Record %ld - Chiave %s"), c.relation()->lfile().recno(), (const char *) key);
|
||||
FOR_EACH_ARRAY_ITEM(fieldlist, r, obj)
|
||||
{
|
||||
TField_info & finfo = (TField_info &) *obj;
|
||||
converted |= convert_field(rec, finfo);
|
||||
converted |= convert_field(rec, finfo, msg);
|
||||
}
|
||||
if (converted)
|
||||
{
|
||||
if (key != f.curr().key())
|
||||
if (key != c.curr().key())
|
||||
{
|
||||
old = f.curr();
|
||||
old = c.curr();
|
||||
f.curr() = rec;
|
||||
f.write();
|
||||
f.curr() = old;
|
||||
@ -385,38 +614,47 @@ void TConvert_archives::convert_file(int logicnum, TArray & fieldlist)
|
||||
}
|
||||
}
|
||||
}
|
||||
_m->set_converted(logicnum);
|
||||
}
|
||||
|
||||
void TConvert_archives::convert_table(const char * tablename, TArray & fieldlist)
|
||||
void TConvert_archives::convert_table(const char * tablename, TArray & fieldlist, bool first)
|
||||
{
|
||||
TTable t(tablename);
|
||||
TRectype rec(t.curr());
|
||||
TCursor c(new TRelation(tablename));
|
||||
TRectype rec(c.curr());
|
||||
TRectype old(rec);
|
||||
TString key;
|
||||
TString msg;
|
||||
int logicnum = tablename[0]== '%' ? LF_TABCOM : LF_TAB;
|
||||
|
||||
msg.format(FR("Conversione Tabella %d - %s"), tablename, t.description());
|
||||
_log.log(0, msg);
|
||||
TProgind p(t.items(), msg);
|
||||
for (int err = t.first(); !p.iscancelled() && err == NOERR; err = t.next())
|
||||
if (_m->converted(logicnum))
|
||||
return;
|
||||
msg.format(FR("Conversione Tabella %s - %s"), tablename, t.description());
|
||||
|
||||
if (first)
|
||||
save_or_restore_file(logicnum);
|
||||
_log->log(0, msg);
|
||||
const int items = c.items();
|
||||
TProgind p(items, msg);
|
||||
c.freeze();
|
||||
for (c = 0L; !p.iscancelled() && c.pos() < items; ++c)
|
||||
{
|
||||
p.addstatus(1L);
|
||||
bool converted = false;
|
||||
|
||||
rec = t.curr();
|
||||
rec = c.curr();
|
||||
key = rec.key();
|
||||
msg.format(FR("Record %ld - Chiave %s"), t.recno(), (const char *) key);
|
||||
_log.log(0, msg);
|
||||
FOR_EACH_ARRAY_ITEM(fieldlist, r, obj)
|
||||
{
|
||||
TField_info & finfo = (TField_info &) *obj;
|
||||
converted |= convert_field(rec, finfo);
|
||||
converted |= convert_field(rec, finfo, msg);
|
||||
}
|
||||
if (converted)
|
||||
{
|
||||
if (key != t.curr().key())
|
||||
if (key != c.curr().key())
|
||||
{
|
||||
old = t.curr();
|
||||
old = c.curr();
|
||||
t.curr() = rec;
|
||||
t.write();
|
||||
t.curr() = old;
|
||||
@ -429,6 +667,11 @@ void TConvert_archives::convert_table(const char * tablename, TArray & fieldlist
|
||||
}
|
||||
}
|
||||
}
|
||||
if (logicnum == LF_TABCOM)
|
||||
_tabcomconverted = true;
|
||||
else
|
||||
_tabconverted = true;
|
||||
|
||||
}
|
||||
|
||||
void TConvert_archives::convert(bool comtables)
|
||||
@ -436,7 +679,15 @@ void TConvert_archives::convert(bool comtables)
|
||||
TArray field_infos;
|
||||
TConfig d(CONFIG_DITTA, "ca");
|
||||
const bool usepdcc = d.get_bool("UsePdcc");
|
||||
_srcdir = firm2dir(-1);
|
||||
|
||||
if (!isalnum(_srcdir.right(1)[0]))
|
||||
_srcdir.rtrim(1);
|
||||
_dstdir = _srcdir;
|
||||
_dstdir << " tc"; // Lo spazio rende inutilizzabile lo studio
|
||||
|
||||
_tabcomconverted = false;
|
||||
_tabconverted = false;
|
||||
field_infos.add(new TField_info("VALUTA", _tabella, "TSVAL"));
|
||||
convert_file(LF_NDITTE, field_infos);
|
||||
|
||||
@ -475,13 +726,13 @@ void TConvert_archives::convert(bool comtables)
|
||||
field_infos.destroy();
|
||||
field_infos.add(new TField_info("CODCAUS", _tabella, "TSCAU"));
|
||||
field_infos.add(new TField_info("REG", _tabella, "TSREG"));
|
||||
field_infos.add(new TField_info("TIPOCF|CODCF", _clifor));
|
||||
field_infos.add(new TField_info("TIPO|CODCF", _clifor));
|
||||
field_infos.add(new TField_info("CODPAG", _tabella, "TSCDP"));
|
||||
convert_file(LF_MOV, field_infos);
|
||||
|
||||
field_infos.destroy();
|
||||
field_infos.add(new TField_info("TIPOC|GRUPPO|CONTO|SOTTOCONTO"));
|
||||
field_infos.add(new TField_info("TIPOCC|GRUPPOC|CONTOC|SOTTOCONTOC"));
|
||||
field_infos.add(new TField_info("TIPOCC|GRUPPOC|CONTOC|SOTTOCONTC"));
|
||||
convert_file(LF_RMOV, field_infos);
|
||||
|
||||
field_infos.destroy();
|
||||
@ -496,7 +747,7 @@ void TConvert_archives::convert(bool comtables)
|
||||
|
||||
field_infos.destroy();
|
||||
field_infos.add(new TField_info("CODCAUS", _tabella, "TSCAU"));
|
||||
field_infos.add(new TField_info("REG", _tabella, "TSREG"));
|
||||
// field_infos.add(new TField_info("REG", _tabella, "TSREG")); verificare
|
||||
field_infos.add(new TField_info("TIPOCF|GRUPPO|CONTO|SOTTOCONTO"));
|
||||
field_infos.add(new TField_info("CODIVA", _tabella, "TSIVA"));
|
||||
convert_file(LF_RCAUSALI, field_infos);
|
||||
@ -644,7 +895,7 @@ void TConvert_archives::convert(bool comtables)
|
||||
field_infos.add(new TField_info("|I3|I4|I5"));
|
||||
field_infos.add(new TField_info("S3[1,4]", _tabella, "TSIVA"));
|
||||
field_infos.add(new TField_info("S4", _tabella, "TSVAL"));
|
||||
convert_table("SPP", field_infos);
|
||||
convert_table("SPP", field_infos, true);
|
||||
|
||||
field_infos.destroy();
|
||||
field_infos.add(new TField_info("|I0|I1|I2"));
|
||||
@ -695,7 +946,7 @@ void TConvert_archives::convert(bool comtables)
|
||||
{
|
||||
field_infos.destroy();
|
||||
field_infos.add(new TField_info("CODTAB", _tabella, "TSIVA", "&TIV"));
|
||||
convert_table("%IVA", field_infos);
|
||||
convert_table("%IVA", field_infos, true);
|
||||
|
||||
field_infos.destroy();
|
||||
field_infos.add(new TField_info("CODTAB", _tabella, "TSNAZ", "&TNA"));
|
||||
@ -707,7 +958,7 @@ void TConvert_archives::convert(bool comtables)
|
||||
convert_table("%CPG", field_infos);
|
||||
|
||||
field_infos.destroy();
|
||||
field_infos.add(new TField_info("CODTAB", _tabella, "TSCDP"));
|
||||
field_infos.add(new TField_info("CODTAB[1,4]", _tabella, "TSCDP"));
|
||||
convert_table("%RPG", field_infos);
|
||||
|
||||
field_infos.destroy();
|
||||
@ -718,18 +969,24 @@ void TConvert_archives::convert(bool comtables)
|
||||
field_infos.destroy();
|
||||
field_infos.add(new TField_info("CODTAB", _tabella, "TSREG", "&TRE"));
|
||||
convert_table("REG", field_infos);
|
||||
if (_tabcomconverted)
|
||||
_m->set_converted(LF_TABCOM);
|
||||
if (_tabconverted)
|
||||
_m->set_converted(LF_TAB);
|
||||
|
||||
|
||||
TReport_book b;
|
||||
|
||||
b.add(_log);
|
||||
b.add(*_log);
|
||||
b.print_or_preview();
|
||||
}
|
||||
|
||||
void TConvert_archives::main_loop()
|
||||
{
|
||||
TConvert_mask m;
|
||||
if (m.run() == K_ENTER)
|
||||
convert(m.get_bool(F_CONVCOM));
|
||||
_m = new TConvert_mask;
|
||||
if (_m->run() == K_ENTER)
|
||||
convert(_m->get_bool(F_CONVCOM));
|
||||
delete _m;
|
||||
}
|
||||
|
||||
int tc0900(int argc, char* argv[])
|
||||
|
@ -9,11 +9,17 @@ BEGIN
|
||||
MESSAGE EXIT,K_ENTER
|
||||
END
|
||||
|
||||
BUTTON DLG_SELECT 10 2
|
||||
BEGIN
|
||||
PROMPT -22 -11 "~Seleziona"
|
||||
PICTURE BMP_SELECT
|
||||
END
|
||||
|
||||
#include <helpbar.h>
|
||||
|
||||
ENDPAGE
|
||||
|
||||
PAGE "Conversione archivi CAMPO" -1 -1 78 20
|
||||
PAGE "Conversione CAMPO" -1 -1 78 20
|
||||
|
||||
GROUPBOX DLG_NULL 76 3
|
||||
BEGIN
|
||||
@ -36,10 +42,11 @@ BEGIN
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
BOOLEAN F_CONVCOM 256 39
|
||||
BOOLEAN F_CONVCOM
|
||||
BEGIN
|
||||
PROMPT 23 5 "Conversione tabelle comuni"
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
||||
|
Loading…
x
Reference in New Issue
Block a user