Aggiunte utili (indispensabili!) setkey(1) ovunque ci fosse una read

git-svn-id: svn://10.65.10.50/trunk@728 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-12-05 14:21:36 +00:00
parent 0bc26beeb3
commit f653e062d1
8 changed files with 2883 additions and 2900 deletions

View File

@ -1631,6 +1631,14 @@ bool TPrimanota_application::corrlire_handler(TMask_field& f, KEY key)
} }
} }
if (key == K_ENTER)
{
const TString16 im(m.get(F_IMPONIBILI));
const char* cl = f.get();
if (im != cl)
warning_box("Il corrispettivo in lire e' diverso dal totale degli imponibili");
}
return TRUE; return TRUE;
} }

View File

@ -46,6 +46,7 @@ bool TRegistro::read(const char* cod, int year)
int err = ~NOERR; int err = ~NOERR;
TTable reg("REG"); TTable reg("REG");
reg.setkey(1);
if (cod && *cod > ' ') if (cod && *cod > ' ')
{ {
TString16 chiave; chiave.format("%04d%s", year, cod); TString16 chiave; chiave.format("%04d%s", year, cod);
@ -144,6 +145,7 @@ bool TRegistro::read_att()
return TRUE; return TRUE;
TLocalisamfile attiv(LF_ATTIV); TLocalisamfile attiv(LF_ATTIV);
attiv.setkey(1);
attiv.put("CODDITTA", main_app().get_firm()); attiv.put("CODDITTA", main_app().get_firm());
attiv.put("CODATT", attivita()); attiv.put("CODATT", attivita());
const int err = attiv.read(); const int err = attiv.read();
@ -220,17 +222,16 @@ bool TRegistro::update(long protiva, const TDate& datareg)
// Legge il libro giornale dell'anno specificato // Legge il libro giornale dell'anno specificato
bool TLibro_giornale::read(int y) bool TLibro_giornale::read(int y)
{ {
bool found = FALSE;
if (y <= 0) if (y <= 0)
{ {
const TDate oggi(TODAY); const TDate oggi(TODAY);
y = oggi.year(); y = oggi.year();
} }
TTable reg("REG");
bool found = FALSE;
TString16 anno; anno.format("%04d", y); TString16 anno; anno.format("%04d", y);
TTable reg("REG");
reg.setkey(1); reg.setkey(1);
reg.put("CODTAB", anno); // Cerca il primo registro dell'anno y reg.put("CODTAB", anno); // Cerca il primo registro dell'anno y
@ -260,8 +261,9 @@ TLibro_giornale::TLibro_giornale(int y)
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
TCausale::TCausale(const char* cod, int year) TCausale::TCausale(const char* cod, int year)
: TArray(12), _rec(LF_CAUSALI), _iva(iva_errata), : TArray(12), _rec(LF_CAUSALI),
_sezione_clifo(' '), _sezione_ritsoc(' '), _corrisp(FALSE) _iva(iva_errata), _corrisp(FALSE),
_sezione_clifo(' '), _sezione_ritsoc(' ')
{ {
if (*cod) read(cod, year); if (*cod) read(cod, year);
} }
@ -281,7 +283,6 @@ bool TCausale::read(const char* cod, int year)
if (*cod > ' ') if (*cod > ' ')
{ {
caus.setkey(1); caus.setkey(1);
caus.zero();
caus.put(CAU_CODCAUS, cod); caus.put(CAU_CODCAUS, cod);
int err = caus.read(); int err = caus.read();
@ -290,7 +291,6 @@ bool TCausale::read(const char* cod, int year)
TLocalisamfile rcaus(LF_RCAUSALI); TLocalisamfile rcaus(LF_RCAUSALI);
rcaus.setkey(1); rcaus.setkey(1);
rcaus.zero();
rcaus.put(CAU_CODCAUS, cod); rcaus.put(CAU_CODCAUS, cod);
rcaus.put(CAU_NRIGA, 0); rcaus.put(CAU_NRIGA, 0);
@ -312,6 +312,7 @@ bool TCausale::read(const char* cod, int year)
if (!ok && codreg.not_empty()) if (!ok && codreg.not_empty())
return error_box("Non esiste il registro '%s' per l'anno %d", return error_box("Non esiste il registro '%s' per l'anno %d",
(const char*)codreg, year); (const char*)codreg, year);
calcIVA();
} }
else else
{ {
@ -429,17 +430,16 @@ char TCausale::sezione_ritsoc()
return _sezione_ritsoc; return _sezione_ritsoc;
} }
TipoIVA TCausale::iva() const void TCausale::calcIVA()
{ {
if (_iva == iva_errata)
{
TipoIVA i = nessuna_iva; // Tipo IVA di default TipoIVA i = nessuna_iva; // Tipo IVA di default
bool c = FALSE; // Corrispettivi di default bool c = FALSE; // Corrispettivi di default
TString16 tipodoc(_rec.get("TIPODOC")); const TString16 tipodoc(_rec.get("TIPODOC"));
if (tipodoc.not_empty()) if (tipodoc.not_empty())
{ {
TTable tpd("%TPD"); TTable tpd("%TPD");
tpd.setkey(1);
tpd.put("CODTAB", tipodoc); tpd.put("CODTAB", tipodoc);
if (tpd.read() == NOERR) if (tpd.read() == NOERR)
{ {
@ -449,22 +449,15 @@ TipoIVA TCausale::iva() const
i = ri; i = ri;
if (i != ri) if (i != ri)
{ {
error_box("Tipo documento incompatibile con tipo registro"); error_box("Tipo documento '%s' incompatibile con tipo registro", (const char*)tipodoc);
i = iva_errata; i = iva_errata;
} }
c = tpd.get_bool("B0"); c = tpd.get_bool("B0");
} }
else error_box("Tipo documento sconosciuto: '%s'", (const char*)tipodoc);
} }
((TCausale*)this)->_iva = i; // Ricorda IVA per la prossima volta _iva = i;
((TCausale*)this)->_corrisp = c; // Ricorda flag per la prossima volta _corrisp = c;
}
return _iva;
}
bool TCausale::corrispettivi() const
{
if (_iva == iva_errata) iva();
return _corrisp;
} }
bool TCausale::similar(const TCausale& c) const bool TCausale::similar(const TCausale& c) const

View File

@ -80,6 +80,7 @@ class TCausale : public TArray
protected: protected:
const TRectype& row(int num) const; const TRectype& row(int num) const;
void calcIVA();
public: public:
TBill& bill(int num, TBill& c) const; TBill& bill(int num, TBill& c) const;
@ -99,8 +100,8 @@ public:
const char* tipo_doc() const; const char* tipo_doc() const;
TRegistro& reg() const { return (TRegistro&)_reg; } TRegistro& reg() const { return (TRegistro&)_reg; }
TipoIVA iva() const; TipoIVA iva() const { return _iva; }
bool corrispettivi() const; bool corrispettivi() const { return _corrisp; }
bool saldaconto() const; bool saldaconto() const;
virtual bool ok() const; virtual bool ok() const;

View File

@ -89,6 +89,7 @@ bool TDeleteprovv_app::menu(MENU_TAG)
TProgind pi(total, caption, FALSE, TRUE, 24); TProgind pi(total, caption, FALSE, TRUE, 24);
cur.freeze();
for (cur = first; cur.pos() <= last; ++cur) for (cur = first; cur.pos() <= last; ++cur)
{ {
const long numreg = mov.get_long(MOV_NUMREG); const long numreg = mov.get_long(MOV_NUMREG);
@ -115,11 +116,13 @@ bool TDeleteprovv_app::menu(MENU_TAG)
if (err == NOERR) if (err == NOERR)
{ {
const TRecnotype n = mov.recno();
mov.setkey(1); // Isam bug on remove with key != 1 mov.setkey(1); // Isam bug on remove with key != 1
mov.readat(n);
err = mov.remove(); err = mov.remove();
} if (err != NOERR)
else
caption = "testata"; caption = "testata";
}
if (err == NOERR) if (err == NOERR)
pi.addstatus(1); pi.addstatus(1);
@ -130,6 +133,7 @@ bool TDeleteprovv_app::menu(MENU_TAG)
break; break;
} }
} }
cur.freeze(FALSE);
} }
return FALSE; return FALSE;
@ -139,6 +143,6 @@ bool TDeleteprovv_app::menu(MENU_TAG)
int cg2200(int argc, char** argv) int cg2200(int argc, char** argv)
{ {
TDeleteprovv_app a; TDeleteprovv_app a;
a.run(argc, argv, "Eliminazione movimenti provvisori"); a.run(argc, argv, "Eliminazione provvisori");
return 0; return 0;
} }

