Files correlati : ba3.exe Ricompilazione Demo : [ ] Commento : RiInserita la stampa tabelle con i report git-svn-id: svn://10.65.10.50/trunk@12899 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			330 lines
		
	
	
		
			9.3 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			330 lines
		
	
	
		
			9.3 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include <mask.h>
 | |
| #include <prefix.h>
 | |
| #include <printapp.h>
 | |
| #include <progind.h>
 | |
| #include <tabutil.h>  
 | |
| 
 | |
| #include "ba3.h"
 | |
| #include "ba3300.h"
 | |
| 
 | |
| class Libribollati_print : public TPrintapp
 | |
| {
 | |
|   static bool registro_handler(TMask_field& field, KEY key);
 | |
|   static bool codditta_handler(TMask_field& field, KEY key);
 | |
|   
 | |
|   TMask*  _msk;
 | |
|   TTable* _tab;        // Tabella dei registri
 | |
|   TProgind *_p;
 | |
|   
 | |
|   TString _cod_reg, _comulc, _ragsoc, _indulc, _civulc;
 | |
|   TString _capulc, _com, _prov, _cofi, _paiv;
 | |
|   TString80 _descr; 
 | |
|   long _num_pag, _pag_ini, _pag_fin; 
 | |
|   int _cod_anno, _anno_stampa;
 | |
|   bool _inizia_dopo;
 | |
|   TLocalisamfile*   _nditte;
 | |
|   TLocalisamfile*   _anag;
 | |
|   TLocalisamfile*   _unloc;
 | |
|   TLocalisamfile*   _comuni;  
 | |
| 
 | |
| protected:
 | |
|   
 | |
|   bool menu(MENU_TAG m) { return TPrintapp::menu(m) ; }
 | |
|   virtual bool user_destroy();
 | |
|   virtual bool user_create() ;
 | |
|   bool set_print(int);
 | |
| 
 | |
|   virtual void set_page(int, int);
 | |
|   virtual print_action postprocess_page(int, int);
 | |
|   virtual bool preprocess_print(int, int);
 | |
|   virtual print_action postprocess_print(int, int);
 | |
|   
 | |
| public:
 | |
|   Libribollati_print() : _p(NULL) {}
 | |
|   ~Libribollati_print() {}
 | |
| };
 | |
| 
 | |
| HIDDEN inline Libribollati_print& app() { return (Libribollati_print&) main_app(); }
 | |
| 
 | |
| print_action Libribollati_print::postprocess_page(int, int counter)
 | |
| {
 | |
|   if (counter == _num_pag - 1)
 | |
|   {  
 | |
|     TString16 dep; dep.format("%04d%-3s", _cod_anno, (const char*) _cod_reg);
 | |
|     _tab->put("CODTAB", (const char*) dep);
 | |
|     _tab->read();
 | |
|     if (_tab->good())
 | |
|     {
 | |
|       _tab->put("I2", _pag_fin);
 | |
|       _tab->rewrite();
 | |
|     }
 | |
|     return NEXT_PAGE;
 | |
|   }    
 | |
|   return REPEAT_PAGE;
 | |
| }
 | |
| 
 | |
| bool Libribollati_print::preprocess_print(int, int)
 | |
