Files correlati : Ricompilazione Demo : [ ] Commento : modifiche alle maschere di files e tabelle git-svn-id: svn://10.65.10.50/trunk@12554 c028cbd2-c16b-5b4b-a496-9718f37d4682
190 lines
4.8 KiB
C++
Executable File
190 lines
4.8 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <progind.h>
|
|
#include <relation.h>
|
|
#include <tabutil.h>
|
|
#include <utility.h>
|
|
|
|
#define usage "Errore - uso : cacnv [1|2|3] ditta"
|
|
|
|
|
|
//----------------------------------------------------------
|
|
// APPLICAZIONE
|
|
//----------------------------------------------------------
|
|
|
|
class TConversione_cm2ca : public TSkeleton_application
|
|
{
|
|
|
|
int _nconv;
|
|
long _codditta;
|
|
long _oldditta;
|
|
|
|
protected:
|
|
virtual void main_loop();
|
|
|
|
public:
|
|
bool convert_clerks();
|
|
bool convert_phases();
|
|
bool set_anal();
|
|
|
|
TConversione_cm2ca() : _oldditta(0), _codditta(0) {}
|
|
~TConversione_cm2ca() {}
|
|
};
|
|
|
|
//gestione del menu (vari tipi di conversione)
|
|
void TConversione_cm2ca::main_loop()
|
|
{
|
|
_nconv = 0;
|
|
if (argc() > 2)
|
|
{
|
|
_nconv = abs(atoi(argv(1)));
|
|
if (_nconv > 0) //se ha una chiamata valida di menu...
|
|
{
|
|
_oldditta = get_firm();
|
|
_codditta = atol(argv(2));
|
|
if (_codditta != _oldditta)
|
|
{
|
|
if (_codditta == 0)
|
|
error_box(TR("Selezionare una ditta"));
|
|
else
|
|
set_firm(_codditta);
|
|
}
|
|
}
|
|
}
|
|
|
|
switch (_nconv)
|
|
{
|
|
case 1:
|
|
{
|
|
if (_codditta > 0)
|
|
convert_clerks(); //da tabella cms a commesse
|
|
}
|
|
break;
|
|
case 2:
|
|
{
|
|
if (_codditta > 0)
|
|
convert_phases(); //da tabella fsc a fasi
|
|
break;
|
|
}
|
|
case 3:
|
|
{
|
|
if (_codditta > 0)
|
|
set_anal(); //setta il flag anal nel pcon
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
if (_nconv > 1 && _codditta != _oldditta)
|
|
{
|
|
if (_oldditta == 0)
|
|
prefix().set("com");
|
|
else
|
|
set_firm(_oldditta);
|
|
}
|
|
}
|
|
|
|
bool TConversione_cm2ca::convert_clerks()
|
|
{
|
|
TLocalisamfile commesse(LF_COMMESSE); //la conversione blocca in automatico gli altri utenti
|
|
//non e' necessario un TSystemisamfile con _excllock
|
|
const long items = commesse.items();
|
|
//trasferimento dati possibile solo se il file di destinazione e' vuoto
|
|
if (items > 0)
|
|
return error_box(TR("File delle commesse non vuoto!"));
|
|
else
|
|
{
|
|
TRelation relcms("CMS");
|
|
TCursor curcms(&relcms);
|
|
const TRectype& cms = relcms.curr();
|
|
const long nrectab = curcms.items();
|
|
curcms.freeze();
|
|
TRectype& commesse_rec = commesse.curr();
|
|
TProgind pi(nrectab, "Conversione tabella commesse");
|
|
for (curcms = 0; curcms.pos() < nrectab; ++curcms)
|
|
{
|
|
pi.addstatus(1);
|
|
commesse_rec.zero(); //azzerare il record prima di cominciare...
|
|
commesse_rec.put("CODCMS", cms.get("CODTAB"));
|
|
commesse_rec.put("DESCRIZ", cms.get("S0"));
|
|
commesse_rec.put("CODCF", cms.get("I0"));
|
|
commesse_rec.put("REGIVA", cms.get("S7"));
|
|
commesse_rec.put("PRORATA", cms.get("B4"));
|
|
commesse_rec.put("PUBBLICA", cms.get("B0"));
|
|
commesse_rec.put("RENDIC", cms.get("B1"));
|
|
commesse_rec.put("DATAINIZIO", cms.get("D0"));
|
|
commesse_rec.put("DATAFINE", cms.get("D1"));
|
|
commesse_rec.put("CHIUSA", cms.get("B3"));
|
|
commesse_rec.put("PROROGA", cms.get("B2"));
|
|
commesse_rec.put("CODRESP", cms.get("S4"));
|
|
|
|
commesse.write();
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
bool TConversione_cm2ca::convert_phases()
|
|
{
|
|
TLocalisamfile fasi(LF_FASI);
|
|
const long items = fasi.items();
|
|
if (items > 0)
|
|
return error_box(TR("File delle fasi non vuoto!"));
|
|
else
|
|
{
|
|
TRelation relfsc("FSC");
|
|
TCursor curfsc(&relfsc);
|
|
const TRectype& fsc = relfsc.curr();
|
|
const long nrectab = curfsc.items();
|
|
curfsc.freeze();
|
|
TRectype& fasi_rec = fasi.curr();
|
|
TProgind pi(nrectab, "Conversione tabella fasi");
|
|
for (curfsc = 0; curfsc.pos() < nrectab; ++curfsc)
|
|
{
|
|
pi.addstatus(1);
|
|
fasi_rec.zero();
|
|
fasi_rec.put("CODFASE", fsc.get("CODTAB"));
|
|
fasi_rec.put("DESCRIZ", fsc.get("S0"));
|
|
fasi.write();
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
bool TConversione_cm2ca::set_anal()
|
|
{
|
|
TRelation relpcon(LF_PCON);
|
|
TCursor curpcon(&relpcon);
|
|
TRectype& recpcon = relpcon.curr();
|
|
|
|
if (!recpcon.exist("ANAL")) //check se gia' avvenuta la conversione con aggiunta del campo ANAL
|
|
return error_box(TR("Prima del controllo e' necessario eseguire una conversione archivi"));
|
|
else
|
|
{
|
|
const long nrecpcon = curpcon.items();
|
|
curpcon.freeze();
|
|
TProgind pi(nrecpcon, "Controllo commesse e fasi sul piano dei conti");
|
|
for (curpcon = 0; curpcon.pos() < nrecpcon; ++curpcon)
|
|
{
|
|
pi.addstatus(1);
|
|
if (recpcon.get("CODCMS").not_empty() || recpcon.get("FASCMS").not_empty())
|
|
{
|
|
recpcon.put("ANAL", "X");
|
|
relpcon.rewrite();
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Programma di conversione da CM a CA
|
|
///////////////////////////////////////////////////////////
|
|
|
|
int main(int argc,char** argv)
|
|
{
|
|
TConversione_cm2ca a;
|
|
a.run(argc,argv, "Trasferimento dati tabelle CM");
|
|
|
|
return 0;
|
|
} |