Aggiunti file riguardanti il programma di agg. codice attivita'
git-svn-id: svn://10.65.10.50/trunk@1506 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
8dccb48bae
commit
bbb0618a67
167
cg/cg1304.cpp
Executable file
167
cg/cg1304.cpp
Executable file
@ -0,0 +1,167 @@
|
||||
//*****************************************************
|
||||
//* Aggiornamento codice attivita' su progressivi IVA *
|
||||
//*****************************************************
|
||||
#include <mov.h>
|
||||
#include "cg1300.h"
|
||||
#include "cg1304.h"
|
||||
#include "cg2103.h"
|
||||
|
||||
HIDDEN TAgg_codatt& app() { return (TAgg_codatt&) main_app(); }
|
||||
|
||||
bool TAgg_codatt::create()
|
||||
{
|
||||
TApplication::create();
|
||||
|
||||
_tab = new TLocalisamfile(LF_TAB);
|
||||
|
||||
dispatch_e_menu (BAR_ITEM(1));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TAgg_codatt::destroy()
|
||||
{
|
||||
delete _tab;
|
||||
|
||||
return TApplication::destroy();
|
||||
}
|
||||
|
||||
bool TAgg_codatt::menu(MENU_TAG m)
|
||||
{
|
||||
TProgind* pri;
|
||||
TMask msk("cg1300c");
|
||||
|
||||
/*
|
||||
TConfig conf(CONFIG_DITTA);
|
||||
int annoiva = conf.get_int("AnLiIv");
|
||||
|
||||
msk.set(F_ANNO, annoiva);
|
||||
*/
|
||||
while (msk.run() == K_ENTER)
|
||||
{
|
||||
pri = new TProgind(2,"Aggiornamento in corso...",FALSE,TRUE,50);
|
||||
_pass = msk.get_bool(F_PASS);
|
||||
if (_pass)
|
||||
{
|
||||
_anno = msk.get_int(F_ANNO);
|
||||
_da = msk.get(F_DA); //se c'e' _da c'e' anche _a e viceversa
|
||||
_a = msk.get(F_A); //_da e' la vecchia attivita'
|
||||
//_a e' la nuova attivita'
|
||||
pri->addstatus(1);
|
||||
aggiorna_att("PIM");
|
||||
aggiorna_att("PUM");
|
||||
aggiorna_att("POM");
|
||||
aggiorna_att("PAM");
|
||||
aggiorna_att("PPA");
|
||||
aggiorna_att("PLA");
|
||||
aggiorna_att("PLM");
|
||||
}
|
||||
else
|
||||
{
|
||||
pri->addstatus(1);
|
||||
cancella_rec();
|
||||
}
|
||||
pri->addstatus(1);
|
||||
msk.reset();
|
||||
//msk.reset(F_ANNO);
|
||||
//msk.reset(F_DA);
|
||||
//msk.reset(F_A);
|
||||
delete pri;
|
||||
message_box("Aggiornamento codice attivita' completato");
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void TAgg_codatt::cancella_rec()
|
||||
{
|
||||
TTable plm("PLM");
|
||||
for (plm.first(); !plm.eof(); plm.next())
|
||||
plm.remove();
|
||||
|
||||
TTable pum("PUM");
|
||||
for (pum.first(); !pum.eof(); pum.next())
|
||||
pum.remove();
|
||||
|
||||
TTable pom("POM");
|
||||
for (pom.first(); !pom.eof(); pom.next())
|
||||
pom.remove();
|
||||
|
||||
TTable pam("PAM");
|
||||
for (pam.first(); !pam.eof(); pam.next())
|
||||
pam.remove();
|
||||
|
||||
TTable ppa("PPA");
|
||||
for (ppa.first(); !ppa.eof(); ppa.next())
|
||||
ppa.remove();
|
||||
|
||||
//non e' indicata la vecchia attivita' => :
|
||||
TTable pim("PIM");
|
||||
for (pim.first(); !pim.eof(); pim.next())
|
||||
{
|
||||
const TString80 codtab = pim.get("CODTAB");
|
||||
int anno = atoi(codtab.mid(0,4));
|
||||
const TString16 codatt = codtab.mid(4,5);
|
||||
const TString16 codreg = codtab.mid(10,3);
|
||||
if (codreg.not_empty())
|
||||
{
|
||||
TRegistro reg(codreg,anno);
|
||||
if (!reg.name().empty()) //se esiste quel registro (ma perche' non dovrebbe?)
|
||||
{
|
||||
const TString16 cda = reg.attivita();
|
||||
if (codatt != cda)
|
||||
{
|
||||
TRectype vecchio (pim.curr());
|
||||
TRectype nuovo (pim.curr());
|
||||
const TString80 cc = codtab.sub(9);
|
||||
TString80 cod;
|
||||
cod << anno << cda << cc;
|
||||
nuovo.put("CODTAB", cod);
|
||||
pim.write(nuovo);
|
||||
pim.read(vecchio);
|
||||
pim.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TTable pla("PLA");
|
||||
for (pla.first(); !pla.eof(); pla.next())
|
||||
pla.remove();
|
||||
|
||||
TTable rmb("RMB");
|
||||
for (rmb.first(); !rmb.eof(); rmb.next())
|
||||
rmb.remove();
|
||||
}
|
||||
|
||||
void TAgg_codatt::aggiorna_att(const char* nome)
|
||||
{
|
||||
TTable tab(nome);
|
||||
tab.setkey(1);
|
||||
tab.zero();
|
||||
TString16 chiave;
|
||||
TString16 old_att(_da); old_att.right_just(5,'0');
|
||||
TString16 new_att(_a); new_att.right_just(5,'0');
|
||||
chiave << _anno << old_att;
|
||||
tab.put("CODTAB", chiave);
|
||||
TRectype curr (tab.curr());
|
||||
tab.read(_isgteq);
|
||||
for (; !tab.eof(); tab.next())
|
||||
{
|
||||
if (tab.curr() != curr) break;
|
||||
|
||||
const TString80 codtab = tab.get("CODTAB");
|
||||
//const TString16 cod_att = codtab.mid(4,5); //e' uguale a old_att
|
||||
if (old_att != new_att)
|
||||
{
|
||||
TRectype vecchio (tab.curr());
|
||||
TRectype nuovo (tab.curr());
|
||||
const TString80 cc = codtab.sub(9);
|
||||
TString80 cod;
|
||||
cod << _anno << new_att << cc;
|
||||
nuovo.put("CODTAB", cod);
|
||||
tab.write(nuovo);
|
||||
tab.read(vecchio);
|
||||
tab.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user