| {
 | |
|   _p = new TProgind(_pag_fin-_pag_ini+1, TR("Preparazione stampa"), FALSE, TRUE, 60);
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| print_action Libribollati_print::postprocess_print(int, int)
 | |
| {
 | |
|   if (_p != NULL) 
 | |
|   {
 | |
|     delete _p;
 | |
|     _p = NULL;
 | |
|   }           
 | |
|   return NEXT_PAGE;
 | |
| }
 | |
| 
 | |
| void Libribollati_print::set_page(int , int counter)
 | |
| {
 | |
|   reset_print();        
 | |
|   _p->addstatus(1);
 | |
| 
 | |
|   long contatore = _pag_ini + counter;
 | |
| 
 | |
|   if (_inizia_dopo) contatore--;
 | |
|   reset_row(1);
 | |
|   reset_row(2);
 | |
|   reset_row(3);
 | |
|   reset_row(4);
 | |
|   reset_row(5);
 | |
|   reset_row(6);
 | |
|   reset_row(7);
 | |
|   reset_row(8);
 | |
|   reset_row(9);
 | |
|   if (counter == 0)
 | |
|   {
 | |
|     if (!_inizia_dopo)
 | |
|     { 
 | |
|       if (_anno_stampa == 0)
 | |
|         set_row(3, FR("@120gPag. %ld"), contatore);
 | |
|       else        
 | |
|         set_row(3, FR("@120gPag. %4d/%ld"), _anno_stampa, contatore);
 | |
|     }      
 | |
|     int pos = printer().formlen() / 2 - 3;
 | |
|     set_row(pos++, "@36g%-50s", (const char*) _descr);
 | |
|     set_row(pos++, "@36g%-50s", (const char*) _ragsoc);
 | |
|     TString s(_indulc);
 | |
|     
 | |
|     s << " " << _civulc ;
 | |
|     set_row(pos++, "@36g%-52s", (const char*) s);
 | |
|     s = _capulc; 
 | |
|     s << " " << _com << " " << _prov;
 | |
|     set_row(pos++, "@36g%-62s", (const char*) s);
 | |
|     set_row(pos++, FR("@36gCODICE FISCALE %-16s"), (const char*)_cofi);
 | |
|     set_row(pos, FR("@36gPARTITA I.V.A. %-11s"), (const char*) _paiv);
 | |
|     
 | |
|   }
 | |
|   else if (counter == _num_pag - 1)       
 | |
|   {
 | |
|     set_row(1, "@1g%-50s", (const char*) _ragsoc);
 | |
|     TString s(_indulc);
 | |
|     
 | |
|     s << " " << _civulc << " " << _capulc << " " << _com << " " << _prov;
 | |
|     set_row(1, "@62g%-65s", (const char*) s);
 | |
|     set_row(2, "@1g%-50s", (const char*) _descr);
 | |
|     set_row(2, FR("@52gCODICE FISCALE %-16s"), (const char*) _cofi);
 | |
|     set_row(2, FR("@85gPARTITA I.V.A. %-11s"), (const char*) _paiv);         
 | |
|     if (_anno_stampa == 0)    
 | |
|       set_row(2, FR("@120gPag. %ld"), contatore);         
 | |
|     else
 | |
|       set_row(2, FR("@120gPag. %4d/%ld"), _anno_stampa, contatore);         
 | |
|     set_row(25, FR("@50gN. ........ DI REPERTORIO"));
 | |
|     set_row(27, FR("@50gIL PRESENTE LIBRO DELLA@75g%-50s"), (const char*) _ragsoc);
 | |
| 
 | |
|     s = _indulc;
 | |
|     s << " " << _civulc;
 | |
|     set_row(29, "@50g%-52s", (const char*) s);
 | |
|     s = _capulc; 
 | |
|     s << " " << _com << " " << _prov;
 | |
|     set_row(31, "@50g%-62s", (const char*) s);
 | |
|     set_row(33, FR("@50gCONSTA DI %ld PAGINE UTILI, BOLLATE E NUMERATE"), _num_pag - (_inizia_dopo ? 1 : 0));
 | |
|     set_row(35, FR("@50gE VIENE OGGI VIDIMATO, il ........."));
 | |
|   }
 | |
|   else
 | |
|   { 
 | |
|     set_row(1, "@1g%-50s", (const char*) _ragsoc);
 | |
|     TString s(_indulc);
 | |
|     
 | |
|     s << " " << _civulc << " " << _capulc << " " << _com << " " << _prov;
 | |
|     set_row(1, "@52g%-68s", (const char*) s);
 | |
|     set_row(2, "@1g%-50s", (const char*) _descr);
 | |
|     set_row(2, FR("@52gCODICE FISCALE %-16s"), (const char*) _cofi);
 | |
|     set_row(2, FR("@85gPARTITA I.V.A. %-11s"), (const char*) _paiv);
 | |
|     if (_anno_stampa == 0)
 | |
|       set_row(2, FR("@120gPag. %ld"), contatore);  
 | |
|     else      
 | |
|       set_row(2, FR("@120gPag. %4d/%ld"), _anno_stampa, contatore);  
 | |
|   }
 | |
| }
 | |
| 
 | |
| bool Libribollati_print::set_print(int)
 | |
| { 
 | |
|   _msk->reset(F_TIPOREG);          
 | |
|   _msk->reset(F_TIPOREGCOM);       
 | |
|   _msk->reset(F_ANNO);          
 | |
|   _msk->reset(F_CODICE);          
 | |
|   _msk->reset(F_ANNOREG);          
 | |
|   _msk->reset(F_CODICEREG);          
 | |
|   _msk->reset(F_REGISTRO);          
 | |
|   _msk->reset(F_NPAGINI);          
 | |
|   _msk->reset(F_NPAGFI);          
 | |
|   _msk->reset(F_PRIMO);          
 | |
|   _msk->reset(F_ANNOSTAMPA);          
 | |
|   if (_msk->run() == K_ENTER) 
 | |
|   {
 | |
|     TPrinter& pr = printer();
 | |
|     //pr.formlen(_msk->get_int(F_LUNG));
 | |
|     int font_size = pr.calc_font_size(132);
 | |
|     if (font_size != pr.get_char_size())
 | |
|     {
 | |
|       warning_box(FR("Il font e' stato ridimensionato a %d punti per\nadattarsi alle dimensioni attuali della pagina."), font_size);
 | |
|       pr.set_char_size(font_size);
 | |
|     } 
 | |
|     _cod_reg      = _msk->get(F_CODICE);
 | |
|     _cod_anno     = _msk->get_int(F_ANNO);
 | |
|     _pag_ini      = _msk->get_long(F_NPAGINI);
 | |
|     _pag_fin      = _msk->get_long(F_NPAGFI);
 | |
|     _inizia_dopo  = _msk->get_bool(F_PRIMO);
 | |
|     _num_pag      = (_pag_fin - _pag_ini) + 1;
 | |
|     _ragsoc       = _msk->get(F_RAGSOC);
 | |
|     _indulc       = _msk->get(F_INDIRIZZO);
 | |
|     _civulc       = _msk->get(F_CIV);
 | |
|     _capulc       = _msk->get(F_CAP);
 | |
|     _comulc       = _msk->get(F_CODCOM);
 | |
|     _com          = _msk->get(F_COM);
 | |
|     _prov         = _msk->get(F_PROV);
 | |
|     _paiv         = _msk->get(F_PAIV);
 | |
|     _cofi         = _msk->get(F_COFI);
 | |
|     _anno_stampa  = _msk->get_int(F_ANNOSTAMPA);
 | |
|     _descr        = _msk->get(F_REGISTRO);
 | |
|     if (_inizia_dopo) _num_pag++; 
 | |
|     enable_print_menu();      
 | |
|     return TRUE;
 | |
|   }
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| bool Libribollati_print::registro_handler(TMask_field& field, KEY key)
 | |
| {
 | |
|   if (key == K_TAB && field.focusdirty())
 | |
|   {
 | |
|     //field.mask().set(F_LUNG,66);
 | |
|     field.mask().set(F_NPAGINI, 0L);
 | |
|     field.mask().set(F_NPAGFI, 0L);
 | |
|   } 
 | |
|   return TRUE;
 | |
| }
 | |
| bool Libribollati_print::codditta_handler(TMask_field& field, KEY key)
 | |
| { 
 | |
|   if (key == K_TAB)
 | |
|   { 
 | |
|     TMask& m = field.mask();
 | |
|     const long codditta = m.get_long(F_CODDITTA);
 | |
|     if (codditta == 0)
 | |
|       m.reset();      
 | |
|     else
 | |
|     {   
 | |
|       TLocalisamfile nditte(LF_NDITTE);
 | |
|       TLocalisamfile unloc(LF_UNLOC);
 | |
|       TLocalisamfile comuni(LF_COMUNI);
 | |
|       TLocalisamfile anag(LF_ANAG);
 | |
|       
 | |
|       nditte.setkey(1);
 | |
|       nditte.zero();
 | |
|       nditte.put(N_CODDITTA, codditta);   
 | |
|       nditte.read();                 
 | |
|       if (nditte.bad()) 
 | |
|         return field.error_box(FR("Il codice ditta %d non esiste"), codditta);
 | |
|       const bool exist_firm = prefix().exist(codditta);  
 | |
|       if (exist_firm)
 | |
|         app().set_firm(codditta);
 | |
|       m.hide(exist_firm ? -4 : -3);
 | |
|       m.show(exist_firm ? -3 : -4);
 | |
|       app()._ragsoc = nditte.get(N_RAGSOC);
 | |
|       m.set(F_RAGSOC,app()._ragsoc);
 | |
|   
 | |
|       const TString16 tipoa = nditte.get(N_TIPOA);
 | |
|       const long codanagr = atol(nditte.get(N_CODANAGR));
 | |
|     
 | |
|       unloc.setkey(1);
 | |
|       unloc.zero();
 | |
|       unloc.put(N_CODDITTA, codditta);
 | |
|       unloc.put(N_CODULC,"1");
 | |
|       unloc.read();
 | |
|       app()._indulc = unloc.get(N_INDULC);
 | |
|       m.set(F_INDIRIZZO, app()._indulc);
 | |
|       app()._civulc = unloc.get(N_CIVULC);
 | |
|       m.set(F_CIV, app()._civulc);
 | |
|       app()._capulc = unloc.get(N_CAPULC);
 | |
|       m.set(F_CAP, app()._capulc);
 | |
|       app()._comulc = unloc.get(N_COMULC);
 | |
|       m.set(F_CODCOM, app()._comulc);
 | |
|     
 | |
|       comuni.setkey(1);
 | |
|       comuni.zero();
 | |
|       comuni.put(N_CODCOM, app()._comulc);
 | |
|       comuni.read();
 | |
|       app()._com = comuni.get(N_COM);
 | |
|       m.set(F_COM, app()._com);
 | |
|       app()._prov = comuni.get(N_PROV);
 | |
|       m.set(F_PROV, app()._prov);
 | |
|     
 | |
|       anag.setkey(1);  
 | |
|       anag.zero();
 | |
|       anag.put(N_TIPOA, tipoa);
 | |
|       anag.put(N_CODANAGR, codanagr);
 | |
|       anag.read();
 | |
|       app()._cofi = anag.get(N_COFI);
 | |
|       m.set(F_COFI, app()._cofi);
 | |
|       app()._paiv = anag.get(N_PAIV);
 | |
|       m.set(F_PAIV, app()._paiv);
 | |
|     }   
 | |
|   }   
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool Libribollati_print::user_create()
 | |
| {
 | |
| //  if (get_firm() == 0L)
 | |
| //    if (!set_firm()) return FALSE;
 | |
| 
 | |
|   enable_print_menu();
 | |
|   _nditte = new TLocalisamfile(LF_NDITTE);
 | |
|   _unloc =  new TLocalisamfile(LF_UNLOC);
 | |
|   _comuni = new TLocalisamfile(LF_COMUNI);
 | |
|   _anag =   new TLocalisamfile(LF_ANAG);
 | |
|   _tab =    new TTable("REG");
 | |
| 
 | |
|   _msk = new TMask("ba3300a") ;
 | |
|   _msk->set_handler(F_REGISTRO, registro_handler);
 | |
|   _msk->set_handler(F_CODDITTA, codditta_handler);
 | |
|   
 | |
|   add_cursor(NULL);
 | |
|   set_auto_ff(TRUE);
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool Libribollati_print::user_destroy()
 | |
| {
 | |
|   delete  _msk;
 | |
|   delete  _nditte;
 | |
|   delete  _unloc;
 | |
|   delete  _comuni;
 | |
|   delete  _anag;
 | |
|   delete  _tab;   
 | |
|   if (_p) delete _p;
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| int ba3300(int argc, char* argv[])
 | |
| {
 | |
|   Libribollati_print a;
 | |
|   a.run(argc, argv, TR("Stampa fogli libri bollati"));
 | |
|   return 0;
 | |
| }
 |