Files correlati : ve6.exe Ricompilazione Demo : [ ] Commento : Riportata la versione 3.1 patch 979 git-svn-id: svn://10.65.10.50/trunk@15623 c028cbd2-c16b-5b4b-a496-9718f37d4682
321 lines
7.8 KiB
C++
Executable File
321 lines
7.8 KiB
C++
Executable File
#include <applicat.h>
|
|
#include <automask.h>
|
|
#include <dongle.h>
|
|
#include <progind.h>
|
|
#include <relapp.h>
|
|
#include <reprint.h>
|
|
#include <tabutil.h>
|
|
|
|
#include "../ba/ba0100a.h"
|
|
|
|
#include "li0.h"
|
|
#include "li0500a.h"
|
|
#include "li0500b.h"
|
|
|
|
#include "letint.h"
|
|
|
|
//--------------------------------------------------------------
|
|
// MASCHERA
|
|
//--------------------------------------------------------------
|
|
class TPrint_letint_mask : public TAutomask
|
|
{
|
|
TDate _last_data;
|
|
protected:
|
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
bool ask_service_pwd();
|
|
|
|
public:
|
|
TPrint_letint_mask();
|
|
virtual ~TPrint_letint_mask() {}
|
|
};
|
|
|
|
TPrint_letint_mask::TPrint_letint_mask()
|
|
:TAutomask("li0500a")
|
|
{
|
|
_last_data = botime;
|
|
}
|
|
|
|
static TDate _da_data, _a_data;
|
|
static bool filtra_per_date(const TRelation* rel)
|
|
{
|
|
const TDate data = rel->curr().get(LETINT_DATAREG);
|
|
return data >= _da_data && data <= _a_data;
|
|
}
|
|
|
|
bool TPrint_letint_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
{
|
|
|
|
switch (o.dlg())
|
|
{
|
|
case F_ANNO:
|
|
if (e == fe_modify || e == fe_init)
|
|
{
|
|
TTable reg("REG");
|
|
TString s(o.get()); s.lpad(4, '0');
|
|
|
|
_last_data = botime;
|
|
o.mask().set(F_PAGINI, "");
|
|
reg.put("CODTAB", s);
|
|
|
|
for (int err = reg.read(_isgteq); s == reg.get("CODTAB").left(4) && err == NOERR; err = reg.next())
|
|
if (reg.get_int("I0") == 10)
|
|
{
|
|
o.mask().set(F_PAGINI, reg.get("I1"));
|
|
_last_data = reg.get_date("D3");
|
|
}
|
|
|
|
}
|
|
break;
|
|
case F_MESE:
|
|
if (e == fe_close)
|
|
{
|
|
const int mese = atoi(o.get());
|
|
|
|
if (mese <= _last_data.month())
|
|
return error_box("Attenzione Stampa definitiva già effettuata. Ripristinare il mese se si desidera procedere");
|
|
}
|
|
break;
|
|
case F_RIPRISTINA:
|
|
if (e == fe_button)
|
|
{
|
|
if (ask_service_pwd()) //chiede la pwd di servizio x ripristinare
|
|
{
|
|
TMask mask("li0500b"); //maschera per selezionare il mese ed anno da ripristinare
|
|
if (mask.run() == K_ENTER)
|
|
{
|
|
//ripristinare solo dichiarazioni del mese/anno selezionato
|
|
const int anno_rip = mask.get_int(F_ANNO);
|
|
const int mese_rip = mask.get_int(F_MESE);
|
|
|
|
TRectype darec(LF_LETINT), arec(LF_LETINT);
|
|
darec.put(LETINT_ANNO, anno_rip);
|
|
arec.put(LETINT_ANNO, anno_rip);
|
|
|
|
TRelation rel_letint(LF_LETINT);
|
|
|
|
_da_data = TDate(1, mese_rip, anno_rip);
|
|
if (mese_rip == 1)
|
|
_last_data = botime;
|
|
else
|
|
{
|
|
_last_data = _da_data;
|
|
--_last_data;
|
|
}
|
|
_a_data = TDate(31, 12, anno_rip);
|
|
|
|
TCursor cur_letint(&rel_letint, "", 1, &darec, &arec);
|
|
cur_letint.set_filterfunction(filtra_per_date);
|
|
|
|
const long items = cur_letint.items();
|
|
//ripristina solo se c'è qualcosa da ripristinare!
|
|
if (items > 0)
|
|
{
|
|
if (yesno_box(TR("Si desidera ripristinare %ld dichiarazioni?"), items))
|
|
if (yesno_box(TR("Si desidera veramente ripristinare %ld dichiarazioni?"), items))
|
|
{
|
|
cur_letint.freeze();
|
|
TProgind pi(items, "Ripristino dichiarazioni", false);
|
|
TRectype& rec_letint = rel_letint.curr();
|
|
|
|
for (cur_letint = 0; cur_letint.pos() < items; ++cur_letint)
|
|
{
|
|
pi.addstatus(1);
|
|
rec_letint.zero(LETINT_STAMPATO); //svuota il campo
|
|
rel_letint.rewrite(); //aggiorna fisicamente il file
|
|
}
|
|
|
|
TTable reg("REG");
|
|
TString s; s.format("%04d", anno_rip);
|
|
|
|
reg.put("CODTAB", s);
|
|
|
|
for (int err = reg.read(_isgteq); s == reg.get("CODTAB").left(4) && err == NOERR; err = reg.next())
|
|
if (reg.get_int("I0") == 10)
|
|
{
|
|
reg.put("D3", _last_data);
|
|
reg.rewrite();
|
|
}
|
|
else
|
|
reg.reread(_unlock);
|
|
}
|
|
else
|
|
return true;
|
|
else
|
|
return true;
|
|
} //end if(items>0)
|
|
else
|
|
message_box(TR("Non ci sono dichiarazioni da ripristinare nel periodo selezionato"));
|
|
} //end mask.run()
|
|
} //end ask_service_pwd()
|
|
} //end if(e==fe_button)
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool TPrint_letint_mask::ask_service_pwd()
|
|
{
|
|
bool ok = false;
|
|
|
|
TMask mask("ba0100a");
|
|
mask.disable(F_USER);
|
|
mask.set(F_USER, "SERVIZIO");
|
|
|
|
if (mask.run() == K_ENTER)
|
|
{
|
|
const TDate oggi(TODAY);
|
|
TString16 pwd; pwd << dongle().administrator() << (oggi.month() + oggi.day());
|
|
ok = pwd == mask.get(F_PASSWORD);
|
|
}
|
|
if (!ok)
|
|
error_box(TR("Password di servizio errata!\nAccesso negato."));
|
|
|
|
return ok;
|
|
}
|
|
|
|
//---------------------------------------------------------------
|
|
// REPORT
|
|
//---------------------------------------------------------------
|
|
class TLetint_report : public TReport
|
|
{
|
|
word _last_printed_page;
|
|
|
|
protected:
|
|
virtual bool use_mask() { return false;}
|
|
virtual word last_printed_page() const { return _last_printed_page; }
|
|
|
|
public:
|
|
TLetint_report(int last_printed_page) : _last_printed_page(last_printed_page) {}
|
|
~TLetint_report() {}
|
|
};
|
|
|
|
|
|
//---------------------------------------------------------------
|
|
// APPLICAZIONE
|
|
//---------------------------------------------------------------
|
|
class TPrint_letint : public TSkeleton_application
|
|
{
|
|
bool create();
|
|
void setta_stampato(TMask& mask, long last_page);
|
|
|
|
public:
|
|
virtual void main_loop();
|
|
};
|
|
|
|
void TPrint_letint::setta_stampato(TMask& mask, long last_page)
|
|
{
|
|
//settare solo dichiarazioni del mese/anno selezionato
|
|
const int anno = mask.get_int(F_ANNO);
|
|
const int mese = mask.get_int(F_MESE);
|
|
|
|
TRectype darec(LF_LETINT), arec(LF_LETINT);
|
|
darec.put(LETINT_ANNO, anno);
|
|
arec.put(LETINT_ANNO, anno);
|
|
|
|
TRelation rel_letint(LF_LETINT);
|
|
|
|
_da_data = TDate(1, mese, anno);
|
|
_a_data = _da_data;
|
|
_a_data.set_end_month();
|
|
|
|
TCursor cur_letint(&rel_letint, "", 1, &darec, &arec);
|
|
cur_letint.set_filterfunction(filtra_per_date);
|
|
|
|
const long items = cur_letint.items();
|
|
//trasferimento dati possibile solo se il file di destinazione e' vuoto
|
|
if (items > 0)
|
|
{
|
|
cur_letint.freeze();
|
|
TProgind pi(items, "Aggiornamento dichiarazioni", false);
|
|
TRectype& rec_letint = rel_letint.curr();
|
|
|
|
for (cur_letint = 0; cur_letint.pos() < items; ++cur_letint)
|
|
{
|
|
pi.addstatus(1);
|
|
rec_letint.put(LETINT_STAMPATO, "X"); //riempie il campo
|
|
rel_letint.rewrite(); //aggiorna fisicamente il file
|
|
}
|
|
} //end if(items>0)
|
|
|
|
TTable reg("REG");
|
|
TString s; s << anno; s.lpad(4, '0');
|
|
|
|
reg.put("CODTAB", s);
|
|
for (int err = reg.read(_isgteq, _lock); s == reg.get("CODTAB").left(4) && err == NOERR; err = reg.next())
|
|
if (reg.get_int("I0") == 10)
|
|
{
|
|
reg.put("I1", last_page);
|
|
reg.put("I2", last_page);
|
|
reg.put("D3", _a_data);
|
|
reg.rewrite();
|
|
}
|
|
else
|
|
reg.reread(_unlock);
|
|
}
|
|
|
|
bool TPrint_letint::create()
|
|
{
|
|
return TSkeleton_application::create();
|
|
}
|
|
|
|
void TPrint_letint::main_loop()
|
|
{
|
|
TFilename path;
|
|
TPrint_letint_mask m;
|
|
|
|
while (m.run() == K_ENTER)
|
|
{
|
|
TReport_book book;
|
|
word last_page = 0;
|
|
const int anno = m.get_int(F_ANNO);
|
|
const bool definitiva = m.get_bool(F_DEFINITIVA);
|
|
if (definitiva)
|
|
{
|
|
last_page = m.get_int(F_PAGINI);
|
|
const int mese = m.get_int(F_MESE);
|
|
|
|
_da_data = TDate(1, mese, anno);
|
|
_a_data = _da_data;
|
|
_a_data.set_end_month();
|
|
}
|
|
else
|
|
{
|
|
_da_data = m.get_date(F_DAL);
|
|
if (!_da_data.ok())
|
|
_da_data = TDate(1, 1, anno);
|
|
_a_data = m.get_date(F_AL);
|
|
if (!_a_data.ok())
|
|
_a_data = TDate(31, 12, anno);
|
|
}
|
|
|
|
TLetint_report rep(last_page);
|
|
|
|
path = m.get(F_REPORT);
|
|
if (path.empty())
|
|
path = "li0500a";
|
|
rep.load(path);
|
|
rep.mask2report(m);
|
|
|
|
|
|
rep.recordset()->set_var("#DADATA", TVariant(_da_data));
|
|
rep.recordset()->set_var("#ADATA", TVariant(_a_data));
|
|
|
|
book.add(rep);
|
|
book.print_or_preview();
|
|
|
|
//in caso di stampa definitiva...
|
|
if (definitiva && yesno_box(TR("La stampa e' corretta?")))
|
|
setta_stampato(m, (long)rep.page());
|
|
}
|
|
}
|
|
|
|
int li0500(int argc, char* argv[])
|
|
{
|
|
TPrint_letint a;
|
|
a.run(argc, argv, TR("Stampa dichiarazioni d'intento"));
|
|
return 0;
|
|
}
|
|
|