Files correlati : Ricompilazione Demo : [ ] Commento :corretta chiamata dei BAR_ITEM con BAR_ITEM_ID git-svn-id: svn://10.65.10.50/trunk@18337 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			190 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			190 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
// 776500.cpp - Parametri di generazione - Maschera di immissione
 | 
						|
#include <applicat.h>
 | 
						|
#include <mailbox.h>
 | 
						|
#include <relation.h>
 | 
						|
#include <urldefid.h> 
 | 
						|
 | 
						|
#include "776.h"
 | 
						|
#include "776500.h"
 | 
						|
#include "77lib.h"
 | 
						|
                                             
 | 
						|
// derivazione della classe Tmask per reimplementare
 | 
						|
// la funzione membro can_be_closed() in modo da poter
 | 
						|
// avvertire l'utente in caso di pressione del tasto ALT+F4
 | 
						|
class TMaskDerived : public TMask  
 | 
						|
{ 
 | 
						|
 | 
						|
public:
 | 
						|
	// @cmember Controlla se la maschera puo' essere chiusa (TRUE se puo' esserlo)
 | 
						|
	virtual bool can_be_closed() const;                                           
 | 
						|
	// @cmember Costruttore (crea la maschera leggendo la descrizione dal file .msk)
 | 
						|
  TMaskDerived(const char* title) : TMask(title) {};
 | 
						|
	// @cmember Distruttore
 | 
						|
  virtual ~TMaskDerived(){};
 | 
						|
};
 | 
						|
 | 
						|
class TParametri_genera : public TApplication
 | 
						|
{ 
 | 
						|
    char  _liv;       // Se stampa a livello di studio
 | 
						|
    int   _anno_dic;  // Anno dichiarazione nei paramentri utente o studio
 | 
						|
    TRelation*       _rel;
 | 
						|
    TString16        _section;
 | 
						|
    TConfig*         _cnf;
 | 
						|
    int              _risposta;
 | 
						|
    bool    init_print();
 | 
						|
  protected:                    
 | 
						|
    virtual void on_config_change();
 | 
						|
    virtual bool create() ;
 | 
						|
    virtual bool destroy();
 | 
						|
    virtual bool menu(MENU_TAG m);
 | 
						|
  public:                   
 | 
						|
    KEY  registra(TMask& m, bool check_dirty);
 | 
						|
    bool main_loop();      
 | 
						|
    static bool tipo_handler(TMask_field& f, KEY k);
 | 
						|
    
 | 
						|
// D = stampa ditta, S = stampa a livello di studio 
 | 
						|
    TParametri_genera(char livello='D') : _liv(toupper(livello)) {}
 | 
						|
};
 | 
						|
 | 
						|
HIDDEN TParametri_genera& app() { return (TParametri_genera&) main_app(); }
 | 
						|
 | 
						|
// implementazione della funzione TMaskDerived::can_be_closed()
 | 
						|
// per segnalare all'utente l'interruzione del processo di generazione
 | 
						|
bool TMaskDerived::can_be_closed() const
 | 
						|
{
 | 
						|
  bool ok = TRUE;
 | 
						|
  if (is_running())
 | 
						|
    ok = yesno_box("Annullare la generazione dei versamenti?");
 | 
						|
  return ok;
 | 
						|
}
 | 
						|
 | 
						|
void TParametri_genera::on_config_change()
 | 
						|
{ 
 | 
						|
  TConfig conf(CONFIG_STUDIO);
 | 
						|
  _anno_dic = (int)conf.get_long(ANNO_SEL, _section); 
 | 
						|
}
 | 
						|
 | 
						|
KEY TParametri_genera::registra(TMask& m, bool check_dirty)
 | 
						|
{
 | 
						|
	KEY k = K_YES;
 | 
						|
	
 | 
						|
	if (check_dirty && m.dirty())                   
 | 
						|
		k = yesnocancel_box("Registrare le modifiche?");
 | 
						|
 | 
						|
  if (k == K_YES) 
 | 
						|
  { 
 | 
						|
		m.autosave(*_rel);
 | 
						|
    _rel->rewrite();	
 | 
						|
	}
 | 
						|
	
 | 
						|
	return k; 			
 | 
						|
}
 | 
						|
 | 
						|
