Files correlati : Ricompilazione Demo : [ ] Commento : aggiunto il controllo sul dninst git-svn-id: svn://10.65.10.50/trunk@19985 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			181 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			181 lines
		
	
	
		
			4.2 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include <applicat.h>
 | |
| #include <automask.h>
 | |
| #include <config.h>
 | |
| #include <defmask.h>
 | |
| #include <dongle.h>
 | |
| #include <recset.h>
 | |
| #include <reprint.h>
 | |
| #include <utility.h>
 | |
| 
 | |
| #include "ve3500a.h"
 | |
| 
 | |
| ////////////////////////////////////////////////////////
 | |
| //	MASCHERA
 | |
| ////////////////////////////////////////////////////////
 | |
| class TPrint_condven_mask : public TAutomask
 | |
| {
 | |
| protected:
 | |
|   virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | |
| public:
 | |
|   TPrint_condven_mask();
 | |
| };
 | |
| 
 | |
| TPrint_condven_mask::TPrint_condven_mask() : TAutomask("ve3500a")
 | |
| {
 | |
|   //legge il parametro con cui è stato chiamato il programma ('C'ontratti,'L'istini,'O'fferte..
 | |
|   //..ed in base a questo setta il valore del campo F_TIPO sulla maschera che fa apparire/scomparire..
 | |
|   //..campi
 | |
|   const char* tipo = "L";
 | |
|   if (main_app().argc() > 2)
 | |
|     tipo = main_app().argv(2);
 | |
|   
 | |
|   set(F_TIPO, tipo);
 | |
|   switch (tipo[0])
 | |
|   {
 | |
|   case 'L':
 | |
|   {
 | |
|     //il costruttore abilita/disabilita i campi delle categorie di vendita in base alla configurazione
 | |
|     const bool gesliscv = ini_get_bool(CONFIG_DITTA, "ve", "GESLISCV");
 | |
|     enable(F_L_CATVEN, gesliscv);
 | |
|     enable(F_L_DESVEN, gesliscv);
 | |
|     //attenzione!!! il campo CATVEN è in chiave 1! per disabilitarlo ci vuole questo trucco!
 | |
|     if (!gesliscv)
 | |
|       efield(F_L_CATVEN).reset_key(1);
 | |
|   }
 | |
|     break;
 | |
|   case 'C':
 | |
|     {
 | |
|       const bool gescf = ini_get_bool(CONFIG_DITTA, "ve", "GESCONCC");
 | |
|       enable(F_C_TIPOCF, gescf);
 | |
|       enable(F_C_CODCF, gescf);
 | |
|       //anche i campi dei clifo stanno in chiave!
 | |
|       if (!gescf)
 | |
|       {
 | |
|         efield(F_C_TIPOCF).reset_key(1);
 | |
|         efield(F_C_CODCF).reset_key(1);
 | |
|       }
 | |
|     }
 | |
|     break;
 | |
|   case 'O':
 | |
|     break;
 | |
|   default:
 | |
|     break;
 | |
|   }
 | |
|   
 | |
| 
 | |
| }
 | |
| 
 | |
| bool TPrint_condven_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 3, per Contratti, Listini, Offerte) 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_condven_report : public TReport
 | |
| {
 | |
| protected:
 | |
|   virtual bool use_mask() { return false; } //questo ci vuole perchè la maschera ha un nome != dai report
 | |
| public:
 | |
|   TPrint_condven_report() {}
 | |
| };
 | |
| 
 | |
| 
 | |
| ////////////////////////////////////////////////////////
 | |
| //	APPLICAZIONE
 | |
| ////////////////////////////////////////////////////////
 | |
| class TPrint_condven : public TSkeleton_application
 | |
| {
 | |
|   TPrint_condven_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_condven::print_or_preview(const bool stampa)
 | |
| {
 | |
|   if (_mask->check_fields())
 | |
|   {
 | |
|     //l'utonto può scegliere che report usare (personalizzato!)
 | |
|     TString rep_name = _mask->get(F_REPORT);
 | |
|     //se il rep non è selezionato usa quello standard
 | |
| 		if (rep_name.empty())
 | |
|       rep_name << "ve3500" << _mask->get(F_TIPO);
 | |
| 
 | |
|     TPrint_condven_report rep;
 | |
| 	  rep.load(rep_name);
 | |
|     
 | |
|     rep.mask2report(*_mask);  //setta i valori della maschera sul report
 | |
| 
 | |
|     TReport_book book;
 | |
| 	  book.add(rep);
 | |
| 	  book.print_or_preview();
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TPrint_condven::print()
 | |
| {
 | |
|   print_or_preview(true);
 | |
| }
 | |
| 
 | |
| void TPrint_condven::preview()
 | |
| {
 | |
|   print_or_preview(false);
 | |
| }
 | |
| 
 | |
| void TPrint_condven::main_loop()
 | |
| {
 | |
|   _mask = new TPrint_condven_mask;
 | |
|   _mask->run();
 | |
|   delete _mask;
 | |
|   _mask = NULL;
 | |
| }
 | |
| 
 | |
| bool TPrint_condven::create()
 | |
| {
 | |
|   //controlla se la chiave ha l'autorizzazione a questo programma
 | |
|   Tdninst dninst;
 | |
|   if (!dninst.can_I_run(true))
 | |
|     return error_box(TR("Programma non autorizzato!"));
 | |
| 
 | |
|   return TSkeleton_application::create();
 | |
| }
 | |
| 
 | |
| int ve3500(int argc, char* argv[])
 | |
| {
 | |
|   TPrint_condven a;
 | |
|   a.run(argc, argv, TR("Stampa condizioni di vendita"));
 | |
|   return 0;
 | |
| } |