Files correlati : cg3.exe Ricompilazione Demo : [ ] Commento : CM20053 Se dall'anteprima di stampa mi collego alla prima nota e faccio una variazione dando registra, rientrando nel mastrino la procedura non mi chiede se voglio riaggionare la stampa. Devo rilanciarla git-svn-id: svn://10.65.10.50/trunk@11556 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			179 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			179 lines
		
	
	
		
			4.0 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| // Rinumerazione movimenti e saldi
 | |
| // fv 12/12/93
 | |
| // -------------------------------------------------------------------------
 | |
| // *TBI* Partenza dall'ultimo movimento stampato
 | |
| // *TBI* Aggiornamento scadenziario
 | |
| // *TBI* Aggiornamento cespiti
 | |
| // -------------------------------------------------------------------------
 | |
| 
 | |
| #include <applicat.h>
 | |
| #include <isam.h>
 | |
| #include <mask.h>
 | |
| #include <progind.h>
 | |
| #include <sort.h>
 | |
| #include <utility.h>
 | |
| 
 | |
| #define FLD_CG41_YEAR 100
 | |
| #define MAX_CNT 300
 | |
| 
 | |
| #include <mov.h>
 | |
| #include <rmov.h>
 | |
| #include <rmoviva.h>
 | |
| #include <saldi.h>
 | |
| #include <causali.h>
 | |
| 
 | |
| #include "cglib02.h"
 | |
| 
 | |
| struct therec {
 | |
|   char DATAREG[9];
 | |
|   char REG[4];
 | |
|   char DATADOC[9];
 | |
|   char NUMPROT[9];
 | |
|   char ANNOES[5];
 | |
|   char NUMREG[8];
 | |
| };
 | |
| 
 | |
| class CG4100_App : public TSkeleton_application
 | |
| {
 | |
|   int  _year;
 | |
|   TMask* _msk;
 | |
|   
 | |
| public:
 | |
|   bool set_parms();
 | |
|   virtual void main_loop();
 | |
| 
 | |
|   void sort_all();
 | |
|   bool sort_sal();
 | |
| 
 | |
|   CG4100_App() {}
 | |
|   virtual ~CG4100_App() {}
 | |
| };
 | |
| 
 | |
| bool CG4100_App::set_parms()
 | |
| {
 | |
|   _msk->run();
 | |
|   _year = _msk->get_int(FLD_CG41_YEAR);
 | |
|   return _msk->last_key() == K_ENTER;
 | |
| }
 | |
| 
 | |
| void CG4100_App::main_loop()
 | |
| {               
 | |
| 
 | |
|   if (fexist("__sal__.sav"))
 | |
|     warning_box(TR("Un'operazione di riordino saldi si e' conclusa"
 | |
|                    " impropriamente. Si raccomanda di rieseguirla"));
 | |
|  
 | |
|   _msk = new TMask("cg4100b");
 | |
| 
 | |
|   sort_sal();
 | |
| 
 | |
|   delete _msk;
 | |
| }
 | |
| 
 | |
| bool CG4100_App::sort_sal()
 | |
| {
 | |
|   if (!set_parms())
 | |
|     return FALSE;
 | |
| 
 | |
|   TSystemisamfile saldi(LF_SALDI);  saldi.open(_excllock);
 | |
|   TLocalisamfile rmov(LF_RMOV);
 | |
|   TLocalisamfile mov(LF_MOV);
 | |
|   TSaldo_agg sal;
 | |
| 
 | |
|   FILE* fp = fopen ("__sal__.sav","w");
 | |
|   fclose(fp);
 | |
| 
 | |
|   int gruppo, conto;
 | |
|   const int year = _year;
 | |
|   long oldnumreg = 0L, sottoconto;
 | |
|   TProgind prnd(rmov.items(),
 | |
|                 TR("Riordino archivio saldi in corso\nLettura archivio movimenti..."),
 | |
|                 FALSE,TRUE);
 | |
| 
 | |
|   mov.setkey(1);
 | |
|   rmov.first(); 
 | |
|   sal.reset();
 | |
|   sal.set_anno_es(year);
 | |
|   sal.clear_saldi(year);
 | |
|   long numreg = 0L;
 | |
|   tiposal tsal = normale;
 | |
|   bool provvis = FALSE;
 | |
|   TDate datareg;
 | |
|   
 | |
|   while (!rmov.eof())
 | |
|   {
 | |
|     if (_year == rmov.get_int(RMV_ANNOES))
 | |
|     {
 | |
|       numreg = rmov.get_long(RMV_NUMREG);
 | |
|       
 | |
|       gruppo = rmov.get_int(RMV_GRUPPO);
 | |
|       conto = rmov.get_int(RMV_CONTO);
 | |
|       sottoconto = rmov.get_long(RMV_SOTTOCONTO);                     
 | |
|       bool scaricato = FALSE;
 | |
|       
 | |
|       if (numreg != oldnumreg)
 | |
|       {
 | |
|         if (oldnumreg !=0)
 | |
|         {
 | |
|           if (sal.items() > 0)
 | |
|             sal.registra();
 | |
|         }
 | |
|         oldnumreg = numreg;
 | |
|         mov.zero();
 | |
|         mov.put(MOV_NUMREG, numreg);
 | |
|         mov.read();
 | |
|         CHECK(mov.good(),"Archivi movimenti e righe inconsistenti");
 | |
| 
 | |
|         // Tipo saldo normale per default
 | |
|         tsal = normale;
 | |
|         const TString& codcaus = mov.get(MOV_CODCAUS); 
 | |
|         if (codcaus.not_empty())   // cerca causale per determinare il tipo del saldo
 | |
|         {
 | |
|           const TRectype& causale = cache().get(LF_CAUSALI, codcaus);
 | |
|           if (!causale.empty())
 | |
|           {
 | |
|             const char ac = causale.get_char(CAU_MOVAP);
 | |
|             if (ac == 'A') 
 | |
|               tsal = apertura;
 | |
|             else 
 | |
|               if (ac == 'C') 
 | |
|                 tsal = chiusura;
 | |
|           }  
 | |
|         }
 | |
| 
 | |
|         scaricato = mov.get_bool(MOV_SCARCON);
 | |
|         provvis   = mov.get(MOV_PROVVIS).not_empty();
 | |
|         datareg   = mov.get_date(MOV_DATAREG);
 | |
| 
 | |
|         sal.reset();
 | |
|         sal.set_anno_es(_year);
 | |
|         sal.set_tipo_saldo(tsal);
 | |
|         sal.set_movprovv(provvis);
 | |
|         sal.set_data_ulmov(datareg);
 | |
|         sal.set_num_ulmov(oldnumreg);
 | |
|       }
 | |
|       const char sezione = rmov.get(RMV_SEZIONE)[0];
 | |
|       real importo(rmov.get(RMV_IMPORTO));
 | |
| 
 | |
|       sal.aggiorna(gruppo, conto, sottoconto, importo, sezione, TRUE, scaricato);
 | |
|     }
 | |
|     rmov.next();
 | |
|     prnd.addstatus(1);
 | |
|     do_events();
 | |
|   }
 | |
| 
 | |
|   if (sal.items() > 0)
 | |
|     sal.registra();
 | |
| 
 | |
|   remove("__sal__.sav");
 | |
|   saldi.close();
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| int cg4100(int argc, char* argv[])
 | |
| {
 | |
|   CG4100_App main_app;
 | |
|   main_app.run(argc, argv, TR("Ricalcolo Saldi"));
 | |
|   return TRUE;
 | |
| }
 |