106 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			106 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| #include "scandich.h"
 | |
| 
 | |
| 
 | |
| ///////////////////////////////////////////////////////////
 | |
| // TScandich
 | |
| ///////////////////////////////////////////////////////////
 | |
| 
 | |
| TScandich::TScandich(scantype type)
 | |
|              : _type(type),   
 | |
|                _lasterr(NOERR)
 | |
| {
 | |
| 	// salvo codice dichiarazione in manutenzione
 | |
| 	_dich_prec = get_firm_770();  
 | |
| 	               
 | |
| 	switch (_type)
 | |
| 	{
 | |
| 		case _sel_dich:
 | |
| 			_cnf_user = new TConfig(CONFIG_USER);
 | |
| 	  	break; 
 | |
| 	  case _all_dich:
 | |
| 	  	_base_file = new TLocalisamfile(LF_BASE);  
 | |
| 	  	_base_file->setkey(1);
 | |
| 	  	break;
 | |
| 	  default:
 | |
| 	  	break;	
 | |
| 	}			
 | |
| }
 | |
| 
 | |
| TScandich::~TScandich()
 | |
| {
 | |
|   switch (_type)
 | |
| 	{
 | |
| 		case _sel_dich:
 | |
| 	  	delete _cnf_user;
 | |
| 	  	break; 
 | |
| 	  case _all_dich:
 | |
| 	  	delete _base_file;
 | |
| 	  	break;
 | |
| 	  default:
 | |
| 	  	break;	
 | |
| 	}	
 | |
| 			    
 | |
| 	// ripristino codice dichiarazione in manutenzione 
 | |
| 	set_firm_770(_dich_prec);   
 | |
| }
 | |
| 
 | |
| // @doc EXTERNAL
 | |
| // @mfunc ritorna il codice della prima dichiarazione da elaborare
 | |
| long TScandich::first()
 | |
| {	
 | |
| 	// codice dichiarazione da restituire
 | |
| 	long coddich = 0L;	
 | |
| 	
 | |
| 	// primo codice se richiesto _sel_dich    
 | |
| 	if (_type == _sel_dich)           
 | |
| 	{
 | |
| 		_num_dich = 0;
 | |
| 		coddich = _cnf_user->get_long(DITTE_SEL, "77", _num_dich++); 
 | |
| 		if (coddich == 0L)
 | |
| 			_lasterr = _iseof;
 | |
| 	}	
 | |
| 	                                          
 | |
| 	// primo codice se richiesto _all_dich    
 | |
| 	if (_type == _all_dich)           
 | |
| 	{                                 
 | |
| 		_lasterr = _base_file->first();
 | |
| 		if (_lasterr == NOERR) 
 | |
| 			coddich = _base_file->get_long("CODDITTA");
 | |
| 	}	                                          
 | |
| 		
 | |
| 	return coddich;
 | |
| }	
 | |
| 	              
 | |
| // @doc EXTERNAL
 | |
| // @mfunc ritorna il codice della successiva dichiarazione da elaborare
 | |
| long TScandich::next()
 | |
| {	
 | |
| 	// codice dichiarazione da restituire
 | |
| 	long coddich = 0L;	
 | |
| 	
 | |
| 	// codice successivo se richiesto _sel_dich    
 | |
| 	if (_type == _sel_dich)           
 | |
| 	{
 | |
| 		coddich = _cnf_user->get_long(DITTE_SEL, "77", _num_dich++); 
 | |
| 		if (coddich == 0L)
 | |
| 			_lasterr = _iseof;
 | |
| 	}	
 | |
| 	                                          
 | |
| 	// codice successivo se richiesto _all_dich    
 | |
| 	if (_type == _all_dich)           
 | |
| 	{                                 
 | |
| 		_lasterr = _base_file->next();
 | |
| 		if (_lasterr == NOERR)
 | |
| 			// se dichiarazione "dichiarante" forzo fine file
 | |
| 			if (_base_file->get_char("TIPOQUA") == 'D')
 | |
| 				_lasterr = _iseof;
 | |
| 			else
 | |
| 				coddich = _base_file->get_long("CODDITTA");
 | |
| 	}	                                          
 | |
| 		
 | |
| 	return coddich;
 | |
| }		              
 | |
| 
 | |
| 
 | |
| 
 |