151 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			151 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
// 776500.cpp - Parametri di generazione - Maschera di immissione
 | 
						|
#include <applicat.h>
 | 
						|
#include <mask.h>
 | 
						|
#include <relation.h>
 | 
						|
#include <config.h>
 | 
						|
#include <urldefid.h> 
 | 
						|
#include <tabutil.h>
 | 
						|
#include <utility.h>
 | 
						|
#include <lffiles.h>
 | 
						|
#include <mailbox.h>
 | 
						|
#include <execp.h>
 | 
						|
#include "776.h"
 | 
						|
#include "776500.h"
 | 
						|
#include "77lib.h"
 | 
						|
 | 
						|
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: 
 | 
						|
    bool main_loop();
 | 
						|
// 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(); }
 | 
						|
 | 
						|
void TParametri_genera::on_config_change()
 | 
						|
{ 
 | 
						|
  TConfig conf(_liv == 'S' ? CONFIG_USER : CONFIG_STUDIO);
 | 
						|
  _anno_dic = (int)conf.get_long(ANNO_SEL, _section); 
 | 
						|
}
 | 
						|
 | 
						|
 | 
						|
bool TParametri_genera::main_loop()
 | 
						|
{
 | 
						|
  KEY tasto;
 | 
						|
  TMask msk ("776500a");
 | 
						|
  long  codditta, codditta_prec;
 | 
						|
  int   i = 0;
 | 
						|
 | 
						|
  if (_liv == 'S')
 | 
						|
  {
 | 
						|
    codditta_prec = get_firm_770();
 | 
						|
    while ((codditta = _cnf->get_long(DITTE_SEL, _section, i++)) != 0L) 
 | 
						|
    {
 | 
						|
      set_firm_770(codditta);
 | 
						|
      
 | 
						|
      _rel->lfile().put("CODDITTA", codditta);
 | 
						|
      _rel->read();
 | 
						|
      msk.autoload(_rel);
 | 
						|
      tasto = msk.run();
 | 
						|
      
 | 
						|
      if (tasto == K_ESC) continue;
 | 
						|
      
 | 
						|
      if (tasto == K_SAVE)
 | 
						|
      {
 | 
						|
        msk.autosave(_rel);
 | 
						|
        _rel->rewrite();
 | 
						|
      }
 | 
						|
      
 | 
						|
      if (tasto == K_QUIT) break;
 | 
						|
    }  
 | 
						|
    set_firm_770(codditta_prec);
 | 
						|
    return FALSE;
 | 
						|
  }
 | 
						|
  else
 | 
						|
  {
 | 
						|
    codditta = get_firm_770(); 
 | 
						|
      
 | 
						|
    _rel->lfile().put("CODDITTA", codditta);
 | 
						|
    _rel->read();
 | 
						|
    msk.autoload(_rel);
 | 
						|
    tasto = msk.run();
 | 
						|
      
 | 
						|
    if (tasto == K_ESC)      
 | 
						|
    {
 | 
						|
      _risposta = 1;
 | 
						|
      return FALSE;
 | 
						|
    }
 | 
						|
      
 | 
						|
    if (tasto == K_SAVE)
 | 
						|
    {
 | 
						|
      msk.autosave(_rel);
 | 
						|
      _rel->rewrite();
 | 
						|
      _risposta = 1;
 | 
						|
    }
 | 
						|
      
 | 
						|
    if (tasto == K_QUIT) 
 | 
						|
    {
 | 
						|
      _risposta = 0;
 | 
						|
      return FALSE; 
 | 
						|
    }
 | 
						|
  }
 | 
						|
  
 | 
						|
  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(1));
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
bool TParametri_genera::destroy()
 | 
						|
{
 | 
						|
  delete _rel;   
 | 
						|
  delete _cnf;
 | 
						|
  
 | 
						|
  if (_liv == 'D')
 | 
						|
  {
 | 
						|
    TString appname = "771mod -3";
 | 
						|
    TString body = "";
 | 
						|
    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(1))
 | 
						|
    return main_loop(); 
 | 
						|
  return FALSE;
 | 
						|
}
 | 
						|
               
 | 
						|
int ParametriGenera(int argc, char* argv[])
 | 
						|
{
 | 
						|
  TParametri_genera a(*argv[2]);
 | 
						|
  a.run(argc, argv, "Parametri di generazione");
 | 
						|
  return 0;
 | 
						|
}
 |