Files correlati : Ricompilazione Demo : [ ] Commento :corretta stampa registro cespiti leggibile git-svn-id: svn://10.65.10.50/trunk@14633 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			220 lines
		
	
	
		
			5.7 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			220 lines
		
	
	
		
			5.7 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <applicat.h>
 | 
						|
#include <automask.h>
 | 
						|
#include <progind.h>
 | 
						|
#include <recarray.h>
 | 
						|
#include <reprint.h>
 | 
						|
 | 
						|
#include "../cg/cglib01.h"
 | 
						|
 | 
						|
#include "ammce.h"
 | 
						|
#include "cespi.h"
 | 
						|
#include "movce.h"
 | 
						|
#include "salce.h"
 | 
						|
#include "celib.h"
 | 
						|
 | 
						|
#include "ce2101.h"
 | 
						|
#include "ce3.h"
 | 
						|
#include "ce3900.h"
 | 
						|
 | 
						|
////////////////////////////////////////////////////////
 | 
						|
//	MASCHERA
 | 
						|
////////////////////////////////////////////////////////
 | 
						|
class TStampa_sintetica_mask : public TAutomask
 | 
						|
{
 | 
						|
protected:
 | 
						|
  bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | 
						|
 | 
						|
public:
 | 
						|
  TStampa_sintetica_mask();
 | 
						|
  virtual ~TStampa_sintetica_mask() {}
 | 
						|
};
 | 
						|
 | 
						|
 | 
						|
