sc0100.h Aggiunte variabili di supporto ai colori sc0101.cpp Corretto messaggio d'errore sugli importi sc2100a.uml Modificata ricerca sul codice lingua sc2101.cpp Cambiate due chiamate dirette con funzioni membro git-svn-id: svn://10.65.10.50/trunk@4288 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			201 lines
		
	
	
		
			4.8 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			201 lines
		
	
	
		
			4.8 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include <stdarg.h>
 | |
| 
 | |
| #include <colors.h>
 | |
| #include <config.h>
 | |
| #include <mask.h>
 | |
| #include <urldefid.h>
 | |
| 
 | |
| #include "sc0100.h"
 | |
| #include "sc0100a.h"
 | |
| 
 | |
| HIDDEN bool gruppo_handler(TMask_field& f, KEY key)
 | |
| {                          
 | |
|   static bool ignore = FALSE;
 | |
|   
 | |
|   if (key == K_TAB && f.focusdirty())
 | |
|   {                                 
 | |
|     if (!ignore)
 | |
|     {
 | |
|       TMask_field& c = f.mask().field(F_CONTO);
 | |
|       if (c.get().not_empty())
 | |
|       {
 | |
|         ignore = TRUE;
 | |
|         c.set_dirty();
 | |
|         c.on_key(K_TAB);
 | |
|         ignore = FALSE;
 | |
|       }
 | |
|     }  
 | |
|   }
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| ///////////////////////////////////////////////////////////
 | |
| // Gestione saldaconto extra-contabile
 | |
| ///////////////////////////////////////////////////////////
 | |
| 
 | |
| TSaldaconto_app::TSaldaconto_app() 
 | |
|                : _file(32), _allow_firm(TRUE)
 | |
| {} 
 | |
| 
 | |
| bool TSaldaconto_app::create()
 | |
| {   
 | |
|   open_files(LF_TAB, LF_TABCOM, LF_CLIFO, 0);                      
 | |
|   open_files(LF_PARTITE, LF_SCADENZE, LF_PAGSCA, 0);  
 | |
|   
 | |
|   load_colors();
 | |
| 
 | |
|   _msk = new TMask("sc0100a");
 | |
|   _msk->set_handler(F_GRUPPO, gruppo_handler);
 | |
|   
 | |
|   TConfig cnf(CONFIG_DITTA, "cg");
 | |
|   const bool ges_sal = cnf.get_bool("GesSal");
 | |
|   if (!ges_sal)                                                  
 | |
|   {
 | |
|     warning_box("Attenzione: La ditta %ld non ha la\n"
 | |
|                 "la gestione del saldaconto attivata!", get_firm());
 | |
|   }              
 | |
| 
 | |
| 
 | |
|   dispatch_e_menu(MENU_ITEM(1));
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TSaldaconto_app::destroy()
 | |
| {
 | |
|   delete _msk;
 | |
|   close_files();
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| void TSaldaconto_app::open_files(int logicnum, ...)  
 | |
| {  
 | |
|   va_list marker;
 | |
|   va_start(marker, logicnum);
 | |
|   while (logicnum > 0)
 | |
|   {
 | |
|     CHECKD(_file.objptr(logicnum) == NULL, "File gia' aperto: ", logicnum);
 | |
|     _file.add(new TLocalisamfile(logicnum), logicnum);
 | |
|     logicnum = va_arg(marker, int);
 | |
|   }
 | |
| }
 | |
| 
 | |
| void TSaldaconto_app::on_config_change()
 | |
| {
 | |
|   TConfig cnf(CONFIG_DITTA, "cg");
 | |
|   _ges_val = cnf.get_bool("GesVal");
 | |
|   TPartita::carica_allineamento();
 | |
| }
 | |
| 
 | |
| bool TSaldaconto_app::menu(MENU_TAG)
 | |
| {          
 | |
|   TMask& m = curr_mask();
 | |
|   
 | |
|   bool ok = TRUE;
 | |
|   while (ok)
 | |
|   {      
 | |
|     xvt_statbar_set("Ricerca", TRUE);
 | |
|     m.reset();
 | |
|     ok = m.run() == K_ENTER;
 | |
|     if (ok)
 | |
|     {
 | |
|       _allow_firm = FALSE;
 | |
|       edit_partite(m);
 | |
|       _allow_firm = TRUE;
 | |
|     }  
 | |
|   }  
 | |
|   return 0;
 | |
| }   
 | |
| 
 | |
| void TSaldaconto_app::load_colors()
 | |
| {
 | |
|   TConfig conf(CONFIG_USER, "cg2");
 | |
|   TAssoc_array& colori = (TAssoc_array&)conf.list_variables();
 | |
|   for (THash_object* o = colori.get_hashobj(); o; o = colori.get_hashobj())
 | |
|   {
 | |
|     const TString& key = o->key();
 | |
|     if (key.len() == 7 && key.compare("Color", 5, TRUE) == 0)
 | |
|     {
 | |
|       const COLOR col = conf.get_color(key);
 | |
|       TString* strcol = new TString(15);
 | |
|       strcol->format("%ld", col);
 | |
|       _colori.add(key.mid(5), strcol);
 | |
|     }  
 | |
|   }
 | |
| }              
 | |
| 
 | |
| COLOR TSaldaconto_app::type2color(char tipor, char tipoc)
 | |
| {  
 | |
|   COLOR col;                         
 | |
|   if (tipor > ' ')
 | |
|   {
 | |
|     const char key[3] = { tipoc, tipor, '\0' }; 
 | |
|     TString* colstr = (TString*)_colori.objptr(key);
 | |
|     if (colstr == NULL)
 | |
|     {
 | |
|       colstr = new TString(8);
 | |
|       colstr->format("%ld", tipoc == 'B' ? NORMAL_BACK_COLOR : NORMAL_COLOR);
 | |
|       _colori.add(key, colstr);
 | |
|     }    
 | |
|     col = atol(*colstr);
 | |
|   }  
 | |
|   else
 | |
|   {
 | |
|     col = tipoc == 'B' ? NORMAL_BACK_COLOR : NORMAL_COLOR;
 | |
|   }
 | |
|   return col;
 | |
| }
 | |
| 
 | |
| void TSaldaconto_app::type2colors(char tipor, COLOR& back, COLOR& fore)
 | |
| {      
 | |
|   back = type2color(tipor, 'B');
 | |
|   fore = type2color(tipor, 'F');
 | |
| }
 | |
| 
 | |
| ///////////////////////////////////////////////////////////
 | |
| // Handlers generali
 | |
| ///////////////////////////////////////////////////////////
 | |
| 
 | |
| #include "sc0100p.h"
 | |
| 
 | |
| void TSaldaconto_app::gioca_cambi(TMask& m, int force)
 | |
| {               
 | |
|   if (m.get(E_VALUTA).empty())
 | |
|     return;
 | |
|   
 | |
|   const real totale = m.get(E_TOTALE);
 | |
|   const real totval = m.get(E_TOTDOCVAL);
 | |
|   const real cambio = m.get(E_CAMBIO);  
 | |
| 
 | |
|   if ( (force == 0x1 || totale.is_zero()) && !(totval.is_zero() || cambio.is_zero()) )
 | |
|   {
 | |
|     const TValuta cam(m, E_VALUTA, E_DATACAMBIO, E_CAMBIO);
 | |
|     const real new_totale = cam.val2lit(totval);
 | |
|     if (new_totale != totale)
 | |
|       m.set(E_TOTALE, new_totale, TRUE);
 | |
|   } 
 | |
|   
 | |
|   if ( (force == 0x2 || totval.is_zero()) && !(totale.is_zero() || cambio.is_zero()) )
 | |
|   {
 | |
|     const TValuta cam(m, E_VALUTA, E_DATACAMBIO, E_CAMBIO);
 | |
|     const real new_totval = cam.lit2val(totale);
 | |
|     if (new_totval != totval)
 | |
|       m.set(E_TOTDOCVAL, new_totval, TRUE);
 | |
|   } 
 | |
|   
 | |
|   if ( (force == 0x4 || cambio.is_zero()) && !(totale.is_zero() || totval.is_zero()) )
 | |
|   {
 | |
|     real new_cambio = totale / totval; new_cambio.round(5);
 | |
|     if (new_cambio != cambio)
 | |
|       m.set(E_CAMBIO, new_cambio, TRUE);
 | |
|   } 
 | |
| }              
 | |
| 
 | |
| ///////////////////////////////////////////////////////////
 | |
| 
 | |
| int sc0100(int argc, char* argv[])
 | |
| {
 | |
|   TSaldaconto_app* salda = new TSaldaconto_app;
 | |
|   salda->run(argc, argv, "Gestione Saldaconto");
 | |
|   return 0;
 | |
| }
 |