bool TParametri_genera::main_loop()
 | 
						|
{                  
 | 
						|
  long  codditta;
 | 
						|
  int   i = 0;
 | 
						|
 | 
						|
  KEY tasto;
 | 
						|
 | 
						|
	TMaskDerived msk("776500a"); 
 | 
						|
	msk.set_handler(F_TIPOVERS, tipo_handler); 
 | 
						|
	msk.set_handler(F_LUOVERS, tipo_handler);
 | 
						|
	msk.open_modal();   
 | 
						|
  codditta = get_firm_770();   
 | 
						|
  _rel->lfile().put("CODDITTA", codditta);
 | 
						|
  _rel->read();
 | 
						|
  msk.autoload(*_rel); 
 | 
						|
  tasto = K_TAB; 
 | 
						|
  _risposta = 0;
 | 
						|
      
 | 
						|
  // loop di gestione maschera 
 | 
						|
  while (tasto != K_ESC && tasto != K_QUIT)
 | 
						|
  {	
 | 
						|
  	tasto = msk.run(); 
 | 
						|
  	switch (tasto)
 | 
						|
    {
 | 
						|
     	case K_ESC: 
 | 
						|
     		if (registra(msk,TRUE) == K_ESC)
 | 
						|
     			tasto = K_TAB;
 | 
						|
     		_risposta = 1;
 | 
						|
     		break; 
 | 
						|
     	case K_QUIT:  
 | 
						|
     		if (yesno_box("Annullare la generazione dei versamenti?"))
 | 
						|
     			_risposta = 0;  
 | 
						|
     		else tasto = K_TAB;	
 | 
						|
     		break;	
 | 
						|
       case K_SAVE:     
 | 
						|
       	registra(msk,FALSE);
 | 
						|
       	_risposta = 1;
 | 
						|
     	default:
 | 
						|
     		break;
 | 
						|
    }				
 | 
						|
  } // endloop di gestione maschera
 | 
						|
	msk.close_modal();
 | 
						|
 | 
						|
  return FALSE;
 | 
						|
}
 | 
						|
 | 
						|
bool TParametri_genera::create()
 | 
						|
{ 
 | 
						|
  TApplication::create();
 | 
						|
// Parametri configurazione
 | 
						|
  _section = name(); 
 | 
						|
  _section.cut(2); 
 | 
						|
  _cnf     = new TConfig(CONFIG_USER, _section);
 | 
						|
  _rel     = new TRelation (LF_BASE);
 | 
						|
  dispatch_e_menu (BAR_ITEM_ID(1));
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
bool TParametri_genera::destroy()
 | 
						|
{
 | 
						|
  delete _rel;   
 | 
						|
  delete _cnf; 
 | 
						|
  
 | 
						|
  TString appname;
 | 
						|
  TString body = "";
 | 
						|
  
 | 
						|
  if (_liv == 'D') 
 | 
						|
  	appname = "771mod -3";
 | 
						|
  else	                  
 | 
						|
  	appname = "774 -0";
 | 
						|
   
 | 
						|
  body << _risposta;
 | 
						|
  TMessage msg (appname,"",(const char*) body);
 | 
						|
  TMailbox mb;
 | 
						|
  mb.send(msg);
 | 
						|
 | 
						|
  return TApplication::destroy();
 | 
						|
}
 | 
						|
               
 | 
						|
bool TParametri_genera::menu(MENU_TAG m)
 | 
						|
{
 | 
						|
  if (m == BAR_ITEM_ID(1))
 | 
						|
    return main_loop(); 
 | 
						|
  return FALSE;
 | 
						|
}                                                   
 | 
						|
 | 
						|
bool TParametri_genera::tipo_handler(TMask_field& f, KEY k) 
 | 
						|
{   
 | 
						|
	if (k == K_SPACE)
 | 
						|
	{
 | 
						|
		TString16 luogo = f.mask().get(F_LUOVERS);
 | 
						|
		TString16 tipo = f.mask().get(F_TIPOVERS);
 | 
						|
		if (tipo == "D")
 | 
						|
			f.mask().show(-G_DISTINTA);
 | 
						|
		if (luogo == "T")
 | 
						|
			f.mask().hide(-G_SERIE);	
 | 
						|
	}	                         
 | 
						|
	
 | 
						|
	return TRUE;
 | 
						|
}
 | 
						|
               
 | 
						|
int ParametriGenera(int argc, char* argv[])
 | 
						|
{
 | 
						|
  TParametri_genera a(*argv[2]);
 | 
						|
  a.run(argc, argv, "Parametri di generazione");
 | 
						|
  return 0;
 | 
						|
}
 |