168 lines
		
	
	
		
			4.7 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			168 lines
		
	
	
		
			4.7 KiB
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
#include <applicat.h>
 | 
						|
#include <mask.h>                                        
 | 
						|
#include <form.h>
 | 
						|
#include <printer.h> 
 | 
						|
#include <tabutil.h>
 | 
						|
#include <sheet.h>              
 | 
						|
 | 
						|
#include "dblib.h"
 | 
						|
#include "db1200a.h"
 | 
						|
 | 
						|
class TStampa_anagrafica : public TSkeleton_application
 | 
						|
{  
 | 
						|
  TForm * _form;
 | 
						|
  TMask * _msk;
 | 
						|
 protected:
 | 
						|
  virtual void main_loop();
 | 
						|
  virtual bool create();
 | 
						|
  virtual bool destroy();
 | 
						|
  void configura_profilo();
 | 
						|
 public:                            
 | 
						|
  TStampa_anagrafica ();
 | 
						|
  virtual ~TStampa_anagrafica() {}
 | 
						|
};                                                         
 | 
						|
                                          
 | 
						|
TStampa_anagrafica::TStampa_anagrafica()
 | 
						|
{}                                                        
 | 
						|
                                            
 | 
						|
bool TStampa_anagrafica::create()
 | 
						|
{ 
 | 
						|
  _msk = new TMask("db1200a");
 | 
						|
  _form = new TForm("db1200a");  
 | 
						|
  return TSkeleton_application::create();
 | 
						|
}
 | 
						|
                                
 | 
						|
bool TStampa_anagrafica::destroy()
 | 
						|
{ 
 | 
						|
  if (_form) delete _form;
 | 
						|
  if (_msk) delete _msk;
 | 
						|
  return TSkeleton_application::destroy();
 | 
						|
}                              
 | 
						|
 | 
						|
