Files correlati : Ricompilazione Demo : [ ] Commento : Riportata la versione P@rtners 2.0 patch 349 git-svn-id: svn://10.65.10.50/trunk@10573 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			181 lines
		
	
	
		
			4.7 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			181 lines
		
	
	
		
			4.7 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include <applicat.h>
 | |
| #include <form.h>
 | |
| #include <relation.h>
 | |
| #include <tabutil.h>
 | |
| #include <utility.h>
 | |
| 
 | |
| #include "ba2.h"
 | |
| 
 | |
| ///////////////////////////////////////////////////////////
 | |
| // Form basato su una tabella
 | |
| ///////////////////////////////////////////////////////////
 | |
| 
 | |
| class TTab_form : public TForm
 | |
| { 
 | |
|   TString256 _result;
 | |
| 
 | |
| protected:  
 | |
|   virtual bool validate(TForm_item& f, TToken_string& s);
 | |
|   virtual word set_body(word p, bool u);
 | |
| 
 | |
| public:
 | |
|   TTab_form(const char* name, const char * code);
 | |
| };
 | |
| 
 | |
| TTab_form::TTab_form(const char* name, const char * code) : TForm(name, code) 
 | |
| {       
 | |
|   TCursor* c = cursor();
 | |
|   if (c == NULL)
 | |
|     fatal_box(FR("Il profilo %s non ha un cursore"), name);
 | |
|   TFilename t("tmp");t << LF_TABCOM;
 | |
|   TIsamtempfile* tmp = new TIsamtempfile(LF_TABCOM, t, FALSE);
 | |
|   relation()->replace(tmp);
 | |
|   
 | |
|   c->setfilter("B0!=\"X\"");    // Esclude le deleghe gia' stampate
 | |
| }
 | |
| 
 | |
| word TTab_form::set_body(word p, bool u)
 | |
| {
 | |
|   const word l = TForm::set_body(p, u);
 | |
|   if (u && l > 0) 
 | |
|   {
 | |
|     TLocalisamfile& f = cursor()->file();
 | |
|     f.put("B0", "X");          // Alza la bandiera di stampato
 | |
|     f.rewrite();
 | |
|   }
 | |
|   return l;
 | |
| } 
 | |
| 
 | |
| 
 | |
| bool TTab_form::validate(TForm_item& fld, TToken_string& s)
 | |
