Files correlati : nessuno Ricompilazione Demo : [ ] Commento : Riportata la versione aga 07.150 sul main trunk git-svn-id: svn://10.65.10.50/trunk@9871 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			400 lines
		
	
	
		
			8.7 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			400 lines
		
	
	
		
			8.7 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include <automask.h>
 | |
| #include <defmask.h>
 | |
| #include <prefix.h>
 | |
| #include <progind.h>
 | |
| #include <relation.h>
 | |
| #include <utility.h>
 | |
| 
 | |
| #include <nditte.h>
 | |
| #include <partite.h>
 | |
| #include <scadenze.h>
 | |
| #include <pagsca.h>
 | |
| #include <saldi.h>
 | |
| #include <tabutil.h>
 | |
| 
 | |
| #include "baeur.h"
 | |
| #include "../cg/cglib01.h"
 | |
| 
 | |
| #include "baeur01.h"
 | |
| #include "baeur02.h"
 | |
| 
 | |
|     
 | |
| ///////////////////////////////////////////////////////////
 | |
| // Main app
 | |
| ///////////////////////////////////////////////////////////
 | |
| 
 | |
| class TEuro00_app : public TEuro_app
 | |
| { 
 | |
| protected:
 | |
|   void set_prassis(const TString& dir, const TMask& m) const;
 | |
|   void reset_770(const TString& dst) const;
 | |
| 
 | |
|   void convert_tabcom(const TString& lit, const TString& eur);
 | |
|   void convert_ini();
 | |
|   void convert_ditte(const TString& eur);
 | |
|   void convert_anag();
 | |
| 
 | |
| public:
 | |
|   KEY step1();
 | |
|   KEY step2();
 | |
|   virtual void main_loop();
 | |
| };
 | |
| 
 | |
| inline TEuro00_app& app() { return (TEuro00_app&)main_app(); }
 | |
| 
 | |
| ///////////////////////////////////////////////////////////
 | |
| // Step 1
 | |
| ///////////////////////////////////////////////////////////
 | |
| 
 | |
| class TEuro01_mask : public TAutomask
 | |
| {
 | |
| public:
 | |
|   virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | |
|   TEuro01_mask() : TAutomask("baeur01") { }
 | |
| };
 | |
| 
 | |
