Files correlati : ve6.exe Ricompilazione Demo : [ ] Commento : Riportata la versione 3.1 patch 979 git-svn-id: svn://10.65.10.50/trunk@15623 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			215 lines
		
	
	
		
			5.2 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			215 lines
		
	
	
		
			5.2 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
| // 776600.cpp - Gestione estinti
 | |
| #include <applicat.h>
 | |
| #include <relation.h>
 | |
| #include <urldefid.h>
 | |
|     
 | |
| #include "776600a.h"                       
 | |
| #include "77lib.h"
 | |
| // 
 | |
| // Lista modifiche
 | |
| // 3.4.96	Aggiunto controllo in save() per impedire la creazione di un record-dichiarazione
 | |
| //			anche quando si vuol solo cancellare il codice dichiarante senza immetterne un altro
 | |
| //
 | |
| 
 | |
| class TEstinti_app : public TApplication
 | |
| {
 | |
|     long			      _codditta;
 | |
|     TMask*			    _msk;
 | |
|     TLocalisamfile*	_base, *_basebis;           
 | |
|     TRelation*		  _rel;
 | |
|     TCursor*		    _cur;
 | |
|     TCursor_sheet*	_estint_sheet;
 | |
|     static bool show_estinti(TMask_field& f, KEY k);    
 | |
|     void 		force_output(int dlg, const long cod);
 | |
| 
 | |
| protected:     
 | |
|     virtual bool create();
 | |
|     virtual bool destroy();
 | |
|     virtual bool menu(MENU_TAG m);             
 | |
|     KEY		save(TMask& m, const long coddic_prec, bool check_dirty);
 | |
|     bool  set_codditta(TMask_field& f);
 | |
|     bool 	main_loop();  
 | |
| 
 | |
| public:
 | |
| 		TEstinti_app();
 | |
| 		~TEstinti_app() {};    
 | |
| };
 | |
| 
 | |
| TEstinti_app& app() { return (TEstinti_app&) main_app(); }   
 | |
| 
 | |
| TEstinti_app::TEstinti_app():
 | |
| 	_base(NULL),   
 | |
| 	_basebis(NULL),
 | |
| 	_rel(NULL),
 | |
| 	_msk(NULL),
 | |
| 	_cur(NULL),
 | |
| 	_estint_sheet(NULL)
 | |
| 	{}
 | |
| 	
 | |
| 
 | |
| bool TEstinti_app::set_codditta(TMask_field& f)
 | |
