Files correlati : fp Commento : Programma aggiornamento cod clifo: - Aggiunta ricerca per rag. soc. - Aggiunto reset sheet
243 lines
5.4 KiB
C++
243 lines
5.4 KiB
C++
#include <applicat.h>
|
|
#include <automask.h>
|
|
#include <config.h>
|
|
#include "fplib.h"
|
|
#include <progind.h>
|
|
#include <cfven.h>
|
|
#include <doc.h>
|
|
|
|
#include "../ve/velib05.h"
|
|
#include "../cg/cglib03.h"
|
|
#include "../fe/felib.h"
|
|
|
|
#include "fp0.h"
|
|
#include "fp0200a.h"
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////
|
|
// TCC_mask
|
|
/////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
class TCC_mask : public TAutomask
|
|
{
|
|
protected:
|
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly) override;
|
|
void fill();
|
|
void init();
|
|
void save_all();
|
|
|
|
public:
|
|
TCC_mask() : TAutomask("fp0200a") {}
|
|
};
|
|
|
|
bool TCC_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
{
|
|
switch (o.dlg())
|
|
{
|
|
case DLG_RECALC:
|
|
if (e == fe_button)
|
|
fill();
|
|
break;
|
|
|
|
case DLG_SAVEREC:
|
|
if (e == fe_button)
|
|
save_all();
|
|
break;
|
|
|
|
case DLG_USER:
|
|
if (e == fe_button && jolly > 0)
|
|
{
|
|
TSheet_field& clifo = sfield(F_RIGHE);
|
|
TToken_string& row = clifo.row(clifo.selected());
|
|
TRectype rec(LF_CLIFO);
|
|
rec.put(CLI_TIPOCF, get(F_TIPOCF));
|
|
rec.put(CLI_CODCF, row.get(0));
|
|
if (rec.edit())
|
|
fill();
|
|
}
|
|
break;
|
|
|
|
case F_TIPOCF:
|
|
if(e == fe_modify)
|
|
{
|
|
set(F_DACODCF, "");
|
|
set(F_ACODCF, "");
|
|
}
|
|
break;
|
|
|
|
case S_CODSDI:
|
|
if(e == fe_modify)
|
|
{
|
|
if (o.mask().get_bool(S_ISPA))
|
|
{
|
|
if (o.mask().get(S_CODSDI).len() != 6)
|
|
{
|
|
warning_box("La lunghezza di un codice SDI di una P.A. deve essere di 6 caratteri!");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (o.mask().get(S_CODSDI).len() != 7)
|
|
{
|
|
warning_box("La lunghezza di un codice SDI di un privato deve essere di 7 caratteri!");
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
default: break;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
void TCC_mask::fill()
|
|
{
|
|
TSheet_field& righe = sfield(F_RIGHE);
|
|
righe.reset();
|
|
TString_array& sht = righe.rows_array();
|
|
|
|
TString query;
|
|
|
|
query << "USE CLIFO \n" <<
|
|
"JOIN CFVEN TO CLIFO INTO TIPOCF==TIPOCF CODCF==CODCF \n"<<
|
|
"FROM TIPOCF=#DATIPOCF ";
|
|
if (get(F_DACODCF).full())
|
|
query << "CODCF=#DACODCF";
|
|
|
|
query << "\nTO TIPOCF=#ATIPOCF ";
|
|
if (get(F_DACODCF).full())
|
|
query << "CODCF=#ACODCF";
|
|
|
|
TISAM_recordset rec(query);
|
|
|
|
// Valorizzo le variabili
|
|
rec.set_var("#DATIPOCF", get(F_TIPOCF));
|
|
rec.set_var("#ATIPOCF", get(F_TIPOCF));
|
|
if (get(F_DACODCF).full())
|
|
rec.set_var("#DACODCF", get(F_DACODCF));
|
|
if (get(F_DACODCF).full())
|
|
rec.set_var("#ACODCF", get(F_ACODCF));
|
|
|
|
TProgress_monitor pi(rec.items(), "Caricamento lista C/F");
|
|
for (bool okc = rec.move_first(); okc; okc = rec.move_next())
|
|
{
|
|
if (!pi.add_status())
|
|
break;
|
|
const TRectype& doc = rec.cursor()->curr();
|
|
TToken_string& row = righe.row(-1);
|
|
|
|
|
|
row.add(rec.get(CLI_CODCF).as_string());
|
|
row.add(rec.get(CLI_RAGSOC).as_string());
|
|
row.add(rec.get(CLI_ALLEG).as_int() == 7 ? "X" : "");
|
|
row.add(rec.get(CLI_PEC).as_string());
|
|
row.add(rec.get("17." CFV_PADESTIN).as_string());
|
|
|
|
}
|
|
righe.force_update();
|
|
righe.show();
|
|
}
|
|
|
|
void TCC_mask::save_all()
|
|
{
|
|
TString_array& sht = sfield(F_RIGHE).rows_array();
|
|
|
|
TLocalisamfile clifo(LF_CLIFO), cfven(LF_CFVEN);
|
|
int ok = NOERR;
|
|
if (!sht.empty())
|
|
{
|
|
TProgress_monitor pi(sht.items(), "Salvataggio dati");
|
|
FOR_EACH_ARRAY_ROW(sht, r, riga)
|
|
{
|
|
if (!pi.add_status())
|
|
break;
|
|
|
|
clifo.zero();
|
|
clifo.put(CLI_TIPOCF, get(F_TIPOCF));
|
|
clifo.put(CLI_CODCF, riga->get(xvtil_cid2index(S_CODCF)));
|
|
|
|
const int clifo_err = clifo.read();
|
|
if (clifo_err == NOERR)
|
|
{
|
|
clifo.put(CLI_PEC, riga->get(xvtil_cid2index(S_PEC)));
|
|
if (clifo.rewrite() != NOERR)
|
|
{
|
|
TString msg = "Fallito salvataggio record in CLIFO";
|
|
msg << clifo.get(CLI_TIPOCF) << " " << clifo.get(CLI_CODCF) << "\nSalvataggio abortito";
|
|
error_box(msg);
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
TString msg = "Impossibile trovare in CLIFO ";
|
|
msg << clifo.get(CLI_TIPOCF) << " " << clifo.get(CLI_CODCF) << " errore " << clifo_err <<".\nSalvataggio abortito";
|
|
error_box(msg);
|
|
break;
|
|
}
|
|
|
|
cfven.zero();
|
|
cfven.put(CFV_TIPOCF, get(F_TIPOCF));
|
|
cfven.put(CFV_CODCF, riga->get(xvtil_cid2index(S_CODCF)));
|
|
const int err = cfven.read();
|
|
if (err == NOERR || err == _iskeynotfound)
|
|
{
|
|
cfven.put(CFV_PADESTIN, riga->get(xvtil_cid2index(S_CODSDI)));
|
|
if (cfven.rewrite_write() != NOERR)
|
|
{
|
|
TString msg = "Fallito salvataggio record in CFVEN ";
|
|
msg << cfven.get(CFV_TIPOCF) << " " << cfven.get(CFV_CODCF) << "\nSalvataggio abortito";
|
|
error_box(msg);
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
TString msg = "Impossibile trovare in CFVEN ";
|
|
msg << clifo.get(CLI_TIPOCF) << " " << clifo.get(CLI_CODCF) << " errore " << clifo_err << ".\nSalvataggio abortito";
|
|
error_box(msg);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////
|
|
// TDoc2Paf
|
|
/////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
class TCC_app : public TSkeleton_application
|
|
{
|
|
|
|
public:
|
|
bool create() override;
|
|
virtual void main_loop();
|
|
|
|
TCC_app() {}
|
|
};
|
|
|
|
bool TCC_app::create()
|
|
{
|
|
open_files(LF_CLIFO, LF_CFVEN, 0);
|
|
|
|
TRectype cfven(LF_CFVEN);
|
|
if (cfven.length(CFV_PADESTIN) != 7) // Nuova lunghezza per privati
|
|
return error_box(TR("Database non convertito per fatturazione F.P."));
|
|
|
|
return TSkeleton_application::create();
|
|
|
|
}
|
|
|
|
void TCC_app::main_loop()
|
|
{
|
|
int ndocs = 0;
|
|
TCC_mask mask;
|
|
|
|
while (mask.run() == K_ENTER) {}
|
|
}
|
|
|
|
int fp0200(int argc, char* argv[])
|
|
{
|
|
TCC_app app;
|
|
app.run(argc, argv, TR("Inserimento massivo codici F.P."));
|
|
return 0;
|
|
} |