Aggiunta codice regione
git-svn-id: svn://10.65.10.50/trunk@2686 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
ebdd4537ce
commit
11eb7b8431
146
ba/bacnv.cpp
146
ba/bacnv.cpp
@ -23,7 +23,7 @@
|
||||
#include <causali.h>
|
||||
#include <rmov.h>
|
||||
|
||||
#define usage "Errore - uso : bacnv [1|2|3|4|5|6|7|8] ditta"
|
||||
#define usage "Errore - uso : bacnv [1|2|3|4|5|6|7|8|9] ditta"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Applicazione di conversione archivi XBase, valida per tutti e 4 i tipi di DLL
|
||||
@ -168,7 +168,7 @@ public:
|
||||
void convert_caus_attiv();
|
||||
void rebuild_indexes();
|
||||
void rebuild_dir_indexes();
|
||||
void aggiorna_causali_pagamento() const;
|
||||
void convert_codreg() const;
|
||||
|
||||
TConversione_archivi() : _oldditta(0), _codditta(0), _error(0) {}
|
||||
};
|
||||
@ -262,9 +262,11 @@ bool TConversione_archivi::menu(MENU_TAG)
|
||||
break;
|
||||
case 8:
|
||||
if (_codditta == 0)
|
||||
rebuild_indexes();
|
||||
rebuild_indexes();
|
||||
break;
|
||||
case 9:
|
||||
aggiorna_causali_pagamento();
|
||||
if (_codditta == 0)
|
||||
convert_codreg();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -845,42 +847,112 @@ void TConversione_archivi::rebuild_dir_indexes()
|
||||
}
|
||||
|
||||
|
||||
void TConversione_archivi::aggiorna_causali_pagamento() const
|
||||
{
|
||||
const int NEWROW = 8;
|
||||
void TConversione_archivi::convert_codreg() const
|
||||
{
|
||||
// (fase 1)
|
||||
// allinea i comuni alle nuove provincie e carica il codice regione
|
||||
// costruisce la tabella comuni -> nuove provincie
|
||||
#ifdef DBG
|
||||
int nerr = 0;
|
||||
#endif
|
||||
TAssoc_array compro;
|
||||
|
||||
TLocalisamfile caus(LF_CAUSALI);
|
||||
TRecord_array rcaus(LF_RCAUSALI, CAU_NRIGA);
|
||||
|
||||
for (int err = caus.first(); err == NOERR; err = caus.next())
|
||||
{
|
||||
const int tipomov = caus.get_int(CAU_TIPOMOV);
|
||||
if (tipomov != 3)
|
||||
continue; // Considera solo pagamenti
|
||||
{
|
||||
TScanner oc(format("%sstd/tbcompro.txt", __ptprf));
|
||||
|
||||
TRectype* key = new TRectype(LF_RCAUSALI);
|
||||
key->put(CAU_CODCAUS, caus.get(CAU_CODCAUS));
|
||||
rcaus.read(key); // Leggi righe causale
|
||||
|
||||
if (rcaus.exist(NEWROW))
|
||||
for (TToken_string s(oc.line()); s.not_empty(); s = oc.line())
|
||||
{
|
||||
const TRectype& riga = rcaus.row(NEWROW);
|
||||
if (riga.get_int(CAU_GRUPPO) == 0) // Se il gruppo e' vuoto ...
|
||||
return; // ... allora conversione gia' effettuata
|
||||
}
|
||||
for (int r = rcaus.last_row(); r >= NEWROW; r = rcaus.pred_row(r))
|
||||
{
|
||||
TRectype riga = rcaus.row(r); // Memorizzo vecchia riga
|
||||
rcaus.destroy_row(r); // Cancello vecchia riga
|
||||
riga.put(CAU_NRIGA, r+1);
|
||||
rcaus.add_row(riga); // Spostala avanti di un posto
|
||||
}
|
||||
if (rcaus.last_row() >= NEWROW)
|
||||
{
|
||||
rcaus.row(NEWROW, TRUE); // Aggiungi riga vuota di sentinella
|
||||
rcaus.rewrite(); // Aggiorna righe causale
|
||||
}
|
||||
TString16 codcom(s.get(0));
|
||||
|
||||
compro.add(codcom, s);
|
||||
}
|
||||
}
|
||||
|
||||
// costruisce la tabella provincie -> regioni
|
||||
TAssoc_array proreg;
|
||||
|
||||
{
|
||||
TScanner oc(format("%sstd/tbproreg.txt", __ptprf));
|
||||
|
||||
for (TToken_string s(oc.line()); s.not_empty(); s = oc.line())
|
||||
{
|
||||
TString16 prov(s.get(0));
|
||||
TString16 codreg(s.get());
|
||||
|
||||
proreg.add(prov, codreg);
|
||||
}
|
||||
}
|
||||
// scorre il file comuni
|
||||
TLocalisamfile comuni(LF_COMUNI);
|
||||
// se il file comuni non é vuoto
|
||||
const long com_items = comuni.items();
|
||||
if (com_items > 0)
|
||||
{
|
||||
TProgind p(com_items, "Conversione archivio anagrafica", FALSE, TRUE, 70);
|
||||
|
||||
p.setstatus(1L);
|
||||
|
||||
// per ogni comune
|
||||
for (comuni.first(); comuni.good(); comuni.next())
|
||||
{
|
||||
bool rewrite = FALSE;
|
||||
|
||||
p.addstatus(1);
|
||||
const TString & cod = comuni.get("COM");
|
||||
TToken_string * t = (TToken_string *) compro.objptr(cod);
|
||||
|
||||
if (t != NULL)
|
||||
{
|
||||
comuni.put("PROVCOM", t->get(1));
|
||||
comuni.put("CODISTAT", t->get());
|
||||
rewrite = TRUE;
|
||||
}
|
||||
|
||||
const TString & prov = comuni.get("PROVCOM");
|
||||
TString16 * s = (TString16 *) proreg.objptr(prov);
|
||||
|
||||
if (s != NULL)
|
||||
{
|
||||
comuni.put("CODREG", *s);
|
||||
rewrite = TRUE;
|
||||
}
|
||||
#ifdef DBG
|
||||
else
|
||||
nerr++;
|
||||
#endif
|
||||
if (rewrite)
|
||||
comuni.rewrite();
|
||||
}
|
||||
}
|
||||
|
||||
// (fase 2)
|
||||
// vuota la tabella concessioni
|
||||
{
|
||||
TTable uffconc("%UCC");
|
||||
|
||||
for (uffconc.first(_lock); uffconc.good(); uffconc.next(_lock))
|
||||
uffconc.remove();
|
||||
}
|
||||
// carica la nuova
|
||||
{
|
||||
TSystemisamfile tabcom(LF_TABCOM);
|
||||
|
||||
tabcom.load(format("%sstd/nconc01.txt", __ptprf));
|
||||
}
|
||||
// (fase 3)
|
||||
// vuota la tabella regioni
|
||||
{
|
||||
TTable regioni("%RGI");
|
||||
|
||||
for (regioni.first(_lock); regioni.good(); regioni.next(_lock))
|
||||
regioni.remove();
|
||||
}
|
||||
// carica la nuova
|
||||
{
|
||||
TSystemisamfile tabcom(LF_TABCOM);
|
||||
|
||||
tabcom.load(format("%sstd/nreg00.txt", __ptprf));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -892,7 +964,7 @@ int main(int argc,char** argv)
|
||||
{
|
||||
const int r = (argc > 1) ? atoi(argv[1]) : 0;
|
||||
|
||||
if (r < 0 || r > 8)
|
||||
if (r < 0 || r > 9)
|
||||
{
|
||||
error_box(usage);
|
||||
return 100;
|
||||
|
@ -12,5 +12,7 @@ ACNV(15)=bacnv 3
|
||||
ACNV(5)=bacnv 5
|
||||
[199507]
|
||||
ACNV(10)=bacnv 6
|
||||
[199508]
|
||||
ACNV(13)=bacnv 9
|
||||
[EOF]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user