campo-sirio/ba/ba2400.cpp
guy fdae1a4bdb ba0.cpp Aggiunta gestione programmi protetti da password
ba2100b.uml  Modificata maschera scelta profili
ba2100f.uml  Abilitato campo testo fisso nei campi
ba2200.cpp   Controllato meglio il cambio disco da parte dell'utente
ba2400.cpp   Aggiornato uso della funzione TForm::validate
ba3100.cpp   Corretta gestione annullamento configurazione stampa registri
ba3300.cpp   Aggiunta chiamata on_firm_change della classe madre
prassi.mnu   Aggiunto flag di protezione da password ad alcuni programmi


git-svn-id: svn://10.65.10.50/trunk@1612 c028cbd2-c16b-5b4b-a496-9718f37d4682
1995-07-19 09:42:25 +00:00

151 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 bool validate(TForm_item& f, 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;
}
bool TTab_form::validate(TForm_item& fld, 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;
fld.set(_result);
return TRUE;
}
return TForm::validate(fld, 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;
}