bool TStampa_sintetica_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | 
						|
{ 
 | 
						|
  bool ok = true;
 | 
						|
  switch (o.dlg())
 | 
						|
  {
 | 
						|
  case F_FROM_CAT:
 | 
						|
  case F_D_FROM_CAT:
 | 
						|
  case F_TO_CAT:
 | 
						|
  case F_D_TO_CAT:
 | 
						|
    {
 | 
						|
      TDitta_cespiti& dc = ditta_cespiti();
 | 
						|
      ok = dc.on_category_event(o, e, jolly);
 | 
						|
    }
 | 
						|
    break;
 | 
						|
 | 
						|
	case F_ESERCIZIO:
 | 
						|
  case F_GRUPPO:
 | 
						|
  case F_SPECIE:
 | 
						|
    if (e == fe_init || e == fe_modify)
 | 
						|
    {
 | 
						|
      const TString& esercizio = get(F_ESERCIZIO);
 | 
						|
      const TString& gruppo = get(F_GRUPPO);
 | 
						|
      const TString& specie = get(F_SPECIE);
 | 
						|
      TString16 key; key << esercizio << gruppo << specie;
 | 
						|
      TRelation ccb("CCB");
 | 
						|
      ccb.curr().put("CODTAB", key);
 | 
						|
      if (ccb.read() == NOERR)
 | 
						|
        autoload(ccb);
 | 
						|
    }
 | 
						|
    break;
 | 
						|
  default: break;
 | 
						|
  }
 | 
						|
  return ok;
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
TStampa_sintetica_mask::TStampa_sintetica_mask()
 | 
						|
								:TAutomask("ce3900")
 | 
						|
{}
 | 
						|
 | 
						|
 | 
						|
///////////////////////////////////////////////////////////////
 | 
						|
//	RECORDSET
 | 
						|
///////////////////////////////////////////////////////////////
 | 
						|
 | 
						|
class TStampa_sintetica_recordset : public TISAM_recordset
 | 
						|
{
 | 
						|
public:
 | 
						|
  void set_filter(const TStampa_sintetica_mask& msk);
 | 
						|
  TStampa_sintetica_recordset(const TString& sql) : TISAM_recordset(sql) { }
 | 
						|
};
 | 
						|
 | 
						|
static const TStampa_sintetica_recordset* myself = NULL;
 | 
						|
 | 
						|
//metodo per caricare i valori nel recordset dalla maschera...fighissimo!!
 | 
						|
void TStampa_sintetica_recordset::set_filter(const TStampa_sintetica_mask& msk)
 | 
						|
{
 | 
						|
	const TString& dacat = msk.get(F_FROM_CAT);
 | 
						|
	const TString& acat = msk.get(F_TO_CAT);
 | 
						|
	TString query = "USE CESPI SELECT\n";
 | 
						|
	query << "((DTALIEN='')||(ANSI(DTALIEN)>=" << msk.get_date(F_DATAINIZIO).date2ansi() << "))";
 | 
						|
	query << "&&(ANSI(DTCOMP)<=" << msk.get_date(F_DATAFINE).date2ansi() << ")";
 | 
						|
	if (dacat.full() || acat.full())
 | 
						|
	{
 | 
						|
		if (dacat == acat)
 | 
						|
		{
 | 
						|
			query << "&&(CODCAT==" << dacat << ")";
 | 
						|
		}
 | 
						|
		else
 | 
						|
		{
 | 
						|
			if (dacat.full())
 | 
						|
				query << "&&(CODCAT>=" << dacat << ")";
 | 
						|
			if (acat.full())
 | 
						|
				query << "&&(CODCAT<=" << acat << ")";
 | 
						|
		}
 | 
						|
	}
 | 
						|
	query << "\nBY CODCAT|IDCESPITE";
 | 
						|
	set(query);	//setta la nuova query nel report (che avrebbe solo USE CESPI)
 | 
						|
}
 | 
						|
 | 
						|
////////////////////////////////////////////////////////
 | 
						|
//	REPORT
 | 
						|
////////////////////////////////////////////////////////
 | 
						|
class TStampa_sintetica_rep : public TReport
 | 
						|
{
 | 
						|
	int _anno;
 | 
						|
	TCespite _cespite;
 | 
						|
 | 
						|
protected:
 | 
						|
	virtual bool get_usr_val(const TString& name, TVariant& var) const;
 | 
						|
public:
 | 
						|
	void set_filter(const TStampa_sintetica_mask& msk);
 | 
						|
};
 | 
						|
 | 
						|
void TStampa_sintetica_rep::set_filter(const TStampa_sintetica_mask& msk)
 | 
						|
{
 | 
						|
  _anno = msk.get_int(F_ESERCIZIO);
 | 
						|
	((TStampa_sintetica_recordset*) recordset())->set_filter(msk);
 | 
						|
}
 | 
						|
 | 
						|
//metodo per il calcolo dei campi da calcolare (ma va'!) nel report
 | 
						|
bool TStampa_sintetica_rep::get_usr_val(const TString& name, TVariant& var) const
 | 
						|
{
 | 
						|
	const TRecordset& recset = *recordset();
 | 
						|
	const TString& idcespite = recset.get("IDCESPITE").as_string();
 | 
						|
  if (idcespite != _cespite.get(CESPI_IDCESPITE))
 | 
						|
	{
 | 
						|
		TCespite& c = (TCespite&)_cespite;
 | 
						|
		c.read(idcespite);
 | 
						|
		c.load_saldi(1, _anno);
 | 
						|
	}
 | 
						|
 | 
						|
	if (name == "#DESCAT")	//categoria (descrizione della categoria corrente)
 | 
						|
	{		
 | 
						|
		const int gruppo = recset.get("CODCGRA").as_int();
 | 
						|
		const TString& specie = recset.get("CODSPA").as_string();
 | 
						|
		const int categoria = recset.get("CODCAT").as_int();
 | 
						|
		const TRectype& rec_cac = ditta_cespiti().categoria(gruppo, specie, categoria);
 | 
						|
		var = rec_cac.get("S0");
 | 
						|
		return true;
 | 
						|
	}
 | 
						|
	if (name.starts_with("#COSTO"))	//costo storico dell'anno
 | 
						|
	{
 | 
						|
		if (name.ends_with("FIN"))  //tiposaldo finale
 | 
						|
			var = _cespite.sal_pro().get_real(SALCE_CSTO);
 | 
						|
		else												//tiposaldo iniziale
 | 
						|
			var = _cespite.sal_ini().get_real(SALCE_CSTO);
 | 
						|
		return true;
 | 
						|
	}
 | 
						|
	if (name == "#PERCAMM")	//percentuale ammortamento
 | 
						|
	{
 | 
						|
		const TRectype& rec_ammce = _cespite.amm_pro();
 | 
						|
		var = rec_ammce.get_real(AMMCE_PNOR) + rec_ammce.get_real(AMMCE_PACC) + rec_ammce.get_real(AMMCE_PANT);
 | 
						|
		return true;
 | 
						|
	}
 | 
						|
	if (name == "#QAMM")	//fondo ammortamento esercizio corrente
 | 
						|
	{
 | 
						|
		const TRectype& rec_ammce = _cespite.amm_pro();
 | 
						|
		var = rec_ammce.get_real(AMMCE_QNOR) + rec_ammce.get_real(AMMCE_QACC) + rec_ammce.get_real(AMMCE_QANT);
 | 
						|
		return true;
 | 
						|
	}
 | 
						|
	if (name == "#FAMM")	//fondo ammortamento alla fine dell'esercizio precedente
 | 
						|
	{
 | 
						|
		const TRectype& rec_ammce = _cespite.amm_ini();
 | 
						|
		var = rec_ammce.get_real(AMMCE_QNOR) + rec_ammce.get_real(AMMCE_QACC) + rec_ammce.get_real(AMMCE_QANT);
 | 
						|
		return true;
 | 
						|
	}
 | 
						|
	if (name == "#RESAMM")	//residuo da ammortizzare
 | 
						|
	{
 | 
						|
		var = _cespite.res_amm();
 | 
						|
		return true;
 | 
						|
	}
 | 
						|
	return TReport::get_usr_val(name, var);
 | 
						|
}
 | 
						|
 | 
						|
////////////////////////////////////////////////////////
 | 
						|
//	APPLICAZIONE
 | 
						|
////////////////////////////////////////////////////////
 | 
						|
class TStampa_sintetica : public TSkeleton_application
 | 
						|
{
 | 
						|
protected:
 | 
						|
  virtual void main_loop();
 | 
						|
};
 | 
						|
 | 
						|
 | 
						|
void TStampa_sintetica::main_loop()
 | 
						|
{
 | 
						|
	TStampa_sintetica_mask mask;
 | 
						|
  while (mask.run() == K_ENTER)
 | 
						|
  {
 | 
						|
		//report e book dei report
 | 
						|
		TReport_book book;
 | 
						|
		TStampa_sintetica_rep rep;
 | 
						|
		rep.load("ce3900a");
 | 
						|
 | 
						|
		rep.set_filter(mask);
 | 
						|
		book.add(rep);
 | 
						|
 | 
						|
		book.print_or_preview();	//stampa il book dei report
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
int ce3900(int argc, char* argv[])
 | 
						|
{
 | 
						|
  TStampa_sintetica a;
 | 
						|
  a.run(argc, argv, TR("Stampa sintetica cespiti"));
 | 
						|
  return 0;
 | 
						|
} |