Files correlati : cg1.exe cg3.exe Ricompilazione Demo : [ ] Commento : Aggiunto supporto per le lingue a cg1.exe e cg3.exe git-svn-id: svn://10.65.10.50/trunk@10914 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			150 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			150 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| //***********************************
 | |
| //* Rinumerazione numero protocollo *
 | |
| //***********************************
 | |
| #include <mask.h>
 | |
| #include <progind.h>
 | |
| #include <tabutil.h>
 | |
| #include <relation.h>
 | |
| 
 | |
| #include "cg1300.h"  
 | |
| #include "cg1303.h"
 | |
| 
 | |
| #include <mov.h>
 | |
| #include <partite.h>
 | |
| 
 | |
| 
 | |
| HIDDEN TAgg_nprot& app() { return (TAgg_nprot&) main_app(); }
 | |
| 
 | |
| HIDDEN bool filtra_mov(const TRelation* r)
 | |
| {           
 | |
|   const TRectype& mov = r->curr(); 
 | |
|   const int annoiva = mov.get_int(MOV_ANNOIVA); 
 | |
|   const TString16 reg = mov.get(MOV_REG); 
 | |
| 
 | |
|   TAgg_nprot& a = app();
 | |
|   return a.anno() == annoiva && a.reg() == reg;
 | |
| }
 | |
| 
 | |
| void TAgg_nprot::main_loop()
 | |
| {
 | |
|   TMask msk("cg1300b");
 | |
| 
 | |
|   while (msk.run() == K_ENTER)
 | |
|   {
 | |
|     _anno = msk.get_int(F_ANNO);   
 | |
|     _reg  = msk.get(F_REG);
 | |
|     
 | |
|     rinumera_prot(msk.get(F_MODE)[0], msk.get_long(F_PROT));
 | |
|     
 | |
|     msk.reset(F_REG);
 | |
|   }         
 | |
| }  
 | |
| 
 | |
| bool TAgg_nprot::rinumera_prot(char mode, long last_prot)
 | |
| {
 | |
|   TTable reg("REG");
 | |
|   TString16 s; s.format("%04d%s", _anno, (const char*)_reg);
 | |
|   reg.put("CODTAB", s);
 | |
|   if (reg.read() != NOERR)
 | |
|     return error_box(FR("Impossibile leggere il registro %s del %d"), 
 | |
|                      (const char*)_reg, _anno); 
 | |
| 
 | |
|   TRelation rel (LF_MOV);
 | |
|   rel.add(LF_PARTITE,"NREG=NUMREG",2);
 | |
| 
 | |
|   TLocalisamfile& mov = rel.lfile();
 | |
|   TLocalisamfile& part= rel.lfile(LF_PARTITE);
 | |
|   
 | |
|   TCursor cursor(&rel, "", 2);  
 | |
|   cursor.set_filterfunction(filtra_mov);
 | |
|   
 | |
|   const long nitems = cursor.items();
 | |
|   if (nitems == 0)
 | |
|     return warning_box(TR("Non ci sono movimenti da rinumerare"));
 | |
| 
 | |
|   TConfig cnf(CONFIG_DITTA,"cg");
 | |
|   const bool sc_enabled = cnf.get_bool("GesSal");
 | |
| 
 | |
|   cursor.freeze();
 | |
|   cursor = 0L;
 | |
| 
 | |
|   TProgind p(nitems, TR("Elaborazione in corso...") , FALSE, TRUE);
 | |
|   
 | |
|   long protiva, uprotiva;
 | |
|   
 | |
|   if (mode == 'N' || mode == 'U')
 | |
|   {
 | |
|     for (; cursor.pos() < nitems; ++cursor)
 | |
|     {
 | |
|       p.addstatus(1);
 | |
|       protiva  = mov.get_long(MOV_PROTIVA); 
 | |
|       uprotiva = mov.get_long(MOV_UPROTIVA);
 | |
| 
 | |
|       if (mode == 'U')
 | |
|       {
 | |
|         if (mov.get_bool(MOV_REGST))
 | |
|         {
 | |
|           last_prot = uprotiva > protiva ? uprotiva : protiva;
 | |
|           continue;
 | |
|         }
 | |
|         break;
 | |
|       }     
 | |
|       
 | |
|       if (mode == 'N')
 | |
|       {
 | |
|         if (protiva != last_prot && uprotiva != last_prot) 
 | |
|           continue;
 | |
|         else
 | |
|         {
 | |
|           if (uprotiva != 0l)
 | |
|             last_prot = uprotiva;
 | |
|           break;
 | |
|         } 
 | |
|       }
 | |
|     }    
 | |
|   
 | |
|     if (last_prot > 0 && mode == 'N')
 | |
|     {
 | |
|       if (protiva != last_prot && uprotiva != last_prot) //sono alla fine del file
 | |
|         return error_box(TR("Non esiste la registrazione con protocollo %ld:\nrinumerazione non avvenuta"), last_prot); 
 | |
|       ++cursor;
 | |
|     }
 | |
|   }  
 | |
|   
 | |
|   long nprot,uprot,dprot;
 | |
|   dprot = uprot = 0L;
 | |
|   nprot = last_prot;
 | |
| 
 | |
|   for (; cursor.pos() < nitems; ++cursor)  
 | |
|   {
 | |
|     p.addstatus(1);
 | |
|     protiva  = mov.get_long(MOV_PROTIVA); 
 | |
|     uprotiva = mov.get_long(MOV_UPROTIVA);
 | |
|     
 | |
|     nprot = nprot+1+dprot;  //stile RPG
 | |
|     dprot = 0L;
 | |
|     uprot = 0L;
 | |
|     dprot = (uprotiva == 0L) ? 0L : (uprotiva - protiva);
 | |
|     uprot = (uprotiva == 0L) ? 0L : (nprot + dprot);
 | |
|     
 | |
|     mov.put(MOV_PROTIVA, nprot);
 | |
|     mov.put(MOV_UPROTIVA, uprot);
 | |
|     mov.rewrite();
 | |
|     // Aggiorna il nr di prot. iva sul file partite
 | |
|     if (sc_enabled && rel.is_first_match(LF_PARTITE))
 | |
|     {
 | |
|       do
 | |
|       {
 | |
|         part.put(PART_PROTIVA,nprot);
 | |
|         part.rewrite();
 | |
|       } while (rel.next_match(LF_PARTITE));
 | |
|     }
 | |
|   }     
 | |
|   
 | |
|   reg.put("I5", nprot + dprot);
 | |
|   reg.rewrite();
 | |
| 
 | |
|   return message_box(TR("Rinumerazione numero protocollo completata"));
 | |
| }
 | |
| 
 |