Files correlati : ce2.exe Ricompilazione Demo : [ ] Commento : Modernizzata maschera ed aggiustati messaggi d'errore git-svn-id: svn://10.65.10.50/branches/R_10_00@21756 c028cbd2-c16b-5b4b-a496-9718f37d4682
193 lines
4.4 KiB
C++
Executable File
193 lines
4.4 KiB
C++
Executable File
#include <applicat.h>
|
||
#include <automask.h>
|
||
#include <progind.h>
|
||
#include <recarray.h>
|
||
#include <tabutil.h>
|
||
|
||
#include "ce2500a.h"
|
||
|
||
#include "celib.h"
|
||
#include "cespi.h"
|
||
#include "movce.h"
|
||
|
||
class TRestore_boll_mask : public TAutomask
|
||
{
|
||
protected:
|
||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||
|
||
public:
|
||
TRestore_boll_mask() : TAutomask("ce2500a") { }
|
||
};
|
||
|
||
bool TRestore_boll_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||
{
|
||
switch (o.dlg())
|
||
{
|
||
case F_ESERCIZIO:
|
||
case F_GRUPPO:
|
||
case F_SPECIE:
|
||
if (e == fe_close)
|
||
{
|
||
const int esercizio = get_int(F_ESERCIZIO);
|
||
const int gruppo = get_int(F_GRUPPO);
|
||
const TString16 specie = get(F_SPECIE);
|
||
TString80 key; key.format("%4d%02d%s",esercizio, gruppo, (const char*)specie);
|
||
const TRectype& ccb = cache().get("CCB", key);
|
||
if (ccb.get_bool("B2"))
|
||
return error_box(TR("L'attivita' selezionata e' gia' stata chiusa.\nNon e' possibile ripristinare il bollato"));
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
//===============================================================================================
|
||
class TRestore_boll : public TSkeleton_application
|
||
{
|
||
TRestore_boll_mask* _mask;
|
||
|
||
protected:
|
||
virtual void main_loop();
|
||
virtual bool create();
|
||
virtual bool destroy();
|
||
|
||
public:
|
||
void pulisci_movce();
|
||
void pulisci_ccb();
|
||
};
|
||
|
||
|
||
void TRestore_boll::pulisci_movce()
|
||
{
|
||
int ese;
|
||
TString4 gru, specie;
|
||
ditta_cespiti().get_attivita(ese, gru, specie);
|
||
|
||
TDate inies, fines;
|
||
ditta_cespiti().esercizio_corrente(inies, fines);
|
||
|
||
//prende tutti i cespiti con gruppo/specie selezionati nel file cespi...
|
||
TRelation relcespi (LF_CESPI);
|
||
TRectype& cespi = relcespi.curr();
|
||
|
||
TRectype cespifilter (LF_CESPI);
|
||
cespifilter.put(CESPI_CODCGRA,gru);
|
||
cespifilter.put(CESPI_CODSPA,specie);
|
||
|
||
TString80 filtro1;
|
||
filtro1 << "ANSI(DTCOMP)<=" << fines.string(ANSI);
|
||
|
||
TCursor curcespi(&relcespi, filtro1, 2, &cespifilter, &cespifilter);
|
||
TRecnotype items = curcespi.items();
|
||
curcespi.freeze();
|
||
|
||
TRelation relmovce (LF_MOVCE);
|
||
TRectype& movce = relmovce.curr();
|
||
TCursor curmovce(&relmovce, "", 2);
|
||
|
||
TProgind barra(items, "Ripristino movimenti", FALSE, TRUE);
|
||
|
||
for(curcespi = 0; curcespi.pos() < items; ++curcespi)
|
||
{
|
||
barra.addstatus(1);
|
||
|
||
movce.zero();
|
||
movce.put(MOVCE_IDCESPITE, cespi.get(CESPI_IDCESPITE));
|
||
|
||
curmovce.setregion(movce,movce);
|
||
TRecnotype movce_items = curmovce.items();
|
||
curmovce.freeze();
|
||
//pulisce il bool per tutti i movimenti del cespite corrente..
|
||
for(curmovce = 0; curmovce.pos() < movce_items; ++curmovce)
|
||
{
|
||
const TDate dtmov = movce.get_date(MOVCE_DTMOV);
|
||
if (dtmov >= inies && dtmov <= fines)
|
||
{
|
||
movce.put(MOVCE_STAMPATO, "");
|
||
relmovce.rewrite();
|
||
}
|
||
}
|
||
|
||
curmovce.freeze(FALSE);
|
||
}
|
||
|
||
}
|
||
|
||
void TRestore_boll::pulisci_ccb()
|
||
{
|
||
int ese;
|
||
TString4 gr, sp;
|
||
const TRectype& curr = ditta_cespiti().get_attivita(ese, gr, sp);
|
||
if (!curr.empty())
|
||
{
|
||
TTable ccb ("CCB");
|
||
ccb.curr() = curr;
|
||
ccb.put("B1", "");
|
||
if (ccb.rewrite() == NOERR)
|
||
(TRectype&)curr = ccb.curr();
|
||
}
|
||
}
|
||
|
||
bool TRestore_boll::create()
|
||
{
|
||
open_files(LF_TAB, LF_CESPI, LF_MOVCE, 0);
|
||
_mask = new TRestore_boll_mask;
|
||
return TSkeleton_application::create();
|
||
}
|
||
|
||
bool TRestore_boll::destroy()
|
||
{
|
||
delete _mask;
|
||
return TRUE;
|
||
}
|
||
|
||
void TRestore_boll::main_loop()
|
||
{
|
||
KEY k = K_ENTER;
|
||
while (k == K_ENTER)
|
||
{
|
||
TDitta_cespiti& dc = ditta_cespiti();
|
||
dc.init_mask(*_mask);
|
||
|
||
k = _mask->run();
|
||
|
||
if (k == K_ENTER)
|
||
{
|
||
const int ese = _mask->get_int(F_ESERCIZIO);
|
||
const int gru = _mask->get_int(F_GRUPPO);
|
||
const TString& spe = _mask->get(F_SPECIE);
|
||
dc.set_attivita(ese, gru, spe);
|
||
|
||
bool ok = true;
|
||
|
||
TString msg; msg << TR(" il bollato dell'attivit<69> ") << gru << ' ' << spe << TR(" dell'anno ") << ese << '.';
|
||
if (dc.bollato_stampato())
|
||
{
|
||
msg.insert(TR("Si desidera veramente ripristinare"));
|
||
ok = yesno_box(msg);
|
||
}
|
||
else
|
||
{
|
||
msg.insert(TR("Non risulta ancora stampato"));
|
||
ok = warning_box(msg);
|
||
}
|
||
|
||
if (ok)
|
||
{
|
||
pulisci_ccb();
|
||
pulisci_movce();
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
int ce2500(int argc, char* argv[])
|
||
{
|
||
TRestore_boll a;
|
||
a.run(argc, argv, TR("Ripristino stampa bollato"));
|
||
return 0;
|
||
}
|