Ricompilazione Demo : [ ] Commento : Riportata la versione 3.1 patch 848 git-svn-id: svn://10.65.10.50/trunk@14996 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			104 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			104 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| // sistema il codice esercizio di tutti i movimenti
 | |
| #include <mask.h>
 | |
| #include <progind.h>
 | |
| #include <recarray.h>
 | |
| #include <relation.h>
 | |
| 
 | |
| #include "cglib01.h"
 | |
| #include "cg1300.h"
 | |
| #include "cg1305.h"
 | |
| 
 | |
| #include <mov.h>
 | |
| #include <rmov.h>
 | |
| #include <rmoviva.h>
 | |
| 
 | |
| inline TAgg_codes& app() { return (TAgg_codes&) main_app(); }
 | |
| 
 | |
| bool TAgg_codes::create()
 | |
| {
 | |
| 	open_files(LF_MOV, LF_RMOV, LF_RMOVIVA, 0);
 | |
| 
 | |
|   return TSkeleton_application::create();
 | |
| }
 | |
| 
 | |
| //bool TAgg_codes::destroy()
 | |
| //{ 
 | |
| //  return TSkeleton_application::destroy();
 | |
| //}                                
 | |
| 
 | |
| void TAgg_codes::main_loop()
 | |
| {
 | |
|   TMask msk("cg1300d");
 | |
|   if (msk.run() == K_ENTER)
 | |
|     calcola_codes();
 | |
| }  
 | |
| 
 | |
| void TAgg_codes::calcola_codes()
 | |
| {
 | |
|   TLocalisamfile mov(LF_MOV);
 | |
|   TEsercizi_contabili esercizi;
 | |
|   TDate data;
 | |
|   long modified_recs=0L;
 | |
| 
 | |
|   long nrecs = (long) mov.eod();
 | |
|   int err = NOERR;
 | |
|   TProgind p(nrecs, TR("Aggiornamento in corso..."), TRUE, TRUE, 100);
 | |
|   TRecord_array righe(LF_RMOV,RMV_NUMRIG);
 | |
|   TRecord_array righeiva(LF_RMOVIVA,RMI_NUMRIG);
 | |
|   TRectype riga(LF_RMOV);
 | |
|   TRectype rigaiva(LF_RMOVIVA);
 | |
|   TString s_codes;
 | |
| 
 | |
|   for (mov.first(); !mov.eof() && err == NOERR; mov.next())
 | |
|   { 
 | |
| 		bool mod = false;
 | |
|     p.addstatus(1);
 | |
|     data=mov.get_date(MOV_DATACOMP);
 | |
|     int codes = mov.get_int(MOV_ANNOES);
 | |
|     const int newcodes = esercizi.date2esc(data);
 | |
|     if (codes != newcodes)
 | |
|     {
 | |
|       mov.put(MOV_ANNOES,newcodes);
 | |
|       err = mov.rewrite();
 | |
| 			mod = err == NOERR;
 | |
| 		}
 | |
|     const long numreg = mov.get_long(MOV_NUMREG);
 | |
| 
 | |
|     riga.put(RMV_NUMREG,numreg);
 | |
|     righe.read(riga);
 | |
| 		bool update_es = false;
 | |
| 		for(int i = righe.first_row() ; !update_es && i <= righe.last_row(); i = righe.succ_row(i))
 | |
| 		{
 | |
| 			codes = righe[i].get_int(RMV_ANNOES);
 | |
| 			update_es = (codes != newcodes);
 | |
| 		}
 | |
| 		if (update_es)
 | |
| 		{
 | |
| 			righe.renum_key(RMV_ANNOES,newcodes);
 | |
|       err = righe.rewrite();
 | |
| 			mod = err == NOERR;
 | |
| 		}
 | |
|     rigaiva.put(RMI_NUMREG,numreg);
 | |
|     righeiva.read(rigaiva);
 | |
| 		update_es = false;
 | |
| 		for(int j = righeiva.first_row() ; !update_es && j <= righeiva.last_row(); j = righeiva.succ_row(j))
 | |
| 		{
 | |
| 	    codes = righeiva[j].get_int(RMI_ANNOES);
 | |
| 			update_es = (codes != newcodes);
 | |
| 		}
 | |
| 		if (update_es)
 | |
| 		{
 | |
| 			s_codes.format("%04d",newcodes);
 | |
| 			righeiva.renum_key(RMI_ANNOES,s_codes);
 | |
|       err = righeiva.rewrite();
 | |
| 			mod = err == NOERR;
 | |
|     }
 | |
| 		if (mod)
 | |
| 			modified_recs++;
 | |
|   }
 | |
|   if (err != NOERR) 
 | |
|     warning_box(FR("Aggiornamento codice esercizio interrotta. Rilevato errore %d in riscrittura"),err);
 | |
|   else 
 | |
|     message_box(FR("Aggiornamento codice esercizio completata. Modificati %ld movimenti.\nE' necessario procedere col ricalcolo saldi"), modified_recs);
 | |
| }
 |