Riordino
git-svn-id: svn://10.65.10.50/trunk@4522 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
a3b4ca81f9
commit
60e67cef72
261
mg/mglib01.cpp
261
mg/mglib01.cpp
@ -1,3 +1,6 @@
|
|||||||
|
// gestione livelli di giacenza e articoli
|
||||||
|
// oggetto movimento di magazzino
|
||||||
|
// funzione di ricostruzione saldi
|
||||||
#include <relapp.h>
|
#include <relapp.h>
|
||||||
#include <tabutil.h>
|
#include <tabutil.h>
|
||||||
#include <recarray.h>
|
#include <recarray.h>
|
||||||
@ -6,6 +9,10 @@
|
|||||||
#include <defmask.h>
|
#include <defmask.h>
|
||||||
|
|
||||||
#include "mglib01.h"
|
#include "mglib01.h"
|
||||||
|
#include "mglib02.h"
|
||||||
|
#include "anamag.h"
|
||||||
|
#include "umart.h"
|
||||||
|
#include "mag.h"
|
||||||
#include "..\cg\cglib.h"
|
#include "..\cg\cglib.h"
|
||||||
|
|
||||||
// **************************************
|
// **************************************
|
||||||
@ -138,9 +145,9 @@ int THead_lines_record::read(TBaseisamfile& f, word op, word lockop)
|
|||||||
{
|
{
|
||||||
TRectype line_key(_rfile);
|
TRectype line_key(_rfile);
|
||||||
|
|
||||||
copy_linekey(head(),line_key);
|
|
||||||
|
|
||||||
int err = TRectype::read(f,op,lockop);
|
int err = TRectype::read(f,op,lockop);
|
||||||
|
|
||||||
|
copy_linekey(head(),line_key);
|
||||||
if (err == NOERR)
|
if (err == NOERR)
|
||||||
{
|
{
|
||||||
_nuovo = FALSE;
|
_nuovo = FALSE;
|
||||||
@ -156,6 +163,28 @@ int THead_lines_record::read(TBaseisamfile& f, word op, word lockop)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int THead_lines_record::readat(TBaseisamfile& f, TRecnotype nrec, word lockop)
|
||||||
|
{
|
||||||
|
TRectype line_key(_rfile);
|
||||||
|
|
||||||
|
int err = TRectype::readat(f,nrec,lockop);
|
||||||
|
|
||||||
|
if (err == NOERR)
|
||||||
|
{
|
||||||
|
_nuovo = FALSE;
|
||||||
|
_rows->read(line_key); //ok
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// nuovo oggetto: resetta tutto
|
||||||
|
_nuovo = TRUE;
|
||||||
|
destroy_rows();
|
||||||
|
_rows->set_key((TRectype *)(line_key.dup())); // ok
|
||||||
|
}
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*int THead_lines_record::read(const TRectype& rec)
|
/*int THead_lines_record::read(const TRectype& rec)
|
||||||
{
|
{
|
||||||
head() = rec;
|
head() = rec;
|
||||||
@ -185,6 +214,7 @@ int THead_lines_record::write(TBaseisamfile& f) const
|
|||||||
{
|
{
|
||||||
return write_rewrite(f,FALSE);
|
return write_rewrite(f,FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int THead_lines_record::rewrite(TBaseisamfile& f) const
|
int THead_lines_record::rewrite(TBaseisamfile& f) const
|
||||||
{
|
{
|
||||||
return write_rewrite(f,TRUE);
|
return write_rewrite(f,TRUE);
|
||||||
@ -247,53 +277,6 @@ int THead_lines_record::remove(TBaseisamfile& f) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// @doc INTERNAL
|
|
||||||
|
|
||||||
// @mfunc costruttore di copia
|
|
||||||
TTimed_box::TTimed_box(const char * header,const char * message,int seconds,short button_id,int x,int y)
|
|
||||||
: TMask(header,1,x,y)
|
|
||||||
{
|
|
||||||
// costruisce una maschera run time
|
|
||||||
add_memo(FIRST_FIELD, 0, "", 1, 0,-1,-3);
|
|
||||||
set(FIRST_FIELD, message);
|
|
||||||
|
|
||||||
// setta il timer per l'evento
|
|
||||||
_timer_delay=seconds *1000+1;
|
|
||||||
_timer_id=XVT_TIMER_ERROR;
|
|
||||||
_button_id=button_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TTimed_box::start_run()
|
|
||||||
{
|
|
||||||
if (_timer_id!=XVT_TIMER_ERROR)
|
|
||||||
xvt_timer_destroy(_timer_id);
|
|
||||||
_timer_id=xvt_timer_create(win(),_timer_delay);
|
|
||||||
TMask::start_run();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TTimed_box::handler(WINDOW win, EVENT* ep)
|
|
||||||
{
|
|
||||||
if (ep->type == E_TIMER && ep->v.timer.id==_timer_id)
|
|
||||||
{
|
|
||||||
send_key(K_SPACE,DLG_OK);
|
|
||||||
}
|
|
||||||
TMask::handler(win, ep);
|
|
||||||
}
|
|
||||||
|
|
||||||
class TTimed_breakbox: public TTimed_box
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TTimed_breakbox(const char * message,int seconds,int x=40,int y=10);
|
|
||||||
};
|
|
||||||
|
|
||||||
TTimed_breakbox::TTimed_breakbox(const char * message,int seconds,int x,int y)
|
|
||||||
: TTimed_box("Richiesta di interruzione",message,seconds,DLG_OK,x,y)
|
|
||||||
{
|
|
||||||
add_button(DLG_CANCEL, 0, "Interrompi", -22, -1, 12, 2,"",0);
|
|
||||||
add_button(DLG_OK, 0, "Riprova", -12, -1, 12, 2,"",0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// **********************************
|
// **********************************
|
||||||
// **********************************
|
// **********************************
|
||||||
// **********************************
|
// **********************************
|
||||||
@ -350,6 +333,15 @@ const int TMag_livelli::code_lenght(int levnum)
|
|||||||
return(0) ;
|
return(0) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const int TMag_livelli::packed_lenght(int levnum)
|
||||||
|
{
|
||||||
|
int start=0;
|
||||||
|
for (int i=1; i<=levnum && levnum<=MANY_MAG_LEV; i++)
|
||||||
|
start+= _code_lenght[i-1];
|
||||||
|
return start;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const TString & TMag_livelli::name(int levnum)
|
const TString & TMag_livelli::name(int levnum)
|
||||||
{
|
{
|
||||||
if (levnum<=MANY_MAG_LEV && levnum>0)
|
if (levnum<=MANY_MAG_LEV && levnum>0)
|
||||||
@ -368,11 +360,7 @@ const TString & TMag_livelli::picture(int levnum)
|
|||||||
|
|
||||||
void TMag_livelli::pack_grpcode(TString & pc, const TString &codlev, const int levnum)
|
void TMag_livelli::pack_grpcode(TString & pc, const TString &codlev, const int levnum)
|
||||||
{
|
{
|
||||||
|
pc.overwrite(codlev.left(_code_lenght[levnum-1]),packed_lenght(levnum-1));
|
||||||
int start=0;
|
|
||||||
for (int i=1; i<levnum; i++)
|
|
||||||
start+= _code_lenght[i-1];
|
|
||||||
pc.overwrite(codlev.left(_code_lenght[levnum-1]),start);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TString TMag_livelli::unpack_grpcode(const TString & pc, const int levnum)
|
TString TMag_livelli::unpack_grpcode(const TString & pc, const int levnum)
|
||||||
@ -389,6 +377,16 @@ TString TMag_livelli::unpack_grpcode(const TString & pc, const int levnum)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TString TMag_livelli::build_tabcode(const TString & pc, const int levnum)
|
||||||
|
{
|
||||||
|
TString valore;
|
||||||
|
valore << levnum;
|
||||||
|
valore << unpack_grpcode(pc,levnum);
|
||||||
|
if (valore.len()>1)
|
||||||
|
return valore;
|
||||||
|
else
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
// *******************************
|
// *******************************
|
||||||
// *******************************
|
// *******************************
|
||||||
@ -961,6 +959,9 @@ TCausale_magazzino::TCausale_magazzino(const char * codice):
|
|||||||
else
|
else
|
||||||
*this=(TCausale_magazzino &)f.curr();
|
*this=(TCausale_magazzino &)f.curr();
|
||||||
}
|
}
|
||||||
|
TCausale_magazzino::~TCausale_magazzino()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
// movimenti
|
// movimenti
|
||||||
TLine_movmag ::TLine_movmag(const TLine_movmag &l)
|
TLine_movmag ::TLine_movmag(const TLine_movmag &l)
|
||||||
@ -1037,6 +1038,27 @@ int TMov_mag::remove(TBaseisamfile& f) const
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TMov_mag::force_update_bal()
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
TToken_string l_key;
|
||||||
|
TLine_movmag l_data;
|
||||||
|
|
||||||
|
// reset delle strutture per il controlli delle variazioni dei saldi
|
||||||
|
_codcaus=get("CODCAUS");
|
||||||
|
_annoes=get("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);
|
||||||
|
((TMov_mag *)this)->insert_line(l_key,l_data);
|
||||||
|
}
|
||||||
|
res=update_balances();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
int TMov_mag::write(TBaseisamfile& f) const
|
int TMov_mag::write(TBaseisamfile& f) const
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
@ -1174,7 +1196,7 @@ bool TMov_mag::lock_anamag(const char *codart)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TMov_mag::giac_putkey2(TLocalisamfile & mag,TString16 annoes,TToken_string curr_key)
|
void TMov_mag::giac_putkey(TLocalisamfile & mag,TString16 annoes,TToken_string curr_key)
|
||||||
{
|
{
|
||||||
mag.zero(' ');
|
mag.zero(' ');
|
||||||
mag.put("ANNOES",annoes);
|
mag.put("ANNOES",annoes);
|
||||||
@ -1203,17 +1225,20 @@ int TMov_mag::update_balances() const
|
|||||||
TToken_string * curr_key=(TToken_string *)keys_to_add.first_item();
|
TToken_string * curr_key=(TToken_string *)keys_to_add.first_item();
|
||||||
|
|
||||||
while (curr_key) {
|
while (curr_key) {
|
||||||
if (lock_anamag(key2field(*curr_key,"CODART"))) {
|
TArticolo articolo(key2field(*curr_key,"CODART"));
|
||||||
|
if (articolo.lock_and_prompt()) {
|
||||||
|
TLine_movmag & line_mov=(TLine_movmag &)lines_to_add[*curr_key];
|
||||||
|
articolo.update_ultcosti(line_mov.prezzo,get_date("DATACOMP"));
|
||||||
// lock gained
|
// lock gained
|
||||||
giac_putkey2(mag,get("ANNOES"),*curr_key);
|
giac_putkey(mag,get("ANNOES"),*curr_key);
|
||||||
if (mag.read()!=NOERR) {
|
if (mag.read()!=NOERR) {
|
||||||
// non trovato: aggiungo
|
// non trovato: aggiungo
|
||||||
giac_putkey2(mag,get("ANNOES"),*curr_key);
|
giac_putkey(mag,get("ANNOES"),*curr_key);
|
||||||
mag.put("NRIGA",giac_last_item(get("ANNOES"),key2field(*curr_key,"CODART"))+1);
|
mag.put("NRIGA",giac_last_item(get("ANNOES"),key2field(*curr_key,"CODART"))+1);
|
||||||
mag.write();
|
mag.write();
|
||||||
}
|
}
|
||||||
// modifica questo record (e lo sblocca)
|
// modifica questo record (e lo sblocca)
|
||||||
update_balances(mag.curr(),(TLine_movmag &)lines_to_add[*curr_key],get("CODCAUS"),+1);
|
update_balances(mag.curr(),line_mov,get("CODCAUS"),+1);
|
||||||
/*// ottimizzazione :(cerca di sfruttare la lettura fatta per un eventuale saldo vecchio)
|
/*// ottimizzazione :(cerca di sfruttare la lettura fatta per un eventuale saldo vecchio)
|
||||||
// ciò causa la modifica dell'oggetto TMov_mag (il metodo non è più const)
|
// ciò causa la modifica dell'oggetto TMov_mag (il metodo non è più const)
|
||||||
if (_annoes == get("ANNOES")
|
if (_annoes == get("ANNOES")
|
||||||
@ -1227,7 +1252,7 @@ int TMov_mag::update_balances() const
|
|||||||
TToken_string *rem_key=(TToken_string *)keys_to_remove.first_item();
|
TToken_string *rem_key=(TToken_string *)keys_to_remove.first_item();
|
||||||
while ( rem_key) {
|
while ( rem_key) {
|
||||||
if (key2field(*rem_key,"CODART")==key2field(*curr_key,"CODART")) {
|
if (key2field(*rem_key,"CODART")==key2field(*curr_key,"CODART")) {
|
||||||
giac_putkey2(mag,_annoes,*rem_key);
|
giac_putkey(mag,_annoes,*rem_key);
|
||||||
if (mag.read()==NOERR) {
|
if (mag.read()==NOERR) {
|
||||||
update_balances(mag.curr(),(TLine_movmag &)lines_to_subtract[*rem_key],_codcaus,-1);
|
update_balances(mag.curr(),(TLine_movmag &)lines_to_subtract[*rem_key],_codcaus,-1);
|
||||||
mag.rewrite();
|
mag.rewrite();
|
||||||
@ -1236,7 +1261,7 @@ int TMov_mag::update_balances() const
|
|||||||
}
|
}
|
||||||
rem_key=(TToken_string *)keys_to_remove.succ_item();
|
rem_key=(TToken_string *)keys_to_remove.succ_item();
|
||||||
}
|
}
|
||||||
unlock_anamag(key2field(*curr_key,"CODART"));
|
articolo.unlock();
|
||||||
} else {
|
} else {
|
||||||
updated_bal=FALSE;
|
updated_bal=FALSE;
|
||||||
}
|
}
|
||||||
@ -1246,14 +1271,15 @@ int TMov_mag::update_balances() const
|
|||||||
curr_key=(TToken_string *)keys_to_remove.first_item();
|
curr_key=(TToken_string *)keys_to_remove.first_item();
|
||||||
|
|
||||||
while (curr_key) {
|
while (curr_key) {
|
||||||
if (lock_anamag(key2field(*curr_key,"CODART"))) {
|
TArticolo articolo(key2field(*curr_key,"CODART"));
|
||||||
giac_putkey2(mag,_annoes,*curr_key);
|
if (articolo.lock_and_prompt()) {
|
||||||
|
giac_putkey(mag,_annoes,*curr_key);
|
||||||
// modifica questo record (e lo sblocca)
|
// modifica questo record (e lo sblocca)
|
||||||
if (mag.read()==NOERR) {
|
if (mag.read()==NOERR) {
|
||||||
update_balances(mag.curr(),(TLine_movmag &)lines_to_subtract[*curr_key],_codcaus,-1);
|
update_balances(mag.curr(),(TLine_movmag &)lines_to_subtract[*curr_key],_codcaus,-1);
|
||||||
mag.rewrite();
|
mag.rewrite();
|
||||||
}
|
}
|
||||||
unlock_anamag(key2field(*curr_key,"CODART"));
|
articolo.unlock();
|
||||||
} else {
|
} else {
|
||||||
updated_bal=FALSE;
|
updated_bal=FALSE;
|
||||||
}
|
}
|
||||||
@ -1263,7 +1289,7 @@ int TMov_mag::update_balances() const
|
|||||||
// saldi non aggiornati
|
// saldi non aggiornati
|
||||||
warning_box("I saldi di magazzino non sono stati del tutto aggiornati. \nProcedere ad una operazione di ''Ricostruzione saldi''");
|
warning_box("I saldi di magazzino non sono stati del tutto aggiornati. \nProcedere ad una operazione di ''Ricostruzione saldi''");
|
||||||
}
|
}
|
||||||
return 0;
|
return updated_bal;
|
||||||
}
|
}
|
||||||
|
|
||||||
// aggiorna i saldi del record corrente
|
// aggiorna i saldi del record corrente
|
||||||
@ -1271,16 +1297,16 @@ int TMov_mag::update_balances() const
|
|||||||
int TMov_mag::update_balances(TRectype & magrec, const TLine_movmag &l,TString16 codcaus,int rett_sign) const
|
int TMov_mag::update_balances(TRectype & magrec, const TLine_movmag &l,TString16 codcaus,int rett_sign) const
|
||||||
{
|
{
|
||||||
TCausale_magazzino caus(codcaus);
|
TCausale_magazzino caus(codcaus);
|
||||||
TLocalisamfile anamag(LF_ANAMAG);
|
|
||||||
TLocalisamfile umart(LF_UMART);
|
TLocalisamfile umart(LF_UMART);
|
||||||
real diff,diff_val;
|
real diff,diff_val;
|
||||||
umart.put("CODART",magrec.get("CODART"));
|
umart.setkey(2);
|
||||||
umart.put("UM",l.um);
|
umart.put(UMART_CODART,magrec.get(MAG_CODART));
|
||||||
|
umart.put(UMART_UM , l.um);
|
||||||
umart.read();
|
umart.read();
|
||||||
real fc=umart.get_real("FC");
|
real fc=umart.get_real("FC");
|
||||||
|
|
||||||
diff=fc*rett_sign*l.quant;
|
diff=fc*rett_sign*l.quant;
|
||||||
diff_val=diff*l.prezzo;
|
diff_val=rett_sign*l.quant*l.prezzo;
|
||||||
update_balance(magrec,"GIAC",diff*caus.sgn(s_giac)); // update ..
|
update_balance(magrec,"GIAC",diff*caus.sgn(s_giac)); // update ..
|
||||||
update_balance(magrec,"ACQ",diff*caus.sgn(s_acq)); // update ..
|
update_balance(magrec,"ACQ",diff*caus.sgn(s_acq)); // update ..
|
||||||
update_balance(magrec,"VALACQ",diff_val*caus.sgn(s_acq)); // update ..
|
update_balance(magrec,"VALACQ",diff_val*caus.sgn(s_acq)); // update ..
|
||||||
@ -1322,3 +1348,100 @@ int TMov_mag::codice_esercizio(TDate &d)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//**********************
|
||||||
|
bool rebuild_balances(TString16 annoes, bool reset_giac)
|
||||||
|
{
|
||||||
|
TArray used_files;
|
||||||
|
used_files.add(new TLocalisamfile(LF_RMOVMAG),LF_RMOVMAG);
|
||||||
|
used_files.add(new TLocalisamfile(LF_MOVMAG),LF_MOVMAG);
|
||||||
|
used_files.add(new TTable("CAU"),5);
|
||||||
|
TMov_mag * m_m= new TMov_mag; // record del movimento di magazzino
|
||||||
|
|
||||||
|
// relazione con un solo file (LF_MOVMAG) ma col record Head_Body
|
||||||
|
TRelation rel(LF_MOVMAG);
|
||||||
|
rel.lfile().set_curr(m_m);
|
||||||
|
int ok=TRUE;
|
||||||
|
TLocalisamfile mag(LF_MAG);
|
||||||
|
if (reset_giac) {
|
||||||
|
// azzera tutte giacenze (ciclo sulle giacenze)
|
||||||
|
mag.put("ANNOES",annoes);
|
||||||
|
mag.read(_isgteq);
|
||||||
|
while (!mag.eof() && annoes==mag.get("ANNOES"))
|
||||||
|
{
|
||||||
|
TString currcode(mag.get("CODART"));
|
||||||
|
TArticolo articolo(currcode);
|
||||||
|
if (articolo.lock_and_prompt())
|
||||||
|
{
|
||||||
|
while (!mag.eof() && currcode==mag.get("CODART"))
|
||||||
|
{
|
||||||
|
mag.put("ACQ",0);mag.put("VALACQ",0);
|
||||||
|
mag.put("ENT",0);mag.put("VALENT",0);
|
||||||
|
mag.put("VEN",0);mag.put("VALVEN",0);
|
||||||
|
mag.put("USC",0);mag.put("VALUSC",0);
|
||||||
|
mag.put("ORDF",0);mag.put("VALORDF",0);
|
||||||
|
mag.put("ORDC",0);mag.put("VALORDC",0);
|
||||||
|
mag.put("SCARTI",0);mag.put("VALSCARTI",0);
|
||||||
|
mag.put("GIAC",0);
|
||||||
|
mag.put("PRODCOMP",0);
|
||||||
|
mag.put("PRODFIN",0);
|
||||||
|
mag.put("INCL",0);
|
||||||
|
mag.put("ACL",0);
|
||||||
|
mag.put("NLABEL",0);
|
||||||
|
mag.rewrite();
|
||||||
|
mag.next();
|
||||||
|
}
|
||||||
|
articolo.unlock();
|
||||||
|
} else {
|
||||||
|
ok=FALSE;
|
||||||
|
mag.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ricostruisce i saldi (ciclo sui movimenti)
|
||||||
|
TString filterexpr;
|
||||||
|
filterexpr << LF_MOVMAG << "->ANNOES==" << annoes;
|
||||||
|
TCursor cur(&rel,filterexpr); // cursore filtrato
|
||||||
|
|
||||||
|
for (int i=0; i<cur.objects(); i++)
|
||||||
|
{
|
||||||
|
cur=i;
|
||||||
|
TMov_mag & mov_rec=(TMov_mag &)cur.file().curr();
|
||||||
|
if (!mov_rec.force_update_bal())
|
||||||
|
ok=FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
static TLocalisamfile *anamag=NULL;
|
||||||
|
|
||||||
|
bool unlock_anamag(const char *codart)
|
||||||
|
{
|
||||||
|
bool rv;
|
||||||
|
if (anamag)
|
||||||
|
{
|
||||||
|
anamag->put("CODART",codart);
|
||||||
|
rv=(anamag->read(_isequal,_unlock)==NOERR);
|
||||||
|
delete anamag;
|
||||||
|
anamag=NULL;
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool lock_anamag(const char *codart)
|
||||||
|
{
|
||||||
|
if (!anamag)
|
||||||
|
anamag = new TLocalisamfile(LF_ANAMAG);
|
||||||
|
anamag->put("CODART",codart);
|
||||||
|
bool insert_new=TRUE;
|
||||||
|
TString mess;
|
||||||
|
mess << "Il record di anagrafica dell'articolo ''"<< codart << "'' risulta essere già in uso.\n Interrompo ?";
|
||||||
|
TTimed_breakbox bbox((const char *)mess,10);
|
||||||
|
do {
|
||||||
|
if (anamag->read(_isequal,_testandlock)==NOERR)
|
||||||
|
return TRUE;
|
||||||
|
} while (bbox.run()!=K_ESC);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
31
mg/mglib01.h
31
mg/mglib01.h
@ -9,6 +9,8 @@
|
|||||||
// ***
|
// ***
|
||||||
#include <varrec.h>
|
#include <varrec.h>
|
||||||
#include <msksheet.h>
|
#include <msksheet.h>
|
||||||
|
#ifndef __MGLIB_H
|
||||||
|
#define __MGLIB_H
|
||||||
class THead_lines_record ;
|
class THead_lines_record ;
|
||||||
//**************************************
|
//**************************************
|
||||||
// classe per il controllo dei record composti da una testata e N righe
|
// classe per il controllo dei record composti da una testata e N righe
|
||||||
@ -77,6 +79,7 @@ public:
|
|||||||
void reset_fields(TAuto_variable_rectype & rec) { rec.remove_field(); }
|
void reset_fields(TAuto_variable_rectype & rec) { rec.remove_field(); }
|
||||||
virtual void set_fields(TAuto_variable_rectype & rec);
|
virtual void set_fields(TAuto_variable_rectype & rec);
|
||||||
|
|
||||||
|
virtual int readat(TBaseisamfile& f, TRecnotype nrec, word lockop= _nolock);
|
||||||
virtual int read(TBaseisamfile& f, word op = _isequal, word lockop = _nolock);
|
virtual int read(TBaseisamfile& f, word op = _isequal, word lockop = _nolock);
|
||||||
|
|
||||||
virtual int write(TBaseisamfile& f) const ;
|
virtual int write(TBaseisamfile& f) const ;
|
||||||
@ -95,19 +98,6 @@ public:
|
|||||||
virtual ~THead_lines_record();
|
virtual ~THead_lines_record();
|
||||||
};
|
};
|
||||||
|
|
||||||
//**********************
|
|
||||||
// classe per la gestione delle finestre temporizzate
|
|
||||||
class TTimed_box: public TMask
|
|
||||||
{
|
|
||||||
long _timer_delay;
|
|
||||||
long _timer_id;
|
|
||||||
short _button_id;
|
|
||||||
protected:
|
|
||||||
virtual void handler(WINDOW win, EVENT* ep);
|
|
||||||
virtual void start_run();
|
|
||||||
public:
|
|
||||||
TTimed_box(const char * header,const char * message,int seconds,short button_id,int x,int y);
|
|
||||||
};
|
|
||||||
|
|
||||||
// **************************************
|
// **************************************
|
||||||
// **************************************
|
// **************************************
|
||||||
@ -135,9 +125,11 @@ public:
|
|||||||
const TString & name(int levnum); // Ritorna il nome (descrizione) di quel livello
|
const TString & name(int levnum); // Ritorna il nome (descrizione) di quel livello
|
||||||
const TString & picture(int levnum);// Ritorna la stringa di picture per i codici gruppo di quel livello
|
const TString & picture(int levnum);// Ritorna la stringa di picture per i codici gruppo di quel livello
|
||||||
const int code_lenght(int levnum); // Ritorna la lunghezza dei codici gruppo di quel livello
|
const int code_lenght(int levnum); // Ritorna la lunghezza dei codici gruppo di quel livello
|
||||||
|
const int packed_lenght(int levnum); // Ritorna la lunghezza del codice compatto fino a quel livello
|
||||||
|
|
||||||
void pack_grpcode(TString & pc, const TString &codlev, const int levnum); // Inserisce il codice del gruppo del livello levnum in pc
|
void pack_grpcode(TString & pc, const TString &codlev, const int levnum); // Inserisce il codice del gruppo del livello levnum in pc
|
||||||
TString unpack_grpcode(const TString & pc, const int levnum); // Estrae il codice del gruppo del livello levnum da pc
|
TString unpack_grpcode(const TString & pc, const int levnum); // Estrae il codice del gruppo del livello levnum da pc
|
||||||
|
TString build_tabcode(const TString & pc, const int levnum);
|
||||||
|
|
||||||
TMag_livelli(const char *tabname); // costruttore
|
TMag_livelli(const char *tabname); // costruttore
|
||||||
~TMag_livelli() {}; // distruttore
|
~TMag_livelli() {}; // distruttore
|
||||||
@ -257,6 +249,7 @@ public:
|
|||||||
const char * get_raggfisc() {return get("S8");}
|
const char * get_raggfisc() {return get("S8");}
|
||||||
int sgn(TTipo_saldomag fieldname) ;
|
int sgn(TTipo_saldomag fieldname) ;
|
||||||
TCausale_magazzino(const char * codice);
|
TCausale_magazzino(const char * codice);
|
||||||
|
~TCausale_magazzino();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -278,6 +271,10 @@ public:
|
|||||||
virtual ~TLine_movmag() {};
|
virtual ~TLine_movmag() {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
bool lock_anamag(const char *codart);
|
||||||
|
bool unlock_anamag(const char *codart) ;
|
||||||
|
|
||||||
// classe per la definizione dei movimenti di magazzino
|
// classe per la definizione dei movimenti di magazzino
|
||||||
// ( un movimento (testata+righe) == un oggetto TMov_mag )
|
// ( un movimento (testata+righe) == un oggetto TMov_mag )
|
||||||
class TMov_mag : public THead_lines_record {
|
class TMov_mag : public THead_lines_record {
|
||||||
@ -315,9 +312,10 @@ protected:
|
|||||||
// @member: effettua l'aggiornamento di un saldo di una giacenza
|
// @member: effettua l'aggiornamento di un saldo di una giacenza
|
||||||
void update_balance(TRectype & magrec, const char * fieldname, real diff) const;
|
void update_balance(TRectype & magrec, const char * fieldname, real diff) const;
|
||||||
|
|
||||||
static void giac_putkey2(TLocalisamfile & mag,TString16 annoes,TToken_string curr_key);
|
static void giac_putkey(TLocalisamfile & mag,TString16 annoes,TToken_string curr_key);
|
||||||
static bool lock_anamag(const char *codart);
|
static bool lock_anamag(const char *codart);
|
||||||
static bool unlock_anamag(const char *codart) ;
|
static bool unlock_anamag(const char *codart) ;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// IO ad alto livello
|
// IO ad alto livello
|
||||||
virtual const char *get_next_key() ;
|
virtual const char *get_next_key() ;
|
||||||
@ -325,11 +323,16 @@ public:
|
|||||||
virtual int remove(TBaseisamfile& f) const ;
|
virtual int remove(TBaseisamfile& f) const ;
|
||||||
virtual int write(TBaseisamfile& f) const ;
|
virtual int write(TBaseisamfile& f) const ;
|
||||||
virtual int rewrite(TBaseisamfile& f) const ;
|
virtual int rewrite(TBaseisamfile& f) const ;
|
||||||
|
int force_update_bal();
|
||||||
|
|
||||||
//
|
//
|
||||||
int codice_esercizio(TDate &d);
|
int codice_esercizio(TDate &d);
|
||||||
// costruttori e distruttori
|
// costruttori e distruttori
|
||||||
TMov_mag();
|
TMov_mag();
|
||||||
virtual ~TMov_mag();
|
virtual ~TMov_mag();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool rebuild_balances(TString16 annoes, bool reset_giac=FALSE);
|
||||||
|
|
||||||
|
#endif //__MGLIB_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user