36 lines
		
	
	
		
			946 B
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			946 B
		
	
	
	
		
			C++
		
	
	
		
			Executable File
		
	
	
	
	
 | 
						|
#include <rectypes.h>
 | 
						|
#include <relation.h>
 | 
						|
#include <recarray.h>
 | 
						|
#include <tabutil.h>
 | 
						|
#include "ve0100b.h"
 | 
						|
 | 
						|
int numerazione_definitiva(TDocumento& doc)
 | 
						|
{
 | 
						|
  if (doc.get("PROVV") == "D" && doc.stampabile())
 | 
						|
  {
 | 
						|
    doc.stato(doc.tipo().stato_finale_stampa()); // Se e' gia' in definitiva aggiorna solo lo stato
 | 
						|
    return doc.rewrite();
 | 
						|
  }
 | 
						|
 | 
						|
  // Scrive il nuovo documento con lo stato, numero e flag di definitiva 
 | 
						|
  int err = NOERR;
 | 
						|
  TDocumento bak_doc;
 | 
						|
  
 | 
						|
  bak_doc = doc; // Setta il flag di nuovo documento
 | 
						|
  bak_doc.put("STATO",doc.tipo().stato_finale_stampa());
 | 
						|
  bak_doc.put("PROVV","D");
 | 
						|
  bak_doc.put("NDOC",-1L);
 | 
						|
  const int pr = bak_doc.physical_rows();
 | 
						|
  for (int i=1;i<=pr;i++)
 | 
						|
    bak_doc[i].put("PROVV","D");
 | 
						|
  
 | 
						|
  err = bak_doc.write(); // Esegue automagicamente rinumerazione di testata e righe nel caso di reinsert
 | 
						|
  if (err != NOERR)
 | 
						|
    return err;
 | 
						|
  
 | 
						|
  // Cancella il vecchio documento
 | 
						|
  err = doc.remove();
 | 
						|
  return err;
 | 
						|
}
 |