149 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			149 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
// Modello 770 - Generazione dettaglio Quadro H
 | 
						|
                  
 | 
						|
#include <applicat.h>                  
 | 
						|
#include <mask.h>
 | 
						|
#include <printapp.h>
 | 
						|
#include <progind.h>
 | 
						|
#include <relation.h>
 | 
						|
#include <tabutil.h>
 | 
						|
#include <utility.h>
 | 
						|
#include <config.h>
 | 
						|
#include <urldefid.h> 
 | 
						|
#include <execp.h> 
 | 
						|
#include <mailbox.h>
 | 
						|
 | 
						|
#include "774100.h"
 | 
						|
 | 
						|
#include <rpag.h>
 | 
						|
#include <rver.h>
 | 
						|
#include <scperc.h>
 | 
						|
#include <quadrol.h>
 | 
						|
 | 
						|
class TGenera_dett : public TApplication
 | 
						|
{
 | 
						|
    TLocalisamfile* _dettH;
 | 
						|
    TLocalisamfile* _quaH;
 | 
						|
    TRelation*      _rel; 
 | 
						|
    
 | 
						|
    long    _codditta;
 | 
						|
    int     _anno;
 | 
						|
    TString _ente;
 | 
						|
    
 | 
						|
  public:
 | 
						|
    virtual bool create();        
 | 
						|
    virtual bool menu(MENU_TAG m);
 | 
						|
    virtual bool destroy(); 
 | 
						|
    
 | 
						|
    bool set();
 | 
						|
 | 
						|
    TGenera_dett() {};
 | 
						|
    ~TGenera_dett() {};  
 | 
						|
};
 | 
						|
          
 | 
						|
bool TGenera_dett::set()
 | 
						|
{ 
 | 
						|
  real    tot_dat,tot_lav;
 | 
						|
  
 | 
						|
  TRecnotype items_deth = _dettH->items();
 | 
						|
  
 | 
						|
  TProgind  progn(items_deth,"Generazione Quadro H in corso... Prego attendere", FALSE, TRUE);
 | 
						|
      
 | 
						|
  TRectype recdet(_dettH->curr());
 | 
						|
   
 | 
						|
  recdet.zero();
 | 
						|
  recdet.put("CODDITTA", _codditta);
 | 
						|
  recdet.put("ANNO",     _anno);
 | 
						|
  recdet.put("ENTE",     _ente);
 | 
						|
    
 | 
						|
  _dettH->setkey(1);
 | 
						|
  _dettH->zero();
 | 
						|
  _dettH->put("CODDITTA", _codditta);
 | 
						|
  _dettH->put("ANNO",     _anno);
 | 
						|
  _dettH->put("ENTE",     _ente);
 | 
						|
    
 | 
						|
  for (_dettH->read(_isgteq); _dettH->good(); _dettH->next())
 | 
						|
  {
 | 
						|
    if (_dettH->curr() > recdet) 
 | 
						|
      break;
 | 
						|
     
 | 
						|
    real dat = _dettH->get_real("CONTRDAT");
 | 
						|
    real lav = _dettH->get_real("CONTRLAV");
 | 
						|
      
 | 
						|
    TString dats = dat.string();
 | 
						|
    TString lavs = lav.string();
 | 
						|
      
 | 
						|
    tot_dat += dat;
 | 
						|
    tot_lav += lav;
 | 
						|
    
 | 
						|
    progn.addstatus(1);
 | 
						|
  }                
 | 
						|
    
 | 
						|
  _quaH->setkey(1);
 | 
						|
  _quaH->zero();
 | 
						|
  _quaH->put("CODDITTA", _codditta);
 | 
						|
  _quaH->put("H1ANNO",   _anno);
 | 
						|
  _quaH->put("H1ENTE",   _ente);
 | 
						|
    
 | 
						|
  if (_quaH->read() == NOERR)
 | 
						|
  {
 | 
						|
    _quaH->put("H1DAT", tot_dat);
 | 
						|
    _quaH->put("H1LAV", tot_lav);
 | 
						|
    _quaH->rewrite();
 | 
						|
  }                  
 | 
						|
    
 | 
						|
  return FALSE; // Per fare in modo che ritorni subito all' applicazione di partenza
 | 
						|
}                
 | 
						|
 | 
						|
bool TGenera_dett::menu(MENU_TAG m)
 | 
						|
{
 | 
						|
  if (m == BAR_ITEM(1))
 | 
						|
    return (set()); 
 | 
						|
  return FALSE;
 | 
						|
}
 | 
						|
 | 
						|
bool TGenera_dett::create()
 | 
						|
{
 | 
						|
  TApplication::create();
 | 
						|
                    
 | 
						|
  _rel   = new TRelation (LF_DETH);                  
 | 
						|
  _dettH = new TLocalisamfile(LF_DETH);
 | 
						|
  _quaH  = new TLocalisamfile(LF_QUAH);
 | 
						|
  
 | 
						|
  TMailbox m;
 | 
						|
  TMessage* msg = m.next_s("");
 | 
						|
  TToken_string subj(50);
 | 
						|
  
 | 
						|
  if (msg != NULL)
 | 
						|
  {
 | 
						|
    subj = msg->body();
 | 
						|
    
 | 
						|
    _codditta = atol(subj.get(0));
 | 
						|
    _anno     = atoi(subj.get(1));
 | 
						|
    _ente     = subj.get(2);  
 | 
						|
  }
 | 
						|
/*
 | 
						|
  _codditta = 1;
 | 
						|
  _anno     = 1994;
 | 
						|
  _ente     = "Aresi Alessandro";
 | 
						|
*/  
 | 
						|
  dispatch_e_menu (BAR_ITEM(1));  
 | 
						|
  return TRUE;
 | 
						|
}
 | 
						|
 | 
						|
bool TGenera_dett::destroy()
 | 
						|
{
 | 
						|
  delete _dettH;                     
 | 
						|
  delete _rel;                         
 | 
						|
  delete _quaH;
 | 
						|
 | 
						|
  return TApplication::destroy();  
 | 
						|
}  
 | 
						|
 | 
						|
int m75200 (int argc, char* argv[])
 | 
						|
{
 | 
						|
  TGenera_dett a;
 | 
						|
  a.run(argc, argv, "Generazione righe dettaglio Quadro H");
 | 
						|
  return 0;
 | 
						|
}            
 | 
						|
 |