| {                              
 | |
|   const TString16 code(s.get(0));
 | |
|   
 | |
|   if (code == "_CENSERoUFFIMP")
 | |
|   { 
 | |
|     const int a_comres = s.get_int();
 | |
|        // Alias del comune di residenza (fiscale)
 | |
|     const int a_anagr  = s.get_int();    // Alias dell'anagrafica della persona
 | |
|     TString16 i_des(s.get());            // Id del campo descrizione Centro Servizio (obbligatorio)
 | |
|     TString16 i_cod(s.get());            // Eventuale Id del campo codice (solo se != 0)
 | |
|     TString16  cod_us_uid;               // Codice del Centro servizio o ufficio imposte dirette (NON E' IL CODICE DEL COMUNE)
 | |
|     
 | |
|     TString80 desc;                      // Denominzazione centro servizi o ufficio imposte
 | |
|     
 | |
|     const TLocalisamfile& com = relation()->lfile(-a_comres);
 | |
|     TString16 cod = com.get("UFFCSERV");
 | |
|     
 | |
|     if (cod.not_empty())                 // Se specificato ...
 | |
|     {            
 | |
|       cod_us_uid = cod;
 | |
|       TTable ucc("%UCS");                // ... usa il centro servizi del comune
 | |
|       ucc.put("CODTAB", cod);
 | |
|       if (ucc.read() == NOERR)
 | |
|       {
 | |
|         desc = ucc.get("S0");
 | |
|         cod = ucc.get("S6");
 | |
|       } else cod.cut(0);
 | |
|     }
 | |
|     else
 | |
|     {                                    // ... se no usa l'ufficio imposte in anagrafica
 | |
|       const TLocalisamfile& anag = relation()->lfile(-a_anagr);
 | |
|       cod = anag.get("UFFIIDD");
 | |
|       if (cod.empty())                   // ... se no usa il primo ufficio imposte del comune
 | |
|       {
 | |
|         TString16 uff("UFFIIDD1"); 
 | |
|         for (char u = '1'; cod.empty() && u < '4'; u++)
 | |
|         {
 | |
|           uff[7] = u;
 | |
|           cod = com.get(uff);
 | |
|         }
 | |
|       }
 | |
|       cod_us_uid = cod;  
 | |
|       TTable uffiva("%UID");  
 | |
|       uffiva.put("CODTAB", cod);
 | |
|       if (uffiva.read() == NOERR)
 | |
|       {
 | |
|         desc = uffiva.get("S0");
 | |
|         cod = uffiva.get("S6");
 | |
|       } else cod.cut(0);  
 | |
|     }                      
 | |
|     
 | |
|     TLocalisamfile comiva(LF_COMUNI);    // Determina la provincia dell'ufficio
 | |
|     comiva.zero("STATO");
 | |
|     comiva.put("COM", cod);
 | |
|     if (comiva.read() == NOERR)
 | |
|       _result = comiva.get("PROVCOM");
 | |
|     else
 | |
|       _result = "  ";  
 | |
|     _result << "  " << desc;
 | |
|     
 | |
| 
 | |
|     if (i_des.not_empty())
 | |
|     {
 | |
|       TForm_item& fi  = fld.find_field(i_des);
 | |
|       fi.set(_result);
 | |
|     }    
 | |
|     if (i_cod.not_empty())
 | |
|     {
 | |
|       TForm_item& fi  = fld.find_field(i_cod);
 | |
|       fi.set(cod_us_uid);
 | |
|     }    
 | |
|     return TRUE;
 | |
|   }
 | |
|   return TForm::validate(fld, s);
 | |
| }
 | |
| 
 | |
| 
 | |
| 
 | |
| ///////////////////////////////////////////////////////////
 | |
| // Stampa di un form generico da una tabella
 | |
| ///////////////////////////////////////////////////////////
 | |
| 
 | |
| class TForm_printer : public TApplication
 | |
| { 
 | |
|   TLocalisamfile* _tabcom;
 | |
|   
 | |
| protected:
 | |
|   virtual bool create();
 | |
|   virtual bool destroy();
 | |
| public:
 | |
|   TForm_printer() {}
 | |
|   virtual ~TForm_printer() {}
 | |
| };
 | |
| 
 | |
| bool TForm_printer::create()
 | |
| {
 | |
|   TString16 cod_prof;
 | |
|   TApplication::create();
 | |
|   
 | |
|   if (argc() < 3)
 | |
|     return error_box("Specificare il nome del profilo di stampa");
 | |
|    
 | |
|   TFilename form(argv(2)); form.ext("frm");form.upper();
 | |
|   long code=0;
 | |
|   if (argc() == 4)
 | |
|     code = atol(argv(3));
 | |
|   if (!fexist(form))
 | |
|     return error_box(FR("Il profilo %s non esiste"), (const char*)form); 
 | |
|   form.ext("");
 | |
|   _tabcom = new TLocalisamfile(LF_TABCOM);
 | |
|   cod_prof.format("%05ld",code);
 | |
|   TTab_form f(form, (code != 0) ? cod_prof : "");
 | |
|   f.print();  
 | |
|   stop_run();
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TForm_printer::destroy()
 | |
| {                         
 | |
|   delete _tabcom;
 | |
|   return TApplication::destroy();
 | |
| }
 | |
| 
 | |
| int ba2400(int argc, char* argv[])
 | |
| {                                             
 | |
|   TForm_printer a;
 | |
| 
 | |
|   a.run(argc, argv, TR("Stampa versamenti"));
 | |
|   return 0;
 | |
| }
 |