152 lines
3.5 KiB
C++
152 lines
3.5 KiB
C++
#include <applicat.h>
|
||
#include <automask.h>
|
||
#include <progind.h>
|
||
#include <recarray.h>
|
||
#include <recset.h>
|
||
#include <relation.h>
|
||
#include <reputils.h>
|
||
#include <sheet.h>
|
||
|
||
#include <mov.h>
|
||
#include <nditte.h>
|
||
#include <partite.h>
|
||
#include <rmov.h>
|
||
|
||
class TXRef_mask : public TAutomask
|
||
{
|
||
protected:
|
||
virtual bool on_field_event(TOperable_field& o, TField_event fe, long jolly);
|
||
void test_rmov();
|
||
|
||
public:
|
||
TXRef_mask(const char* title);
|
||
};
|
||
|
||
void TXRef_mask::test_rmov()
|
||
{
|
||
TLog_report log;
|
||
|
||
TFast_isamfile mov(LF_MOV);
|
||
TFast_isamfile part(LF_PARTITE); part.setkey(2);
|
||
|
||
TString msg;
|
||
TISAM_recordset rmov_set("USE RMOV");
|
||
const TRectype& rmov = rmov_set.cursor()->curr();
|
||
TProgress_monitor pm(rmov_set.items(), TR("Scansione righe contabili"));
|
||
for (bool ok = rmov_set.move_first(); ok; ok = rmov_set.move_next())
|
||
{
|
||
const long numreg = rmov.get_long(RMV_NUMREG);
|
||
const int numrig = rmov.get_int(RMV_NUMRIG);
|
||
|
||
msg.format(FR("Riga %3d del movimento %7ld del %s: "), numrig, numreg, (const char*)rmov.get(RMV_DATAREG));
|
||
|
||
if (numreg != mov.get_long(MOV_NUMREG))
|
||
{
|
||
mov.put(MOV_NUMREG, numreg);
|
||
if (mov.read() != NOERR)
|
||
mov.zero();
|
||
}
|
||
if (numreg != mov.get_long(MOV_NUMREG))
|
||
{
|
||
msg << TR("manca il record di testata");
|
||
log.log(2, msg);
|
||
}
|
||
if (rmov.get_char(RMV_ROWTYPE) == 'K')
|
||
{
|
||
part.put(PART_NREG, numreg);
|
||
part.put(PART_NUMRIG, numrig);
|
||
if (part.read() != NOERR)
|
||
{
|
||
msg << TR("manca il record di saldaconto");
|
||
log.log(2, msg);
|
||
}
|
||
}
|
||
if (!pm.add_status())
|
||
break;
|
||
}
|
||
|
||
log.preview();
|
||
}
|
||
|
||
bool TXRef_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||
{
|
||
switch (o.dlg())
|
||
{
|
||
case DLG_USER:
|
||
if (e == fe_button)
|
||
{
|
||
TArray_sheet sheet(-1, -1, 70, 20, TR("Scelta ditta"), HR("Codice|Ragione Sociale@50"));
|
||
TToken_string row;
|
||
TLocalisamfile ditte(LF_NDITTE);
|
||
|
||
FOR_EACH_FILE_RECORD(ditte)
|
||
{
|
||
const long cod = ditte.get_long(NDT_CODDITTA);
|
||
if (prefix().exist(cod))
|
||
{
|
||
row.cut(0);
|
||
row.add(cod);
|
||
row.add(ditte.get(NDT_RAGSOC));
|
||
|
||
const long pos = sheet.add(row);
|
||
if (cod == prefix().get_codditta())
|
||
sheet.select(pos);
|
||
}
|
||
}
|
||
if (sheet.run() == K_ENTER)
|
||
set(DLG_USER, sheet.row().get(0), 0x3);
|
||
return false;
|
||
}
|
||
if (e == fe_modify || e == fe_close)
|
||
{
|
||
const long cod = atol(o.get());
|
||
if (prefix().exist(cod))
|
||
prefix().set_codditta(cod);
|
||
else
|
||
return error_box(FR("La ditta %05ld non <20> attivata per la contabilit<69>"), cod);
|
||
}
|
||
break;
|
||
case DLG_SELECT:
|
||
if (e == fe_button)
|
||
{
|
||
test_rmov();
|
||
return false;
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
TXRef_mask::TXRef_mask(const char* title) : TAutomask(title, 1, 30, 5)
|
||
{
|
||
add_number(DLG_USER, 0, TR("Codice ditta "), 1, 1, 5, "BUF");
|
||
add_button(DLG_SELECT, 0, "", -12, -1, 10, 2);
|
||
add_button(DLG_QUIT, 0, "", -22, -1, 10, 2);
|
||
set_handlers();
|
||
}
|
||
|
||
|
||
class TXRef_check: public TSkeleton_application
|
||
{
|
||
public:
|
||
const char* app_name() const { return TR("Controllo integrit<69> archivi"); }
|
||
virtual void main_loop();
|
||
};
|
||
|
||
void TXRef_check::main_loop()
|
||
{
|
||
open_files(LF_CLIFO, LF_NDITTE, LF_PCON, LF_MOV, LF_RMOV, LF_RMOVIVA,
|
||
LF_PARTITE, LF_SCADENZE, LF_PAGSCA, 0);
|
||
|
||
TXRef_mask m(app_name());
|
||
while (m.run() != K_QUIT);
|
||
}
|
||
|
||
void xref_check(int argc, char* argv[])
|
||
{
|
||
TXRef_check ez;
|
||
ez.run(argc, argv, ez.app_name());
|
||
}
|