b8db9bcfae
git-svn-id: svn://10.65.10.50/trunk@1033 c028cbd2-c16b-5b4b-a496-9718f37d4682
150 lines
3.7 KiB
C++
Executable File
150 lines
3.7 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <form.h>
|
|
#include <relation.h>
|
|
#include <tabutil.h>
|
|
#include <utility.h>
|
|
|
|
#include "ba2.h"
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Form basato su una tabella
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TTab_form : public TForm
|
|
{
|
|
TString256 _result;
|
|
|
|
protected:
|
|
virtual const char* validate(const char* v, TToken_string& s);
|
|
virtual word set_body(word p, bool u);
|
|
|
|
public:
|
|
TTab_form(const char* name);
|
|
};
|
|
|
|
TTab_form::TTab_form(const char* name) : TForm(name)
|
|
{
|
|
TCursor* c = cursor();
|
|
if (c == NULL)
|
|
fatal_box("Il profilo %s non ha un cursore", name);
|
|
|
|
TIsamtempfile* tmp = new TIsamtempfile(LF_TAB, "tmp4", 0);
|
|
relation()->replace(tmp);
|
|
|
|
c->setfilter("B0==\"\""); // Esclude le deleghe gia' stampate
|
|
}
|
|
|
|
word TTab_form::set_body(word p, bool u)
|
|
{
|
|
const word l = TForm::set_body(p, u);
|
|
if (u && l > 0)
|
|
{
|
|
TLocalisamfile& f = cursor()->file();
|
|
f.put("B0", "X"); // Alza la bandiera di stampato
|
|
f.rewrite();
|
|
}
|
|
return l;
|
|
}
|
|
|
|
|
|
const char* TTab_form::validate(const char* v, TToken_string& s)
|
|
{
|
|
const TString16 code(s.get(0));
|
|
|
|
if (code == "_CENSERoUFFIMP")
|
|
{
|
|
const int a_comres = s.get_int(); // Alias del comune di residenza (fiscale)
|
|
const int a_anagr = s.get_int(); // Alias dell'anagrafica della persona
|
|
|
|
TString80 desc; // Denominzazione centro servizi o ufficio imposte
|
|
|
|
const TLocalisamfile& com = relation()->lfile(-a_comres);
|
|
TString16 cod = com.get("UFFCSERV");
|
|
|
|
if (cod.not_empty()) // Se specificato ...
|
|
{
|
|
TTable ucc("%UCC"); // ... usa il centro servizi del comune
|
|
ucc.put("CODTAB", cod);
|
|
if (ucc.read() == NOERR)
|
|
{
|
|
desc = ucc.get("S0");
|
|
cod = ucc.get("S6");
|
|
} else cod.cut(0);
|
|
}
|
|
else
|
|
{ // ... se no usa l'ufficio imposte in anagrafica
|
|
const TLocalisamfile& anag = relation()->lfile(-a_anagr);
|
|
cod = anag.get("UFFIVA");
|
|
if (cod.empty()) // ... se no usa il primo ufficio imposte del comune
|
|
{
|
|
TString16 uff("UFFIIDD1");
|
|
for (char u = '1'; cod.empty() && u < '4'; u++)
|
|
{
|
|
uff[7] = u;
|
|
cod = com.get(uff);
|
|
}
|
|
}
|
|
TTable uffiva("%UID");
|
|
uffiva.put("CODTAB", cod);
|
|
if (uffiva.read() == NOERR)
|
|
{
|
|
desc = uffiva.get("S0");
|
|
cod = uffiva.get("S6");
|
|
} else cod.cut(0);
|
|
}
|
|
|
|
TLocalisamfile comiva(LF_COMUNI); // Determina la provincia dell'ufficio
|
|
comiva.zero("STATO");
|
|
comiva.put("COM", cod);
|
|
if (comiva.read() == NOERR)
|
|
_result = comiva.get("PROVCOM");
|
|
else
|
|
_result = " ";
|
|
_result << " " << desc;
|
|
|
|
return _result;
|
|
}
|
|
return TForm::validate(v, s);
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// Stampa di un form generico da una tabella
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TForm_printer : public TApplication
|
|
{
|
|
protected:
|
|
virtual bool create();
|
|
|
|
public:
|
|
TForm_printer() {}
|
|
virtual ~TForm_printer() {}
|
|
};
|
|
|
|
bool TForm_printer::create()
|
|
{
|
|
TApplication::create();
|
|
|
|
if (argc() < 3)
|
|
return error_box("Specificare il nome del profilo di stampa");
|
|
|
|
TFilename form(argv(2)); form.ext("frm");
|
|
if (!fexist(form))
|
|
return error_box("Il profilo %s non esiste", (const char*)form);
|
|
|
|
TTab_form f(form);
|
|
f.print();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
int ba2400(int argc, char* argv[])
|
|
{
|
|
TForm_printer a;
|
|
a.run(argc, argv, "Stampa deleghe");
|
|
return 0;
|
|
}
|