Corrette le create delle TApplication
Corretta ricerca saldi da visualizzare git-svn-id: svn://10.65.10.50/trunk@737 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
034dfd861c
commit
2dc933c084
@ -36,6 +36,7 @@ public:
|
||||
|
||||
bool TStampa_deleghe_IVA::create()
|
||||
{
|
||||
TApplication::create();
|
||||
CHECK(_ditte == NULL, "Eh la vaca!");
|
||||
_ditte = new TArray_sheet(-1, -1, 0, 0, "Selezione Deleghe da stampare" ,"@1|Cod.@5|Ragione Sociale@50|Importo@15|Azienda|Dipend.");
|
||||
dispatch_e_menu(BAR_ITEM(1));
|
||||
@ -45,7 +46,7 @@ bool TStampa_deleghe_IVA::create()
|
||||
bool TStampa_deleghe_IVA::destroy()
|
||||
{
|
||||
delete _ditte;
|
||||
return TRUE;
|
||||
return TApplication::destroy();
|
||||
}
|
||||
|
||||
|
||||
|
@ -36,6 +36,7 @@ public:
|
||||
|
||||
bool TStampa_deleghe_IVA::create()
|
||||
{
|
||||
TApplication::create();
|
||||
CHECK(_ditte == NULL, "Eh la vaca!");
|
||||
_ditte = new TArray_sheet(-1, -1, 0, 0, "Selezione Deleghe da stampare" ,"@1|Cod.@5|Ragione Sociale@50|Importo@15|Azienda|Dipend.");
|
||||
dispatch_e_menu(BAR_ITEM(1));
|
||||
@ -45,7 +46,7 @@ bool TStampa_deleghe_IVA::create()
|
||||
bool TStampa_deleghe_IVA::destroy()
|
||||
{
|
||||
delete _ditte;
|
||||
return TRUE;
|
||||
return TApplication::destroy();
|
||||
}
|
||||
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <rcausali.h>
|
||||
|
||||
TPrimanota_application::TPrimanota_application()
|
||||
: _rel(NULL), _lastreg(0), _mode(0), _iva(nessuna_iva)
|
||||
: _rel(NULL), _lastreg(0), _mode(0), _iva(nessuna_iva), _causale(NULL), _giornale(NULL)
|
||||
{
|
||||
memset(_msk, 0, sizeof(_msk));
|
||||
}
|
||||
@ -137,8 +137,10 @@ bool TPrimanota_application::user_create()
|
||||
_rel = new TMovimentoPN;
|
||||
_rel->add(LF_PARTITE, "NREG=NUMREG", 2);
|
||||
|
||||
set_search_field(F_NUMREG); // Set field for default search
|
||||
_causale = new TCausale();
|
||||
_giornale = new TLibro_giornale();
|
||||
|
||||
set_search_field(F_NUMREG); // Set field for default search
|
||||
load_mask(0);
|
||||
|
||||
return TRUE;
|
||||
@ -153,7 +155,9 @@ bool TPrimanota_application::user_destroy()
|
||||
{
|
||||
for (int m = 3; m >= 0; m--)
|
||||
if (_msk[m] != NULL) delete _msk[m];
|
||||
|
||||
|
||||
delete _giornale;
|
||||
delete _causale;
|
||||
delete _rel;
|
||||
delete _nditte;
|
||||
delete _occas;
|
||||
@ -177,17 +181,17 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
|
||||
bool ok = TRUE;
|
||||
|
||||
if (cod != NULL)
|
||||
ok = _causale.read(cod, year);
|
||||
ok = causale().read(cod, year);
|
||||
|
||||
bool nob = FALSE, dob = FALSE, sal = FALSE;
|
||||
TipoIVA iva = nessuna_iva;
|
||||
|
||||
if (ok)
|
||||
{
|
||||
sal = gestione_saldaconto() && _causale.saldaconto();
|
||||
dob = sal | _causale.data_doc();
|
||||
nob = sal | _causale.num_doc();
|
||||
iva = _causale.iva();
|
||||
sal = gestione_saldaconto() && causale().saldaconto();
|
||||
dob = sal | causale().data_doc();
|
||||
nob = sal | causale().num_doc();
|
||||
iva = causale().iva();
|
||||
}
|
||||
|
||||
TMask* m = _msk[iva == nessuna_iva ? 1 : 2];
|
||||
@ -201,7 +205,7 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
|
||||
if (iva != nessuna_iva)
|
||||
{
|
||||
m->efield(F_CODPAG).check_type(sal ? CHECK_REQUIRED : CHECK_NORMAL);// Cod. pag. obbligatorio
|
||||
const bool av = _causale.reg().agenzia_viaggi();
|
||||
const bool av = causale().reg().agenzia_viaggi();
|
||||
m->show(F_DATA74TER, av);
|
||||
if (!av) m->reset(F_DATA74TER);
|
||||
|
||||
@ -212,7 +216,7 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
|
||||
|
||||
if (ins)
|
||||
{
|
||||
const long protiva = _causale.reg().protocol() + 1;
|
||||
const long protiva = causale().reg().protocol() + 1;
|
||||
m->set(F_PROTIVA, protiva); // Aggiorna protocollo IVA
|
||||
}
|
||||
}
|
||||
@ -220,18 +224,18 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
|
||||
if (ins && !ci_sono_importi())
|
||||
{
|
||||
cgs().reset();
|
||||
for (int i = 1; i < _causale.size(); i++)
|
||||
for (int i = 1; i < causale().size(); i++)
|
||||
{
|
||||
const TRectype* rcaus = (TRectype*)_causale.objptr(i);
|
||||
const TRectype* rcaus = (TRectype*)causale().objptr(i);
|
||||
if (rcaus == NULL) continue; // Evita eventuali righe nulle
|
||||
|
||||
const int nriga = rcaus->get_int(RCA_NRIGA);
|
||||
if (nriga < 1) continue; // Considera solo righe reali (non riempimenti)
|
||||
|
||||
TBill tc; _causale.bill(nriga, tc);
|
||||
TBill tc; causale().bill(nriga, tc);
|
||||
if (tc.gruppo() < 1) continue; // Considera solo gruppi validi
|
||||
|
||||
if (tc.tipo() > ' ' && tc.sottoconto() != 0)
|
||||
if (tc.tipo() > ' ' && tc.ok())
|
||||
{
|
||||
TBill clifo(0, 0, tc.sottoconto(), tc.tipo());
|
||||
clifo.descrizione();
|
||||
@ -241,7 +245,7 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
|
||||
|
||||
const char sezione = rcaus->get_char(RCA_SEZIONE);
|
||||
const TImporto zero('D', ZERO);
|
||||
const TString80 desc(_causale.desc_agg(i));
|
||||
const TString80 desc(causale().desc_agg(i));
|
||||
|
||||
if (nriga == 1) m->set(F_DESCR, desc);
|
||||
|
||||
@ -257,7 +261,7 @@ bool TPrimanota_application::read_caus(const char* cod, int year)
|
||||
continue; // Conti per IVA detraibile e non, ritenute sociali e fiscali
|
||||
|
||||
const char tipo = nriga == 1 ? 'T' : ' ';
|
||||
if (nriga == 1 && tc.tipo() > ' ' && tc.sottoconto() != 0)
|
||||
if (nriga == 1 && tc.tipo() > ' ' && tc.ok())
|
||||
m->set(tc.tipo() == 'C' ? F_CLIENTE : F_FORNITORE, tc.sottoconto());
|
||||
set_cgs_row(-1,zero,tc,desc,tipo);
|
||||
}
|
||||
@ -320,9 +324,12 @@ TMask* TPrimanota_application::get_mask(int mode)
|
||||
default:
|
||||
return load_mask(0);
|
||||
}
|
||||
|
||||
giornale().read(annoes);
|
||||
causale().read(caus, annoiva);
|
||||
|
||||
if (giornale().year() != annoes)
|
||||
giornale().read(annoes);
|
||||
|
||||
if (caus != causale().codice() || causale().reg().year() != annoiva)
|
||||
causale().read(caus, annoiva);
|
||||
_iva = causale().iva();
|
||||
|
||||
return load_mask(_iva == nessuna_iva ? 1 : 2);
|
||||
@ -350,8 +357,8 @@ void TPrimanota_application::init_mask(TMask& m)
|
||||
read_caus(NULL, 0); // Setta campi obbligatori
|
||||
fill_sheet(m);
|
||||
|
||||
const bool valintra = _causale.valintra();
|
||||
const bool corrisp = _causale.corrispettivi();
|
||||
const bool valintra = causale().valintra();
|
||||
const bool corrisp = causale().corrispettivi();
|
||||
|
||||
if (_iva != nessuna_iva)
|
||||
{
|
||||
@ -377,13 +384,8 @@ void TPrimanota_application::init_mask(TMask& m)
|
||||
}
|
||||
|
||||
// Show/Hide campi valuta: F_VALUTA, F_CAMBIO, F_VISVAL (GROUP 3)
|
||||
const bool valuta = _ges_val && _causale.valuta();
|
||||
const bool valuta = _ges_val && causale().valuta();
|
||||
m.show(-3, valuta);
|
||||
if (valuta)
|
||||
{
|
||||
const bool ok = m.get(F_VALUTA).not_empty();
|
||||
m.field(F_VISVAL).set(ok ? "X" : " ");
|
||||
}
|
||||
}
|
||||
|
||||
void TPrimanota_application::init_query_mode(TMask& m)
|
||||
@ -442,7 +444,7 @@ void TPrimanota_application::init_insert_mode(TMask& m)
|
||||
init_mask(m);
|
||||
_saldi.reset(); // Inizializza saldi
|
||||
_saldi.set_movprovv(_rel->lfile().get_char("PROVVIS") > ' ' ? TRUE : FALSE);
|
||||
_saldi.set_movap(_causale.apertura());
|
||||
_saldi.set_movap(causale().apertura());
|
||||
_saldi.set_anno_es(m.get_int(F_ANNOES));
|
||||
_saldi.set_num_ulmov(m.get_long(F_NUMREG));
|
||||
_saldi.set_data_ulmov((TDate)m.get(F_DATAREG));
|
||||
@ -517,7 +519,7 @@ int TPrimanota_application::read(TMask& m)
|
||||
|
||||
_saldi.reset(); // Azzera saldi
|
||||
_saldi.set_movprovv(_rel->lfile().get_bool("PROVVIS"));
|
||||
_saldi.set_movap(_causale.apertura());
|
||||
_saldi.set_movap(causale().apertura());
|
||||
_saldi.set_anno_es(m.get_int(F_ANNOES));
|
||||
_saldi.set_num_ulmov(m.get_long(F_NUMREG));
|
||||
_saldi.set_data_ulmov((TDate)m.get(F_DATAREG));
|
||||
@ -612,7 +614,7 @@ void TPrimanota_application::mask2rel(const TMask& m)
|
||||
const int annoes = m.get_int(F_ANNOES);
|
||||
|
||||
_saldi.set_movprovv(m.get_bool(F_PROVVISORIO));
|
||||
_saldi.set_movap(_causale.apertura());
|
||||
_saldi.set_movap(causale().apertura());
|
||||
_saldi.set_anno_es(annoes);
|
||||
|
||||
_rel->destroy_rows(); // Destroy all records
|
||||
@ -765,7 +767,7 @@ int TPrimanota_application::rewrite(const TMask& m)
|
||||
const int err = _rel->rewrite(TRUE);
|
||||
if (err == NOERR)
|
||||
_saldi.registra();
|
||||
if (gestione_saldaconto() && _causale.saldaconto())
|
||||
if (gestione_saldaconto() && causale().saldaconto())
|
||||
aggiorna_scadenzario(m);
|
||||
return err;
|
||||
}
|
||||
|
@ -124,7 +124,6 @@ int TMovimentoPN::cancella(TLocalisamfile& f, int da, int a)
|
||||
const long numreg = lfile().get_long(MOV_NUMREG);
|
||||
for (int i = da; i <= a; i++)
|
||||
{
|
||||
f.zero();
|
||||
f.put(MOV_NUMREG, numreg);
|
||||
f.put(RMV_NUMRIG, i);
|
||||
if (f.read(_isequal, _lock) == NOERR)
|
||||
@ -143,10 +142,12 @@ char TMovimentoPN::frequenza_versamenti(int year) const
|
||||
TString16 key;
|
||||
key << year;
|
||||
TTable lia("LIA");
|
||||
lia.setkey(1);
|
||||
lia.put("CODTAB", key);
|
||||
if (lia.read() != NOERR)
|
||||
{
|
||||
TLocalisamfile nditte(LF_NDITTE);
|
||||
nditte.setkey(1);
|
||||
nditte.put("CODDITTA", main_app().get_firm());
|
||||
nditte.read();
|
||||
last_freq = nditte.get_char("FREQVIVA");
|
||||
@ -177,9 +178,10 @@ bool TMovimentoPN::controlla_liquidazione(const TDate& data, bool reset) const
|
||||
const int mese = date2liq(data);
|
||||
|
||||
// Chiave di LIM: Anno (1-4), Mese (5-6)
|
||||
TTable lim("LIM");
|
||||
TString16 key;
|
||||
key << anno << mese;
|
||||
TTable lim("LIM");
|
||||
lim.setkey(1);
|
||||
lim.put("CODTAB", key);
|
||||
if (lim.read() == NOERR)
|
||||
calcolata = lim.get_bool("B1"); // Controlla se calcolata in definitivo
|
||||
@ -268,6 +270,7 @@ int TMovimentoPN::registra(bool re, bool force)
|
||||
const int att = att_mista ? 2 : 1;
|
||||
// Chiave di PLM: Anno (1-4), Cod. Att. (5-9), Tipo att. (10-10), Mese (11-12)
|
||||
TTable plm("PLM");
|
||||
plm.setkey(1);
|
||||
for (int a = 1; a <= att; a++)
|
||||
{
|
||||
TString16 chiave;
|
||||
|
@ -1356,7 +1356,7 @@ void TPrimanota_application::add_cgs_tot(TMask& m)
|
||||
if (conto == 0 || causale().corrispettivi())
|
||||
{
|
||||
// Se l'utente non ha ancora specificato un conto lo prendo dalla prima riga della causale
|
||||
TBill bill; _causale.bill(1, bill);
|
||||
TBill bill; causale().bill(1, bill);
|
||||
gruppo = bill.gruppo();
|
||||
conto = bill.conto();
|
||||
if (causale().corrispettivi())
|
||||
@ -1528,8 +1528,8 @@ void TPrimanota_application::add_cgs_rit(bool fiscali)
|
||||
if (pos < 0)
|
||||
{
|
||||
const int riga = fiscali ? 8 : 9;
|
||||
TBill conto; _causale.bill(riga, conto);
|
||||
const TString80 desc(_causale.desc_agg(riga));
|
||||
TBill conto; causale().bill(riga, conto);
|
||||
const TString80 desc(causale().desc_agg(riga));
|
||||
set_cgs_row(-1, real2imp(imp, tipo), conto, desc, tipo);
|
||||
}
|
||||
else
|
||||
|
@ -36,8 +36,8 @@ class TPrimanota_application : public TRelation_application
|
||||
TLocalisamfile* _occas;
|
||||
TLocalisamfile* _nditte;
|
||||
|
||||
TCausale _causale; // Causale corrente
|
||||
TLibro_giornale _giornale; // Libro giornale corrente
|
||||
TCausale* _causale; // Causale corrente
|
||||
TLibro_giornale* _giornale; // Libro giornale corrente
|
||||
TipoIVA _iva; // Tipo di IVA corrente
|
||||
bool _ges_val, _ges_sal; // Gestione valuta e saldaconto
|
||||
bool _savenew; // Registra e nuovo
|
||||
@ -146,8 +146,8 @@ protected:
|
||||
TBill& ivas_bill(TBill& tc);
|
||||
|
||||
bool read_caus(const char* cod, int year);
|
||||
TCausale& causale() { return _causale; }
|
||||
TLibro_giornale& giornale() { return _giornale; }
|
||||
TCausale& causale() { return *_causale; }
|
||||
TLibro_giornale& giornale() { return *_giornale; }
|
||||
|
||||
bool test_swap(bool ritsoc);
|
||||
TImporto real2imp(const real& r, char tipo);
|
||||
|
@ -55,8 +55,7 @@ bool TRegistro::read(const char* cod, int year)
|
||||
}
|
||||
_rec = reg.curr();
|
||||
|
||||
if (_att.ok())
|
||||
_att.zero();
|
||||
_att.zero();
|
||||
if (err != NOERR)
|
||||
_rec.zero();
|
||||
|
||||
@ -76,22 +75,15 @@ bool TRegistro::reread()
|
||||
|
||||
int TRegistro::year() const
|
||||
{
|
||||
int anno = 0;
|
||||
if (ok())
|
||||
{
|
||||
TString16 sanno(_rec.get("CODTAB")); sanno.cut(4);
|
||||
anno = atoi(sanno);
|
||||
}
|
||||
return anno;
|
||||
TString16 anno(_rec.get("CODTAB"));
|
||||
anno.cut(4);
|
||||
return atoi(anno);
|
||||
}
|
||||
|
||||
|
||||
static TString16 n;
|
||||
const TString& TRegistro::name() const
|
||||
{
|
||||
if (ok()) n = _rec.get("CODTAB").mid(4);
|
||||
else n = "";
|
||||
return n;
|
||||
return _rec.get("CODTAB").mid(4);
|
||||
}
|
||||
|
||||
|
||||
@ -106,14 +98,14 @@ TRegistro& TRegistro::operator =(const TRegistro& r)
|
||||
|
||||
int TRegistro::tipo() const
|
||||
{
|
||||
const int t = ok() ? _rec.get_int("I0") : 0;
|
||||
const int t = _rec.get_int("I0");
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
bool TRegistro::corrispettivi() const
|
||||
{
|
||||
const bool c = ok() ? _rec.get_bool("B0") : FALSE;
|
||||
const bool c = _rec.get_bool("B0");
|
||||
return c;
|
||||
}
|
||||
|
||||
@ -355,41 +347,41 @@ const char* TCausale::desc_agg(int num) const
|
||||
}
|
||||
|
||||
const char* TCausale::descrizione() const
|
||||
{ return _rec.ok() ? _rec.get(CAU_DESCR) : ""; }
|
||||
{ return _rec.get(CAU_DESCR); }
|
||||
|
||||
const char* TCausale::codice() const
|
||||
{ return _rec.ok() ? _rec.get(CAU_CODCAUS) : ""; }
|
||||
{ return _rec.get(CAU_CODCAUS); }
|
||||
|
||||
|
||||
bool TCausale::data_doc() const
|
||||
{ return _rec.ok() ? _rec.get_bool("DATADOC") : FALSE; }
|
||||
{ return _rec.get_bool("DATADOC"); }
|
||||
|
||||
bool TCausale::num_doc() const
|
||||
{ return _rec.ok() ? _rec.get_bool("NUMDOC") : FALSE; }
|
||||
{ return _rec.get_bool("NUMDOC"); }
|
||||
|
||||
bool TCausale::apertura() const
|
||||
{ return _rec.ok() ? _rec.get_char("MOVAP") == 'A' : FALSE; }
|
||||
{ return _rec.get_char("MOVAP") == 'A'; }
|
||||
|
||||
bool TCausale::sezionale() const
|
||||
{ return _rec.ok() ? _rec.get_bool("MOVSEZ") : FALSE; }
|
||||
{ return _rec.get_bool("MOVSEZ"); }
|
||||
|
||||
bool TCausale::valuta() const
|
||||
{ return _rec.ok() ? _rec.get_bool("MOVVAL") : FALSE; }
|
||||
{ return _rec.get_bool("MOVVAL"); }
|
||||
|
||||
bool TCausale::intra() const
|
||||
{ return _rec.ok() ? _rec.get_bool("INTRACOM") : FALSE; }
|
||||
{ return _rec.get_bool("INTRACOM"); }
|
||||
|
||||
bool TCausale::valintra() const
|
||||
{ return _rec.ok() ? _rec.get_bool("VALINTRA") : FALSE; }
|
||||
{ return _rec.get_bool("VALINTRA"); }
|
||||
|
||||
const char* TCausale::causale_inc_imm() const
|
||||
{ return _rec.ok() ? _rec.get("CODCAUSIM") : ""; }
|
||||
{ return _rec.get("CODCAUSIM"); }
|
||||
|
||||
const char* TCausale::tipo_doc() const
|
||||
{ return _rec.ok() ? _rec.get("TIPODOC") : ""; }
|
||||
{ return _rec.get("TIPODOC"); }
|
||||
|
||||
bool TCausale::saldaconto() const
|
||||
{ return _rec.ok() ? (_rec.get_int("TIPOMOV") > 0) : FALSE; }
|
||||
{ return _rec.get_int("TIPOMOV") > 0; }
|
||||
|
||||
bool TCausale::ok() const
|
||||
{
|
||||
|
@ -46,13 +46,14 @@ public:
|
||||
|
||||
bool TDeleteprovv_app::create()
|
||||
{
|
||||
TApplication::create();
|
||||
dispatch_e_menu(BAR_ITEM(1));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool TDeleteprovv_app::destroy()
|
||||
{
|
||||
return TRUE;
|
||||
return TApplication::destroy();
|
||||
}
|
||||
|
||||
bool TDeleteprovv_app::menu(MENU_TAG)
|
||||
|
@ -6,20 +6,19 @@
|
||||
// *TBI* Aggiornamento cespiti
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
#include <applicat.h>
|
||||
#include <isam.h>
|
||||
#include <sort.h>
|
||||
#include <lffiles.h>
|
||||
#include <urldefid.h>
|
||||
#include <stdlib.h>
|
||||
#include <utility.h>
|
||||
#include <mask.h>
|
||||
#include <progind.h>
|
||||
|
||||
//#if XVT_OS == XVT_OS_SCOUNIX
|
||||
#include <signal.h>
|
||||
//#endif
|
||||
|
||||
#include <applicat.h>
|
||||
#include <isam.h>
|
||||
#include <mask.h>
|
||||
#include <progind.h>
|
||||
#include <sort.h>
|
||||
#include <urldefid.h>
|
||||
#include <utility.h>
|
||||
|
||||
#define FLD_CG41_YEAR 100
|
||||
#define MAX_CNT 300
|
||||
|
||||
@ -28,14 +27,8 @@
|
||||
#include <rmoviva.h>
|
||||
#include <saldi.h>
|
||||
#include <causali.h>
|
||||
#include "cglib.h"
|
||||
|
||||
// for access()
|
||||
#if XVT_OS == XVT_OS_DOS || XVT_OS == XVT_OS_WIN
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include "cglib.h"
|
||||
|
||||
struct therec {
|
||||
char DATAREG[9];
|
||||
|
@ -1,15 +1,15 @@
|
||||
#include <applicat.h>
|
||||
#include <assoc.h>
|
||||
#include <isam.h>
|
||||
#include <mask.h>
|
||||
|
||||
#include <pconti.h>
|
||||
#include <assoc.h>
|
||||
#include <urldefid.h>
|
||||
#include <prefix.h>
|
||||
#include <urldefid.h>
|
||||
|
||||
#include "cg4.h"
|
||||
#include "cg4200.h"
|
||||
|
||||
#include <pconti.h>
|
||||
|
||||
class TCopia_archivi : public TApplication
|
||||
{
|
||||
TMask* _msk;
|
||||
@ -141,6 +141,7 @@ void TCopia_archivi::copyivd(long from, long to)
|
||||
|
||||
bool TCopia_archivi::create()
|
||||
{
|
||||
TApplication::create();
|
||||
_msk = new TMask("cg4200a") ;
|
||||
_default_firm = get_firm();
|
||||
dispatch_e_menu(BAR_ITEM(1));
|
||||
@ -150,7 +151,7 @@ bool TCopia_archivi::create()
|
||||
bool TCopia_archivi::destroy()
|
||||
{
|
||||
if (_msk != NULL) delete _msk;
|
||||
return TRUE;
|
||||
return TApplication::destroy();
|
||||
}
|
||||
|
||||
bool TCopia_archivi::menu(MENU_TAG)
|
||||
|
@ -22,7 +22,7 @@ int main(int argc,char** argv)
|
||||
case 4:
|
||||
cg5400(argc,argv) ; break;
|
||||
case 5:
|
||||
cg5500(argc,argv) ; break;
|
||||
// cg5500(argc,argv) ; break;
|
||||
default:
|
||||
error_box(usage, argv[0]) ;
|
||||
}
|
||||
|
12
cg/cg5.h
12
cg/cg5.h
@ -1,6 +1,6 @@
|
||||
extern int cg5000 (int argc, char* argv[]);
|
||||
extern int cg5100 (int argc, char* argv[]);
|
||||
extern int cg5200 (int argc, char* argv[]);
|
||||
extern int cg5300 (int argc, char* argv[]);
|
||||
extern int cg5400 (int argc, char* argv[]);
|
||||
extern int cg5500 (int argc, char* argv[]);
|
||||
int cg5000 (int argc, char* argv[]);
|
||||
int cg5100 (int argc, char* argv[]);
|
||||
int cg5200 (int argc, char* argv[]);
|
||||
int cg5300 (int argc, char* argv[]);
|
||||
int cg5400 (int argc, char* argv[]);
|
||||
int cg5500 (int argc, char* argv[]);
|
||||
|
178
cg/cg5200.cpp
178
cg/cg5200.cpp
@ -1,9 +1,7 @@
|
||||
// cg5200.cpp - Visualizzazione saldi
|
||||
|
||||
#include <brwapp.h>
|
||||
#include <config.h>
|
||||
#include <msksheet.h>
|
||||
#include <relapp.h>
|
||||
#include <tabutil.h>
|
||||
#include <utility.h>
|
||||
#include <urldefid.h>
|
||||
@ -96,7 +94,11 @@ bool TRiga_array::add_riga(const TRectype& rec_saldi)
|
||||
add(r);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Visualizzazione saldi
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TSaldibrowse_application : public TBrowse_application
|
||||
{
|
||||
@ -106,7 +108,7 @@ class TSaldibrowse_application : public TBrowse_application
|
||||
TCursor * _cur;
|
||||
TRelation * _rel,* _rel1;
|
||||
TRiga_array _riga;
|
||||
int _items, _anno, _g, _c;
|
||||
int _anno, _g, _c;
|
||||
long _s;
|
||||
bool _saldo_conto, _saldo_gruppo, _saldo_sottoc;
|
||||
|
||||
@ -126,9 +128,7 @@ public:
|
||||
void add_r(int,int,real&,real&,real&,char,real&,real&,
|
||||
real&,real&,TDate&,long,real&,real&,real&);
|
||||
void compilasheet();
|
||||
void disable_all();
|
||||
bool fai_filtro();
|
||||
TMask* main_mask() const {return _msk;}
|
||||
TSheet_field& ss() const { return (TSheet_field&)_msk->field(F_SHEET_SALDI);}
|
||||
|
||||
TSaldibrowse_application() {}
|
||||
@ -153,16 +153,16 @@ bool TSaldibrowse_application::fai_filtro()
|
||||
char tipo;
|
||||
|
||||
_saldo_gruppo = _saldo_conto = _saldo_sottoc = FALSE;
|
||||
TMask* m = app().main_mask();
|
||||
tipo = m->get(F_TIPOCF)[0];
|
||||
_anno = m->get_int(F_ANNO);
|
||||
_g = m->get_int(F_GRUPPO);
|
||||
_c = m->get_int(F_CONTO);
|
||||
TMask& m = curr_mask();
|
||||
tipo = m.get(F_TIPOCF)[0];
|
||||
_anno = m.get_int(F_ANNO);
|
||||
_g = m.get_int(F_GRUPPO);
|
||||
_c = m.get_int(F_CONTO);
|
||||
if (tipo == '\0')
|
||||
_s = m->get_long(F_SOTTOCONTO);
|
||||
_s = m.get_long(F_SOTTOCONTO);
|
||||
else if (tipo == 'C')
|
||||
_s = m->get_long(F_SOTTOC_CLIENTE);
|
||||
else _s = m->get_long(F_SOTTOC_FORN);
|
||||
_s = m.get_long(F_SOTTOC_CLIENTE);
|
||||
else _s = m.get_long(F_SOTTOC_FORN);
|
||||
if (_c == 0)
|
||||
_saldo_gruppo = TRUE;
|
||||
else if (_s == 0l)
|
||||
@ -211,101 +211,64 @@ bool TSaldibrowse_application::fai_filtro()
|
||||
|
||||
bool TSaldibrowse_application::sottoc_handler(TMask_field& f, KEY key)
|
||||
{
|
||||
if ( key == K_TAB)
|
||||
{
|
||||
const int gruppo = f.mask().get_int(F_GRUPPO);
|
||||
const int conto = f.mask().get_int(F_CONTO);
|
||||
if (gruppo == 0 || conto == 0) return TRUE;
|
||||
bool ok = TRUE;
|
||||
|
||||
const short id = f.dlg();
|
||||
if (key == K_TAB)
|
||||
{
|
||||
TMask& m = f.mask();
|
||||
int gruppo = m.get_int(F_GRUPPO);
|
||||
int conto = m.get_int(F_CONTO);
|
||||
const long sottoconto = atol(f.get());
|
||||
|
||||
const short id = f.dlg();
|
||||
TLocalisamfile& pconti = app().get_relation()->lfile();
|
||||
|
||||
/*
|
||||
if (!f.focusdirty() && gruppo == 0 && conto == 0) return TRUE;
|
||||
|
||||
if (sottoconto != 0 && conto == 0)
|
||||
{
|
||||
f.warning_box("Manca il CONTO");
|
||||
f.mask().stop_run(K_ESC);
|
||||
return FALSE;
|
||||
}
|
||||
if (conto != 0 && gruppo == 0)
|
||||
{
|
||||
f.warning_box("Manca il GRUPPO");
|
||||
f.mask().stop_run(K_ESC);
|
||||
return FALSE;
|
||||
}
|
||||
*/
|
||||
if (id == F_SOTTOCONTO)
|
||||
|
||||
if (sottoconto > 0)
|
||||
{
|
||||
if (id == F_SOTTOCONTO)
|
||||
{
|
||||
if (gruppo == 0 || conto == 0)
|
||||
return TRUE;
|
||||
pconti.setkey(1);
|
||||
pconti.put(PCN_GRUPPO, gruppo) ;
|
||||
pconti.put(PCN_CONTO, conto);
|
||||
pconti.put(PCN_SOTTOCONTO, sottoconto);
|
||||
ok = pconti.read(_isequal, _nolock) == NOERR;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char tipo = id == F_SOTTOC_CLIENTE ? 'C' : 'F';
|
||||
TLocalisamfile clifo (LF_CLIFO);
|
||||
clifo.setkey(1);
|
||||
clifo.put(CLI_TIPOCF,tipo);
|
||||
clifo.put(CLI_CODCF, sottoconto) ;
|
||||
ok = clifo.read(_isequal, _nolock) == NOERR;
|
||||
if (ok && (gruppo == 0 || conto == 0))
|
||||
{
|
||||
m.set(F_GRUPPO, gruppo = clifo.get_int("GRUPPO"));
|
||||
m.set(F_CONTO, conto = clifo.get_int("CONTO"));
|
||||
ok = gruppo != 0 && conto != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pconti.setkey(1);
|
||||
pconti.zero();
|
||||
pconti.put(PCN_GRUPPO, gruppo) ;
|
||||
pconti.put(PCN_CONTO, conto);
|
||||
pconti.put(PCN_SOTTOCONTO, sottoconto);
|
||||
pconti.setkey(1);
|
||||
pconti.read(_isequal, _nolock);
|
||||
if (pconti.good())
|
||||
ok = pconti.read(_isequal, _nolock) == NOERR;
|
||||
if (ok)
|
||||
{
|
||||
TString ds = pconti.get(PCN_DESCR);
|
||||
f.mask().set(F_DESCR_CONTO, ds);
|
||||
f.mask().set(F_DESCR_CLIENTE, ds);
|
||||
f.mask().set(F_DESCR_FORN, ds);
|
||||
f.mask().stop_run(K_AUTO_ENTER);
|
||||
}
|
||||
else return f.warning_box("Registrazione assente");
|
||||
}
|
||||
else
|
||||
{
|
||||
const char tipo = id == F_SOTTOC_CLIENTE ? 'C' : 'F';
|
||||
TLocalisamfile clifo (LF_CLIFO);
|
||||
if (sottoconto != 0)
|
||||
{
|
||||
clifo.zero();
|
||||
clifo.put(CLI_TIPOCF,tipo);
|
||||
clifo.put(CLI_CODCF, sottoconto) ;
|
||||
clifo.setkey(1);
|
||||
if (clifo.read(_isequal, _nolock) == NOERR)
|
||||
{
|
||||
TString80 rs = clifo.get(CLI_RAGSOC);
|
||||
char tipoa = clifo.get_char("TIPOAPER");
|
||||
|
||||
if (tipoa == 'F')
|
||||
{
|
||||
TString80 cognome, nome;
|
||||
cognome = rs.mid(0,30);
|
||||
nome = rs.mid(30,20);
|
||||
cognome.trim(); nome.trim();
|
||||
|
||||
rs = cognome;
|
||||
rs << " " << nome;
|
||||
}
|
||||
f.mask().set(F_DESCR_CLIENTE, rs);
|
||||
f.mask().set(F_DESCR_FORN, rs);
|
||||
f.mask().stop_run(K_AUTO_ENTER);
|
||||
}
|
||||
else return f.warning_box("Registrazione assente");
|
||||
}
|
||||
else
|
||||
if (gruppo != 0 && conto != 0)
|
||||
{
|
||||
pconti.zero();
|
||||
pconti.put(PCN_GRUPPO, gruppo) ;
|
||||
pconti.put(PCN_CONTO, conto);
|
||||
pconti.setkey(1);
|
||||
pconti.read(_isequal, _nolock);
|
||||
if (pconti.good())
|
||||
{
|
||||
TString ds = pconti.get(PCN_DESCR);
|
||||
f.mask().set(F_DESCR_CLIENTE, ds);
|
||||
f.mask().set(F_DESCR_FORN, ds);
|
||||
f.mask().set(F_DESCR_CONTO, ds);
|
||||
}
|
||||
f.mask().stop_run(K_AUTO_ENTER);
|
||||
}
|
||||
m.set(id, pconti.get(PCN_DESCR));
|
||||
m.disable(id);
|
||||
}
|
||||
else m.reset(id);
|
||||
}
|
||||
if (ok) m.stop_run(K_AUTO_ENTER);
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool TSaldibrowse_application::user_create()
|
||||
@ -314,7 +277,7 @@ bool TSaldibrowse_application::user_create()
|
||||
_msk->set_handler(F_SOTTOCONTO, sottoc_handler);
|
||||
_msk->set_handler(F_SOTTOC_CLIENTE, sottoc_handler);
|
||||
_msk->set_handler(F_SOTTOC_FORN, sottoc_handler);
|
||||
disable_all();
|
||||
ss().disable();
|
||||
_clifo = new TLocalisamfile(LF_CLIFO);
|
||||
_rel = new TRelation(LF_PCON);
|
||||
_rel1 = new TRelation(LF_SALDI);
|
||||
@ -324,11 +287,6 @@ bool TSaldibrowse_application::user_create()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void TSaldibrowse_application::disable_all()
|
||||
{
|
||||
ss().disable();
|
||||
}
|
||||
|
||||
bool TSaldibrowse_application::user_destroy()
|
||||
{
|
||||
delete _msk;
|
||||
@ -357,16 +315,6 @@ void TSaldibrowse_application::add_r(int numrig,int a,real& pds,real& pas,real&
|
||||
char segno = ' ';
|
||||
|
||||
TToken_string& riga = cs.row(numrig);
|
||||
/*
|
||||
TString dep (18);
|
||||
if (sc > ZERO)
|
||||
dep << sc.string(REAL_PICTURE) << " D";
|
||||
else if (sc < ZERO)
|
||||
{
|
||||
sc = -sc;
|
||||
dep << sc.string(REAL_PICTURE) << " A";
|
||||
}
|
||||
*/
|
||||
riga.add(a, 0);
|
||||
riga.add(si.string(),1);
|
||||
if (si != ZERO)
|
||||
|
16
cg/cg5200.h
16
cg/cg5200.h
@ -2,12 +2,10 @@
|
||||
#define F_TIPOCF 102
|
||||
#define F_GRUPPO 103
|
||||
#define F_CONTO 104
|
||||
#define F_CONTO_CLIENTE 105
|
||||
#define F_CONTO_FORN 106
|
||||
#define F_SOTTOCONTO 107
|
||||
#define F_DESCR_CONTO 108
|
||||
#define F_SOTTOC_CLIENTE 109
|
||||
#define F_DESCR_CLIENTE 110
|
||||
#define F_SOTTOC_FORN 111
|
||||
#define F_DESCR_FORN 112
|
||||
#define F_SHEET_SALDI 113
|
||||
#define F_SOTTOCONTO 105
|
||||
#define F_SOTTOC_CLIENTE 106
|
||||
#define F_SOTTOC_FORN 107
|
||||
#define F_DESCR_CONTO 108
|
||||
#define F_DESCR_CLIENTE 109
|
||||
#define F_DESCR_FORN 110
|
||||
#define F_SHEET_SALDI 111
|
||||
|
@ -58,7 +58,7 @@ NUMBER F_CONTO 3
|
||||
BEGIN
|
||||
PROMPT 40 3 "Conto "
|
||||
HELP "Codice del conto da visualizzare"
|
||||
USE LF_PCON SELECT (CONTO!="") && (SOTTOCONTO="") && (TMCF="")
|
||||
USE LF_PCON SELECT (CONTO!="") && (SOTTOCONTO="")
|
||||
FIELD LF_PCON->CONTO
|
||||
KEY 1
|
||||
INPUT GRUPPO F_GRUPPO
|
||||
@ -66,64 +66,14 @@ BEGIN
|
||||
DISPLAY "Gruppo" GRUPPO
|
||||
DISPLAY "Conto" CONTO
|
||||
DISPLAY "Descrizione@50" DESCR
|
||||
OUTPUT F_CONTO CONTO
|
||||
DISPLAY "Tipo" TMCF
|
||||
OUTPUT F_TIPOCF TMCF
|
||||
OUTPUT F_GRUPPO GRUPPO
|
||||
//OUTPUT F_DESCR_CLIENTE DESCR
|
||||
//OUTPUT F_DESCR_FORN DESCR
|
||||
OUTPUT F_CONTO CONTO
|
||||
OUTPUT F_DESCR_CONTO DESCR
|
||||
FLAGS "R"
|
||||
CHECKTYPE NORMAL
|
||||
WARNING "Conto inesistente o mancante"
|
||||
MESSAGE COPY,F_CONTO_CLIENTE|COPY,F_CONTO_FORN
|
||||
GROUP 1
|
||||
END
|
||||
|
||||
NUMBER F_CONTO_CLIENTE 3
|
||||
BEGIN
|
||||
PROMPT 40 3 "Conto "
|
||||
HELP "Codice del conto da visualizzare"
|
||||
USE LF_PCON SELECT (CONTO!="") && (SOTTOCONTO="") && (TMCF="C")
|
||||
FIELD LF_PCON->CONTO
|
||||
KEY 1
|
||||
INPUT GRUPPO F_GRUPPO
|
||||
INPUT CONTO F_CONTO_CLIENTE
|
||||
DISPLAY "Gruppo" GRUPPO
|
||||
DISPLAY "Conto" CONTO
|
||||
DISPLAY "Descrizione@50" DESCR
|
||||
OUTPUT F_CONTO_CLIENTE CONTO
|
||||
OUTPUT F_GRUPPO GRUPPO
|
||||
//OUTPUT F_DESCR_CLIENTE DESCR
|
||||
//OUTPUT F_DESCR_FORN DESCR
|
||||
//OUTPUT F_DESCR_CONTO DESCR
|
||||
FLAGS "R"
|
||||
CHECKTYPE NORMAL
|
||||
WARNING "Conto inesistente o mancante"
|
||||
MESSAGE COPY,F_CONTO|COPY,F_CONTO_FORN
|
||||
GROUP 2
|
||||
END
|
||||
|
||||
NUMBER F_CONTO_FORN 3
|
||||
BEGIN
|
||||
PROMPT 40 3 "Conto "
|
||||
HELP "Codice del conto da visualizzare"
|
||||
USE LF_PCON SELECT (CONTO!="") && (SOTTOCONTO="") && (TMCF="F")
|
||||
FIELD LF_PCON->CONTO
|
||||
KEY 1
|
||||
INPUT GRUPPO F_GRUPPO
|
||||
INPUT CONTO F_CONTO_FORN
|
||||
DISPLAY "Gruppo" GRUPPO
|
||||
DISPLAY "Conto" CONTO
|
||||
DISPLAY "Descrizione@50" DESCR
|
||||
OUTPUT F_CONTO_FORN CONTO
|
||||
OUTPUT F_GRUPPO GRUPPO
|
||||
//OUTPUT F_DESCR_CLIENTE DESCR
|
||||
//OUTPUT F_DESCR_FORN DESCR
|
||||
//OUTPUT F_DESCR_CONTO DESCR
|
||||
FLAGS "R"
|
||||
CHECKTYPE NORMAL
|
||||
WARNING "Conto inesistente o mancante"
|
||||
MESSAGE COPY,F_CONTO_CLIENTE|COPY,F_CONTO
|
||||
GROUP 3
|
||||
END
|
||||
|
||||
NUMBER F_SOTTOCONTO 6
|
||||
@ -144,13 +94,8 @@ BEGIN
|
||||
OUTPUT F_CONTO CONTO
|
||||
OUTPUT F_SOTTOCONTO SOTTOCONTO
|
||||
OUTPUT F_DESCR_CONTO DESCR
|
||||
//OUTPUT F_DESCR_CLIENTE DESCR
|
||||
//OUTPUT F_DESCR_FORN DESCR
|
||||
//MESSAGE COPY,F_SOTTOC_FORN
|
||||
//MESSAGE COPY,F_SOTTOC_CLIENTE
|
||||
FLAGS "R"
|
||||
CHECKTYPE NORMAL
|
||||
//VALIDATE AUTOEXIT_FUNC 3 F_GRUPPO F_CONTO F_SOTTOCONTO //come pure questo
|
||||
GROUP 1
|
||||
WARNING "Conto inesistente"
|
||||
END
|
||||
@ -160,7 +105,6 @@ BEGIN
|
||||
PROMPT 54 3 "Cliente "
|
||||
HELP "Codice del conto da visualizzare"
|
||||
USE LF_CLIFO
|
||||
//FIELD LF_CLIFO->CODCF
|
||||
INPUT TIPOCF "C"
|
||||
INPUT CODCF F_SOTTOC_CLIENTE
|
||||
DISPLAY "Codice" CODCF
|
||||
@ -168,16 +112,11 @@ BEGIN
|
||||
DISPLAY "Gruppo" GRUPPO
|
||||
DISPLAY "Conto" CONTO
|
||||
OUTPUT F_SOTTOC_CLIENTE CODCF
|
||||
OUTPUT F_GRUPPO GRUPPO
|
||||
OUTPUT F_CONTO_CLIENTE CONTO
|
||||
//OUTPUT F_DESCR_CONTO RAGSOC
|
||||
OUTPUT F_DESCR_CLIENTE RAGSOC
|
||||
//OUTPUT F_DESCR_FORN RAGSOC
|
||||
FLAGS "R"
|
||||
CHECKTYPE NORMAL
|
||||
KEY 1
|
||||
WARNING "Cliente inesistente"
|
||||
//VALIDATE AUTOEXIT_FUNC 3 F_GRUPPO F_CONTO F_SOTTOC_CLIENTE
|
||||
GROUP 2
|
||||
END
|
||||
|
||||
@ -193,16 +132,11 @@ BEGIN
|
||||
DISPLAY "Gruppo" GRUPPO
|
||||
DISPLAY "Conto" CONTO
|
||||
OUTPUT F_SOTTOC_FORN CODCF
|
||||
OUTPUT F_GRUPPO GRUPPO
|
||||
OUTPUT F_CONTO_FORN CONTO
|
||||
OUTPUT F_DESCR_FORN RAGSOC
|
||||
// OUTPUT F_DESCR_CONTO RAGSOC
|
||||
// OUTPUT F_DESCR_CLIENTE RAGSOC
|
||||
FLAGS "R"
|
||||
CHECKTYPE NORMAL
|
||||
KEY 1
|
||||
WARNING "Fornitore inesistente"
|
||||
//VALIDATE AUTOEXIT_FUNC 3 F_GRUPPO F_CONTO F_SOTTOC_FORN
|
||||
GROUP 3
|
||||
END
|
||||
|
||||
@ -304,6 +238,7 @@ STRING 103 1
|
||||
BEGIN
|
||||
PROMPT 44 3 ""
|
||||
HELP "Sezione del saldo iniziale"
|
||||
FLAGS ""
|
||||
END
|
||||
|
||||
NUMBER 104 15
|
||||
@ -333,6 +268,7 @@ END
|
||||
STRING 107 1
|
||||
BEGIN
|
||||
PROMPT 44 5 ""
|
||||
FLAGS "R"
|
||||
HELP "Sezione del saldo attuale del conto"
|
||||
END
|
||||
|
||||
@ -364,6 +300,7 @@ STRING 111 1
|
||||
BEGIN
|
||||
PROMPT 44 7 ""
|
||||
HELP "Sezione del saldo attuale complessivo del conto"
|
||||
FLAGS "R"
|
||||
END
|
||||
|
||||
DATE 112
|
||||
@ -407,7 +344,8 @@ END
|
||||
STRING 117 1
|
||||
BEGIN
|
||||
PROMPT 44 11 ""
|
||||
HELP "Sezione del saldo progressivi dei moviemnti provvisori del conto"
|
||||
HELP "Sezione del saldo progressivi dei movimenti provvisori del conto"
|
||||
FLAGS "R"
|
||||
END
|
||||
|
||||
BUTTON DLG_CANCEL 9 2
|
||||
|
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 <isam.h>
|
||||
#include <mask.h>
|
||||
#include <prefix.h>
|
||||
#include <progind.h>
|
||||
#include <relation.h>
|
||||
#include <tabutil.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()
|
||||
{
|
||||
TApplication::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 TApplication::destroy();
|
||||
}
|
||||
|
||||
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