214 lines
4.9 KiB
C++
214 lines
4.9 KiB
C++
|
#include <applicat.h>
|
||
|
#include <execp.h>
|
||
|
#include <progind.h>
|
||
|
#include <reprint.h>
|
||
|
|
||
|
#include "ca3.h"
|
||
|
#include "ca3800.h"
|
||
|
#include "calib01.h"
|
||
|
#include "calib02.h"
|
||
|
|
||
|
////////////////////////////////////////////////////////
|
||
|
// MASCHERA
|
||
|
////////////////////////////////////////////////////////
|
||
|
class TPrint_bilancio_cms_mask : public TAnal_report_mask
|
||
|
{
|
||
|
protected:
|
||
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||
|
const TString& get_report_class() const;
|
||
|
bool test_compatible_report();
|
||
|
|
||
|
public:
|
||
|
TPrint_bilancio_cms_mask();
|
||
|
virtual ~TPrint_bilancio_cms_mask() {}
|
||
|
};
|
||
|
|
||
|
const TString& TPrint_bilancio_cms_mask::get_report_class() const
|
||
|
{
|
||
|
TString& classe = get_tmp_string();
|
||
|
classe = "ca3800a";
|
||
|
return classe;
|
||
|
}
|
||
|
|
||
|
bool TPrint_bilancio_cms_mask::test_compatible_report()
|
||
|
{
|
||
|
const TString& cls = get_report_class();
|
||
|
const TString& name = get(F_REPORT);
|
||
|
bool ok = name.not_empty();
|
||
|
if (ok)
|
||
|
{
|
||
|
TReport rep;
|
||
|
ok = rep.load(name);
|
||
|
if (ok)
|
||
|
{
|
||
|
const TString& classe = rep.get_class();
|
||
|
ok = classe == cls;
|
||
|
}
|
||
|
}
|
||
|
if (!ok)
|
||
|
{
|
||
|
set(F_REPORT, cls);
|
||
|
TFilename path = cls;
|
||
|
path.ext("rep");
|
||
|
ok = path.custom_path();
|
||
|
}
|
||
|
return ok;
|
||
|
}
|
||
|
|
||
|
bool TPrint_bilancio_cms_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||
|
{
|
||
|
switch (o.dlg())
|
||
|
{
|
||
|
case F_REPORT:
|
||
|
if (e == fe_button)
|
||
|
{
|
||
|
const TString8 lib = get_report_class();
|
||
|
TFilename path = o.get();
|
||
|
if (select_custom_file(path, "rep", lib))
|
||
|
{
|
||
|
path = path.name();
|
||
|
path.ext("");
|
||
|
o.set(path);
|
||
|
}
|
||
|
} else
|
||
|
if (e == fe_close)
|
||
|
{
|
||
|
if (!test_compatible_report())
|
||
|
return error_box(TR("Impossibile trovare un report compatibile"));
|
||
|
}
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
return TAnal_report_mask::on_field_event(o, e, jolly);
|
||
|
}
|
||
|
|
||
|
|
||
|
TPrint_bilancio_cms_mask::TPrint_bilancio_cms_mask()
|
||
|
:TAnal_report_mask("ca3800")
|
||
|
{
|
||
|
}
|
||
|
|
||
|
|
||
|
///////////////////////////////////////////////////////////////
|
||
|
// RECORDSET
|
||
|
///////////////////////////////////////////////////////////////
|
||
|
class TPrint_bilancio_cms_recordset : public TRecordset
|
||
|
{
|
||
|
TArray _righe;
|
||
|
TRecnotype _curr;
|
||
|
TArray _colonne;
|
||
|
|
||
|
private:
|
||
|
int _anno;
|
||
|
|
||
|
protected:
|
||
|
virtual TRecnotype items() const { return _righe.items(); }
|
||
|
virtual bool move_to(TRecnotype pos);
|
||
|
virtual TRecnotype current_row() const { return _curr; }
|
||
|
virtual void requery();
|
||
|
virtual const TString& query_text() const { return EMPTY_STRING; }
|
||
|
virtual unsigned int columns() const { return _colonne.items(); }
|
||
|
virtual const TRecordset_column_info& column_info(unsigned int column) const { return (TRecordset_column_info&) _colonne[column]; }
|
||
|
virtual const TVariant& get(unsigned int column) const;
|
||
|
virtual const TVariant& get(const char* column_name) const;
|
||
|
|
||
|
public:
|
||
|
virtual void set_filter(const TPrint_bilancio_cms_mask& msk);
|
||
|
};
|
||
|
|
||
|
|
||
|
bool TPrint_bilancio_cms_recordset::move_to(TRecnotype pos)
|
||
|
{
|
||
|
_curr = pos;
|
||
|
return pos >= 0 && pos < items();
|
||
|
}
|
||
|
|
||
|
void TPrint_bilancio_cms_recordset::requery()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
const TVariant& TPrint_bilancio_cms_recordset::get(unsigned int column) const
|
||
|
{
|
||
|
return NULL_VARIANT;
|
||
|
}
|
||
|
|
||
|
const TVariant& TPrint_bilancio_cms_recordset::get(const char* column_name) const
|
||
|
{
|
||
|
return NULL_VARIANT;
|
||
|
}
|
||
|
|
||
|
|
||
|
void TPrint_bilancio_cms_recordset::set_filter(const TPrint_bilancio_cms_mask& msk)
|
||
|
{
|
||
|
_anno = msk.get_int(F_ESERCIZIO);
|
||
|
}
|
||
|
|
||
|
////////////////////////////////////////////////////////
|
||
|
// REPORT
|
||
|
////////////////////////////////////////////////////////
|
||
|
class TPrint_bilancio_cms_rep : public TAnal_report
|
||
|
{
|
||
|
|
||
|
protected:
|
||
|
virtual bool set_recordset();
|
||
|
virtual bool get_usr_val(const TString& name, TVariant& var) const;
|
||
|
|
||
|
public:
|
||
|
void set_filter(const TPrint_bilancio_cms_mask& msk);
|
||
|
};
|
||
|
|
||
|
bool TPrint_bilancio_cms_rep::get_usr_val(const TString& name, TVariant& var) const
|
||
|
{
|
||
|
return TAnal_report::get_usr_val(name, var);
|
||
|
}
|
||
|
|
||
|
bool TPrint_bilancio_cms_rep::set_recordset()
|
||
|
{
|
||
|
TPrint_bilancio_cms_recordset* rs = new TPrint_bilancio_cms_recordset();
|
||
|
return TAnal_report::set_recordset(rs);
|
||
|
}
|
||
|
|
||
|
void TPrint_bilancio_cms_rep::set_filter(const TPrint_bilancio_cms_mask& msk)
|
||
|
{
|
||
|
TPrint_bilancio_cms_recordset* recset = new TPrint_bilancio_cms_recordset();
|
||
|
|
||
|
recset->set_filter(msk);
|
||
|
TAnal_report::set_recordset(recset);
|
||
|
}
|
||
|
|
||
|
////////////////////////////////////////////////////////
|
||
|
// APPLICAZIONE
|
||
|
////////////////////////////////////////////////////////
|
||
|
class TPrint_bilancio_cms : public TSkeleton_application
|
||
|
{
|
||
|
public:
|
||
|
virtual void main_loop();
|
||
|
};
|
||
|
|
||
|
void TPrint_bilancio_cms::main_loop()
|
||
|
{
|
||
|
TPrint_bilancio_cms_mask mask;
|
||
|
while (mask.run() == K_ENTER)
|
||
|
{
|
||
|
//report e book dei report
|
||
|
TReport_book book;
|
||
|
TString path = mask.get(F_REPORT);
|
||
|
if (path.empty())
|
||
|
path = "ca3800a";
|
||
|
TPrint_bilancio_cms_rep rep;
|
||
|
rep.load(path);
|
||
|
|
||
|
rep.set_filter(mask); //fa la set filter sulla commessa in corso
|
||
|
book.add(rep);
|
||
|
book.print_or_preview(); //stampa il book dei report
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int ca3800(int argc, char* argv[])
|
||
|
{
|
||
|
TPrint_bilancio_cms a;
|
||
|
a.run(argc, argv, TR("Stampa bilancio di commessa"));
|
||
|
return 0;
|
||
|
}
|