Modifiche per gestione stati:
esegue la write/rewrite di TDocumento, per aggiornare anche il magazzino. git-svn-id: svn://10.65.10.50/trunk@5026 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
01d70b8140
commit
5f80dd5869
@ -3,73 +3,33 @@
|
|||||||
#include <relation.h>
|
#include <relation.h>
|
||||||
#include <recarray.h>
|
#include <recarray.h>
|
||||||
#include <tabutil.h>
|
#include <tabutil.h>
|
||||||
|
#include "ve0100b.h"
|
||||||
|
|
||||||
int numerazione_definitiva(TLocalisamfile& doc, const int final_status)
|
int numerazione_definitiva(TDocumento& doc, const int final_status)
|
||||||
{
|
{
|
||||||
if (doc.curr().get("PROVV") == "D")
|
if (doc.get("PROVV") == "D")
|
||||||
{
|
{
|
||||||
doc.put("STATO",final_status); // Se e' gia' in definitiva aggiorna solo lo stato
|
doc.put("STATO",final_status); // Se e' gia' in definitiva aggiorna solo lo stato
|
||||||
return doc.rewrite();
|
return doc.rewrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
int err = NOERR; // istanzia la variabile per il codice d'errore
|
// Scrive il nuovo documento con lo stato, numero e flag di definitiva
|
||||||
TRectype doc_rec(doc.curr());
|
int err = NOERR;
|
||||||
TRectype rec(doc.curr()); // record campione
|
TDocumento bak_doc;
|
||||||
|
|
||||||
rec.zero();
|
bak_doc = doc; // Setta il flag di nuovo documento
|
||||||
rec.put("CODNUM", doc.get("CODNUM"));
|
bak_doc.put("STATO",final_status);
|
||||||
rec.put("ANNO", doc.get("ANNO"));
|
bak_doc.put("PROVV","D");
|
||||||
rec.put("PROVV", "D");
|
bak_doc.put("NDOC",-1L);
|
||||||
|
const int pr = bak_doc.physical_rows();
|
||||||
TRectype cmp_rec(rec); // record campione
|
for (int i=1;i<=pr;i++)
|
||||||
|
bak_doc[i].put("PROVV","D");
|
||||||
|
|
||||||
rec.put( "NDOC", 9999999L );
|
err = bak_doc.write(); // Esegue automagicamente rinumerazione di testata e righe nel caso di reinsert
|
||||||
|
|
||||||
bool unlock = FALSE;
|
|
||||||
|
|
||||||
if (doc.read(rec, _isgreat) == NOERR)
|
|
||||||
{
|
|
||||||
doc.prev(_lock); // blocca il record corrente del file documenti
|
|
||||||
unlock = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
long numdoc = ((doc.curr() == cmp_rec) ? doc.get_long( "NDOC" ) : 0) + 1;
|
|
||||||
cmp_rec = doc.curr();
|
|
||||||
|
|
||||||
TRectype newrec_doc(doc_rec); // istanzia un nuovo record su quello corrente
|
|
||||||
TRectype rec_rdoc(LF_RIGHEDOC); // istanzia il record delle righe per effettuare la lettura
|
|
||||||
|
|
||||||
newrec_doc.put("NDOC", numdoc); // scrive il nuovo numero di documento nel nuovo record
|
|
||||||
newrec_doc.put("PROVV", "D"); // aggiorna il flag di tipo di numerazione
|
|
||||||
newrec_doc.put("STATO",final_status); // Stato finale del documento
|
|
||||||
while ((err = doc.write(newrec_doc)) == _isreinsert)
|
|
||||||
{
|
|
||||||
numdoc++;
|
|
||||||
newrec_doc.put("NDOC", numdoc);
|
|
||||||
}
|
|
||||||
if (err != NOERR)
|
if (err != NOERR)
|
||||||
return err;
|
return err;
|
||||||
if (unlock)
|
|
||||||
doc.read(cmp_rec, _isequal, _unlock);
|
// Cancella il vecchio documento
|
||||||
|
err = doc.remove();
|
||||||
rec_rdoc.put("CODNUM",doc_rec.get("CODNUM")); // compone la chiave per le righe
|
|
||||||
rec_rdoc.put("ANNO",doc_rec.get("ANNO"));
|
|
||||||
rec_rdoc.put("NDOC", doc_rec.get("NDOC"));
|
|
||||||
rec_rdoc.put("PROVV","P");
|
|
||||||
TRecord_array arr_rdoc(LF_RIGHEDOC, "NRIGA"); // istanzia il record array per le righe
|
|
||||||
arr_rdoc.read(rec_rdoc);
|
|
||||||
|
|
||||||
TRecord_array newarr_rdoc(arr_rdoc); // crea una copia del record array per tenere le nuove righe
|
|
||||||
|
|
||||||
for (int i=1; i<=newarr_rdoc.last_row(); i++)
|
|
||||||
{ // ciclo sui record delle righe
|
|
||||||
TRectype &newrec_rdoc= newarr_rdoc.row(i, FALSE); // prende il record della riga corrente
|
|
||||||
|
|
||||||
newrec_rdoc.put("NDOC", numdoc); // scrive il nuovo numero di documento
|
|
||||||
newrec_rdoc.put("PROVV", "D"); // aggiorna il flag di tipo di numerazione
|
|
||||||
}
|
|
||||||
if ((err = newarr_rdoc.write()) == NOERR && // scrive le righe con la nuova numerazione
|
|
||||||
(err = arr_rdoc.remove()) == NOERR) // rimuove le vecchie righe
|
|
||||||
doc.remove(doc_rec); // cancella il vecchio record della testata
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
#ifndef __VE0100B_H
|
#ifndef __VE0100B_H
|
||||||
#define __VE0100B_H
|
#define __VE0100B_H
|
||||||
|
|
||||||
int numerazione_definitiva(TLocalisamfile &, const int); // prototipo della funzione di rinumerazione definitiva dei documenti
|
#ifndef __VELIB_H
|
||||||
|
#include "velib.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int numerazione_definitiva(TDocumento &, const int); // prototipo della funzione di rinumerazione definitiva dei documenti
|
||||||
|
|
||||||
#endif // __VE0100B_H
|
#endif // __VE0100B_H
|
||||||
|
@ -13,10 +13,10 @@
|
|||||||
#include <doc.h>
|
#include <doc.h>
|
||||||
#include <rdoc.h>
|
#include <rdoc.h>
|
||||||
|
|
||||||
#include "ve1100.h"
|
|
||||||
#include "ve0100b.h"
|
|
||||||
#include "velib.h"
|
#include "velib.h"
|
||||||
#include "sconti.h"
|
#include "sconti.h"
|
||||||
|
#include "ve1100.h"
|
||||||
|
#include "ve0100b.h"
|
||||||
|
|
||||||
#define LISTADOC "listadoc"
|
#define LISTADOC "listadoc"
|
||||||
#define Usage "Usage: ve1 -0 {[codnum anno {D|P} dalnum alnum {D|P} [ncopie]] | [L]}"
|
#define Usage "Usage: ve1 -0 {[codnum anno {D|P} dalnum alnum {D|P} [ncopie]] | [L]}"
|
||||||
@ -1047,7 +1047,7 @@ void TStampaDoc_application::print_selected()
|
|||||||
_form->doc().summary_reset();
|
_form->doc().summary_reset();
|
||||||
_form->doc().scadenze_reset();
|
_form->doc().scadenze_reset();
|
||||||
}
|
}
|
||||||
if (_definitiva && (numerazione_definitiva(doc,_form->final_status()) != NOERR))
|
if (_definitiva && (numerazione_definitiva(_form->doc(),_form->final_status()) != NOERR))
|
||||||
{ // se la stampa è definitiva viene lanciata la procedura di rinumerazione
|
{ // se la stampa è definitiva viene lanciata la procedura di rinumerazione
|
||||||
if (_interattivo) error_box("Non è possibile completare la procedura di numerazione definitiva dei documenti. Errore %d", doc.status());
|
if (_interattivo) error_box("Non è possibile completare la procedura di numerazione definitiva dei documenti. Errore %d", doc.status());
|
||||||
break;
|
break;
|
||||||
|
@ -1664,9 +1664,8 @@ error_type TContabilizzazione_app::write_all()
|
|||||||
error_type TContabilizzazione_app::change_doc_status()
|
error_type TContabilizzazione_app::change_doc_status()
|
||||||
// Cambia lo stato del documento
|
// Cambia lo stato del documento
|
||||||
{
|
{
|
||||||
TLocalisamfile d(LF_DOC);
|
|
||||||
_doc->stato(_final_doc_status);
|
_doc->stato(_final_doc_status);
|
||||||
if (_doc->head().rewrite(d) != NOERR)
|
if (_doc->rewrite() != NOERR)
|
||||||
_error = chg_stat_error;
|
_error = chg_stat_error;
|
||||||
return _error;
|
return _error;
|
||||||
}
|
}
|
||||||
|
@ -356,7 +356,7 @@ error_type TGenerazioneEffetti_app::change_doc_status()
|
|||||||
// Cambia lo stato del documento
|
// Cambia lo stato del documento
|
||||||
{
|
{
|
||||||
_doc->stato(_final_doc_status);
|
_doc->stato(_final_doc_status);
|
||||||
if (_doc->head().rewrite(*_docfile) != NOERR)
|
if (_doc->rewrite() != NOERR)
|
||||||
_error = chg_stat_error;
|
_error = chg_stat_error;
|
||||||
return _error;
|
return _error;
|
||||||
}
|
}
|
||||||
@ -382,14 +382,10 @@ error_type TGenerazioneEffetti_app::change_group_status()
|
|||||||
int anno = t.get_int(1);
|
int anno = t.get_int(1);
|
||||||
TString codnum(t.get(2));
|
TString codnum(t.get(2));
|
||||||
long numdoc = t.get_long(3);
|
long numdoc = t.get_long(3);
|
||||||
_docfile->put(DOC_PROVV,provv);
|
if (_doc->read(provv,anno,codnum,numdoc) == NOERR) // Legge il documento
|
||||||
_docfile->put(DOC_ANNO,anno);
|
|
||||||
_docfile->put(DOC_CODNUM,codnum);
|
|
||||||
_docfile->put(DOC_NDOC,numdoc);
|
|
||||||
if (_docfile->read() == NOERR) // Legge il documento
|
|
||||||
{
|
{
|
||||||
_docfile->put(DOC_STATO,_final_doc_status);
|
_doc->put(DOC_STATO,_final_doc_status);
|
||||||
_docfile->rewrite();
|
_doc->rewrite();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user