2005-04-01 20:05:19 +00:00
|
|
|
//Programma per stampa report tabelle
|
1995-01-04 09:36:32 +00:00
|
|
|
|
2005-04-01 20:05:19 +00:00
|
|
|
#include <applicat.h>
|
2005-04-02 22:36:24 +00:00
|
|
|
#include <automask.h>
|
2005-04-01 20:05:19 +00:00
|
|
|
#include <relation.h>
|
|
|
|
#include <reprint.h>
|
1998-11-04 18:04:26 +00:00
|
|
|
#include <tabutil.h>
|
2005-04-02 22:36:24 +00:00
|
|
|
#include "ba3200.h"
|
1995-01-04 09:36:32 +00:00
|
|
|
|
2005-04-01 20:05:19 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
2005-04-02 22:36:24 +00:00
|
|
|
// TMask_print_table
|
2005-04-01 20:05:19 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
1995-01-04 09:36:32 +00:00
|
|
|
|
2005-04-02 22:36:24 +00:00
|
|
|
class TMask_print_table : public TAutomask
|
1995-01-04 09:36:32 +00:00
|
|
|
{
|
1998-11-04 18:04:26 +00:00
|
|
|
protected:
|
2005-04-02 22:36:24 +00:00
|
|
|
bool on_field_event(TOperable_field& o, TField_event e, long jolly) {return true;}
|
2008-09-12 10:29:57 +00:00
|
|
|
|
2005-04-02 22:36:24 +00:00
|
|
|
public:
|
|
|
|
TMask_print_table(const char * name);
|
|
|
|
virtual ~TMask_print_table() {}
|
1995-01-04 09:36:32 +00:00
|
|
|
};
|
|
|
|
|
2008-09-12 10:29:57 +00:00
|
|
|
TMask_print_table::TMask_print_table(const char* name)
|
2005-04-02 22:36:24 +00:00
|
|
|
:TAutomask(name)
|
2004-11-30 22:02:59 +00:00
|
|
|
{
|
2008-07-10 09:11:30 +00:00
|
|
|
const int reporty = toolbar() != NULL_WIN ? -2 : -3;
|
|
|
|
TEdit_field & f = add_string(F_REPORT, 0, "Report ", 2, reporty, 20, "B");
|
2005-04-02 22:36:24 +00:00
|
|
|
f.set_query_button(new TReport_select(&f, name));
|
|
|
|
f.enable_check();
|
|
|
|
}
|
2004-11-30 22:02:59 +00:00
|
|
|
|
2007-03-07 10:23:42 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TTable_recordset
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TTable_recordset : public TISAM_recordset
|
|
|
|
{
|
2008-09-12 10:29:57 +00:00
|
|
|
TMask* _mask;
|
2007-03-07 10:23:42 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void set_custom_filter(TCursor& cursor) const;
|
|
|
|
|
|
|
|
public:
|
2008-09-12 10:29:57 +00:00
|
|
|
TTable_recordset(const char* use, TMask* mask) : TISAM_recordset(use), _mask(mask) { }
|
2007-03-07 10:23:42 +00:00
|
|
|
virtual ~TTable_recordset() { }
|
|
|
|
};
|
|
|
|
|
|
|
|
void TTable_recordset::set_custom_filter(TCursor& cursor) const
|
|
|
|
{
|
|
|
|
CHECK(_mask, "NULL selection mask");
|
|
|
|
TRectype from(cursor.curr()); from.zero();
|
|
|
|
TRectype to(from);
|
2008-09-12 10:29:57 +00:00
|
|
|
bool key1_full = false;
|
2007-03-07 10:23:42 +00:00
|
|
|
for (int i = _mask->fields() - 1; i >= 0; i--)
|
|
|
|
{
|
2008-09-12 10:29:57 +00:00
|
|
|
const TMask_field& f = _mask->fld(i);
|
|
|
|
const TFieldref* ref = f.field();
|
|
|
|
if (ref != NULL && ref->name() == "CODTAB" && !f.empty())
|
2007-03-07 10:23:42 +00:00
|
|
|
{
|
2008-09-12 10:29:57 +00:00
|
|
|
const bool is_final = f.in_group(2);
|
|
|
|
ref->write(f.get(), is_final ? to : from);
|
|
|
|
key1_full = true;
|
2007-03-07 10:23:42 +00:00
|
|
|
}
|
|
|
|
}
|
2008-09-12 10:29:57 +00:00
|
|
|
if (key1_full) // Se e' stato impostato il filtro tramite CODTAB (non #FROM e #TO)
|
|
|
|
cursor.setregion(from, to);
|
2007-03-07 10:23:42 +00:00
|
|
|
}
|
|
|
|
|
2005-04-02 22:36:24 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TTable_report
|
|
|
|
///////////////////////////////////////////////////////////
|
2004-11-30 22:02:59 +00:00
|
|
|
|
2005-04-02 22:36:24 +00:00
|
|
|
class TTable_report : public TReport
|
|
|
|
{
|
2008-09-12 10:29:57 +00:00
|
|
|
TMask* _mask;
|
2007-03-07 10:23:42 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool set_recordset(const TString& query);
|
|
|
|
|
2005-04-02 22:36:24 +00:00
|
|
|
public:
|
|
|
|
virtual bool use_mask() { return false;}
|
2005-04-01 20:05:19 +00:00
|
|
|
|
2007-03-07 10:23:42 +00:00
|
|
|
TTable_report(TMask * mask) : _mask(mask) {}
|
2005-04-02 22:36:24 +00:00
|
|
|
virtual ~TTable_report() {}
|
|
|
|
};
|
2004-11-30 22:02:59 +00:00
|
|
|
|
2007-03-07 10:23:42 +00:00
|
|
|
bool TTable_report::set_recordset(const TString& query)
|
|
|
|
{
|
|
|
|
return TReport::set_recordset(new TTable_recordset(query, _mask));
|
|
|
|
}
|
|
|
|
|
2005-04-01 20:05:19 +00:00
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TTable_reporter
|
|
|
|
///////////////////////////////////////////////////////////
|
2004-11-30 22:02:59 +00:00
|
|
|
|
2005-04-01 20:05:19 +00:00
|
|
|
class TTable_reporter : public TSkeleton_application
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
virtual void main_loop();
|
2004-11-30 22:02:59 +00:00
|
|
|
|
2005-04-01 20:05:19 +00:00
|
|
|
public:
|
|
|
|
bool get_rpt_name(TFilename& rptname) const;
|
|
|
|
};
|
2004-11-30 22:02:59 +00:00
|
|
|
|
2005-04-01 20:05:19 +00:00
|
|
|
bool TTable_reporter::get_rpt_name(TFilename& rptname) const
|
2004-11-30 22:02:59 +00:00
|
|
|
{
|
2005-04-01 20:05:19 +00:00
|
|
|
TTable tab(argv(2));
|
|
|
|
rptname = tab.module();
|
2008-09-12 10:29:57 +00:00
|
|
|
rptname << "st" << tab.name();
|
2005-04-01 20:05:19 +00:00
|
|
|
rptname.ext("rep");
|
|
|
|
rptname.lower();
|
|
|
|
return rptname.custom_path();
|
2004-11-30 22:02:59 +00:00
|
|
|
}
|
|
|
|
|
2005-04-01 20:05:19 +00:00
|
|
|
void TTable_reporter::main_loop()
|
2004-11-30 22:02:59 +00:00
|
|
|
{
|
2005-04-01 20:05:19 +00:00
|
|
|
TFilename rptname;
|
|
|
|
if (get_rpt_name(rptname))
|
2004-11-30 22:02:59 +00:00
|
|
|
{
|
2005-04-02 22:36:24 +00:00
|
|
|
TFilename msk(rptname.name()); msk.ext(""); msk.lower();
|
|
|
|
TMask_print_table m(msk);
|
|
|
|
|
|
|
|
while (m.run() == K_ENTER)
|
2004-11-30 22:02:59 +00:00
|
|
|
{
|
2007-03-07 10:23:42 +00:00
|
|
|
TTable_report rep(&m);
|
2005-04-02 22:36:24 +00:00
|
|
|
TString name(m.get(F_REPORT));
|
|
|
|
|
2008-04-14 13:50:09 +00:00
|
|
|
if (name.blank())
|
2005-04-02 22:36:24 +00:00
|
|
|
name = rptname;
|
2008-04-14 13:50:09 +00:00
|
|
|
|
|
|
|
if (rep.load(name))
|
|
|
|
{
|
|
|
|
rep.mask2report(m);
|
|
|
|
rep.print_or_preview();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
error_box(FR("Report %s mancante !"), name);
|
2004-11-30 22:02:59 +00:00
|
|
|
}
|
|
|
|
}
|
2005-04-01 20:05:19 +00:00
|
|
|
else
|
2008-04-14 13:50:09 +00:00
|
|
|
error_box(FR("Manca il file %s !"), (const char *)rptname);
|
1998-11-04 18:04:26 +00:00
|
|
|
}
|
|
|
|
|
1995-01-04 09:36:32 +00:00
|
|
|
|
|
|
|
int ba3200(int argc, char* argv[])
|
2005-04-01 20:05:19 +00:00
|
|
|
{
|
|
|
|
TTable_reporter app;
|
2005-04-02 22:36:24 +00:00
|
|
|
app.run(argc, argv, TR("Stampa Tabelle"));
|
1995-01-04 09:36:32 +00:00
|
|
|
return 0;
|
2008-09-12 10:29:57 +00:00
|
|
|
}
|