Files correlati : Ricompilazione Demo : [ ] Commento : Corretta esportazione listini per TERASHOP git-svn-id: svn://10.65.10.50/branches/R_10_00@22486 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			158 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			158 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include <applicat.h>
 | |
| #include <automask.h>
 | |
| #include <dongle.h>
 | |
| #include <modaut.h>
 | |
| #include <progind.h>
 | |
| #include <reprint.h>
 | |
| #include <reputils.h>
 | |
| #include <utility.h>
 | |
| 
 | |
| #include "../mg/anamag.h"
 | |
| 
 | |
| #include "ps0330100a.h"
 | |
| 
 | |
| ///////////////////////////////////////////////
 | |
| //  MASCHERA
 | |
| ///////////////////////////////////////////////
 | |
| class TMultimarche_mask : public TAutomask
 | |
| {
 | |
| protected:
 | |
|   virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | |
| 
 | |
| public:
 | |
|   TMultimarche_mask();
 | |
| };
 | |
| 
 | |
| TMultimarche_mask::TMultimarche_mask() : TAutomask("ps0330100a")
 | |
| {
 | |
| }
 | |
| 
 | |
| bool TMultimarche_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | |
| {
 | |
|   /*switch(o.dlg())
 | |
|   {
 | |
|   default:
 | |
|     break;
 | |
|   }*/
 | |
|   return true;
 | |
| }
 | |
| 
 | |
| ///////////////////////////////////////////////
 | |
| //  RECORDSET
 | |
| ///////////////////////////////////////////////
 | |
| 
 | |
| 
 | |
| 
 | |
| ///////////////////////////////////////////////
 | |
| //  REPORT
 | |
| ///////////////////////////////////////////////
 | |
| //il report in questione ha la query inside..
 | |
| //..e non necessita di altro che i FIELD #... dei campi della maschera per avere i valori..
 | |
| //..delle set_var interne
 | |
| class TMultimarche_report : public TReport
 | |
| {
 | |
| protected:
 | |
|   virtual bool use_mask() { return false; } //questo ci vuole perchè la maschera ha un nome != dai report
 | |
| public:
 | |
|   TMultimarche_report() {}
 | |
| };
 | |
| 
 | |
| 
 | |
| ///////////////////////////////////////////////
 | |
| //  APPLICAZIONE
 | |
| ///////////////////////////////////////////////
 | |
| class TMultimarche : public TSkeleton_application
 | |
| {
 | |
|   TMultimarche_mask*  _mask;
 | |
| 
 | |
| protected:
 | |
|   virtual bool check_autorization() const { return false; }
 | |
|   virtual const char* extra_modules() const { return "ve"; }
 | |
|   virtual bool create();
 | |
|   virtual void main_loop();
 | |
| 
 | |
| public:
 | |
|   void elabora();
 | |
| 
 | |
| };
 | |
| 
 | |
| void TMultimarche::elabora()
 | |
| {
 | |
|   TMultimarche_report rep;
 | |
|   if (rep.load(_mask->get(F_REPORT)))
 | |
|   {
 | |
|     TRecordset* recset = rep.recordset();
 | |
|     const long anno = _mask->get_int(F_ANNO);
 | |
|     const TString4 codmag = _mask->get(F_CODMAG);
 | |
| 
 | |
|     //crea l'elenco delle marche
 | |
|     TString marche_query;
 | |
|     marche_query << "USE ANAMAG\nSELECT CODART?=\"???";
 | |
|     marche_query << "\nFROM CODART=#DAMARCA";
 | |
|     marche_query << "\nTO CODART=#AMARCA";
 | |
|     TISAM_recordset marche_recset(marche_query);
 | |
|     const TString& damarca = _mask->get(F_DAMARCA);
 | |
|     const TString& amarca = _mask->get(F_AMARCA);
 | |
|     marche_recset.set_var("#DAMARCA", damarca);
 | |
|     marche_recset.set_var("#AMARCA", amarca);
 | |
|     const long marche_items = marche_recset.items();
 | |
| 
 | |
|     TProgind pi(marche_items, "Esportazione bovina in corso...", true, true);
 | |
| 
 | |
|     for (bool ok = marche_recset.move_first(); ok; ok = marche_recset.move_next())
 | |
|     {
 | |
|       if (!pi.addstatus(1))
 | |
|         break;
 | |
| 
 | |
|       const TString4 marca = marche_recset.get(ANAMAG_CODART).as_string();
 | |
|       recset->set_var("#MARCA", marca);
 | |
|       recset->set_var("#ANNO", anno);
 | |
|       recset->set_var("#CODMAG", codmag);
 | |
|       const long items = recset->items();
 | |
|       if (items > 0)
 | |
|       {  
 | |
|         TReport_book book;
 | |
| 	      book.add(rep);
 | |
|         TFilename fname = _mask->get(F_PATH_FILE);
 | |
|         TString4 str_anno;
 | |
|         str_anno << anno;
 | |
|         fname.add(str_anno);
 | |
|         fname << "_" << marca;
 | |
|         fname.ext("xls");
 | |
| 	      book.export_excel(fname, false);
 | |
|       }
 | |
|     }
 | |
|   }
 | |
| 
 | |
| }
 | |
| 
 | |
| bool TMultimarche::create()
 | |
| {
 | |
|   //se non ha VE non può proseguire
 | |
|   if (!has_module(VEAUT))
 | |
|     return error_box(TR("Modulo non autorizzato"));
 | |
|   
 | |
|   Tdninst dninst;
 | |
|   if (!dninst.can_I_run(true))
 | |
|     return error_box(TR("Programma non autorizzato!"));
 | |
|   
 | |
|   return TSkeleton_application::create();
 | |
| }
 | |
| 
 | |
| void TMultimarche::main_loop()
 | |
| {
 | |
|   _mask = new TMultimarche_mask;
 | |
|   if (_mask->run() != K_QUIT)
 | |
|     elabora();
 | |
| 
 | |
|   delete _mask;
 | |
|   _mask = NULL;
 | |
| }
 | |
| 
 | |
| 
 | |
| int ps0330100 (int argc, char **argv)
 | |
| {
 | |
|   TMultimarche a;
 | |
|   a.run(argc,argv, TR("Rimanenze per marca"));
 | |
|   return true;
 | |
| } |