| {
 | |
| 	f.set(get_firm_770()); 
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TEstinti_app::show_estinti(TMask_field& f, KEY k)
 | |
| {
 | |
|   if (k == K_SPACE)
 | |
|     app()._estint_sheet->run();
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TEstinti_app::create()
 | |
| {
 | |
|   TApplication::create();
 | |
|   _base    = new TLocalisamfile(LF_BASE);
 | |
|   _basebis = new TLocalisamfile(LF_BASEBIS);
 | |
|   _msk     = new TMask("776600a");
 | |
|   _rel     = new TRelation(LF_BASE);
 | |
|   _rel->add(LF_NDITTE, "CODDITTA=CODDITTA");  
 | |
| 
 | |
|   _codditta = get_firm_770();
 | |
|   set_codditta(_msk->field(F_CODDITTA));    
 | |
|   TString16 filt;
 | |
|   filt.format("CODDIC=%ld", _codditta);   
 | |
|   _cur  = new TCursor(_rel, filt);
 | |
|   _estint_sheet = new TCursor_sheet(_cur,"CODDITTA|9->RAGSOC", "Elenco estinti",              
 | |
|                                     "Codice|Ragione sociale@50", 0x18, 3);
 | |
|   _msk->set_handler(F_ESTINTI, show_estinti);
 | |
|   dispatch_e_menu (BAR_ITEM(1));
 | |
|   return TRUE;
 | |
| }
 | |
| 
 | |
| bool TEstinti_app::destroy()
 | |
| {
 | |
|   delete _estint_sheet;
 | |
|   delete _rel;  delete _cur;
 | |
|   delete _msk;  delete _base; delete _basebis;
 | |
|   return TApplication::destroy();
 | |
| }
 | |
| 
 | |
| void TEstinti_app::force_output(int dlg, const long codditta)
 | |
| {
 | |
|   TLocalisamfile ditte(LF_NDITTE);
 | |
|   ditte.zero();
 | |
|   ditte.put("CODDITTA", (long)codditta);
 | |
|   int ret = ditte.read(_isequal);
 | |
|   if (ret == NOERR)
 | |
|   {
 | |
|     TString80 ragsoc(ditte.get("RAGSOC"));
 | |
|     _msk->set(dlg, ragsoc);
 | |
|   }
 | |
| }
 | |
| 
 | |
| KEY TEstinti_app::save(TMask& m, const long codic_prec,
 | |
|                         bool check_dirty = FALSE)
 | |
| {
 | |
|   KEY k = K_YES;
 | |
| 	
 | |
| 	if (check_dirty && m.dirty())                   
 | |
| 		k = yesnocancel_box("Registrare le modifiche?");
 | |
| 
 | |
|   if (k == K_YES) 
 | |
|   {
 | |
|   	const long new_codic = m.get_long(F_CODDIC);
 | |
|   	TRectype _rec = _base->curr(); 
 | |
|   	_base->setkey(1);
 | |
|   	_rec.zero();     
 | |
|   	_rec.put("TIPOQUA", ' '); 
 | |
|   	_rec.put("CODDITTA",(long)_codditta);
 | |
|   	if (_base->read(_rec) == NOERR)
 | |
|   	{    
 | |
|   		_rec.put("CODDIC",(long)new_codic);
 | |
|     	_base->rewrite(_rec);
 | |
|   	}  
 | |
| 
 | |
| // Stessa cosa su basebis  
 | |
| 		TRectype _recbis = _basebis->curr();
 | |
| 		_basebis->setkey(1);
 | |
| 		_recbis.zero(); 
 | |
| 		_recbis.put("TIPOQUA", ' '); 
 | |
|   	_recbis.put("CODDITTA",(long)_codditta); 
 | |
|   
 | |
|   	if (_basebis->read(_recbis) == NOERR)
 | |
| 		{    
 | |
|   		_recbis.put("CODDIC",(long)new_codic);
 | |
|     	_basebis->rewrite(_rec);
 | |
| 		}                  
 | |
| 
 | |
| // Crea il record globale per il dichiarante scelto se non esiste
 | |
| // 3.4.96 - Solo se il dichiarante e' diverso da 0, senno' quando si vuol cancellare
 | |
| //          il dichiarante crea un record duplicato!
 | |
| 	  if (new_codic != 0L)
 | |
|   	  if (!exist_dichiar_770(new_codic, TRUE))
 | |
|       	enter_dichiar_770(new_codic, anno_770(), TRUE);
 | |
| 	}
 | |
| 	
 | |
| 	return k;		     
 | |
| }
 | |
| 
 | |
| bool TEstinti_app::main_loop()
 | |
| {
 | |
|   KEY  tasto = K_ESC;            
 | |
| 
 | |
|   const long codditta = _msk->get_long(F_CODDITTA);
 | |
|   _base->zero();            
 | |
|   _base->setkey(1);
 | |
|   _base->put("CODDITTA", (long)codditta);
 | |
|   _base->read(); 
 | |
|   _msk->open_modal();
 | |
| 
 | |
|   while (tasto != K_QUIT) 
 | |
|   {                     
 | |
|     const bool dichiarante = sogg_dic(_codditta);
 | |
|     long  coddic = 0L;
 | |
|     if (!dichiarante)
 | |
|       coddic = sogg_estinto(_codditta);
 | |
|     _msk->set(F_CODDIC, coddic);     
 | |
|     
 | |
|     force_output(F_RAGSOC, coddic);   	
 | |
|     _msk->enable(F_CODDIC,   !dichiarante);
 | |
|     _msk->enable(F_ESTINTI,   dichiarante);
 | |
|     _msk->enable(DLG_SAVEREC,!dichiarante);
 | |
|     _msk->set_mode(MODE_MOD);
 | |
|     
 | |
|     tasto = _msk->run();
 | |
| 
 | |
|     switch (tasto) {      
 | |
|       case K_ENTER:
 | |
| 				if (!dichiarante)
 | |
|         	save(*_msk, coddic);
 | |
|         break;
 | |
|       case K_ESC :
 | |
|         break;
 | |
|       case K_QUIT : 
 | |
|         if (!dichiarante && (save(*_msk, coddic, TRUE) == K_ESC))
 | |
|         	tasto = K_ESC;   
 | |
|         break;
 | |
|       case K_SAVE :
 | |
|         if (!dichiarante)
 | |
|           save(*_msk, coddic);
 | |
|         break;
 | |
|       default:
 | |
|         break;
 | |
|     }
 | |
|   }     
 | |
|   _msk->close_modal();                        
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| bool TEstinti_app::menu(MENU_TAG m)
 | |
| {
 | |
|   if (m == BAR_ITEM(1))
 | |
|     return main_loop(); 
 | |
|   return FALSE;
 | |
| }
 | |
| 
 | |
| int Estinti(int argc, char* argv[])
 | |
| {
 | |
|   TEstinti_app a;         
 | |
|   a.run(argc, argv, "Gestione dichiarante / estinti");
 | |
|   return 0;
 | |
| }
 | |
| 
 |