Files correlati : Ricompilazione Demo : [ ] Commento : prima implementazione stampe cup-cig sugli effetti git-svn-id: svn://10.65.10.50/branches/R_10_00@21440 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			168 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			168 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include <applicat.h>
 | |
| #include <automask.h>
 | |
| #include <defmask.h>
 | |
| #include <isam.h>
 | |
| #include <recset.h>
 | |
| #include <reprint.h>
 | |
| #include <utility.h>
 | |
| 
 | |
| #include <mov.h>
 | |
| 
 | |
| #include "ct0100a.h"
 | |
| 
 | |
| ////////////////////////////////////////////////////////
 | |
| //	MASCHERA
 | |
| ////////////////////////////////////////////////////////
 | |
| class TPrint_CUP_mask : public TAutomask
 | |
| {
 | |
| protected:
 | |
|   virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | |
| public:
 | |
|   TPrint_CUP_mask();
 | |
| };
 | |
| 
 | |
| TPrint_CUP_mask::TPrint_CUP_mask() : TAutomask("ct0100a")
 | |
| {
 | |
| }
 | |
| 
 | |
| bool TPrint_CUP_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | |
| {
 | |
|   switch(o.dlg())
 | |
|   {
 | |
|   case DLG_PRINT:
 | |
|     if (e == fe_button)
 | |
|     {
 | |
|       main_app().print();
 | |
|       return false;
 | |
|     }
 | |
|     break;
 | |
|   case DLG_PREVIEW:
 | |
|     if (e == fe_button)
 | |
|     {
 | |
|       main_app().preview();
 | |
|       return false;
 | |
|     }
 | |
|     break;
 | |
|   default:
 | |
|     break;
 | |
|   }
 | |
|   return true;
 | |
| }
 | |
| 
 | |
| 
 | |
| ////////////////////////////////////////////////////////
 | |
| //  REPORT
 | |
| ////////////////////////////////////////////////////////
 | |
| //i report in questione (sono 8) hanno la query inside..
 | |
| //..e non necessitano di altro che i FIELD #... dei campi della maschera per avere i valori..
 | |
| //..delle set_var interne
 | |
| class TPrint_CUP_report : public TReport
 | |
| {
 | |
| protected:
 | |
|   virtual bool use_mask() { return false; } //questo ci vuole perchè la maschera ha un nome != dai report
 | |
| public:
 | |
|   TPrint_CUP_report() {}
 | |
| };
 | |
| 
 | |
| 
 | |
| ////////////////////////////////////////////////////////
 | |
| //	APPLICAZIONE
 | |
| ////////////////////////////////////////////////////////
 | |
| class TPrint_CUP : public TSkeleton_application
 | |
| {
 | |
|   TPrint_CUP_mask* _mask;
 | |
| 
 | |
| protected:
 | |
|   virtual bool create();
 | |
|   virtual void print();
 | |
|   virtual void preview();
 | |
|   virtual void print_or_preview(const bool stampa);
 | |
| 
 | |
| public:
 | |
|   virtual void main_loop();
 | |
|   
 | |
| };
 | |
| 
 | |
| //fantastico metodo per gestire stampa o anteprima
 | |
| void TPrint_CUP::print_or_preview(const bool stampa)
 | |
| {
 | |
|   if (_mask->check_fields())
 | |
|   {
 | |
|     //crea il nome del report da usare in base alle scelte di stampa (radiobuttons)
 | |
|     //schema dei reports classe ct0100xx:
 | |
|     //M1 = movimenti per cup-cig  M2 = movimenti per clifo
 | |
|     //D1 = documenti    //        D2 = documenti    //
 | |
|     //E1 = effetti      //        E2 = effetti      //
 | |
|     //R1 = rilevazione  //        R2 = rilevazione  //
 | |
|     const TString& tipo_archivio = _mask->get(F_ARCHIVI);
 | |
|     const TString& tipo_ordinamento = _mask->get(F_ORDINAMENTO);
 | |
|     TString rep_name = "ct0100";
 | |
|     rep_name << tipo_archivio << tipo_ordinamento;
 | |
| 
 | |
|     TPrint_CUP_report rep;
 | |
| 	  rep.load(rep_name);
 | |
|     
 | |
|     rep.mask2report(*_mask);  //setta i valori della maschera sul report
 | |
| 
 | |
|     //solo per la ricerca in RMOV
 | |
|     if (tipo_archivio == "M")
 | |
|     {
 | |
|       long from_nreg = 0L;
 | |
|       long to_nreg = 0L;
 | |
|       TLocalisamfile mov(LF_MOV);
 | |
|       mov.setkey(2);
 | |
|       //se viene settata una data -> la usa per restringere il campo di ricerca dei numreg, visto che non esiste una..
 | |
|       //..chiave per data su RMOV
 | |
|       const TDate dataini = _mask->get_date(F_DADATA);
 | |
|       if (dataini.ok())
 | |
|       {
 | |
|         mov.put(MOV_DATAREG, dataini);
 | |
|         if (mov.read(_isgteq) == NOERR)
 | |
|           from_nreg = mov.get_long(MOV_NUMREG);
 | |
|       }
 | |
|       const TDate datafine = _mask->get_date(F_ADATA);
 | |
|       if (datafine.ok())
 | |
|       {
 | |
|         mov.put(MOV_DATAREG, datafine);
 | |
|         if (mov.read(_isgreat) == NOERR)
 | |
|           to_nreg = mov.get_long(MOV_NUMREG);
 | |
|       }
 | |
|       rep.recordset()->set_var("#DANUMREG", from_nreg);
 | |
|       rep.recordset()->set_var("#ANUMREG", to_nreg);
 | |
|     } //if (tipo_archivio == "M")...
 | |
| 
 | |
|     TReport_book book;
 | |
| 	  book.add(rep);
 | |
| 	  book.print_or_preview();
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TPrint_CUP::print()
 | |
| {
 | |
|   print_or_preview(true);
 | |
| }
 | |
| 
 | |
| void TPrint_CUP::preview()
 | |
| {
 | |
|   print_or_preview(false);
 | |
| }
 | |
| 
 | |
| void TPrint_CUP::main_loop()
 | |
| {
 | |
|   _mask = new TPrint_CUP_mask;
 | |
|   _mask->run();
 | |
|   delete _mask;
 | |
|   _mask = NULL;
 | |
| }
 | |
| 
 | |
| bool TPrint_CUP::create()
 | |
| {
 | |
|   return TSkeleton_application::create();
 | |
| }
 | |
| 
 | |
| int ct0100(int argc, char* argv[])
 | |
| {
 | |
|   TPrint_CUP a;
 | |
|   a.run(argc, argv, TR("Stampa tracciabilita' CUP"));
 | |
|   return 0;
 | |
| } |