Patch level :10.0 974
Files correlati : Ricompilazione Demo : [ ] Commento : gestione attrezzature di hardy git-svn-id: svn://10.65.10.50/branches/R_10_00@21918 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
3dbbe2c27d
commit
f050c21bde
206
ha/ha3900.cpp
206
ha/ha3900.cpp
@ -3,6 +3,8 @@
|
||||
#include <defmask.h>
|
||||
#include <recarray.h>
|
||||
#include <recset.h>
|
||||
#include <relation.h>
|
||||
#include <tabmod.h>
|
||||
#include <tree.h>
|
||||
#include <treectrl.h>
|
||||
|
||||
@ -19,6 +21,8 @@ class TCoffee_tree : public TBidirectional_tree
|
||||
{
|
||||
TString8 _curr_node;
|
||||
long _codcf;
|
||||
TString8 _codart;
|
||||
TString16 _matricola;
|
||||
TISAM_recordset _recset;
|
||||
|
||||
public:
|
||||
@ -44,6 +48,9 @@ public:
|
||||
public:
|
||||
bool set_clifo(long codcf);
|
||||
bool select_attr(const TString& codart, const TString& matricola);
|
||||
const long get_codcf() const;
|
||||
const TString& get_codart() const;
|
||||
const TString& get_matricola() const;
|
||||
TCoffee_tree() : _codcf(0), _recset("USE &ATT") { set_clifo(0L); }
|
||||
};
|
||||
|
||||
@ -103,7 +110,7 @@ bool TCoffee_tree::goto_node(const TString &id)
|
||||
|
||||
bool TCoffee_tree::get_description(TString& desc) const
|
||||
{
|
||||
desc = _recset.get("S0").as_string();
|
||||
desc = _recset.get("CODTAB").as_string();
|
||||
return desc.full();
|
||||
}
|
||||
|
||||
@ -120,16 +127,29 @@ TFieldtypes TCoffee_tree::get_var(const TString& name, TVariant& var) const
|
||||
else
|
||||
var = _recset.get(name);
|
||||
|
||||
return _alfafld;
|
||||
return var.type();
|
||||
}
|
||||
|
||||
const TString& TCoffee_tree::get_codart() const
|
||||
{
|
||||
return _codart;
|
||||
}
|
||||
|
||||
const TString& TCoffee_tree::get_matricola() const
|
||||
{
|
||||
return _matricola;
|
||||
}
|
||||
|
||||
const long TCoffee_tree::get_codcf() const
|
||||
{
|
||||
return _codcf;
|
||||
}
|
||||
|
||||
bool TCoffee_tree::set_clifo(long codcf)
|
||||
{
|
||||
_codcf = codcf;
|
||||
TString query;
|
||||
query << "USE &ATT";
|
||||
if (codcf > 0L)
|
||||
query << "\nSELECT I0=" << codcf;
|
||||
query << "USE &ATT\nSELECT I0=" << codcf;
|
||||
_recset.set(query);
|
||||
return goto_root();
|
||||
}
|
||||
@ -143,12 +163,14 @@ bool TCoffee_tree::select_attr(const TString& codart, const TString& matricola)
|
||||
curr_codart.trim();
|
||||
if (curr_codart == codart)
|
||||
{
|
||||
_codart = codart;
|
||||
TString16 curr_matricola = _recset.get("CODTAB[16,30]").as_string();
|
||||
curr_matricola.trim();
|
||||
if (curr_matricola == matricola)
|
||||
{
|
||||
_curr_node.format("%ld", _recset.current_row());
|
||||
found = true;
|
||||
_matricola = matricola;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -161,12 +183,12 @@ bool TCoffee_tree::select_attr(const TString& codart, const TString& matricola)
|
||||
//////////////////////////////////////////////
|
||||
class TGestione_attrezzature_mask : public TAutomask
|
||||
{
|
||||
int _pos_tipo, _pos_data, _pos_note, _pos_codart, _pos_um, _pos_qta, _pos_importo,
|
||||
_pos_bo_anno, _pos_bo_codnum, _pos_bo_ndoc, _pos_bc_anno, _pos_bc_codnum, _pos_bc_ndoc,
|
||||
_pos_clifo, _pos_mag;
|
||||
bool _sheet_dirty;
|
||||
|
||||
protected:
|
||||
void fill_sheet_storico(const TString& codattr);
|
||||
bool write();
|
||||
void save_if_dirty();
|
||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||
|
||||
public:
|
||||
@ -191,12 +213,28 @@ void TGestione_attrezzature_mask::fill_sheet_storico(const TString& codattr)
|
||||
TSheet_field& sf_righe = sfield(F_STORICO);
|
||||
sf_righe.destroy();
|
||||
|
||||
//maschera di sheet
|
||||
TMask& msk = sf_righe.sheet_mask();
|
||||
//record del recordset con i valori da mettere sulla riga sheet
|
||||
const TRectype& rec = recset.cursor()->curr();
|
||||
|
||||
//new style (seza _pos_campo!)
|
||||
for (bool ok = recset.move_first(); ok; ok = recset.move_next())
|
||||
{
|
||||
TToken_string& row = sf_righe.row(-1); //riga sheet da riempire
|
||||
row.add(""); //nuova riga
|
||||
/*const TString& row_nr = recset.get("CODTAB[31,35]").as_string();
|
||||
row.add(row_codattr, _pos_nr);*/
|
||||
|
||||
//per ogni campo della maschera di sheet setta..
|
||||
//..il valore di quei campi che hanno un field
|
||||
FOR_EACH_MASK_FIELD(msk, i, f)
|
||||
{
|
||||
const short id = f->dlg();
|
||||
if (id >= 101 && id < 200)
|
||||
{
|
||||
const TFieldref* fr = f->field();
|
||||
if (fr != NULL)
|
||||
row.add(fr->read(rec), id - 101);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//mostra e aggiorna lo sheet
|
||||
@ -205,6 +243,86 @@ void TGestione_attrezzature_mask::fill_sheet_storico(const TString& codattr)
|
||||
|
||||
}
|
||||
|
||||
|
||||
//metodo di salvataggio dei record dello sheet
|
||||
bool TGestione_attrezzature_mask::write()
|
||||
{
|
||||
TTreelist_field& tf = (TTreelist_field&)field(F_ATTREZZATURE);
|
||||
TCoffee_tree* ct = (TCoffee_tree*)tf.tree();
|
||||
if (ct == NULL)
|
||||
return false;
|
||||
|
||||
const TString& codart = ct->get_codart();
|
||||
const TString& matricola = ct->get_matricola();
|
||||
|
||||
TSheet_field& sf_righe = sfield(F_STORICO);
|
||||
//maschera di riga dello sheet
|
||||
TMask& sm = sf_righe.sheet_mask();
|
||||
//tabella di modulo con lo storico interventi
|
||||
TModule_table his("&HIS");
|
||||
TRectype& rec_his = his.curr();
|
||||
//codice articolo + matricola (prima parte del CODTAB del record di tabmod)
|
||||
TString80 codtab;
|
||||
codtab.format("%-15s%-15s", (const char*)codart, (const char*)matricola);
|
||||
|
||||
//contatore delle righe che vengono salvate
|
||||
int righe_tot = 0;
|
||||
|
||||
//giro su tutte le righe dello sheet
|
||||
FOR_EACH_SHEET_ROW(sf_righe, r, riga)
|
||||
{
|
||||
short id = 101;
|
||||
//giro su tutti i campi della riga (che è una sporca token_string)
|
||||
//per prima cosa mette la chiave del record che è così fatta:
|
||||
// codart=codtab[1,5] - matricola=codtab[16,30] - nriga=codtab[31,35]
|
||||
TString80 curr_codtab;
|
||||
curr_codtab.format("%05d", r + 1);
|
||||
curr_codtab.insert(codtab);
|
||||
//azzera il record senno' nei campi vuoti ci metterebbe quelli del record precedente
|
||||
//deve azzerare la tabella, senno' perde il codice modulo HA ed il codice tabella HIS
|
||||
his.zero();
|
||||
rec_his.put("CODTAB", curr_codtab);
|
||||
FOR_EACH_TOKEN(*riga, str)
|
||||
{
|
||||
const TMask_field& mf = sm.field(id);
|
||||
const TFieldref* fr = mf.field();
|
||||
//solo i campi della maschera di riga che hanno un FIELD vengono salvati, gli altri si arrangino!
|
||||
if (fr != NULL)
|
||||
{
|
||||
fr->write(str, rec_his);
|
||||
}
|
||||
id ++;
|
||||
}
|
||||
his.rewrite_write();
|
||||
righe_tot ++;
|
||||
}
|
||||
|
||||
//compatta le righe dello storico, eliminando quelle in esubero
|
||||
TString query;
|
||||
query << "USE &HIS";
|
||||
query << "\nFROM CODTAB=#DACODTAB";
|
||||
TISAM_recordset recset(query);
|
||||
TString80 dacodtab;
|
||||
dacodtab.format("%05d", righe_tot + 1);
|
||||
dacodtab.insert(codtab);
|
||||
recset.set_var("#DACODTAB", dacodtab);
|
||||
//accoppa tutte le righe in esubero dalla tabella &HIS
|
||||
for (bool ok = recset.move_first(); ok; ok = recset.move_next())
|
||||
recset.cursor()->relation()->remove();
|
||||
|
||||
//una volta che ha salvato lo sheet deve risultare immacolato!
|
||||
_sheet_dirty = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void TGestione_attrezzature_mask::save_if_dirty()
|
||||
{
|
||||
if (_sheet_dirty && yesno_box(TR("Salvare le modifiche ?")))
|
||||
write();
|
||||
}
|
||||
|
||||
bool TGestione_attrezzature_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
{
|
||||
switch (o.dlg())
|
||||
@ -232,10 +350,14 @@ bool TGestione_attrezzature_mask::on_field_event(TOperable_field& o, TField_even
|
||||
TCoffee_tree* ct = (TCoffee_tree*)tf.tree();
|
||||
if (ct != NULL)
|
||||
{
|
||||
ct->set_clifo(get_long(F_CODCF));
|
||||
const TString& codart = get(F_COD_ART);
|
||||
const TString& matricola = get(F_COD_MATR);
|
||||
if (ct->select_attr(codart, matricola))
|
||||
{
|
||||
tf.select_current();
|
||||
send_key(K_SPACE, F_ATTREZZATURE, &o);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -248,15 +370,53 @@ bool TGestione_attrezzature_mask::on_field_event(TOperable_field& o, TField_even
|
||||
{
|
||||
TString80 codattr;
|
||||
ct->get_description(codattr);
|
||||
//riempie i campi di intestazione maschera
|
||||
set(F_COD_ART, codattr.left(5));
|
||||
set(F_COD_MATR, codattr.mid(15,15));
|
||||
//chiede di salvare le modifiche al cambio attrezzatura
|
||||
save_if_dirty();
|
||||
//riempie lo sheet
|
||||
fill_sheet_storico(codattr);
|
||||
//riempie anche i campi codart e matricola?
|
||||
}
|
||||
}
|
||||
break;
|
||||
case F_STORICO:
|
||||
if (e == se_query_modify || e == se_notify_del)
|
||||
{
|
||||
_sheet_dirty = true;
|
||||
}
|
||||
break;
|
||||
//bottoni
|
||||
case DLG_SAVEREC:
|
||||
if (e == fe_button && check_fields())
|
||||
{
|
||||
write();
|
||||
}
|
||||
break;
|
||||
case DLG_CANCEL:
|
||||
if (e == fe_button && jolly == 0) //il jolly=0 significa che si riferisce alla maschera principale!..
|
||||
{ //..se non ci fosse azzererebbe tutto anche quando si fa annulla sulla maschera di riga!
|
||||
|
||||
//nel caso l'utonto clicchi su ANNULLA dopo aver fatto modifiche sara' meglio chiedere conferma se le vuole mantenere
|
||||
save_if_dirty();
|
||||
|
||||
//azzera i campi della maschera
|
||||
reset();
|
||||
TTreelist_field& tf = (TTreelist_field&)field(F_ATTREZZATURE);
|
||||
TCoffee_tree* ct = (TCoffee_tree*)tf.tree();
|
||||
if (ct != NULL)
|
||||
{
|
||||
ct->set_clifo(0L);
|
||||
tf.win().force_update();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case DLG_QUIT:
|
||||
if (e == fe_button)
|
||||
{
|
||||
//nel caso l'utonto clicchi su FINE dopo aver fatto modifiche sara' meglio chiedere conferma se le vuole mantenere
|
||||
save_if_dirty();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -273,26 +433,8 @@ TGestione_attrezzature_mask::TGestione_attrezzature_mask() : TAutomask("ha3900a"
|
||||
TCoffee_tree* ct = new TCoffee_tree;
|
||||
tf.set_tree(ct);
|
||||
|
||||
//assegna una volta per tutte le pos delle colonne di sheet
|
||||
TSheet_field& sf_righe = sfield(F_STORICO);
|
||||
_pos_tipo = sf_righe.cid2index(S_TIPO);
|
||||
_pos_data = sf_righe.cid2index(S_DATA);
|
||||
_pos_note = sf_righe.cid2index(S_NOTE);
|
||||
_pos_codart = sf_righe.cid2index(S_CODART);
|
||||
_pos_um = sf_righe.cid2index(S_UM_GENERICO);
|
||||
_pos_qta = sf_righe.cid2index(S_QTA);
|
||||
_pos_importo = sf_righe.cid2index(S_IMPORTO);
|
||||
//campi 'B'olla 'O'pen (di apertura per gli italici)
|
||||
_pos_bo_anno = sf_righe.cid2index(S_BOL_OPEN_ANNO);
|
||||
_pos_bo_codnum = sf_righe.cid2index(S_BOL_OPEN_CODNUM);
|
||||
_pos_bo_ndoc = sf_righe.cid2index(S_BOL_OPEN_NDOC);
|
||||
//'B'olla 'C'lose
|
||||
_pos_bc_anno = sf_righe.cid2index(S_BOL_CLOSE_ANNO);
|
||||
_pos_bc_codnum = sf_righe.cid2index(S_BOL_CLOSE_CODNUM);
|
||||
_pos_bc_ndoc = sf_righe.cid2index(S_BOL_CLOSE_NDOC);
|
||||
|
||||
_pos_clifo = sf_righe.cid2index(S_CODCF);
|
||||
_pos_mag = sf_righe.cid2index(S_CODMAG);
|
||||
//inizializza lo "sporcatore" dello sheet
|
||||
_sheet_dirty = false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////
|
||||
|
15
ha/ha3900a.h
15
ha/ha3900a.h
@ -1,13 +1,13 @@
|
||||
#define F_CODCF 201
|
||||
#define F_DESCF 202
|
||||
#define F_COD_ART 203
|
||||
#define F_DESCR_ART 204
|
||||
#define F_COD_MATR 205
|
||||
#define F_CODCF 301
|
||||
#define F_DESCF 302
|
||||
#define F_COD_ART 303
|
||||
#define F_DESCR_ART 304
|
||||
#define F_COD_MATR 305
|
||||
|
||||
//tree
|
||||
#define F_ATTREZZATURE 300
|
||||
#define F_ATTREZZATURE 350
|
||||
//sheet
|
||||
#define F_STORICO 301
|
||||
#define F_STORICO 351
|
||||
|
||||
//sheet storico
|
||||
#define S_TIPO 101
|
||||
@ -17,7 +17,6 @@
|
||||
#define S_UM_GENERICO 105
|
||||
#define S_UM_CODART 205
|
||||
#define S_QTA 106
|
||||
//#define S_PREZZO 107
|
||||
#define S_IMPORTO 107
|
||||
|
||||
#define S_BOL_OPEN_ANNO 108
|
||||
|
@ -59,7 +59,7 @@ BEGIN
|
||||
DISPLAY "Descrizione@50" DESCR
|
||||
OUPUT F_COD_ART CODART
|
||||
OUPUT F_DESCR_ART DESCR
|
||||
CHECKTYPE NORMAL
|
||||
CHECKTYPE REQUIRED
|
||||
ADD RUN ve2 -3
|
||||
END
|
||||
|
||||
@ -79,16 +79,17 @@ BEGIN
|
||||
PROMPT 1 3 "Matricola "
|
||||
FLAGS "U"
|
||||
USE &ATT
|
||||
JOIN LF_ANAMAG INTO CODART=CODTAB[1,5]
|
||||
INPUT CODTAB[1,5] F_COD_ART
|
||||
INPUT CODTAB[16,30] F_COD_MATR
|
||||
DISPLAY "Codice@5" CODTAB[1,5]
|
||||
DISPLAY "Matricola@15" CODTAB[16,30]
|
||||
DISPLAY "Descrizione@50" S0
|
||||
DISPLAY "Descrizione@50" LF_ANAMAG->DESCR
|
||||
DISPLAY "Cliente" I0
|
||||
OUTPUT F_COD_ART CODTAB[1,5]
|
||||
OUTPUT F_COD_MATR CODTAB[16,30]
|
||||
OUTPUT F_CODCF I0
|
||||
CHECKTYPE NORMAL
|
||||
CHECKTYPE REQUIRED
|
||||
END
|
||||
|
||||
TEXT DLG_NULL
|
||||
@ -119,7 +120,6 @@ BEGIN
|
||||
ITEM "Articolo"
|
||||
ITEM "UM"
|
||||
ITEM "Quantita"
|
||||
//ITEM "Prezzo@10"
|
||||
ITEM "Importo@10"
|
||||
ITEM "Ap.Anno"
|
||||
ITEM "Ap.Codnum"
|
||||
@ -141,13 +141,14 @@ ENDMASK
|
||||
|
||||
PAGE "Dati intervento" -1 -1 78 15
|
||||
|
||||
LISTBOX S_TIPO 1 35
|
||||
LISTBOX S_TIPO 1 16
|
||||
BEGIN
|
||||
PROMPT 1 1 "Tipo intervento"
|
||||
ITEM "C|Comodato" MESSAGE DISABLE,1@
|
||||
ITEM "R|Riparazione" MESSAGE DISABLE,1@
|
||||
ITEM "S|Sostituzione" MESSAGE DISABLE,1@
|
||||
ITEM "A|Accessori" MESSAGE ENABLE,1@
|
||||
ITEM "C|Comodato d'uso" MESSAGE DISABLE,1@
|
||||
ITEM "D|Descrittivo" MESSAGE DISABLE,1@
|
||||
ITEM "I|Insegne nuove" MESSAGE DISABLE,1@
|
||||
ITEM "R|Riparazione" MESSAGE DISABLE,1@
|
||||
ITEM "V|Varie" MESSAGE ENABLE,1@
|
||||
FIELD S7
|
||||
END
|
||||
|
||||
@ -203,7 +204,7 @@ END
|
||||
STRING S_UM_CODART 2
|
||||
BEGIN
|
||||
PROMPT 1 3 "U.M. "
|
||||
USE LF_UMART KEY 2 SELECT CODART==#S_CODART
|
||||
USE LF_UMART KEY 2 SELECT CODART=#S_CODART
|
||||
INPUT CODART S_CODART SELECT
|
||||
INPUT UM S_UM_CODART
|
||||
DISPLAY "U.M." UM
|
||||
@ -220,11 +221,6 @@ BEGIN
|
||||
FIELD R0
|
||||
END
|
||||
|
||||
/*CURRENCY S_PREZZO 10
|
||||
BEGIN
|
||||
PROMPT 32 3 "Prezzo "
|
||||
END*/
|
||||
|
||||
CURRENCY S_IMPORTO 12
|
||||
BEGIN
|
||||
PROMPT 32 3 "Importo "
|
||||
@ -314,7 +310,8 @@ END
|
||||
NUMBER S_CODCF 6
|
||||
BEGIN
|
||||
PROMPT 1 10 "Cliente "
|
||||
USE LF_CLIFO SELECT TIPOCF="C"
|
||||
USE LF_CLIFO
|
||||
INPUT TIPOCF "C"
|
||||
INPUT CODCF S_CODCF
|
||||
DISPLAY "Codice" CODCF
|
||||
DISPLAY "Ragione sociale@50" RAGSOC
|
||||
@ -327,7 +324,8 @@ END
|
||||
STRING S_DESCF 50
|
||||
BEGIN
|
||||
PROMPT 20 10 ""
|
||||
USE LF_CLIFO KEY 2 SELECT TIPOCF="C"
|
||||
USE LF_CLIFO KEY 2
|
||||
INPUT TIPOCF "C"
|
||||
INPUT RAGSOC S_DESCF
|
||||
DISPLAY "Ragione sociale@50" RAGSOC
|
||||
DISPLAY "Codice" CODCF
|
||||
|
Loading…
x
Reference in New Issue
Block a user