View File

@ -1291,16 +1291,9 @@ void TMastrini_application::ricerca_dati_ditta()
_comuni->setkey(1); _comuni->setkey(1);
_comuni->curr().zero(); _comuni->curr().zero();
_comuni->curr().put(COM_COM,_comulc); _comuni->curr().put(COM_COM,_comulc);
if (_comuni->read() == NOERR) _comuni->read();
{
_com=_comuni->curr().get(COM_DENCOM); _com=_comuni->curr().get(COM_DENCOM);
_prov=_comuni->curr().get(COM_PROVCOM); _prov=_comuni->curr().get(COM_PROVCOM);
}
else
{
_com="";
_prov="";
}
} }
// Crea l'intestazione per la stampa a 132 e a 198 caratteri // Crea l'intestazione per la stampa a 132 e a 198 caratteri
@ -1674,7 +1667,6 @@ void TMastrini_application::ricerca_clifo()
paiv = clifo.get(CLI_PAIV); paiv = clifo.get(CLI_PAIV);
cofi = clifo.get(CLI_COFI); cofi = clifo.get(CLI_COFI);
indcf = clifo.get(CLI_INDCF); indcf = clifo.get(CLI_INDCF);
indcf << " " << clifo.get(CLI_CIVCF);
capcf = clifo.get(CLI_CAPCF); capcf = clifo.get(CLI_CAPCF);
ptel = clifo.get(CLI_PTEL); ptel = clifo.get(CLI_PTEL);
tel = clifo.get(CLI_TEL); tel = clifo.get(CLI_TEL);
@ -1685,16 +1677,9 @@ void TMastrini_application::ricerca_clifo()
_comuni->curr().zero(); _comuni->curr().zero();
_comuni->curr().put(COM_STATO, statocf); _comuni->curr().put(COM_STATO, statocf);
_comuni->curr().put(COM_COM, comcf); _comuni->curr().put(COM_COM, comcf);
if (_comuni->read() == NOERR) _comuni->read();
{
dencom = _comuni->curr().get(COM_DENCOM); dencom = _comuni->curr().get(COM_DENCOM);
provcom = _comuni->curr().get(COM_PROVCOM); provcom = _comuni->curr().get(COM_PROVCOM);
}
else
{
dencom = "";
provcom = "";
}
pconti.setkey(1); pconti.setkey(1);
pconti.zero(); pconti.zero();
@ -1750,28 +1735,19 @@ void TMastrini_application::ricerca_clifo()
set_header (5, "Comp. da@9g%s", (const char*) dataini); set_header (5, "Comp. da@9g%s", (const char*) dataini);
set_header (5, "@20ga@22g%s", (const char*) datafine); set_header (5, "@20ga@22g%s", (const char*) datafine);
} }
TParagraph_string s(indcf), s1(dencom);
set_header (5, "@33gP.I.@37g%-11s",(const char*) paiv); set_header (5, "@33gP.I.@37g%-11s",(const char*) paiv);
set_header (5, "@49gCF@52g%-16s",(const char*) cofi); set_header (5, "@49gCF@52g%-16s",(const char*) cofi);
set_header (5, "@69g%-25s", s.get()); set_header (5, "@69g%-25s",(const char*) indcf);
set_header (5, "@95g%-5s",(const char*) capcf); set_header (5, "@95g%-5s",(const char*) capcf);
set_header (5, "@101g%-25s", s1.get()); set_header (5, "@101g%-24s",(const char*) dencom);
set_header (5,"@127g%-5s",(const char*) provcom); set_header (5,"@126g%-5s",(const char*) provcom);
if (_numcarat == 2) if (_numcarat == 2)
{ {
set_header (5,"@134g%-4s",(const char*) ptel); set_header (5,"@134g%-4s",(const char*) ptel);
set_header (5,"@138g/@139g%-10s",(const char*) tel); set_header (5,"@138g/@139g%-10s",(const char*) tel);
} }
const char * p = s.get();
if (p != NULL)
set_header (5, "@69g%-25s", p);
p = s1.get();
if (p != NULL)
set_header (5, "@101g%-25s", p);
} }
// Se la ricerca selezionata sulla maschera e' per gruppo, conto, sottoconto // Se la ricerca selezionata sulla maschera e' per gruppo, conto, sottoconto
@ -1975,3 +1951,4 @@ int cg3200(int argc, char* argv[])
return 0; return 0;
} }