void TStampa_anagrafica::configura_profilo()
 | 
						|
{   
 | 
						|
  int  ordinamento = _msk->get_int(F_SORT);
 | 
						|
           
 | 
						|
  TRectype da(LF_DIST);
 | 
						|
  TRectype  a(LF_DIST);  
 | 
						|
  TString sda = _msk->get(F_DISTDA);
 | 
						|
  TString sa = _msk->get(F_DISTA);
 | 
						|
  TString stemp;
 | 
						|
    
 | 
						|
  da.put("CODDIST", _msk->get(F_DISTDA));
 | 
						|
  a.put("CODDIST", _msk->get(F_DISTA));
 | 
						|
  TCursor * cur  = _form->cursor();
 | 
						|
  TString filtrorighe,filtrodist;
 | 
						|
  const bool r_lavorazioni = _msk->get_bool(F_RIGHE_LAVORAZIONI);
 | 
						|
  const bool r_articoli = _msk->get_bool(F_RIGHE_ARTICOLI);
 | 
						|
  const bool r_virtuali = _msk->get_bool(F_RIGHE_VIRTUALI);
 | 
						|
  const bool r_variabili = _msk->get_bool(F_RIGHE_VARIABILI);
 | 
						|
  const bool lavorazioni = _msk->get_bool(F_DIST_LAVORAZIONI);
 | 
						|
  const bool articoli = _msk->get_bool(F_DIST_ARTICOLI);
 | 
						|
  const bool virtuali = _msk->get_bool(F_DIST_VIRTUALI);
 | 
						|
  bool update=FALSE;
 | 
						|
  if (articoli)
 | 
						|
  {
 | 
						|
    filtrodist << "(CODDIST!=" << LF_ANAMAG << "->CODART)";
 | 
						|
    update=TRUE;
 | 
						|
  }                                 
 | 
						|
  if (lavorazioni)
 | 
						|
  {                                                        
 | 
						|
    if (filtrodist.not_empty())
 | 
						|
      filtrodist << "&&";
 | 
						|
    filtrodist << "(CODDIST!=" << LF_TAB << "->CODTAB)";
 | 
						|
    update=TRUE;
 | 
						|
  }                            
 | 
						|
  if (virtuali)
 | 
						|
  {                                                        
 | 
						|
    if (filtrodist.not_empty())
 | 
						|
      filtrodist << "&&";
 | 
						|
    filtrodist << "(VIRTUALE==\" \")";
 | 
						|
  }
 | 
						|
  cur->setregion (da,a);
 | 
						|
  cur->setfilter ("");
 | 
						|
  if (filtrodist.not_empty())
 | 
						|
    cur->setfilter (filtrodist,update);
 | 
						|
 | 
						|
  const bool righe = _msk->get_bool(F_DETT_RIGHE);
 | 
						|
  _form->find_field('S', odd_page, "RIGHE_SUB").enable(righe); 
 | 
						|
  if (righe)
 | 
						|
  	_form->find_field('B', odd_page, 1).section().set_height(2);
 | 
						|
  else
 | 
						|
  	_form->find_field('B', odd_page, 1).section().set_height(1);
 | 
						|
  if (r_articoli)
 | 
						|
  {
 | 
						|
    filtrorighe << "(" << LF_RDIST << "->TIPO!=\"A\")";
 | 
						|
  }                                 
 | 
						|
  if (r_lavorazioni)
 | 
						|
  {                                                        
 | 
						|
    if (filtrorighe.not_empty()) 
 | 
						|
      filtrorighe << "&&";
 | 
						|
    filtrorighe << "(" << LF_RDIST << "->TIPO!=\"L\")";
 | 
						|
  }                            
 | 
						|
  if (r_virtuali)
 | 
						|
  {               
 | 
						|
    if (filtrorighe.not_empty()) 
 | 
						|
      filtrorighe << "&&";
 | 
						|
    filtrorighe << "(" << LF_RDIST << "->TIPO!=\"D\")";
 | 
						|
  } 
 | 
						|
  if (r_variabili)
 | 
						|
  {               
 | 
						|
    if (filtrorighe.not_empty())
 | 
						|
      filtrorighe << "&&";
 | 
						|
    filtrorighe << "(" << LF_RDIST << "->TIPO!=\"V\")";
 | 
						|
  } 
 | 
						|
 | 
						|
  if (ordinamento)
 | 
						|
  {
 | 
						|
    if (filtrorighe.not_empty())
 | 
						|
     filtrorighe << "&&";
 | 
						|
           
 | 
						|
    filtrorighe.insert("(");
 | 
						|
    filtrorighe << "(" << LF_RDIST << "->SORT" << ordinamento << "!=0))";
 | 
						|
  }  
 | 
						|
 | 
						|
  // Sostituisce il file delle Righe distinte
 | 
						|
  if (righe)
 | 
						|
  {
 | 
						|
    TRelation* rel = _form->relation();
 | 
						|
    stemp= "CODDIST|NRIG";
 | 
						|
    if (ordinamento)
 | 
						|
      stemp << "|SORT" << ordinamento;
 | 
						|
      
 | 
						|
    TSortedfile *sf = new TSortedfile(LF_RDIST, NULL,stemp);
 | 
						|
    sf->cursor().setfilter(filtrorighe, TRUE);
 | 
						|
    rel->replace(sf, 3);
 | 
						|
  }
 | 
						|
}                                                    
 | 
						|
 | 
						|
void TStampa_anagrafica::main_loop()
 | 
						|
{ 
 | 
						|
  while (_msk->run()!=K_QUIT)
 | 
						|
  {                            
 | 
						|
    configura_profilo();
 | 
						|
               
 | 
						|
    // Fincature & altro
 | 
						|
    const int hh = 6;
 | 
						|
    const int fl = printer().formlen();
 | 
						|
              
 | 
						|
    int rows[4];         // Righe orizzontali
 | 
						|
    rows[0] = hh-2;
 | 
						|
    rows[1] = hh;
 | 
						|
    rows[2] = fl-1;
 | 
						|
    rows[3] = 0;
 | 
						|
    _form->genera_intestazioni(odd_page, hh-1);
 | 
						|
    _form->genera_fincatura(odd_page, hh-2, fl-1, rows);
 | 
						|
    if (_form->cursor()->items() > 0)
 | 
						|
      _form->print();
 | 
						|
  } 
 | 
						|
}       
 | 
						|
 | 
						|
int db1200(int argc, char* argv[])
 | 
						|
{
 | 
						|
  TStampa_anagrafica app;
 | 
						|
  app.run(argc, argv, TR("Stampa anagrafica distinte"));
 | 
						|
  return 0;
 | 
						|
}
 | 
						|
 |