Patch level :
Files correlati : Ricompilazione Demo : [ ] Commento : git-svn-id: svn://10.65.10.50/trunk@17188 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
79af82bd6e
commit
0dc6f571c6
42
mg/clifogiac.h
Executable file
42
mg/clifogiac.h
Executable file
@ -0,0 +1,42 @@
|
||||
#ifndef __CLIFOGIAC_H
|
||||
#define __CLIFOGIAC_H
|
||||
|
||||
#define CLIFOGIAC_TIPOCF "TIPOCF"
|
||||
#define CLIFOGIAC_CODCF "CODCF"
|
||||
#define CLIFOGIAC_ANNOES "ANNOES"
|
||||
#define CLIFOGIAC_INDSPED "INDSPED"
|
||||
#define CLIFOGIAC_CODART "CODART"
|
||||
#define CLIFOGIAC_LIVELLO "LIVELLO"
|
||||
#define CLIFOGIAC_NRIGA "NRIGA"
|
||||
#define CLIFOGIAC_DATARIF "DATARIF"
|
||||
#define CLIFOGIAC_UBICAZ "UBICAZ"
|
||||
#define CLIFOGIAC_RIM "RIM"
|
||||
#define CLIFOGIAC_VALRIM "VALRIM"
|
||||
#define CLIFOGIAC_ACQ "ACQ"
|
||||
#define CLIFOGIAC_VALACQ "VALACQ"
|
||||
#define CLIFOGIAC_ENT "ENT"
|
||||
#define CLIFOGIAC_VALENT "VALENT"
|
||||
#define CLIFOGIAC_VEN "VEN"
|
||||
#define CLIFOGIAC_VALVEN "VALVEN"
|
||||
#define CLIFOGIAC_USC "USC"
|
||||
#define CLIFOGIAC_VALUSC "VALUSC"
|
||||
#define CLIFOGIAC_GIAC "GIAC"
|
||||
#define CLIFOGIAC_ORDF "ORDF"
|
||||
#define CLIFOGIAC_VALORDF "VALORDF"
|
||||
#define CLIFOGIAC_ORDC "ORDC"
|
||||
#define CLIFOGIAC_VALORDC "VALORDC"
|
||||
#define CLIFOGIAC_INCL "INCL"
|
||||
#define CLIFOGIAC_ACL "ACL"
|
||||
#define CLIFOGIAC_PRODCOMP "PRODCOMP"
|
||||
#define CLIFOGIAC_PRODFIN "PRODFIN"
|
||||
#define CLIFOGIAC_NLABEL "NLABEL"
|
||||
#define CLIFOGIAC_NDIST "NDIST"
|
||||
#define CLIFOGIAC_SCARTI "SCARTI"
|
||||
#define CLIFOGIAC_VALSCARTI "VALSCARTI"
|
||||
#define CLIFOGIAC_LIVRIOR "LIVRIOR"
|
||||
#define CLIFOGIAC_LOTTORIOR "LOTTORIOR"
|
||||
#define CLIFOGIAC_LOTTOIRIOR "LOTTOIRIOR"
|
||||
#define CLIFOGIAC_GIORNIRIOR "GIORNIRIOR"
|
||||
#define CLIFOGIAC_SCORTAMIN "SCORTAMIN"
|
||||
|
||||
#endif
|
197
mg/mg0400.cpp
197
mg/mg0400.cpp
@ -1,11 +1,14 @@
|
||||
#include <modaut.h>
|
||||
#include <progind.h>
|
||||
#include <relapp.h>
|
||||
#include <reputils.h>
|
||||
#include <tabutil.h>
|
||||
#include <urldefid.h>
|
||||
|
||||
#include "../ve/velib.h"
|
||||
|
||||
#include "mg0400a.h"
|
||||
#include "clifogiac.h"
|
||||
|
||||
//---------------------------------------------------
|
||||
// MASCHERA
|
||||
@ -248,10 +251,17 @@ protected:
|
||||
virtual bool user_destroy();
|
||||
virtual TMask *get_mask(int) { return _msk; }
|
||||
|
||||
TISAM_recordset recset_giacenze(const char tipocf, const long codcf, const TString& codart, const int annoes);
|
||||
|
||||
virtual int read(TMask& m);
|
||||
void fill_giacenze(const char tipocf, const long codcf, const TString& codart, const int annoes);
|
||||
|
||||
virtual bool remove();
|
||||
virtual int write(const TMask& m);
|
||||
virtual int rewrite(const TMask& m);
|
||||
int remove_giacenze(const char tipocf, const long codcf, const TString& codart, const int annoes);
|
||||
|
||||
virtual int write(const TMask& m);
|
||||
virtual int rewrite(const TMask& m);
|
||||
int write_giacenze(TSheet_field& sheet_giac, const char tipocf, const long codcf, const TString& codart, const int annoes);
|
||||
|
||||
public:
|
||||
virtual TRelation *get_relation() const { return _rel; }
|
||||
@ -259,32 +269,195 @@ public:
|
||||
virtual ~TClifo_giac() {}
|
||||
};
|
||||
|
||||
//-------------------------------------------
|
||||
// Metodo comune per riempire un recordset
|
||||
//-------------------------------------------
|
||||
TISAM_recordset TClifo_giac::recset_giacenze(const char tipocf, const long codcf, const TString& codart, const int annoes)
|
||||
{
|
||||
TISAM_recordset giacenze("USE CLIFOGIAC\nSELECT CODART=#CODART\nFROM TIPOCF=#TIPOCF CODCF=#CODCF ANNOES=#ANNOES\nTO TIPOCF=#TIPOCF CODCF=#CODCF ANNOES=#ANNOES");
|
||||
giacenze.set_var("#CODART", TVariant(codart));
|
||||
TString4 str_tipocf; str_tipocf << tipocf;
|
||||
giacenze.set_var("#TIPOCF", TVariant(str_tipocf));
|
||||
giacenze.set_var("#CODCF", codcf);
|
||||
giacenze.set_var("#ANNOES", (long)annoes);
|
||||
|
||||
return giacenze;
|
||||
}
|
||||
|
||||
//------------------
|
||||
// Metodi READ
|
||||
//------------------
|
||||
//FILL_GIACENZE: metodo x riempire lo sheet della maschera con tutti i record che soddisfano la chiave incompleta
|
||||
void TClifo_giac::fill_giacenze(const char tipocf, const long codcf, const TString& codart, const int annoes)
|
||||
{
|
||||
//e usiamo 'sti recordset che sono comodi e capibili...quasi
|
||||
TISAM_recordset giacenze = recset_giacenze(tipocf, codcf, codart, annoes);
|
||||
|
||||
TProgind pi(giacenze.items(), TR("Ricerca giacenze per indirizzo di spedizione..."), true, true);
|
||||
|
||||
TSheet_field& sheet = _msk->sfield(F_SHEETGIAC);
|
||||
TMask& sheetmask = sheet.sheet_mask();
|
||||
TRelation& rel = *giacenze.cursor()->relation(); //accesso alle righe
|
||||
|
||||
sheet.destroy();
|
||||
|
||||
if (giacenze.items() > 0)
|
||||
{
|
||||
for (bool ok = giacenze.move_first(); ok; ok = giacenze.move_next())
|
||||
{
|
||||
if (!pi.addstatus(1))
|
||||
break;
|
||||
|
||||
TToken_string& row = sheet.row(-1); //crea una nuova riga dello sheet
|
||||
|
||||
//scandisco nella maschera tutti i campi che hanno un field
|
||||
FOR_EACH_MASK_FIELD(sheetmask, i, f)
|
||||
{
|
||||
const TFieldref* fr = f->field(); //leggo il valore dalla relation
|
||||
if (fr != NULL)
|
||||
row.add(fr->read(rel),sheet.cid2index(f->dlg())); //metto il valore letto nella posizione corretta nella TToken_string
|
||||
}
|
||||
sheet.check_row(sheet.items()-1); //fa fare alla maschera la decodifica dei codici e aggiorna la TToken_string
|
||||
}
|
||||
sheet.force_update(); //forza l'update dello sheet, in modo da rendere visibili i cambiamneti fatti
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int TClifo_giac::read(TMask& m)
|
||||
{
|
||||
int err = TRelation_application::read(m);
|
||||
// int err = TRelation_application::read(m);
|
||||
// return err;
|
||||
|
||||
//recupero i dati della testata
|
||||
const char tipocf = m.get(F_TIPOCF)[0];
|
||||
const long codcf = m.get_long(F_CODCF);
|
||||
const TString80 codart = m.get(F_CODART);
|
||||
const int annoes = m.get_int(F_ANNOES);
|
||||
|
||||
fill_giacenze(tipocf, codcf, codart, annoes);
|
||||
|
||||
return NOERR;
|
||||
}
|
||||
|
||||
//------------------
|
||||
// Metodi WRITE
|
||||
//------------------
|
||||
//WRITE_GIACENZE:scrive i dati sul file 166 (CLIFOGIAC)
|
||||
int TClifo_giac::write_giacenze(TSheet_field& sheet_giac, const char tipocf, const long codcf, const TString& codart,
|
||||
const int annoes)
|
||||
{
|
||||
TISAM_recordset giacenze = recset_giacenze(tipocf, codcf, codart, annoes);
|
||||
int items = giacenze.items();
|
||||
int err = NOERR;
|
||||
|
||||
TLocalisamfile& clifogiac = giacenze.cursor()->file();
|
||||
|
||||
//Maschera di sheet
|
||||
TMask& msk = sheet_giac.sheet_mask();
|
||||
|
||||
//per ogni riga dello sheet
|
||||
FOR_EACH_SHEET_ROW(sheet_giac, r, row)
|
||||
{
|
||||
clifogiac.zero();
|
||||
//dati comuni a tutte le righe dello sheet
|
||||
clifogiac.put(CLIFOGIAC_TIPOCF, tipocf);
|
||||
clifogiac.put(CLIFOGIAC_CODCF, codcf);
|
||||
clifogiac.put(CLIFOGIAC_ANNOES, annoes);
|
||||
clifogiac.put(CLIFOGIAC_CODART, codart);
|
||||
|
||||
|
||||
//per ogno campo della maschera di sheet
|
||||
FOR_EACH_MASK_FIELD(msk, i, f)
|
||||
{
|
||||
//prendo il FIELD a cui si riferiscono
|
||||
const TFieldref*fr = f->field();
|
||||
|
||||
//se efftivamente il campo ha un field di riferimento
|
||||
if (fr != NULL)
|
||||
{
|
||||
const int pos = sheet_giac.cid2index(f->dlg()); //salvo la sua posizione all'inetrno dello sheet
|
||||
fr->write(row->get(pos), clifogiac.curr()); //scrivo il valore che sto leggendo nel record corrente del file
|
||||
}
|
||||
}
|
||||
|
||||
//o faccio la rewrite, o faccio la write
|
||||
err = clifogiac.rewrite_write();
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
bool TClifo_giac::remove()
|
||||
{
|
||||
bool ok = TRelation_application::remove();
|
||||
return ok;
|
||||
}
|
||||
|
||||
int TClifo_giac::write(const TMask& m)
|
||||
{
|
||||
int err = TRelation_application::write(m);
|
||||
return err;
|
||||
//int err = TRelation_application::write(m);
|
||||
//return err;
|
||||
|
||||
const char tipocf = m.get(F_TIPOCF)[0];
|
||||
const long codcf = m.get_long(F_CODCF);
|
||||
const TString80 codart = m.get(F_CODART);
|
||||
const int annoes = m.get_int(F_ANNOES);
|
||||
|
||||
TSheet_field& sheet_giac = m.sfield(F_SHEETGIAC);
|
||||
|
||||
return write_giacenze(sheet_giac, tipocf, codcf, codart, annoes);
|
||||
}
|
||||
|
||||
int TClifo_giac::rewrite(const TMask& m)
|
||||
{
|
||||
int err = TRelation_application::rewrite(m);
|
||||
return err;
|
||||
//int err = TRelation_application::rewrite(m);
|
||||
//return err;
|
||||
|
||||
const char tipocf = m.get(F_TIPOCF)[0];
|
||||
const long codcf = m.get_long(F_CODCF);
|
||||
const TString80 codart = m.get(F_CODART);
|
||||
const int annoes = m.get_int(F_ANNOES);
|
||||
|
||||
TSheet_field& sheet_giac = m.sfield(F_SHEETGIAC);
|
||||
|
||||
return write_giacenze(sheet_giac, tipocf, codcf, codart, annoes);
|
||||
}
|
||||
|
||||
//------------------
|
||||
// Metodi REMOVE
|
||||
//------------------
|
||||
//REMOVE_GIACENZE: elimina tutte le righe dello sheet per il clifo,l'articolo e l'anno passati
|
||||
int TClifo_giac::remove_giacenze(const char tipocf, const long codcf, const TString& codart, const int annoes)
|
||||
{
|
||||
TISAM_recordset giacenze = recset_giacenze(tipocf, codcf, codart, annoes);
|
||||
int items = giacenze.items();
|
||||
int err = NOERR;
|
||||
|
||||
//l'accoppamento delle righe va fatto proprio sul file, quindi sotto con il localisamfile..
|
||||
TLocalisamfile& clifogiac = giacenze.cursor()->file();
|
||||
|
||||
//per ogni riga del recordset
|
||||
for (bool ok = giacenze.move_first(); ok; ok = giacenze.move_next())
|
||||
{
|
||||
err = clifogiac.remove();
|
||||
}
|
||||
return err;
|
||||
}
|
||||
bool TClifo_giac::remove()
|
||||
{
|
||||
//bool ok = TRelation_application::remove();
|
||||
//return ok;
|
||||
|
||||
//recupero i dati della testata
|
||||
const char tipocf = _msk->get(F_TIPOCF)[0];
|
||||
const long codcf = _msk->get_long(F_CODCF);
|
||||
const TString80 codart = _msk->get(F_CODART);
|
||||
const int annoes = _msk->get_int(F_ANNOES);
|
||||
|
||||
//variabili per lavorare sugli sheet
|
||||
TSheet_field& sheet_giac = _msk->sfield(F_SHEETGIAC);
|
||||
|
||||
return remove_giacenze(tipocf, codcf, codart, annoes) > 0;
|
||||
}
|
||||
|
||||
//---------------------
|
||||
// Metodi GENERICI
|
||||
//---------------------
|
||||
bool TClifo_giac::user_create()
|
||||
{
|
||||
_rel = new TRelation(LF_CLIFOGIAC);
|
||||
|
@ -14,7 +14,7 @@
|
||||
#define F_LIV2 103
|
||||
#define F_LIV3 104
|
||||
#define F_LIV4 105
|
||||
#define F_CAZZO 106
|
||||
#define F_DATARIF 106
|
||||
#define F_UBICAZ 107
|
||||
#define F_LIVRIOR 108
|
||||
#define F_SCORTAMIN 109
|
||||
|
@ -95,16 +95,18 @@ BEGIN
|
||||
PROMPT 0 6 "Giacenze"
|
||||
FLAGS "A"
|
||||
USE LF_CLIFOGIAC KEY NRIGA
|
||||
INPUT TIPOCF F_TIPOCF
|
||||
INPUT CODCF F_CODCF
|
||||
INPUT ANNOES F_ANNOES
|
||||
INPUT CODART F_CODART
|
||||
ITEM "Ind.Sped."
|
||||
// la sequenza delle colonne livelliX è usata per ottenere
|
||||
// un ordinamento delle righe dello sheet: NON cambiarla
|
||||
ITEM "Ind.Sped."
|
||||
ITEM "Liv1@10"
|
||||
ITEM "Liv2@10"
|
||||
ITEM "Liv3@10"
|
||||
ITEM "Liv4@10"
|
||||
ITEM "Cazzone"
|
||||
ITEM "Data rif.@10"
|
||||
ITEM "Livello rior.@10"
|
||||
ITEM "Scorta min.@10"
|
||||
ITEM "Lotto rior.@10"
|
||||
@ -246,9 +248,10 @@ BEGIN
|
||||
CHECKTYPE NORMAL
|
||||
END
|
||||
|
||||
STRING F_CAZZO 2
|
||||
DATE F_DATARIF
|
||||
BEGIN
|
||||
PROMPT 60 60 ""
|
||||
PROMPT 46 4 "Data rif. "
|
||||
FIELD DATARIF
|
||||
END
|
||||
|
||||
// ubicazione introdotta da tabella ubicazioni
|
||||
|
Loading…
x
Reference in New Issue
Block a user