2011-01-27 15:16:23 +00:00
|
|
|
|
// gestione tabelle di modulo hardy
|
|
|
|
|
|
|
|
|
|
#include <automask.h>
|
|
|
|
|
#include <modtbapp.h>
|
2011-04-06 13:32:29 +00:00
|
|
|
|
#include <recset.h>
|
2011-01-27 15:16:23 +00:00
|
|
|
|
#include <tabutil.h>
|
|
|
|
|
|
2011-04-18 10:10:12 +00:00
|
|
|
|
#include "halib.h"
|
|
|
|
|
|
2011-04-15 13:49:27 +00:00
|
|
|
|
#include "hatbatt.h"
|
2011-01-27 15:16:23 +00:00
|
|
|
|
#include "hatbcau.h"
|
2011-03-01 09:48:27 +00:00
|
|
|
|
#include "hatbcel.h"
|
2011-01-27 15:16:23 +00:00
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Maschera generica di gestione tabelle hardy
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class THA_table_mask : public TAutomask
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual bool on_field_event(TOperable_field &o, TField_event e, long jolly);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
THA_table_mask(const char* name) : TAutomask(name) {}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool THA_table_mask::on_field_event(TOperable_field &o, TField_event e, long jolly)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Applicazione generica di gestione tabelle hardy
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
// applicazione per la gestione delle tabelle di lavanderia
|
|
|
|
|
class THA_table_app : public TTable_module_application
|
|
|
|
|
{
|
2012-11-06 10:55:40 +00:00
|
|
|
|
bool _trans_done;
|
|
|
|
|
|
2012-07-02 13:04:46 +00:00
|
|
|
|
private:
|
|
|
|
|
int update_gcg(const TRectype& att);
|
|
|
|
|
|
2011-01-27 15:16:23 +00:00
|
|
|
|
protected: // TRelation_application
|
2011-04-06 13:32:29 +00:00
|
|
|
|
virtual bool protected_record(TRectype& record);
|
2011-03-01 09:48:27 +00:00
|
|
|
|
virtual void init_query_mode(TMask& m);
|
|
|
|
|
virtual void init_query_insert_mode(TMask& m);
|
2011-04-27 14:28:42 +00:00
|
|
|
|
virtual void init_insert_mode(TMask& m);
|
|
|
|
|
virtual void init_modify_mode(TMask& m);
|
2011-04-15 13:49:27 +00:00
|
|
|
|
|
2012-07-02 13:04:46 +00:00
|
|
|
|
virtual int write(const TMask& m);
|
|
|
|
|
virtual int rewrite(const TMask& m);
|
|
|
|
|
|
2011-04-15 13:49:27 +00:00
|
|
|
|
virtual bool get_next_key(TToken_string& key);
|
2012-11-06 10:55:40 +00:00
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
THA_table_app() : _trans_done(false) {}
|
2011-01-27 15:16:23 +00:00
|
|
|
|
};
|
|
|
|
|
|
2011-04-06 13:32:29 +00:00
|
|
|
|
|
2011-04-15 13:49:27 +00:00
|
|
|
|
bool THA_table_app::get_next_key(TToken_string& key)
|
|
|
|
|
{
|
|
|
|
|
//casino per la tabella attrezzature "&ATT"
|
2012-07-02 13:04:46 +00:00
|
|
|
|
const TFixed_string name = get_relation()->file(0).name();
|
2011-04-15 13:49:27 +00:00
|
|
|
|
if (name == "ATT")
|
|
|
|
|
{
|
|
|
|
|
const TString& codart = curr_mask().get(F_CODART);
|
|
|
|
|
if (codart.full())
|
|
|
|
|
{
|
2011-06-07 10:04:39 +00:00
|
|
|
|
const TString& codtab = hd_get_next_att_key(codart);
|
2011-04-15 13:49:27 +00:00
|
|
|
|
|
|
|
|
|
//riempie la token_string con i dati richiesti
|
|
|
|
|
key.add(F_CODART);
|
|
|
|
|
key.add(codart);
|
|
|
|
|
key.add(F_PROGRESSIVO);
|
2011-04-18 10:10:12 +00:00
|
|
|
|
key.add(codtab.mid(5));
|
2012-07-02 13:04:46 +00:00
|
|
|
|
return true;
|
2011-04-15 13:49:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TTable_module_application::get_next_key(key);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-06 13:32:29 +00:00
|
|
|
|
bool THA_table_app::protected_record(TRectype& record)
|
|
|
|
|
{
|
2012-07-02 13:04:46 +00:00
|
|
|
|
const TFixed_string name = get_relation()->file(0).name();
|
2011-04-06 13:32:29 +00:00
|
|
|
|
|
|
|
|
|
//tabella delle attrezzature
|
|
|
|
|
//non si pu<70> eliminare una attrezzatura se la medesima ha una storia! rispettiamo gli anziani!
|
|
|
|
|
if (name == "ATT")
|
|
|
|
|
{
|
2011-09-12 11:09:22 +00:00
|
|
|
|
const TString80 codattr = record.get("CODTAB");
|
|
|
|
|
|
2011-04-06 13:32:29 +00:00
|
|
|
|
//controlla che l'attrezzatura non abbia record nella tabella della storia attrezzature
|
|
|
|
|
TString query;
|
2011-04-13 14:05:12 +00:00
|
|
|
|
query << "USE &HIS";
|
2011-04-06 13:32:29 +00:00
|
|
|
|
query << "\nFROM CODTAB=#CODATTR";
|
|
|
|
|
query << "\nTO CODTAB=#CODATTR";
|
|
|
|
|
|
|
|
|
|
TISAM_recordset attr_recset(query);
|
|
|
|
|
attr_recset.set_var("#CODATTR", codattr);
|
|
|
|
|
|
|
|
|
|
const long items = attr_recset.items();
|
|
|
|
|
return items > 0;
|
|
|
|
|
}
|
2012-11-06 10:55:40 +00:00
|
|
|
|
|
|
|
|
|
return false;
|
2011-04-06 13:32:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-04-27 14:28:42 +00:00
|
|
|
|
void THA_table_app::init_insert_mode(TMask& m)
|
|
|
|
|
{
|
2012-07-02 13:04:46 +00:00
|
|
|
|
const TFixed_string name = get_relation()->file(0).name();
|
2011-04-27 14:28:42 +00:00
|
|
|
|
if (name == "ATT")
|
|
|
|
|
{
|
|
|
|
|
m.hide(-2);
|
|
|
|
|
m.show(-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void THA_table_app::init_modify_mode(TMask& m)
|
|
|
|
|
{
|
2012-07-02 13:04:46 +00:00
|
|
|
|
const TFixed_string name = get_relation()->file(0).name();
|
2011-04-27 14:28:42 +00:00
|
|
|
|
if (name == "ATT")
|
|
|
|
|
{
|
|
|
|
|
m.hide(-2);
|
|
|
|
|
m.show(-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-01 09:48:27 +00:00
|
|
|
|
void THA_table_app::init_query_mode(TMask& m)
|
2011-01-27 15:16:23 +00:00
|
|
|
|
{
|
2012-07-02 13:04:46 +00:00
|
|
|
|
const TFixed_string name = get_relation()->file(0).name();
|
2011-03-01 09:48:27 +00:00
|
|
|
|
if (name == "CEL")
|
|
|
|
|
{
|
|
|
|
|
m.hide(F_CODCLI1);
|
|
|
|
|
m.show(F_CODCLI);
|
2012-11-06 10:55:40 +00:00
|
|
|
|
} else
|
2011-04-27 14:28:42 +00:00
|
|
|
|
if (name == "ATT") //inizialmente vedo il gruppo 2 di SEARCH e non quello 1 di NEW
|
|
|
|
|
{
|
|
|
|
|
m.hide(-1);
|
|
|
|
|
m.show(-2);
|
|
|
|
|
}
|
2012-11-06 10:55:40 +00:00
|
|
|
|
|
|
|
|
|
if (!_trans_done && argc() > 3)
|
|
|
|
|
{
|
|
|
|
|
_trans_done = true;
|
|
|
|
|
const TFixed_string a = argv(3);
|
|
|
|
|
if (a.starts_with("CODTAB="))
|
|
|
|
|
{
|
|
|
|
|
const TString& codtab = a.after("=");
|
|
|
|
|
get_relation()->curr().put("CODTAB", codtab);
|
|
|
|
|
FOR_EACH_MASK_FIELD(m, i, f) if (f->active() && f->field() != NULL && f->in_key(1))
|
|
|
|
|
{
|
|
|
|
|
const TFieldref* fref = f->field();
|
|
|
|
|
if (fref->name() == "CODTAB")
|
|
|
|
|
{
|
|
|
|
|
const TString& val = fref->read(*get_relation());
|
|
|
|
|
f->set(val);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m.send_key(K_AUTO_ENTER, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-01-27 15:16:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-03-01 09:48:27 +00:00
|
|
|
|
void THA_table_app::init_query_insert_mode(TMask& m)
|
2011-01-27 15:16:23 +00:00
|
|
|
|
{
|
2012-07-02 13:04:46 +00:00
|
|
|
|
const TFixed_string name = get_relation()->file(0).name();
|
2011-03-01 09:48:27 +00:00
|
|
|
|
if (name == "CEL")
|
|
|
|
|
{
|
|
|
|
|
m.hide(F_CODCLI);
|
|
|
|
|
m.show(F_CODCLI1);
|
|
|
|
|
}
|
2011-04-27 14:28:42 +00:00
|
|
|
|
if (name == "ATT")
|
|
|
|
|
{
|
|
|
|
|
m.hide(-2); //in caso di 'nuovo' vedo il gruppo di NEW
|
|
|
|
|
m.show(-1);
|
|
|
|
|
}
|
2011-01-27 15:16:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-07-02 13:04:46 +00:00
|
|
|
|
int THA_table_app::update_gcg(const TRectype& att)
|
|
|
|
|
{
|
|
|
|
|
TTable gcg("GCG");
|
|
|
|
|
TString str;
|
|
|
|
|
str << '1' << att.get("CODTAB");
|
|
|
|
|
gcg.put("CODTAB", str);
|
|
|
|
|
|
|
|
|
|
str = TR("Matricola ");
|
|
|
|
|
str << att.get("S0").mid(20,15);
|
|
|
|
|
gcg.put("S0", str);
|
|
|
|
|
|
|
|
|
|
const int err = gcg.rewrite_write();
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int THA_table_app::write(const TMask& m)
|
|
|
|
|
{
|
|
|
|
|
const int err = TTable_module_application::write(m);
|
|
|
|
|
|
|
|
|
|
if (err == NOERR)
|
|
|
|
|
{
|
|
|
|
|
const TFixed_string name = get_relation()->file(0).name();
|
|
|
|
|
if (name == "ATT")
|
|
|
|
|
update_gcg(get_relation()->curr());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int THA_table_app::rewrite(const TMask& m)
|
|
|
|
|
{
|
|
|
|
|
const int err = TTable_module_application::rewrite(m);
|
|
|
|
|
|
|
|
|
|
if (err == NOERR)
|
|
|
|
|
{
|
|
|
|
|
const TFixed_string name = get_relation()->file(0).name();
|
|
|
|
|
if (name == "ATT")
|
|
|
|
|
update_gcg(get_relation()->curr());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-01-27 15:16:23 +00:00
|
|
|
|
int ha0100(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
THA_table_app a;
|
2012-11-06 10:55:40 +00:00
|
|
|
|
a.run(argc, argv, TR("Tabella Hardy"));
|
2011-01-27 15:16:23 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|