Creazione delle righe automatica in scrittura di TMov_mag
git-svn-id: svn://10.65.10.50/trunk@4746 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
50aea726b0
commit
0bd507dd78
@ -1,7 +1,11 @@
|
||||
// oggetto TArticolo, multirecord dell'articolo di anagrafica magazzino
|
||||
// oggetto TArticolo_giacenza, multirecord dell'articolo di magazzino
|
||||
// oggetto TMov_Mag , multirecord del moviemnto di magazzino
|
||||
// funzione di ricostruzione saldi
|
||||
#include "mglib.h"
|
||||
#include "anamag.h"
|
||||
#include "mag.h"
|
||||
#include <mask.h>
|
||||
#include "movmag.h"
|
||||
|
||||
// libreria per i movimenti
|
||||
|
||||
@ -907,12 +911,11 @@ int TMov_mag::read(TBaseisamfile& f, word op , word lockop)
|
||||
for (int i=0; i<rows(); i++) {
|
||||
l_key=line2key(i+1);
|
||||
l_data=line2data(i+1);
|
||||
delete_line(l_key,l_data);
|
||||
line_deleted(l_key,l_data);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
int TMov_mag::remove(TBaseisamfile& f) const
|
||||
{
|
||||
int res;
|
||||
@ -922,16 +925,43 @@ int TMov_mag::remove(TBaseisamfile& f) const
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
void TMov_mag::add_automatiche()
|
||||
{
|
||||
for (int r=rows(); r>0; r--)
|
||||
{
|
||||
TString16 codcaus(body()[r].get(RMOVMAG_CODCAUS));
|
||||
if (codcaus.blank())
|
||||
codcaus=get(RMOVMAG_CODCAUS);
|
||||
TCausale_magazzino cau(codcaus);
|
||||
if (*cau.get_collegata()!='\0')
|
||||
{
|
||||
// deve esserci una riga collegata
|
||||
if (r < rows()-1 && body()[r+1].get(RMOVMAG_TIPORIGA)[0] != riga_automatica)
|
||||
{
|
||||
// manca, la inserisco
|
||||
TRectype linea_auto(body()[r]);
|
||||
|
||||
if (codmag_rauto(r)!=NULL) linea_auto.put(RMOVMAG_CODMAG,codmag_rauto(r));
|
||||
if (prezzo_rauto(r)!=NULL) linea_auto.put(RMOVMAG_PREZZO,prezzo_rauto(r));
|
||||
linea_auto.put(RMOVMAG_NRIG,r+1);
|
||||
body().insert_row(&linea_auto);
|
||||
}
|
||||
}
|
||||
} // ciclo righe
|
||||
}
|
||||
|
||||
int TMov_mag::write(TBaseisamfile& f) const
|
||||
{
|
||||
int res;
|
||||
((TMov_mag *)this)->add_automatiche();
|
||||
TToken_string l_key;
|
||||
TLine_movmag l_data;
|
||||
// memorizza le variazioni
|
||||
for (int i=0; i<rows(); i++) {
|
||||
l_key=line2key(i+1);
|
||||
l_data=line2data(i+1);
|
||||
((TMov_mag *)this)->insert_line(l_key,l_data);
|
||||
((TMov_mag *)this)->line_inserted(l_key,l_data);
|
||||
}
|
||||
if ((res=TMultiple_rectype::write(f))==NOERR )
|
||||
// effettua la variazione dei saldi
|
||||
@ -942,13 +972,14 @@ int TMov_mag::write(TBaseisamfile& f) const
|
||||
int TMov_mag::rewrite(TBaseisamfile& f) const
|
||||
{
|
||||
int res;
|
||||
((TMov_mag *)this)->add_automatiche();
|
||||
TToken_string l_key;
|
||||
TLine_movmag l_data;
|
||||
// memorizza le variazioni
|
||||
for (int i=0; i<rows(); i++) {
|
||||
l_key=line2key(i+1);
|
||||
l_data=line2data(i+1);
|
||||
((TMov_mag *)this)->insert_line(l_key,l_data);
|
||||
((TMov_mag *)this)->line_inserted(l_key,l_data);
|
||||
}
|
||||
if ((res=TMultiple_rectype::rewrite(f))==NOERR )
|
||||
// effettua la variazione dei saldi
|
||||
@ -960,7 +991,7 @@ const char *TMov_mag::get_next_key()
|
||||
{
|
||||
TLocalisamfile f(LF_MOVMAG);
|
||||
f.last();
|
||||
int a=atoi(f.get("NUMREG"))+1;
|
||||
int a=atoi(f.get(MOVMAG_NUMREG))+1;
|
||||
return _nextcod.format("%d",a);
|
||||
}
|
||||
|
||||
@ -975,15 +1006,15 @@ int TMov_mag::force_update_bal()
|
||||
TLine_movmag l_data;
|
||||
|
||||
// reset delle strutture per il controlli delle variazioni dei saldi
|
||||
_codcaus=get("CODCAUS");
|
||||
_annoes=get("ANNOES");
|
||||
_codcaus=get(MOVMAG_CODCAUS);
|
||||
_annoes=get(MOVMAG_ANNOES);
|
||||
lines_to_add.destroy();
|
||||
lines_to_subtract.destroy();
|
||||
// memorizza le variazioni
|
||||
for (int i=0; i<rows(); i++) {
|
||||
l_key=line2key(i+1);
|
||||
l_data=line2data(i+1);
|
||||
insert_line(l_key,l_data);
|
||||
line_inserted(l_key,l_data);
|
||||
}
|
||||
res=update_balances();
|
||||
return res;
|
||||
@ -1023,7 +1054,7 @@ TString TMov_mag::key2field(TToken_string &key,const char *fieldname)
|
||||
}
|
||||
|
||||
|
||||
int TMov_mag::insert_line(TToken_string &k,TLine_movmag &r)
|
||||
int TMov_mag::line_inserted(TToken_string &k,TLine_movmag &r)
|
||||
{
|
||||
if (_codcaus != get("CODCAUS") || _annoes != get("ANNOES")) {
|
||||
lines_to_add.add(k,r);
|
||||
@ -1038,7 +1069,7 @@ int TMov_mag::insert_line(TToken_string &k,TLine_movmag &r)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TMov_mag::delete_line(TToken_string &k,TLine_movmag &r)
|
||||
int TMov_mag::line_deleted(TToken_string &k,TLine_movmag &r)
|
||||
{
|
||||
if (_codcaus != get("CODCAUS") || _annoes != get("ANNOES")) {
|
||||
lines_to_subtract.add(k,r);
|
||||
|
Loading…
x
Reference in New Issue
Block a user