158 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			158 lines
		
	
	
		
			3.2 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| //********************************
 | |
| //* Aggiornamento Tipo Attivita' *
 | |
| //********************************
 | |
| #include <applicat.h> 
 | |
| #include <mask.h>
 | |
| #include <relation.h>
 | |
| #include <tabutil.h>
 | |
| #include <utility.h>
 | |
| #include <progind.h>
 | |
| #include <urldefid.h>
 | |
| #include <prefix.h>   
 | |
| #include <mov.h>  
 | |
| #include <rmoviva.h>
 | |
| #include "conto.h"
 | |
| #include "cg2103.h"
 | |
| #include "cg1301.h"
 | |
| #include "cg1302.h" 
 | |
| #include "cg1303.h" 
 | |
| #include "cg1304.h"
 | |
| #include "cg1.h"  
 | |
| 
 | |
| class TAgg_attiv : public TApplication
 | |
| {
 | |
|   TLocalisamfile*  _pcon,* _attiv;
 | |
|   TTable*          _reg;
 | |
|   
 | |
| public:        
 | |
|   virtual bool create();
 | |
|   virtual bool destroy();
 | |
|   virtual bool menu(MENU_TAG m);         
 | |
|   
 | |
|   void elabora_mov();
 | |
| 
 | |
|   TAgg_attiv() {};
 | |
|   virtual ~TAgg_attiv() {};
 | |
| };                                      
 | |
| 
 | |
| HIDDEN TAgg_attiv& app() { return (TAgg_attiv&)main_app(); }
 | |
| 
 | |
| bool TAgg_attiv::create()
 | |
| {
 | |
|   TApplication::create();
 | |
| 
 | |
|   _pcon    = new TLocalisamfile(LF_PCON);
 | |
|   _attiv   = new TLocalisamfile(LF_ATTIV);
 | |
|   _reg     = new TTable("REG");
 | |
|   
 | |
|   dispatch_e_menu (BAR_ITEM(1));
 | |
| 
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TAgg_attiv::destroy()
 | |
| { 
 | |
|   delete _pcon;
 | |
|   delete _attiv;  
 | |
|   delete _reg;
 | |
|   
 | |
|   return TApplication::destroy();
 | |
| }                                
 | |
| 
 | |
| bool TAgg_attiv::menu(MENU_TAG m)
 | |
| {
 | |
|   TMask msk("cg1300a");
 | |
|   
 | |
|   while (msk.run() == K_ENTER) 
 | |
|   {
 | |
|     elabora_mov();
 | |
|     message_box("Aggiornamento completato");
 | |
|     //return TRUE;
 | |
|   }
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| void TAgg_attiv::elabora_mov()
 | |
| {
 | |
|   TRelation rel (LF_MOV);
 | |
|   rel.add(LF_RMOVIVA, "NUMREG=NUMREG",1);
 | |
|   TCursor cursor(&rel,"",1);
 | |
|   
 | |
|   TLocalisamfile& mov = rel.lfile();
 | |
|   TLocalisamfile& rmoviva = rel.lfile(LF_RMOVIVA);
 | |
|   
 | |
|   long ditta = get_firm();
 | |
|   cursor = 0L;
 | |
|   const long nitems = cursor.items();
 | |
|   
 | |
|   TProgind p(nitems ? nitems : 1, "Aggiornamento in corso..." , TRUE, TRUE, 70);
 | |
| 
 | |
|   for (; cursor.pos() < cursor.items(); ++cursor)
 | |
|   {
 | |
|     p.addstatus(1);
 | |
|     const TString16 reg(mov.get(MOV_REG));
 | |
|     if (reg.empty()) continue;
 | |
|     
 | |
|     const int annoiva = mov.get_int(MOV_ANNOIVA);
 | |
|     TRegistro registro(reg, annoiva);
 | |
|     const bool att_mista = registro.attivita_mista();
 | |
|     
 | |
|     if (att_mista)
 | |
|     {   
 | |
|       bool ok = rel.is_first_match(LF_RMOVIVA);
 | |
|       while (ok)
 | |
|       {
 | |
|         const char tipo = rmoviva.get_char("TIPOC");
 | |
|         if (tipo <= ' ')               
 | |
|         {
 | |
|           TBill c(rmoviva.get_int("GRUPPO"), rmoviva.get_int("CONTO"), rmoviva.get_long("SOTTOCONTO"));
 | |
|           int tipoatt = c.tipo_att();
 | |
|           rmoviva.put("TIPOATT", tipoatt); 
 | |
|           rmoviva.rewrite();      
 | |
|         }
 | |
|         ok = rel.next_match(LF_RMOVIVA);  
 | |
|       }
 | |
|     }  
 | |
|   } 
 | |
| }
 | |
| 
 | |
| int cg1300(int argc, char* argv[])
 | |
| {                                
 | |
|   switch (*argv[2])
 | |
|   {
 | |
|   case 'A':
 | |
|   {
 | |
|     TAgg_attiv a;      
 | |
|     a.run(argc, argv, "Aggiornamento tipo attivita' su movimenti iva");
 | |
|   }
 | |
|   break;
 | |
|  case 'I':
 | |
| {
 | |
|   TAgg_opintra a;
 | |
|   a.run(argc, argv, "Aggiornamento flag op. intracomunitarie");       
 | |
| }
 | |
| break;
 | |
|  case 'T':
 | |
| {
 | |
|   TAgg_tconto a;                      
 | |
|   a.run(argc, argv, "Aggiornamento tipo conto");       
 | |
| }
 | |
| break;
 | |
|  case 'P':
 | |
| {   
 | |
|   TAgg_nprot a;       
 | |
|   a.run(argc, argv,"Rinumerazione numero di protocollo");
 | |
| } 
 | |
| break;
 | |
|  case 'C':
 | |
| {   
 | |
|   TAgg_codatt a;       
 | |
|   a.run(argc, argv,"Aggiornamento codice attivita'");
 | |
| } 
 | |
| break;
 | |
| default:
 | |
| break;
 | |
| }
 | |
| return TRUE;
 | |
| }
 |