Aggiustamenti alle maschere
git-svn-id: svn://10.65.10.50/trunk@695 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
9c32b12f28
commit
f86f671813
@ -609,21 +609,30 @@ void TCaus_app::compila_array(const TString& tpd, int tpm, int tpr, int m770)
|
||||
{
|
||||
if (tpd.empty() || tpd == "IN" || tpd == "AN" || tpd == "PG")
|
||||
{
|
||||
bool canc = TRUE;
|
||||
switch (tpm)
|
||||
{
|
||||
case 0:
|
||||
if (m770 == 6)
|
||||
{
|
||||
causale_ritenute();
|
||||
canc = FALSE;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
case 5:
|
||||
case 6:
|
||||
if (saldaconto())
|
||||
{
|
||||
causale_inc_pag();
|
||||
canc = FALSE;
|
||||
};
|
||||
break;
|
||||
case 0:
|
||||
if (m770 == 6)
|
||||
causale_ritenute();
|
||||
default:
|
||||
clear_descr();
|
||||
break;
|
||||
}
|
||||
if (canc)
|
||||
clear_descr();
|
||||
}
|
||||
else // C'e' il tipodoc.
|
||||
{
|
||||
|
@ -56,7 +56,6 @@ BEGIN
|
||||
MESSAGE HIDE,96|HIDE,97|HIDE,98|HIDE,99
|
||||
MESSAGE HIDE,F_MODULO|RESET,F_MODULO
|
||||
MESSAGE SHOW,F_STAMPA|K_SPACE,F_STAMPA
|
||||
MESSAGE HIDE,DLG_PAGE
|
||||
ITEM "2|Bilancio di verifica"
|
||||
MESSAGE HIDE,F_STAMPA|RESET,F_STAMPA
|
||||
MESSAGE HIDE,F_DATALIM|RESET,F_DATALIM|HIDE,F_TOTALI|RESET,F_TOTALI
|
||||
@ -65,7 +64,6 @@ BEGIN
|
||||
MESSAGE SHOW,F_VERIFICA|K_SPACE,F_VERIFICA|SHOW,F_STAMPA1|K_SPACE,F_STAMPA1
|
||||
MESSAGE SHOW,F_MODULO|K_SPACE,F_MODULO
|
||||
MESSAGE SHOW,96|SHOW,97|SHOW,98|SHOW,99
|
||||
MESSAGE SHOW,DLG_PAGE
|
||||
END
|
||||
|
||||
RADIOBUTTON F_STAMPA 28
|
||||
|
@ -824,7 +824,7 @@ void TPrimanota_application::genera_incasso(const char* causimm)
|
||||
m.set(F_DATACOMP, curr_mask().get(F_DATACOMP));
|
||||
m.set(F_DATADOC, curr_mask().get(F_DATADOC));
|
||||
m.set(F_NUMDOC, curr_mask().get(F_NUMDOC));
|
||||
m.set(F_NUMREG, ++_lastreg); // Incrementa numero di registrazione
|
||||
m.set(F_NUMREG, _lastreg+1); // Incrementa numero di registrazione
|
||||
m.set(F_DESCR, caus.desc_agg(1)); // Descrizione
|
||||
m.set(F_CODCAUS, causimm); // Cambia causale
|
||||
m.set(F_DESCRCAUS, caus.descrizione());
|
||||
@ -855,10 +855,11 @@ void TPrimanota_application::genera_incasso(const char* causimm)
|
||||
|
||||
const int annoes = m.get_int(F_ANNOES);
|
||||
const TString16 datareg = m.get(F_DATAREG);
|
||||
long num = m.get_long(F_NUMREG);
|
||||
|
||||
TRectype& r = inc.cg(0);
|
||||
r.zero();
|
||||
r.put("NUMREG", _lastreg);
|
||||
r.put("NUMREG", num);
|
||||
r.put("NUMRIG", 1);
|
||||
r.put("DATAREG", datareg);
|
||||
r.put("ANNOES", annoes);
|
||||
@ -896,7 +897,7 @@ void TPrimanota_application::genera_incasso(const char* causimm)
|
||||
TRectype& r = inc.cg(i-1);
|
||||
r.zero();
|
||||
r.put("IMPORTO", imp);
|
||||
r.put("NUMREG", _lastreg);
|
||||
r.put("NUMREG", num);
|
||||
r.put("NUMRIG", i);
|
||||
r.put("DATAREG", datareg);
|
||||
r.put("ANNOES", annoes);
|
||||
@ -917,10 +918,15 @@ void TPrimanota_application::genera_incasso(const char* causimm)
|
||||
}
|
||||
|
||||
while (inc.write() == _isreinsert) // In caso di riscrittura
|
||||
inc.lfile().put("NUMREG", ++_lastreg); // Incrementa numero registrazione
|
||||
{
|
||||
num++; // Incrementa numero registrazione
|
||||
inc.lfile().put("NUMREG", num);
|
||||
}
|
||||
|
||||
if (inc.good())
|
||||
{
|
||||
if (num > _lastreg) _lastreg = num;
|
||||
|
||||
_saldi.reset(); // Inizializza saldi
|
||||
_saldi.set_movprovv(FALSE);
|
||||
_saldi.set_movap(FALSE);
|
||||
|
@ -18,8 +18,6 @@ BEGIN
|
||||
USE LF_NDITTE KEY 1
|
||||
CHECKTYPE REQUIRED
|
||||
INPUT CODDITTA F_CODDITTA
|
||||
DISPLAY "Codice" CODDITTA
|
||||
DISPLAY "Ragione sociale @50" RAGSOC
|
||||
OUTPUT F_RAGSOC RAGSOC
|
||||
END
|
||||
|
||||
@ -31,7 +29,7 @@ END
|
||||
|
||||
NUMBER F_NUMREG 6
|
||||
BEGIN
|
||||
PROMPT 1 4 "Operazione n. "
|
||||
PROMPT 1 4 "Numero operazione "
|
||||
HELP "Numero del movimento di prima nota da gestire"
|
||||
FLAGS "R"
|
||||
FIELD LF_MOV->NUMREG
|
||||
@ -41,6 +39,7 @@ BEGIN
|
||||
DISPLAY "Data@10" DATAREG
|
||||
DISPLAY "Causale" CODCAUS
|
||||
DISPLAY "Documento" NUMDOC
|
||||
DISPLAY "Protoc." PROTIVA
|
||||
DISPLAY "Descrizione@50" DESCR
|
||||
OUTPUT F_NUMREG NUMREG
|
||||
KEY 1
|
||||
@ -48,10 +47,9 @@ END
|
||||
|
||||
DATE F_DATAREG
|
||||
BEGIN
|
||||
PROMPT 1 6 "Data dell'operazione "
|
||||
PROMPT 1 6 "Data operazione "
|
||||
CHECKTYPE REQUIRED
|
||||
FLAGS "A"
|
||||
WARNING "E' obbligatorio specificare la data dell'operazione"
|
||||
HELP "Data in cui viene registrata l'operazione"
|
||||
MESSAGE COPY,F_ANNOIVA,7,10
|
||||
END
|
||||
@ -64,10 +62,9 @@ END
|
||||
|
||||
DATE F_DATACOMP
|
||||
BEGIN
|
||||
PROMPT 1 7 "Data di competenza "
|
||||
PROMPT 1 7 "Data di competenza "
|
||||
HELP "Data di competenza dell'operazione"
|
||||
CHECKTYPE REQUIRED
|
||||
WARNING "La data di competenza non appartiene all'esercizio"
|
||||
FLAGS "A"
|
||||
END
|
||||
|
||||
@ -79,8 +76,8 @@ END
|
||||
|
||||
STRING F_CODCAUS 3
|
||||
BEGIN
|
||||
PROMPT 1 9 "Causale "
|
||||
HELP "Codice della causale generante l'operazione"
|
||||
PROMPT 1 9 "Causale "
|
||||
HELP "Codice della causale dell'operazione"
|
||||
FLAGS "U"
|
||||
FIELD LF_MOV->CODCAUS
|
||||
USE LF_CAUSALI KEY 1
|
||||
@ -93,12 +90,13 @@ BEGIN
|
||||
OUTPUT F_DESCRCAUS DESCR
|
||||
ADD RUN cg0 -4
|
||||
CHECKTYPE REQUIRED
|
||||
WARNING "Causale assente"
|
||||
END
|
||||
|
||||
STRING F_DESCRCAUS 50
|
||||
BEGIN
|
||||
PROMPT 23 9 ""
|
||||
HELP "Descrizione della causale generante l'operazione"
|
||||
PROMPT 21 9 ""
|
||||
HELP "Descrizione della causale dell'operazione"
|
||||
USE LF_CAUSALI KEY 2
|
||||
CHECKTYPE NORMAL
|
||||
INPUT DESCR F_DESCRCAUS
|
||||
|
@ -4,7 +4,7 @@ PAGE "Movimento di incasso immediato" -1 -1 75 13
|
||||
|
||||
DATE F_DATAREG
|
||||
BEGIN
|
||||
PROMPT 1 1 "Data di registrazione "
|
||||
PROMPT 1 1 "Data dell' operazione "
|
||||
HELP "Data in cui viene registrata l'operazione"
|
||||
FIELD LF_MOV->DATAREG
|
||||
CHECKTYPE REQUIRED
|
||||
|
@ -21,6 +21,11 @@ END
|
||||
STRING 109 50
|
||||
BEGIN
|
||||
PROMPT 14 2 ""
|
||||
USE %DPN
|
||||
INPUT S0 109
|
||||
DISPLAY "Descrizione@50" S0
|
||||
DISPLAY "Codice" CODTAB
|
||||
COPY OUTPUT 108
|
||||
HELP "Descrizione aggiuntiva di riga"
|
||||
FIELD DESCR
|
||||
END
|
||||
|
@ -326,10 +326,6 @@ bool TSaldibrowse_application::user_create()
|
||||
|
||||
void TSaldibrowse_application::disable_all()
|
||||
{
|
||||
/*
|
||||
for (int i = 0; i < 17; i++)
|
||||
ss().enable_column(i,FALSE);
|
||||
*/
|
||||
ss().disable();
|
||||
}
|
||||
|
||||
|
@ -1,16 +1,18 @@
|
||||
// cg5300.cpp
|
||||
// modifica parametri contabilita' relativi alla liquidazione
|
||||
|
||||
#include <config.h>
|
||||
#include <msksheet.h>
|
||||
#include <relapp.h>
|
||||
#include <tabutil.h>
|
||||
#include <urldefid.h>
|
||||
#include <utility.h>
|
||||
#include <msksheet.h>
|
||||
#include <config.h>
|
||||
#include <attiv.h>
|
||||
#include <nditte.h>
|
||||
|
||||
#include "cg5.h"
|
||||
#include "cg5300a.h"
|
||||
|
||||
#include <attiv.h>
|
||||
#include <nditte.h>
|
||||
|
||||
#define TAB_LIA "LIA"
|
||||
#define TAB_PLA "PLA"
|
||||
|
@ -35,7 +35,7 @@ END
|
||||
NUMBER F_YEAR 4
|
||||
BEGIN
|
||||
PROMPT 6 3 "Anno "
|
||||
HELP "Anno d'esercizio ??????"
|
||||
HELP "Anno d'esercizio"
|
||||
FIELD LIA->CODTAB
|
||||
USE LIA
|
||||
INPUT CODTAB F_YEAR
|
||||
@ -43,7 +43,7 @@ BEGIN
|
||||
DISPLAY "@2" S0
|
||||
OUTPUT F_YEAR CODTAB
|
||||
KEY 1
|
||||
FLAGS "RZ"
|
||||
FLAGS "Z"
|
||||
CHECKTYPE REQUIRED
|
||||
ADD NONE
|
||||
END
|
||||
@ -62,22 +62,24 @@ BEGIN
|
||||
FIELD LIA->S7
|
||||
END
|
||||
|
||||
NUMBER F_CRED_PREC 15 0
|
||||
NUMBER F_CRED_PREC 15
|
||||
BEGIN
|
||||
PROMPT 6 6 "Credito precedente "
|
||||
HELP "Eventuale credito di imposta dell'anno precedente"
|
||||
FIELD LIA->R0
|
||||
PICTURE "."
|
||||
FLAGS "R"
|
||||
NUM_CALC ROUND(#THIS_FIELD,-3)
|
||||
END
|
||||
|
||||
NUMBER F_CRED_COST 15 0
|
||||
NUMBER F_CRED_COST 15
|
||||
BEGIN
|
||||
PROMPT 6 7 "Credito di costo "
|
||||
HELP "Eventuale crediti—o di costo dell'anno precedente"
|
||||
HELP "Eventuale credito di costo dell'anno precedente"
|
||||
FIELD LIA->R5
|
||||
PICTURE "."
|
||||
FLAGS "R"
|
||||
NUM_CALC ROUND(#THIS_FIELD,-3)
|
||||
END
|
||||
|
||||
SPREADSHEET F_SHEET_PLA 78 6
|
||||
@ -96,10 +98,10 @@ ENDMASK
|
||||
|
||||
PAGE "" -1 -1 65 16
|
||||
|
||||
NUMBER F_CODATT 5
|
||||
STRING F_CODATT 5
|
||||
BEGIN
|
||||
PROMPT 4 1 "Codice Attivita' "
|
||||
FLAGS "DZG"
|
||||
FLAGS "DUZ"
|
||||
USE %AIS
|
||||
INPUT CODTAB F_CODATT
|
||||
DISPLAY "Codice" CODTAB
|
||||
@ -111,17 +113,16 @@ END
|
||||
|
||||
STRING F_DESATT 50 30
|
||||
BEGIN
|
||||
PROMPT 31 1 ""
|
||||
PROMPT 4 2 "Descrizione "
|
||||
FLAGS "D"
|
||||
END
|
||||
|
||||
LIST F_TIPOATT 26
|
||||
BEGIN
|
||||
PROMPT 4 3 "Tipo "
|
||||
HELP "Tipo di attivita' a della ditta"
|
||||
HELP "Tipo di attivita' della ditta"
|
||||
FLAGS "U"
|
||||
ITEM " |Altre"
|
||||
ITEM "M|Mista"
|
||||
ITEM "E|Mista evidenziata"
|
||||
ITEM "S|Servizio o mista generica"
|
||||
END
|
||||
@ -129,7 +130,7 @@ END
|
||||
NUMBER F_PRORATA 6 2
|
||||
BEGIN
|
||||
PROMPT 4 5 "% Pro-Rata "
|
||||
HELP "Percentuale di pro-rata ???????"
|
||||
HELP "Percentuale di pro-rata"
|
||||
PICTURE ".2"
|
||||
NUM_EXPR {(#F_PRORATA>=0.0)&&(#F_PRORATA<=100.0)}
|
||||
WARNING "La percentuale deve essere compresa tra 0 e 100"
|
||||
@ -140,7 +141,7 @@ END
|
||||
NUMBER F_P8 15
|
||||
BEGIN
|
||||
PROMPT 4 7 "Plafond art. 8 "
|
||||
HELP "?????????????"
|
||||
HELP "Ammontare plafond articolo 8"
|
||||
PICTURE "."
|
||||
FLAGS "R"
|
||||
GROUP 1
|
||||
@ -148,8 +149,8 @@ END
|
||||
|
||||
NUMBER F_P8B 15
|
||||
BEGIN
|
||||
PROMPT 4 9 "Plafond art. 8b "
|
||||
HELP "????????????"
|
||||
PROMPT 4 9 "Plafond art. 8 bis "
|
||||
HELP "Ammontare plafond articolo 8 bis"
|
||||
PICTURE "."
|
||||
FLAGS "R"
|
||||
GROUP 1
|
||||
@ -158,7 +159,7 @@ END
|
||||
NUMBER F_P9 15
|
||||
BEGIN
|
||||
PROMPT 4 11 "Plafond art. 9 "
|
||||
HELP "?????????????"
|
||||
HELP "Ammontare plafond articolo 9"
|
||||
PICTURE "."
|
||||
FLAGS "R"
|
||||
GROUP 1
|
||||
|
394
cg/cg5400.cpp
394
cg/cg5400.cpp
@ -1,197 +1,197 @@
|
||||
#include <applicat.h>
|
||||
#include <date.h>
|
||||
#include <isam.h>
|
||||
#include <relation.h>
|
||||
#include <tabutil.h>
|
||||
#include <mask.h>
|
||||
#include <prefix.h>
|
||||
#include <progind.h>
|
||||
#include <utility.h>
|
||||
|
||||
#include <mov.h>
|
||||
#include <urldefid.h>
|
||||
|
||||
#include "cg5.h"
|
||||
#include "cg5400.h"
|
||||
|
||||
class TRipristina_stampa : public TApplication
|
||||
{
|
||||
TMask* _msk;
|
||||
long _default_firm;
|
||||
|
||||
virtual bool create() ;
|
||||
virtual bool destroy() ;
|
||||
bool menu(MENU_TAG);
|
||||
bool do_restore(long firm, const char * reg, const char * year, int month,
|
||||
bool giornale);
|
||||
static bool firm_handler(TMask_field& f, KEY key);
|
||||
|
||||
public:
|
||||
TRipristina_stampa() : _msk(NULL) {}
|
||||
};
|
||||
|
||||
bool TRipristina_stampa::firm_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
if (f.to_check(key))
|
||||
{
|
||||
const long firm = atol(f.get());
|
||||
|
||||
if (firm < 0)
|
||||
return f.error_box("Codice ditta impossibile");
|
||||
else
|
||||
if (firm == 0)
|
||||
return f.error_box("La ditta e' obbligatoria");
|
||||
else
|
||||
if (!prefhndl->exist(firm))
|
||||
return f.error_box("Gli archivi della ditta %d non sono stati ancora generati",firm);
|
||||
else
|
||||
main_app().set_firm(firm);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TRipristina_stampa::do_restore(long firm, const char * regist,
|
||||
const char * year, int month,
|
||||
bool giornale)
|
||||
{
|
||||
bool ok = TRUE;
|
||||
CHECK(firm > 0, "Non posso ripristinare sui dati comuni");
|
||||
CHECK(regist != NULL && strlen(regist) < 4, "Registro impossibile");
|
||||
CHECK(month > 0 && month < 13, "Mese impossibile");
|
||||
set_firm(firm);
|
||||
|
||||
const char * const fieldname = giornale ? MOV_STAMPATO : MOV_REGST;
|
||||
TRelation rel(LF_MOV);
|
||||
TLocalisamfile & mov = rel.lfile();
|
||||
TTable reg("REG");
|
||||
TString16 s;
|
||||
|
||||
s.format("%-4s%s", year, regist);
|
||||
|
||||
reg.zero();
|
||||
reg.put("CODTAB", s);
|
||||
if (reg.read(_isequal, _lock) == NOERR)
|
||||
{
|
||||
TDate dlast(reg.get_date("D3"));
|
||||
int wyear = atoi(year);
|
||||
|
||||
if (giornale)
|
||||
{
|
||||
TTable esc("ESC");
|
||||
esc.zero();
|
||||
esc.put("CODTAB", year);
|
||||
if (esc.read() != NOERR)
|
||||
{
|
||||
set_firm(_default_firm);
|
||||
return error_box("Esercizio %s assente", year);
|
||||
}
|
||||
|
||||
TDate wd(esc.get_date("D0"));
|
||||
|
||||
wyear = wd.year();
|
||||
if (wd.month() > month)
|
||||
wyear++;
|
||||
}
|
||||
TDate d(1, month, wyear);
|
||||
|
||||
TRectype from(mov.curr()); from.zero();
|
||||
TRectype to(from);
|
||||
TString16 filter;
|
||||
|
||||
from.put(MOV_DATAREG, d);
|
||||
to.put(MOV_DATAREG, dlast);
|
||||
if (!giornale)
|
||||
filter.format("%s==\"%s\"", MOV_REG, regist);
|
||||
|
||||
TCursor cursor(&rel, filter, 2, &from, &to);
|
||||
long last_num = 0L;
|
||||
|
||||
cursor = 0L;
|
||||
const long nitems = cursor.items();
|
||||
|
||||
TProgind p(nitems ? nitems : 1, format("Ripristino stampa del registro %s", (const char *) regist) , TRUE, TRUE, 70);
|
||||
|
||||
if (giornale)
|
||||
{
|
||||
last_num = mov.get_long(MOV_NUMGIO);
|
||||
if (last_num > 0) last_num--;
|
||||
CHECK(last_num >= 0, "Ultimo numero stampato impossibile");
|
||||
}
|
||||
for (; ok && cursor.pos() < cursor.items(); ++cursor)
|
||||
{
|
||||
p.addstatus(1);
|
||||
mov.read(_isequal, _lock);
|
||||
mov.zero(fieldname);
|
||||
ok = (mov.rewrite() == NOERR);
|
||||
if (!ok)
|
||||
error_box("Errore nell' aggiornamento del movimento %ld.\n Errore n. %d",
|
||||
mov.get_long(MOV_NUMREG), mov.status());
|
||||
}
|
||||
d--;
|
||||
reg.put("D3", d);
|
||||
if (giornale)
|
||||
reg.put("I6", last_num);
|
||||
ok = (reg.rewrite() == NOERR);
|
||||
if (!ok)
|
||||
error_box("Errore nell' aggiornamento del registro %s.\n Errore n. %d",
|
||||
(const char * ) regist, mov.status());
|
||||
|
||||
}
|
||||
else
|
||||
ok = error_box("Non riesco a leggere il registro %s anno %s", (const char *) regist, (const char *) year);
|
||||
|
||||
set_firm(_default_firm);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TRipristina_stampa::create()
|
||||
{
|
||||
_msk = new TMask("cg5400a") ;
|
||||
_msk->set_handler(F_FIRM, firm_handler);
|
||||
_default_firm = get_firm();
|
||||
dispatch_e_menu(BAR_ITEM(1));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TRipristina_stampa::destroy()
|
||||
{
|
||||
if (_msk != NULL) delete _msk;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TRipristina_stampa::menu(MENU_TAG)
|
||||
{
|
||||
while (_msk->run() == K_ENTER)
|
||||
{
|
||||
const long firm = _msk->get_long(F_FIRM);
|
||||
const TString16 reg = _msk->get(F_REG);
|
||||
const bool giornale = _msk->get_int(F_TIPO) == 5;
|
||||
const TString16 year = _msk->get(giornale ? F_ESER : F_YEAR);
|
||||
int month = _msk->get_int(F_MESE);
|
||||
|
||||
if (prefhndl->exist(firm))
|
||||
{
|
||||
TString mess;
|
||||
|
||||
mess.format("Attenzione sara' ripristinata la stampa\n del registro %s %s %s della ditta %ld dal mese di %s. Devo continuare",
|
||||
(const char *) reg, giornale ? "esercizio" : "anno",
|
||||
(const char *) year, (const char *) firm, itom(month));
|
||||
if (yesno_box((const char *) mess))
|
||||
{
|
||||
mess.rtrim(16); mess << " Devo veramente continuare";
|
||||
if (yesno_box((const char *) mess))
|
||||
do_restore(firm, reg, year, month, giornale);
|
||||
}
|
||||
}
|
||||
else error_box("Gli archivi della ditta %d non sono stati ancora generati",firm);
|
||||
_msk->reset();
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int cg5400(int argc, char* argv[])
|
||||
{
|
||||
TRipristina_stampa a ;
|
||||
a.run(argc, argv, "Ripristino stampa registri");
|
||||
return 0;
|
||||
}
|
||||
#include <applicat.h>
|
||||
#include <date.h>
|
||||
#include <isam.h>
|
||||
#include <relation.h>
|
||||
#include <tabutil.h>
|
||||
#include <mask.h>
|
||||
#include <prefix.h>
|
||||
#include <progind.h>
|
||||
#include <utility.h>
|
||||
|
||||
#include <mov.h>
|
||||
#include <urldefid.h>
|
||||
|
||||
#include "cg5.h"
|
||||
#include "cg5400.h"
|
||||
|
||||
class TRipristina_stampa : public TApplication
|
||||
{
|
||||
TMask* _msk;
|
||||
long _default_firm;
|
||||
|
||||
virtual bool create() ;
|
||||
virtual bool destroy() ;
|
||||
bool menu(MENU_TAG);
|
||||
bool do_restore(long firm, const char * reg, const char * year, int month,
|
||||
bool giornale);
|
||||
static bool firm_handler(TMask_field& f, KEY key);
|
||||
|
||||
public:
|
||||
TRipristina_stampa() : _msk(NULL) {}
|
||||
};
|
||||
|
||||
bool TRipristina_stampa::firm_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
if (f.to_check(key))
|
||||
{
|
||||
const long firm = atol(f.get());
|
||||
|
||||
if (firm < 0)
|
||||
return f.error_box("Codice ditta impossibile");
|
||||
else
|
||||
if (firm == 0)
|
||||
return f.error_box("La ditta e' obbligatoria");
|
||||
else
|
||||
if (!prefhndl->exist(firm))
|
||||
return f.error_box("Gli archivi della ditta %d non sono stati ancora generati",firm);
|
||||
else
|
||||
main_app().set_firm(firm);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TRipristina_stampa::do_restore(long firm, const char * regist,
|
||||
const char * year, int month,
|
||||
bool giornale)
|
||||
{
|
||||
bool ok = TRUE;
|
||||
CHECK(firm > 0, "Non posso ripristinare sui dati comuni");
|
||||
CHECK(regist != NULL && strlen(regist) < 4, "Registro impossibile");
|
||||
CHECK(month > 0 && month < 13, "Mese impossibile");
|
||||
set_firm(firm);
|
||||
|
||||
const char * const fieldname = giornale ? MOV_STAMPATO : MOV_REGST;
|
||||
TRelation rel(LF_MOV);
|
||||
TLocalisamfile & mov = rel.lfile();
|
||||
TTable reg("REG");
|
||||
TString16 s;
|
||||
|
||||
s.format("%-4s%s", year, regist);
|
||||
|
||||
reg.zero();
|
||||
reg.put("CODTAB", s);
|
||||
if (reg.read(_isequal, _lock) == NOERR)
|
||||
{
|
||||
TDate dlast(reg.get_date("D3"));
|
||||
int wyear = atoi(year);
|
||||
|
||||
if (giornale)
|
||||
{
|
||||
TTable esc("ESC");
|
||||
esc.zero();
|
||||
esc.put("CODTAB", year);
|
||||
if (esc.read() != NOERR)
|
||||
{
|
||||
set_firm(_default_firm);
|
||||
return error_box("Esercizio %s assente", year);
|
||||
}
|
||||
|
||||
TDate wd(esc.get_date("D0"));
|
||||
|
||||
wyear = wd.year();
|
||||
if (wd.month() > month)
|
||||
wyear++;
|
||||
}
|
||||
TDate d(1, month, wyear);
|
||||
|
||||
TRectype from(mov.curr()); from.zero();
|
||||
TRectype to(from);
|
||||
TString16 filter;
|
||||
|
||||
from.put(MOV_DATAREG, d);
|
||||
to.put(MOV_DATAREG, dlast);
|
||||
if (!giornale)
|
||||
filter.format("%s==\"%s\"", MOV_REG, regist);
|
||||
|
||||
TCursor cursor(&rel, filter, 2, &from, &to);
|
||||
long last_num = 0L;
|
||||
|
||||
cursor = 0L;
|
||||
const long nitems = cursor.items();
|
||||
|
||||
TProgind p(nitems ? nitems : 1, format("Ripristino stampa del registro %s", (const char *) regist) , TRUE, TRUE, 70);
|
||||
|
||||
if (giornale)
|
||||
{
|
||||
last_num = mov.get_long(MOV_NUMGIO);
|
||||
if (last_num > 0) last_num--;
|
||||
CHECK(last_num >= 0, "Ultimo numero stampato impossibile");
|
||||
}
|
||||
for (; ok && cursor.pos() < cursor.items(); ++cursor)
|
||||
{
|
||||
p.addstatus(1);
|
||||
mov.read(_isequal, _lock);
|
||||
mov.zero(fieldname);
|
||||
ok = (mov.rewrite() == NOERR);
|
||||
if (!ok)
|
||||
error_box("Errore nell' aggiornamento del movimento %ld.\n Errore n. %d",
|
||||
mov.get_long(MOV_NUMREG), mov.status());
|
||||
}
|
||||
--d;
|
||||
reg.put("D3", d);
|
||||
if (giornale)
|
||||
reg.put("I6", last_num);
|
||||
ok = (reg.rewrite() == NOERR);
|
||||
if (!ok)
|
||||
error_box("Errore nell' aggiornamento del registro %s.\n Errore n. %d",
|
||||
(const char * ) regist, mov.status());
|
||||
|
||||
}
|
||||
else
|
||||
ok = error_box("Non riesco a leggere il registro %s anno %s", (const char *) regist, (const char *) year);
|
||||
|
||||
set_firm(_default_firm);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TRipristina_stampa::create()
|
||||
{
|
||||
_msk = new TMask("cg5400a") ;
|
||||
_msk->set_handler(F_FIRM, firm_handler);
|
||||
_default_firm = get_firm();
|
||||
dispatch_e_menu(BAR_ITEM(1));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TRipristina_stampa::destroy()
|
||||
{
|
||||
if (_msk != NULL) delete _msk;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TRipristina_stampa::menu(MENU_TAG)
|
||||
{
|
||||
while (_msk->run() == K_ENTER)
|
||||
{
|
||||
const long firm = _msk->get_long(F_FIRM);
|
||||
const TString16 reg = _msk->get(F_REG);
|
||||
const bool giornale = _msk->get_int(F_TIPO) == 5;
|
||||
const TString16 year = _msk->get(giornale ? F_ESER : F_YEAR);
|
||||
int month = _msk->get_int(F_MESE);
|
||||
|
||||
if (prefhndl->exist(firm))
|
||||
{
|
||||
TString mess;
|
||||
|
||||
mess.format("Attenzione sara' ripristinata la stampa\n del registro %s %s %s della ditta %ld dal mese di %s. Devo continuare",
|
||||
(const char *) reg, giornale ? "esercizio" : "anno",
|
||||
(const char *) year, (const char *) firm, itom(month));
|
||||
if (yesno_box((const char *) mess))
|
||||
{
|
||||
mess.rtrim(16); mess << " Devo veramente continuare";
|
||||
if (yesno_box((const char *) mess))
|
||||
do_restore(firm, reg, year, month, giornale);
|
||||
}
|
||||
}
|
||||
else error_box("Gli archivi della ditta %d non sono stati ancora generati",firm);
|
||||
_msk->reset();
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int cg5400(int argc, char* argv[])
|
||||
{
|
||||
TRipristina_stampa a ;
|
||||
a.run(argc, argv, "Ripristino stampa registri");
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user