2011-04-06 13:30:49 +00:00
|
|
|
|
#include <applicat.h>
|
|
|
|
|
#include <automask.h>
|
|
|
|
|
#include <defmask.h>
|
|
|
|
|
#include <recarray.h>
|
|
|
|
|
#include <recset.h>
|
|
|
|
|
#include <tree.h>
|
|
|
|
|
#include <treectrl.h>
|
|
|
|
|
|
|
|
|
|
#include "../mg/anamag.h"
|
|
|
|
|
|
|
|
|
|
#include "ha3.h"
|
|
|
|
|
#include "ha3900a.h"
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////
|
|
|
|
|
// Albero
|
|
|
|
|
//////////////////////////////////////////////
|
|
|
|
|
//Albero per la gestione delle macchine di un cliente
|
|
|
|
|
class TCoffee_tree : public TBidirectional_tree
|
|
|
|
|
{
|
|
|
|
|
TString8 _curr_node;
|
|
|
|
|
long _codcf;
|
|
|
|
|
TISAM_recordset _recset;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual bool goto_root();
|
|
|
|
|
virtual bool goto_firstson() { return false; }
|
|
|
|
|
virtual bool goto_rbrother();
|
|
|
|
|
virtual bool goto_node(const TString &id);
|
|
|
|
|
virtual bool could_have_son() const { return false; }
|
|
|
|
|
virtual bool has_son() const { return false; }
|
|
|
|
|
virtual bool has_rbrother() const;
|
|
|
|
|
virtual TObject* curr_node() const { return (TObject*)&_curr_node; }
|
|
|
|
|
virtual void node2id(const TObject* obj, TString& id) const { id = *(TString*)obj; }
|
|
|
|
|
|
|
|
|
|
virtual bool has_root() const;
|
|
|
|
|
virtual bool has_father() const { return false; }
|
|
|
|
|
virtual bool has_lbrother() const;
|
|
|
|
|
virtual bool goto_father() { return false; }
|
|
|
|
|
virtual bool goto_lbrother();
|
|
|
|
|
virtual bool get_description(TString& desc) const;
|
|
|
|
|
virtual TFieldtypes get_var(const TString& name, TVariant& var) const;
|
|
|
|
|
virtual TImage* image(bool selected) const { return get_res_icon(10232); }
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
bool set_clifo(long codcf);
|
|
|
|
|
bool select_attr(const TString& codart, const TString& matricola);
|
|
|
|
|
TCoffee_tree() : _codcf(0), _recset("USE &ATT") { set_clifo(0L); }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool TCoffee_tree::has_root() const
|
|
|
|
|
{
|
|
|
|
|
return _recset.items() > 0L;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TCoffee_tree::goto_root()
|
|
|
|
|
{
|
|
|
|
|
const bool ok = _recset.move_first();
|
|
|
|
|
if (ok)
|
|
|
|
|
_curr_node = "0";
|
|
|
|
|
else
|
|
|
|
|
_curr_node.cut(0);
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TCoffee_tree::has_rbrother() const
|
|
|
|
|
{
|
|
|
|
|
const long pos = atol(_curr_node);
|
|
|
|
|
return pos < _recset.items() - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TCoffee_tree::goto_rbrother()
|
|
|
|
|
{
|
|
|
|
|
const long pos = atol(_curr_node) + 1;
|
|
|
|
|
const bool ok = _recset.move_to(pos);
|
|
|
|
|
if (ok)
|
|
|
|
|
_curr_node.format("%ld", pos);
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TCoffee_tree::has_lbrother() const
|
|
|
|
|
{
|
|
|
|
|
return atol(_curr_node) > 0L;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TCoffee_tree::goto_lbrother()
|
|
|
|
|
{
|
|
|
|
|
const long pos = atol(_curr_node) - 1;
|
|
|
|
|
const bool ok = pos >= 0 && _recset.move_to(pos);
|
|
|
|
|
if (ok)
|
|
|
|
|
_curr_node.format("%ld", pos);
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TCoffee_tree::goto_node(const TString &id)
|
|
|
|
|
{
|
|
|
|
|
const long pos = atol(id);
|
|
|
|
|
const bool ok = _recset.move_to(pos);
|
|
|
|
|
if (ok)
|
|
|
|
|
_curr_node = id;
|
|
|
|
|
return ok;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TCoffee_tree::get_description(TString& desc) const
|
|
|
|
|
{
|
|
|
|
|
desc = _recset.get("S0").as_string();
|
|
|
|
|
return desc.full();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TFieldtypes TCoffee_tree::get_var(const TString& name, TVariant& var) const
|
|
|
|
|
{
|
|
|
|
|
//se il campo richiesto <20> la descrizione ci vuole quella dell'articolo, non dell'attrezzatura..
|
|
|
|
|
//..che risulta vuota
|
|
|
|
|
if (name == "S0")
|
|
|
|
|
{
|
|
|
|
|
TString8 codart = _recset.get("CODTAB[1,5]").as_string();
|
|
|
|
|
codart.trim();
|
|
|
|
|
var = cache().get(LF_ANAMAG, codart, ANAMAG_DESCR);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
var = _recset.get(name);
|
|
|
|
|
|
|
|
|
|
return _alfafld;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TCoffee_tree::set_clifo(long codcf)
|
|
|
|
|
{
|
|
|
|
|
_codcf = codcf;
|
|
|
|
|
TString query;
|
|
|
|
|
query << "USE &ATT";
|
|
|
|
|
if (codcf > 0L)
|
|
|
|
|
query << "\nSELECT I0=" << codcf;
|
|
|
|
|
_recset.set(query);
|
|
|
|
|
return goto_root();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TCoffee_tree::select_attr(const TString& codart, const TString& matricola)
|
|
|
|
|
{
|
|
|
|
|
bool found = false;
|
|
|
|
|
for (bool ok = _recset.move_first(); ok; ok = _recset.move_next())
|
|
|
|
|
{
|
|
|
|
|
TString8 curr_codart = _recset.get("CODTAB[1,5]").as_string();
|
|
|
|
|
curr_codart.trim();
|
|
|
|
|
if (curr_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;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return found;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////
|
|
|
|
|
// Maschera
|
|
|
|
|
//////////////////////////////////////////////
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void fill_sheet_storico(const TString& codattr);
|
|
|
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
TGestione_attrezzature_mask();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//metodo che riempie il primo sheet delle attrezzature in base ai filtri su cliente/attrezztura
|
|
|
|
|
void TGestione_attrezzature_mask::fill_sheet_storico(const TString& codattr)
|
|
|
|
|
{
|
|
|
|
|
//riempie lo sheet dello storico in base all'attrezzatura scelta nell'albero
|
|
|
|
|
TString query;
|
|
|
|
|
query << "USE &HIS";
|
|
|
|
|
query << "\nFROM CODTAB=#CODATTR";
|
|
|
|
|
query << "\nTO CODTAB=#CODATTR";
|
|
|
|
|
|
|
|
|
|
TISAM_recordset recset(query);
|
|
|
|
|
recset.set_var("#CODATTR", codattr);
|
|
|
|
|
|
|
|
|
|
const long recset_items = recset.items();
|
|
|
|
|
|
|
|
|
|
TSheet_field& sf_righe = sfield(F_STORICO);
|
|
|
|
|
sf_righe.destroy();
|
|
|
|
|
|
|
|
|
|
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
|
2011-04-06 13:32:29 +00:00
|
|
|
|
/*const TString& row_nr = recset.get("CODTAB[31,35]").as_string();
|
|
|
|
|
row.add(row_codattr, _pos_nr);*/
|
2011-04-06 13:30:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//mostra e aggiorna lo sheet
|
|
|
|
|
sf_righe.show();
|
|
|
|
|
sf_righe.force_update();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TGestione_attrezzature_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
|
|
|
{
|
|
|
|
|
switch (o.dlg())
|
|
|
|
|
{
|
|
|
|
|
//campi
|
|
|
|
|
case F_CODCF:
|
|
|
|
|
if (e == fe_modify)
|
|
|
|
|
{
|
|
|
|
|
//albero magico: selezionando un cliente riempie l'albero con tutte le attrezzature del cliente
|
|
|
|
|
TTreelist_field& tf = (TTreelist_field&)field(F_ATTREZZATURE);
|
|
|
|
|
TCoffee_tree* ct = (TCoffee_tree*)tf.tree();
|
|
|
|
|
if (ct != NULL)
|
|
|
|
|
{
|
|
|
|
|
ct->set_clifo(atol(o.get()));
|
|
|
|
|
tf.win().force_update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case F_COD_MATR:
|
|
|
|
|
if (e == fe_modify)
|
|
|
|
|
{
|
|
|
|
|
//albero magico: selezionando un'attrezzatura, si posiziona direttamente sulla giusta posizione nell'albero..
|
|
|
|
|
//..(il cliente viene riempito dalla maschera)
|
|
|
|
|
TTreelist_field& tf = (TTreelist_field&)field(F_ATTREZZATURE);
|
|
|
|
|
TCoffee_tree* ct = (TCoffee_tree*)tf.tree();
|
|
|
|
|
if (ct != NULL)
|
|
|
|
|
{
|
|
|
|
|
const TString& codart = get(F_COD_ART);
|
|
|
|
|
const TString& matricola = get(F_COD_MATR);
|
|
|
|
|
if (ct->select_attr(codart, matricola))
|
|
|
|
|
tf.select_current();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case F_ATTREZZATURE:
|
|
|
|
|
if (e == fe_modify)
|
|
|
|
|
{
|
|
|
|
|
TTreelist_field& tf = (TTreelist_field&)field(F_ATTREZZATURE);
|
|
|
|
|
TCoffee_tree* ct = (TCoffee_tree*)tf.tree();
|
|
|
|
|
if (ct != NULL)
|
|
|
|
|
{
|
|
|
|
|
TString80 codattr;
|
|
|
|
|
ct->get_description(codattr);
|
|
|
|
|
fill_sheet_storico(codattr);
|
|
|
|
|
//riempie anche i campi codart e matricola?
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
//bottoni
|
|
|
|
|
case DLG_SAVEREC:
|
|
|
|
|
if (e == fe_button)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TGestione_attrezzature_mask::TGestione_attrezzature_mask() : TAutomask("ha3900a")
|
|
|
|
|
{
|
|
|
|
|
//assegna l'albero del caffe' al campo di tipo albero sulla maschera
|
|
|
|
|
TTreelist_field& tf = (TTreelist_field&)field(F_ATTREZZATURE);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////
|
|
|
|
|
// Applicazione
|
|
|
|
|
//////////////////////////////////////////////
|
|
|
|
|
class TGestione_attrezzature : public TSkeleton_application
|
|
|
|
|
{
|
|
|
|
|
virtual void main_loop();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TGestione_attrezzature::main_loop()
|
|
|
|
|
{
|
|
|
|
|
TGestione_attrezzature_mask mask;
|
|
|
|
|
while (mask.run() == K_ENTER)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ha3900(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
TGestione_attrezzature app;
|
|
|
|
|
app.run(argc, argv, TR("Gestione attrezzature"));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|