campo-sirio/co/co1300.cpp
alex ffb1216450 Patch level : 10.0 163
Files correlati     :
Ricompilazione Demo : [ ]
Commento            :

Riportata la versione 3.2 patch 1262


git-svn-id: svn://10.65.10.50/trunk@17645 c028cbd2-c16b-5b4b-a496-9718f37d4682
2008-11-15 01:22:03 +00:00

216 lines
4.3 KiB
C++
Executable File

#include <applicat.h>
#include <automask.h>
#include <form.h>
#include <report.h>
#include <reprint.h>
#include <textset.h>
#include "co1.h"
#include "co1300a.h"
#include "socicoop.h"
#include "..\ve\velib.h"
#include "..\ve\velib07.h"
////////////////////////////////////////////////////////
// MASCHERA
////////////////////////////////////////////////////////
class TEstrattoConto_mask : public TAutomask
{
protected:
bool on_field_event(TOperable_field& o, TField_event e, long jolly);
public:
TEstrattoConto_mask();
virtual ~TEstrattoConto_mask() {};
};
TEstrattoConto_mask::TEstrattoConto_mask() :TAutomask ("co1300a")
{
}
bool TEstrattoConto_mask::on_field_event(TOperable_field& f, TField_event e, long jolly)
{
return TRUE;
}
////////////////////////////////////////////////////////
// REPORT
////////////////////////////////////////////////////////
class TEstrattoConto_rep : public TDocument_report
{
int _riga;
protected:
virtual bool use_mask() {return false;}
virtual bool set_usr_val(const TString& name, const TVariant& var);
bool incr_field(int idx, const TVariant& var);
public:
TEstrattoConto_rep();
};
bool TEstrattoConto_rep::incr_field(int idx, const TVariant& var)
{
if (_riga > 0)
{
TReport_section& f1 = section('F',1);
TReport_field* rf = f1.find_field(_riga * 1000 + 100 + idx);
if (rf != NULL)
{
TVariant v = rf->get();
v += var;
rf->set(v);
return true;
}
}
return false;
}
bool TEstrattoConto_rep::set_usr_val(const TString& name, const TVariant& var)
{
if(name == "#EC_TIPOMOV")
{
TReport_section& f1 = section('F',1);
TReport_field* rf = NULL;
int id = 1100;
for (int id = 1100; ; id += 1000)
{
rf = f1.find_field(id);
if (rf == NULL)
break;
const TVariant& rfv = rf->get();
if (rfv == var)
break;
if (rfv.is_empty())
{
rf->set(var);
break;
}
}
if (rf != NULL)
_riga = id / 1000;
else
_riga = 0;
return true;
}
if (name == "#EC_QTA")
{
incr_field(2, var);
return true;
}
if (name == "#EC_MER")
{
incr_field(5, var);
return true;
}
if (name == "#EC_ACC")
{
incr_field(6, var);
return true;
}
if (name == "#EC_IMPCRE")
{
incr_field(7, var);
return true;
}
if (name == "#EC_IMPDEB")
{
incr_field(8, var);
return true;
}
if (name == "#EC_IMPO")
{
incr_field(9, var);
return true;
}
return TDocument_report::set_usr_val(name,var);
}
TEstrattoConto_rep::TEstrattoConto_rep()
{
load("co1300a");
TReport_section& b11 = section('B',11);
TReport_section& f1 = section('F',1);
long y = 400;
for (int i = 1000; i <= 8000; i += 1000)
{
for (int j = 100; j <= 109; ++j)
{
if (j == 101 || j == 103 || j == 104)
continue;
TReport_field* rf_b11 = b11.find_field(j);
TReport_field* rf_f1 = new TReport_field(*rf_b11);
f1.add(rf_f1);
const int id = rf_f1->id() + i;
rf_f1->set_id(id);
rf_f1->set_row(y);
rf_f1->set_postscript("");
rf_f1->set_prescript("");
rf_f1->set_field("");
}
y += 100;
}
}
////////////////////////////////////////////////////////
// APPLICAZIONE
////////////////////////////////////////////////////////
class TEstrattoConto : public TSkeleton_application
{
public:
virtual void main_loop();
};
void TEstrattoConto::main_loop()
{
TEstrattoConto_mask m;
while (m.run() == K_ENTER)
{
TReport_book book;
TEstrattoConto_rep rep;
const TDate dataini = m.get_date(F_DATAINI);
const TDate datafin = m.get_date(F_DATAFIN);
const int anno = dataini.year();
// creo recordset dei soci da stampare
TISAM_recordset soci("USE SOCICOOP\nFROM CODCF=#DASOCIO\nTO CODCF=#ASOCIO");
soci.set_var("#DASOCIO", m.get_long(F_DASOCIO));
soci.set_var("#ASOCIO", m.get_long(F_ASOCIO));
for (bool ok = soci.move_first(); ok; ok = soci.move_next())
{
TRecordset* r = rep.recordset();
long codcf = soci.get(SC_CODCF).as_int();
r->set_var("#SOCIO", soci.get("CODCF"));
r->set_var("#ANNO", TVariant(long(anno)));
r->set_var("#DATAINI", dataini);
r->set_var("#DATAFIN", datafin);
book.add(rep);
}
book.print_or_preview();
}
}
int co1300(int argc, char* argv[])
{
TEstrattoConto a;
a.run(argc, argv, TR("Stampa estratto conto"));
return 0;
}