| bool TEuro01_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | |
| {
 | |
|   switch (o.dlg())
 | |
|   {              
 | |
|   case F01_DATIE:
 | |
|     if (e == fe_close || e == fe_modify)
 | |
|     {
 | |
|       const TFilename n = o.get();
 | |
|       const bool esiste = n.exist();
 | |
|       enable(DLG_QUIT, esiste);
 | |
|       if (strlen(n.name()) > 8)  
 | |
|         return error_box("L'area dati in Euro ha un nome troppo lungo: %s", (const char*)n.name());
 | |
|       if (esiste)
 | |
|         return error_box("L'area dati in Euro esiste già");
 | |
|     } else
 | |
|     if (e == fe_init)
 | |
|     {
 | |
|       TFilename lit, eur;
 | |
|       app().get_aree_dati(lit, eur);
 | |
|       set(F01_DATI, lit);
 | |
|       if (eur.empty())
 | |
|         eur << lit << "e";
 | |
|       set(F01_DATIE, eur);
 | |
|       enable(DLG_QUIT, eur.exist());
 | |
|     }
 | |
|     break;
 | |
|   default: 
 | |
|     break;
 | |
|   }
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| void TEuro00_app::set_prassis(const TString& dir, const TMask& m) const
 | |
| {
 | |
|   TFilename str = dir;
 | |
|   str.add("config/prassis.ini");
 | |
|   TConfig prassis(str, "Euro");
 | |
|   prassis.set("DatiLire", m.get(F01_DATI));
 | |
|   prassis.set("DatiEuro", m.get(F01_DATIE));
 | |
| }
 | |
| 
 | |
| void TEuro00_app::reset_770(const TString& dst) const
 | |
| {
 | |
|   TFilename filemask = dst; filemask.add("*.dbf");
 | |
|   TString_array files;
 | |
|   list_files(filemask, files);
 | |
|   FOR_EACH_ARRAY_ROW(files, i, name)
 | |
|   {
 | |
|     TExternisamfile eif(*name);
 | |
|     eif.zap();
 | |
|   }
 | |
| }
 | |
| 
 | |
| KEY TEuro00_app::step1()
 | |
| {             
 | |
|   goto_lire();
 | |
| 
 | |
|   TEuro01_mask* m = new TEuro01_mask;
 | |
|   KEY k = m->run();
 | |
|   if (k == K_ENTER)
 | |
|   {
 | |
|     const TFilename dir1 = m->get(F01_DATI);
 | |
|     const TFilename dir2 = m->get(F01_DATIE);
 | |
|   
 | |
|     if (!fexist(dir2))
 | |
|       make_dir(dir2);
 | |
|    
 | |
|     TFilename src = dir1; src.add("config");
 | |
|     TFilename dst = dir2; dst.add("config");
 | |
|     copy_dir(src, dst);
 | |
|     
 | |
|     set_prassis(dir1, *m);
 | |
|     set_prassis(dir2, *m);
 | |
|       
 | |
|     delete m; m = NULL;
 | |
|     TCurrency::force_cache_update(); // Chiude cache valute     
 | |
|     prefix().set(NULL);              // Chiude tutti i files
 | |
| 
 | |
|     src = dir1; src.add("com");      // Copia dati comuni
 | |
|     dst = dir2; dst.add("com");
 | |
|     copy_dir(src, dst);
 | |
|     
 | |
|     src = dir1; src.add("std");      // Copia dati standard
 | |
|     dst = dir2; dst.add("std");
 | |
|     copy_dir(src, dst);
 | |
|     
 | |
|     src = dir1; src.add("m770");     // Copia dati 770
 | |
|     dst = dir2; dst.add("m770");
 | |
|     copy_dir(src, dst);
 | |
|     goto_lire();                     // Necessario per riaccedere ai tracciati
 | |
|     reset_770(dst);
 | |
|   } 
 | |
|   if (m) delete m;
 | |
|   return k;
 | |
| }
 | |
| 
 | |
| ///////////////////////////////////////////////////////////
 | |
| // Step 2
 | |
| ///////////////////////////////////////////////////////////
 | |
| 
 | |
| class TEuro02_mask : public TAutomask
 | |
| {
 | |
| protected:
 | |
|   virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
 | |
| 
 | |
| public:
 | |
|   TEuro02_mask() : TAutomask("baeur02") { }
 | |
| };
 | |
| 
 | |
| bool TEuro02_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
 | |
| {
 | |
|   switch (o.dlg())
 | |
|   {              
 | |
|   case F02_LIT:
 | |
|   case F02_EUR:
 | |
|     if (e == fe_init)
 | |
|     {
 | |
|       TEdit_field& ef = (TEdit_field&)o;
 | |
|       TCursor* cur = ef.browse()->cursor();
 | |
|       if (cur != NULL && cur->items() > 0)
 | |
|       {
 | |
|         *cur = 0;
 | |
|         ef.set(cur->curr().get("CODTAB"));
 | |
|         ef.check(STARTING_CHECK);
 | |
|       }
 | |
|     }
 | |
|     break;
 | |
|   default: break;
 | |
|   }
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| struct TTabcom_data
 | |
| {
 | |
|   TString4 _lit, _eur; 
 | |
|   int _last_stato;
 | |
| };
 | |
|     
 | |
| HIDDEN bool tabcom_handler(TRectype& curr, void* jolly)
 | |
| {                   
 | |
|   bool update = TRUE;
 | |
|   const TString4 cod = curr.get("COD");
 | |
|   if (cod == "CLM")
 | |
|   {
 | |
|     convert_import(curr, "R0|R1|R2|R3");
 | |
|   }
 | |
|   if (cod == "DEL")
 | |
|   {
 | |
|     update = FALSE;
 | |
|   }
 | |
|   if (cod == "LIA")
 | |
|   {
 | |
|     const int anno = atoi(curr.get("CODTAB").mid(5, 4));
 | |
|     if (anno >= 2001)
 | |
|       keep_import(curr, "COD|CODTAB|B1|B2|S7|S8|S9");    // Azzera quasi tutto
 | |
|     else  
 | |
|       update = FALSE;
 | |
|   }
 | |
|   if (cod == "PLA")
 | |
|   {
 | |
|     update = FALSE;
 | |
|   }
 | |
|   if (cod == "VAL")
 | |
|   {    
 | |
|     TTabcom_data* data = (TTabcom_data*)jolly;
 | |
|     const TString& lit = data->_lit;
 | |
|     const TString& eur = data->_eur;
 | |
|     
 | |
|     const TString& val = curr.get("CODTAB");
 | |
|     if (val == lit)
 | |
|     { 
 | |
|       const real r = 1.0 / EURO;
 | |
|       curr.put("B0", "");  curr.put("B1", "X");
 | |
|       curr.put("S4", EURO); curr.put("R10", r);
 | |
|     } else
 | |
|     if (val == eur)
 | |
|     {
 | |
|       curr.put("B0", "X"); curr.put("B1", "");
 | |
|       curr.put("S4", "1"); curr.put("R10", "1");
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       curr.put("B0", "");
 | |
|       if (!curr.get_bool("B1"))
 | |
|       {
 | |
|         real c = curr.get("S4"); 
 | |
|         if (c != ZERO)
 | |
|         {
 | |
|           c = EURO / c;
 | |
|           curr.put("S4", c.string(0,6));
 | |
|           curr.put("B1", "X");
 | |
|         }
 | |
|         curr.zero("R10");
 | |
|       }
 | |
|     } 
 | |
|   }
 | |
|   if (cod == "VER")
 | |
|   {
 | |
|     zero_import(curr, "R5|R6|R7|R8|R9|R10");
 | |
|   }
 | |
|   return update;
 | |
| }
 | |
| 
 | |
| void TEuro00_app::convert_tabcom(const TString& lit, const TString& eur)
 | |
| {
 | |
|   TTabcom_data data;
 | |
| 
 | |
|   data._lit = lit;
 | |
|   data._eur = eur;
 | |
|   
 | |
|   TTable stati("%STD");
 | |
|   TTable tipi("%TIP");
 | |
|   stati.last();
 | |
|   const int last_stato = stati.get_int("CODTAB");
 | |
|   
 | |
|   for (tipi.first(); tipi.good(); tipi.next())
 | |
|   {
 | |
|     TString80 s2;
 | |
|     
 | |
|     s2 = tipi.get("S2");
 | |
|     if (s2.len() < 3 || s2[2] == ' ')
 | |
|     {
 | |
|       const char s[2] = { last_stato + '0', '\0'};
 | |
|   
 | |
|       s2.overwrite(s, 2, 1);
 | |
|       tipi.put("S2", s2);
 | |
|       tipi.rewrite();
 | |
|     }
 | |
|   }      
 | |
|   convert_file(LF_TABCOM, NULL, NULL, NULL, tabcom_handler, &data);
 | |
| }
 | |
| 
 | |
| HIDDEN void convert_ini_val(TConfig& inilit, TConfig& inieur, const char* name, int index)
 | |
| {
 | |
|   real val = inilit.get(name, NULL, index);
 | |
|   if (!val.is_zero())
 | |
|   {
 | |
|     val /= EURO;
 | |
|     val.round(2);
 | |
|     inieur.set(name, val.string(0, 2), NULL, TRUE, index);
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TEuro00_app::convert_ini()
 | |
| {
 | |
|   TFilename lit, eur;
 | |
|   app().get_aree_dati(lit, eur);
 | |
|   
 | |
|   lit.add("config\\prassis.ini");
 | |
|   TConfig inilit(lit, "ve");
 | |
| 
 | |
|   eur.add("config\\prassis.ini");
 | |
|   TConfig inieur(eur, "ve");
 | |
|   
 | |
|   for (int i = 1; i <= 7; i++)
 | |
|   {
 | |
|     convert_ini_val(inilit, inieur, "SPBOSCA", i);
 | |
|     convert_ini_val(inilit, inieur, "SPBOIMP", i);
 | |
|   }
 | |
|   convert_ini_val(inilit, inieur, "BOLLIES", -1);
 | |
|   convert_ini_val(inilit, inieur, "IMPMINBOLLI", -1);
 | |
|   for (i = 1; i <= 9; i++)
 | |
|     convert_ini_val(inilit, inieur, "IMPSPINC", i);
 | |
| }
 | |
| 
 | |
| HIDDEN bool ditte_handler(TRectype& curr, void* jolly)
 | |
| {
 | |
|   TTabcom_data* data = (TTabcom_data*)jolly;
 | |
|   curr.put(NDT_VALUTA, data->_eur);
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| void TEuro00_app::convert_ditte(const TString& eur)
 | |
| {
 | |
|   TTabcom_data data;
 | |
|   data._eur = eur;
 | |
|   convert_file(LF_NDITTE, NULL, NULL, NULL, ditte_handler, &data);
 | |
|   
 | |
|   zap_file(LF_TAB1100A, TRUE);
 | |
|   zap_file(LF_TAB1100B, TRUE);
 | |
| }
 | |
| 
 | |
| void TEuro00_app::convert_anag()
 | |
| {
 | |
|   convert_file(LF_ANAGGIU, NULL, "VALNOM|CAPSOC|CAPVER|FATT", NULL, NULL);
 | |
|   convert_file(LF_SOCI, NULL, "EMOLUMENTO", NULL, NULL);
 | |
|   if (is_com_file(LF_CLIFO))
 | |
|   {
 | |
|     convert_file(LF_CLIFO, NULL, "FIDO", NULL, NULL);
 | |
|     convert_file(LF_CFVEN, "IMPMINEFF", "", NULL, NULL);
 | |
|   }
 | |
| }
 | |
| 
 | |
| KEY TEuro00_app::step2()
 | |
| {                
 | |
|   goto_lire();
 | |
| 
 | |
|   TString16 eur, lit;
 | |
|   KEY k = K_QUIT;
 | |
|   {
 | |
|     TEuro02_mask m;
 | |
|     k = m.run();
 | |
|     lit = m.get(F02_LIT);
 | |
|     eur = m.get(F02_EUR);
 | |
|   }
 | |
|   if (k == K_ENTER)
 | |
|   {
 | |
|     convert_tabcom(lit, eur);
 | |
|     convert_ini();
 | |
|     convert_ditte(eur);
 | |
|     convert_anag();
 | |
|  }
 | |
|   return k;
 | |
| }
 | |
| 
 | |
| ///////////////////////////////////////////////////////////
 | |
| // Main 
 | |
| ///////////////////////////////////////////////////////////
 | |
| 
 | |
| void TEuro00_app::main_loop()
 | |
| { 
 | |
|   int step = 1;
 | |
|   while (step >= 1 && step <= 2)
 | |
|   {   
 | |
|     KEY k = K_ENTER;
 | |
|     switch (step)
 | |
|     { 
 | |
|     case 1: k = step1(); break;
 | |
|     case 2: k = step2(); break;
 | |
|     default: break;
 | |
|     }
 | |
|     if (k == K_ENTER || k == K_QUIT)
 | |
|       step++;
 | |
|     if (k == K_ESC)
 | |
|       step--;
 | |
|   }
 | |
| }
 | |
| 
 | |
| int baeur00(int argc, char* argv[])
 | |
| {  
 | |
|   TEuro00_app ma;
 | |
|   ma.run(argc, argv, "Creazione Studio Euro");
 | |
|   
 | |
|   return 0;
 | |
| } |