1995-07-31 09:49:11 +00:00
|
|
|
//*****************************************************
|
|
|
|
//* Aggiornamento codice attivita' su progressivi IVA *
|
|
|
|
//*****************************************************
|
2003-03-17 10:53:46 +00:00
|
|
|
#include <mask.h>
|
|
|
|
#include <progind.h>
|
|
|
|
#include <tabutil.h>
|
1997-06-19 14:33:52 +00:00
|
|
|
|
1995-07-31 09:49:11 +00:00
|
|
|
#include <mov.h>
|
1997-06-19 14:33:52 +00:00
|
|
|
|
1995-07-31 09:49:11 +00:00
|
|
|
#include "cg1300.h"
|
|
|
|
#include "cg1304.h"
|
1997-06-19 14:33:52 +00:00
|
|
|
#include "cglib01.h"
|
1995-07-31 09:49:11 +00:00
|
|
|
|
|
|
|
HIDDEN TAgg_codatt& app() { return (TAgg_codatt&) main_app(); }
|
|
|
|
|
|
|
|
bool TAgg_codatt::create()
|
|
|
|
{
|
2003-03-14 15:13:36 +00:00
|
|
|
open_files(LF_TAB, 0);
|
|
|
|
|
|
|
|
return TSkeleton_application::create();
|
1995-07-31 09:49:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TAgg_codatt::destroy()
|
|
|
|
{
|
2003-03-14 15:13:36 +00:00
|
|
|
return TSkeleton_application::destroy();
|
1995-07-31 09:49:11 +00:00
|
|
|
}
|
|
|
|
|
2003-03-14 15:13:36 +00:00
|
|
|
void TAgg_codatt::main_loop()
|
1995-07-31 09:49:11 +00:00
|
|
|
{
|
|
|
|
TProgind* pri;
|
|
|
|
TMask msk("cg1300c");
|
|
|
|
|
|
|
|
while (msk.run() == K_ENTER)
|
|
|
|
{
|
2002-12-20 17:08:30 +00:00
|
|
|
pri = new TProgind(2,TR("Aggiornamento in corso..."),FALSE,TRUE,50);
|
1995-07-31 09:49:11 +00:00
|
|
|
_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");
|
1996-08-26 08:36:58 +00:00
|
|
|
aggiorna_att("%PLA");
|
1995-07-31 09:49:11 +00:00
|
|
|
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;
|
2002-12-20 17:08:30 +00:00
|
|
|
message_box(TR("Aggiornamento codice attivita' completato"));
|
1995-07-31 09:49:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1996-08-26 08:36:58 +00:00
|
|
|
TTable pla("%PLA");
|
|
|
|
TRecfield r_ditta(pla.curr(),"CODTAB",0,4);
|
1997-06-19 14:33:52 +00:00
|
|
|
const long firm = get_firm();
|
1996-08-26 08:36:58 +00:00
|
|
|
for (pla.first(); !pla.eof(); pla.next())
|
|
|
|
{
|
|
|
|
if (firm != (long)r_ditta)
|
|
|
|
continue;
|
|
|
|
pla.remove();
|
|
|
|
}
|
1995-07-31 09:49:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void TAgg_codatt::aggiorna_att(const char* nome)
|
|
|
|
{
|
1996-08-26 08:36:58 +00:00
|
|
|
const bool is_pla = nome == "%PLA";
|
1997-06-19 14:33:52 +00:00
|
|
|
const long firm = get_firm();
|
1995-07-31 09:49:11 +00:00
|
|
|
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');
|
1996-08-26 08:36:58 +00:00
|
|
|
if (is_pla) chiave << firm;
|
1995-07-31 09:49:11 +00:00
|
|
|
chiave << _anno << old_att;
|
|
|
|
tab.put("CODTAB", chiave);
|
|
|
|
TRectype curr (tab.curr());
|
1996-08-26 08:36:58 +00:00
|
|
|
TRecfield r_ditta(tab.curr(),"CODTAB",0,4);
|
1995-07-31 09:49:11 +00:00
|
|
|
tab.read(_isgteq);
|
|
|
|
for (; !tab.eof(); tab.next())
|
1996-08-26 08:36:58 +00:00
|
|
|
{
|
|
|
|
if (is_pla)
|
|
|
|
{
|
|
|
|
if (firm != (long)r_ditta) break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
if (tab.curr() != curr) break;
|
1995-07-31 09:49:11 +00:00
|
|
|
|
|
|
|
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());
|
1996-08-26 08:36:58 +00:00
|
|
|
TString80 cc;
|
|
|
|
if (is_pla)
|
|
|
|
cc = codtab.sub(13);
|
|
|
|
else
|
|
|
|
cc = codtab.sub(9);
|
1995-07-31 09:49:11 +00:00
|
|
|
TString80 cod;
|
1996-08-26 08:36:58 +00:00
|
|
|
if (is_pla) cod << firm;
|
1995-07-31 09:49:11 +00:00
|
|
|
cod << _anno << new_att << cc;
|
|
|
|
nuovo.put("CODTAB", cod);
|
|
|
|
tab.write(nuovo);
|
|
|
|
tab.read(vecchio);
|
|
|
|
tab.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|