1995-05-29 10:28:33 +00:00
|
|
|
//***********************************
|
|
|
|
//* Rinumerazione numero protocollo *
|
|
|
|
//***********************************
|
1999-07-16 14:59:11 +00:00
|
|
|
#include <mask.h>
|
|
|
|
#include <progind.h>
|
|
|
|
#include <tabutil.h>
|
|
|
|
#include <relation.h>
|
|
|
|
|
1995-05-29 10:28:33 +00:00
|
|
|
#include "cg1300.h"
|
|
|
|
#include "cg1303.h"
|
|
|
|
|
1999-07-16 14:59:11 +00:00
|
|
|
#include <mov.h>
|
|
|
|
#include <partite.h>
|
|
|
|
|
|
|
|
|
1995-05-29 10:28:33 +00:00
|
|
|
HIDDEN TAgg_nprot& app() { return (TAgg_nprot&) main_app(); }
|
|
|
|
|
1999-07-16 14:59:11 +00:00
|
|
|
HIDDEN bool filtra_mov(const TRelation* r)
|
1995-05-29 10:28:33 +00:00
|
|
|
{
|
1999-07-16 14:59:11 +00:00
|
|
|
const TRectype& mov = r->curr();
|
1995-05-29 10:28:33 +00:00
|
|
|
const int annoiva = mov.get_int(MOV_ANNOIVA);
|
1999-07-16 14:59:11 +00:00
|
|
|
const TString& reg = mov.get(MOV_REG);
|
|
|
|
TAgg_nprot& a = app();
|
|
|
|
return a.anno() == annoiva && a.reg() == reg;
|
1995-05-29 10:28:33 +00:00
|
|
|
}
|
|
|
|
|
1999-07-16 14:59:11 +00:00
|
|
|
void TAgg_nprot::main_loop()
|
1995-05-29 10:28:33 +00:00
|
|
|
{
|
|
|
|
TMask msk("cg1300b");
|
1999-07-16 14:59:11 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
TConfig conf(CONFIG_DITTA);
|
|
|
|
int annoiva = conf.get_int("AnLiIv");
|
|
|
|
msk.set(F_ANNO, annoiva);
|
|
|
|
*/
|
1995-05-29 10:28:33 +00:00
|
|
|
|
|
|
|
while (msk.run() == K_ENTER)
|
|
|
|
{
|
|
|
|
_anno = msk.get_int(F_ANNO);
|
|
|
|
_reg = msk.get(F_REG);
|
|
|
|
|
1999-07-16 14:59:11 +00:00
|
|
|
rinumera_prot(msk.get(F_MODE)[0], msk.get_long(F_PROT));
|
1995-05-29 10:28:33 +00:00
|
|
|
|
|
|
|
msk.reset(F_REG);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-16 14:59:11 +00:00
|
|
|
bool TAgg_nprot::rinumera_prot(char mode, long last_prot)
|
1995-05-29 10:28:33 +00:00
|
|
|
{
|
1999-07-16 14:59:11 +00:00
|
|
|
TTable reg("REG");
|
|
|
|
TString16 s; s.format("%04d%s", _anno, (const char*)_reg);
|
|
|
|
reg.put("CODTAB", s);
|
|
|
|
if (reg.read() != NOERR)
|
|
|
|
return error_box("Impossibile leggere il registro %s del %d",
|
|
|
|
(const char*)_reg, _anno);
|
1996-05-20 13:47:51 +00:00
|
|
|
|
1995-05-29 10:28:33 +00:00
|
|
|
TRelation rel (LF_MOV);
|
1996-05-20 13:47:51 +00:00
|
|
|
rel.add(LF_PARTITE,"NREG=NUMREG",2);
|
|
|
|
|
1995-05-29 10:28:33 +00:00
|
|
|
TLocalisamfile& mov = rel.lfile();
|
1996-05-20 13:47:51 +00:00
|
|
|
TLocalisamfile& part= rel.lfile(LF_PARTITE);
|
1995-05-29 10:28:33 +00:00
|
|
|
|
|
|
|
TCursor cursor(&rel, "", 2);
|
|
|
|
cursor.set_filterfunction(filtra_mov);
|
|
|
|
|
|
|
|
const long nitems = cursor.items();
|
1999-07-16 14:59:11 +00:00
|
|
|
if (nitems == 0)
|
|
|
|
return warning_box("Non ci sono movimenti da rinumerare");
|
|
|
|
|
|
|
|
TConfig cnf(CONFIG_DITTA,"cg");
|
|
|
|
const bool sc_enabled = cnf.get_bool("GesSal");
|
|
|
|
|
|
|
|
cursor.freeze();
|
|
|
|
cursor = 0L;
|
|
|
|
|
|
|
|
TProgind p(nitems, "Elaborazione in corso..." , FALSE, TRUE);
|
1995-05-29 10:28:33 +00:00
|
|
|
|
|
|
|
long protiva, uprotiva;
|
|
|
|
|
1999-07-16 14:59:11 +00:00
|
|
|
if (mode == 'N' || mode == 'U')
|
1995-05-29 10:28:33 +00:00
|
|
|
{
|
1999-07-16 14:59:11 +00:00
|
|
|
for (; cursor.pos() < nitems; ++cursor)
|
1995-05-29 10:28:33 +00:00
|
|
|
{
|
1999-07-16 14:59:11 +00:00
|
|
|
p.addstatus(1);
|
|
|
|
protiva = mov.get_long(MOV_PROTIVA);
|
|
|
|
uprotiva = mov.get_long(MOV_UPROTIVA);
|
|
|
|
|
|
|
|
if (mode == 'U')
|
|
|
|
{
|
|
|
|
if (mov.get_bool(MOV_REGST))
|
|
|
|
{
|
|
|
|
last_prot = uprotiva > protiva ? uprotiva : protiva;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mode == 'N')
|
|
|
|
{
|
|
|
|
if (protiva != last_prot && uprotiva != last_prot)
|
|
|
|
continue;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (uprotiva != 0l)
|
|
|
|
last_prot = uprotiva;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-10-03 13:45:12 +00:00
|
|
|
if (last_prot > 0 && mode == 'N')
|
1999-07-16 14:59:11 +00:00
|
|
|
{
|
|
|
|
if (protiva != last_prot && uprotiva != last_prot) //sono alla fine del file
|
|
|
|
return error_box("Non esiste la registrazione con protocollo %ld:\nrinumerazione non avvenuta", last_prot);
|
|
|
|
++cursor;
|
|
|
|
}
|
|
|
|
}
|
1995-05-29 10:28:33 +00:00
|
|
|
|
|
|
|
long nprot,uprot,dprot;
|
|
|
|
dprot = uprot = 0L;
|
1999-07-16 14:59:11 +00:00
|
|
|
nprot = last_prot;
|
1995-05-29 10:28:33 +00:00
|
|
|
|
1999-07-16 14:59:11 +00:00
|
|
|
for (; cursor.pos() < nitems; ++cursor)
|
1995-05-29 10:28:33 +00:00
|
|
|
{
|
1999-07-16 14:59:11 +00:00
|
|
|
p.addstatus(1);
|
1995-05-29 10:28:33 +00:00
|
|
|
protiva = mov.get_long(MOV_PROTIVA);
|
|
|
|
uprotiva = mov.get_long(MOV_UPROTIVA);
|
|
|
|
|
|
|
|
nprot = nprot+1+dprot; //stile RPG
|
|
|
|
dprot = 0L;
|
|
|
|
uprot = 0L;
|
|
|
|
dprot = (uprotiva == 0L) ? 0L : (uprotiva - protiva);
|
|
|
|
uprot = (uprotiva == 0L) ? 0L : (nprot + dprot);
|
|
|
|
|
|
|
|
mov.put(MOV_PROTIVA, nprot);
|
|
|
|
mov.put(MOV_UPROTIVA, uprot);
|
|
|
|
mov.rewrite();
|
1996-05-20 13:47:51 +00:00
|
|
|
// Aggiorna il nr di prot. iva sul file partite
|
|
|
|
if (sc_enabled && rel.is_first_match(LF_PARTITE))
|
1999-07-16 14:59:11 +00:00
|
|
|
{
|
1996-05-20 13:47:51 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
part.put(PART_PROTIVA,nprot);
|
|
|
|
part.rewrite();
|
|
|
|
} while (rel.next_match(LF_PARTITE));
|
1999-07-16 14:59:11 +00:00
|
|
|
}
|
1995-05-29 10:28:33 +00:00
|
|
|
}
|
|
|
|
|
1999-07-16 14:59:11 +00:00
|
|
|
reg.put("I5", nprot + dprot);
|
|
|
|
reg.rewrite();
|
|
|
|
|
1995-05-29 10:28:33 +00:00
|
|
|
return message_box("Rinumerazione numero protocollo completata");
|
|
|
|
}
|
|
|
|
|