1999-04-06 15:34:39 +00:00
|
|
|
#include <automask.h>
|
2005-04-21 16:40:40 +00:00
|
|
|
#include <modaut.h>
|
1999-04-06 15:34:39 +00:00
|
|
|
#include <printer.h>
|
|
|
|
#include <tabapp.h>
|
|
|
|
|
|
|
|
#include "vetbnum.h"
|
2005-04-21 16:40:40 +00:00
|
|
|
#include "../ca/calib01.h"
|
|
|
|
|
|
|
|
#include "vetbspp.h"
|
|
|
|
#include "vetbprs.h"
|
|
|
|
#include "vetbrss.h"
|
|
|
|
#include "vetbatr.h"
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TVendite_mask
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TVendite_mask : public TAutomask
|
|
|
|
{
|
2005-04-21 16:40:40 +00:00
|
|
|
TString4 _tab; // Voglio la tabella sempre sotto mano
|
1999-04-06 15:34:39 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
|
|
|
|
bool is_table(const char* tab) const { return _tab == tab; }
|
|
|
|
|
|
|
|
void get_printer_config(TString& name) const;
|
|
|
|
bool get_printer_name(TString& name) const;
|
|
|
|
void reset_printer_config() const;
|
|
|
|
|
|
|
|
bool on_num_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
|
|
|
|
public:
|
2005-04-21 16:40:40 +00:00
|
|
|
const TString& table_code() const { return _tab; }
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
TVendite_mask(const char* name);
|
|
|
|
virtual ~TVendite_mask() { }
|
|
|
|
};
|
|
|
|
|
|
|
|
void TVendite_mask::get_printer_config(TString& config) const
|
|
|
|
{
|
|
|
|
config = _tab;
|
|
|
|
for (TEditable_field* f = get_key_field(1, TRUE); f;
|
|
|
|
f = get_key_field(1, FALSE)) if (f->shown())
|
|
|
|
config << f->get();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TVendite_mask::get_printer_name(TString& name) const
|
|
|
|
{
|
2003-04-17 09:27:00 +00:00
|
|
|
TString config; get_printer_config(config);
|
1999-04-06 15:34:39 +00:00
|
|
|
TConfig ini(CONFIG_STAMPE, config);
|
2003-04-17 09:27:00 +00:00
|
|
|
name = ini.get("Name");
|
1999-04-06 15:34:39 +00:00
|
|
|
return name.not_empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TVendite_mask::reset_printer_config() const
|
|
|
|
{
|
|
|
|
TString16 config; get_printer_config(config);
|
|
|
|
TConfig ini(CONFIG_STAMPE, config);
|
|
|
|
ini.remove_all();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TVendite_mask::on_num_event(TOperable_field& o, TField_event e, long jolly)
|
|
|
|
{
|
2005-10-27 15:06:43 +00:00
|
|
|
return true; //metodo che gestiva la stampante per le numerazioni documenti
|
1999-04-06 15:34:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool TVendite_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
|
|
{
|
|
|
|
if (is_table("NUM"))
|
|
|
|
return on_num_event(o, e, jolly);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
TVendite_mask::TVendite_mask(const char* name) : TAutomask(name)
|
|
|
|
{
|
|
|
|
const TFixed_string n(name);
|
|
|
|
_tab = n.mid(4,3);
|
|
|
|
_tab.upper();
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// TVendite_tabapp
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class TVendite_tabapp : public TTable_application
|
|
|
|
{
|
2005-09-19 12:45:16 +00:00
|
|
|
|
|
|
|
virtual const char * extra_modules() const {return "dt";}
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
protected:
|
|
|
|
virtual TMask* set_mask(TMask* m);
|
2005-04-21 16:40:40 +00:00
|
|
|
virtual void init_query_mode(TMask& m);
|
|
|
|
virtual void init_insert_mode(TMask& m);
|
|
|
|
virtual void init_modify_mode(TMask& m);
|
2005-12-08 03:05:30 +00:00
|
|
|
virtual int read(TMask& m);
|
|
|
|
virtual int write(const TMask& m);
|
|
|
|
virtual int rewrite(const TMask& m);
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
};
|
|
|
|
|
|
|
|
TMask* TVendite_tabapp::set_mask(TMask* m)
|
|
|
|
{
|
|
|
|
if (m == NULL)
|
|
|
|
{
|
|
|
|
TFilename mn; get_mask_name(mn);
|
2005-04-21 16:40:40 +00:00
|
|
|
TVendite_mask* vm = new TVendite_mask(mn);
|
|
|
|
|
|
|
|
if (has_module(CAAUT, CHK_DONGLE) || has_module(CMAUT, CHK_DONGLE))
|
|
|
|
{
|
|
|
|
// Crea i campi per i conti analitici (vendite e acquisti)
|
|
|
|
if (vm->table_code() == "SPP")
|
|
|
|
{
|
2005-07-20 14:58:52 +00:00
|
|
|
ca_create_fields(*vm, 0, LF_PCONANA, 2, 11, SPP_CDC_V1, SPP_CDC_V1+10, 0x0, "S1");
|
|
|
|
ca_create_fields(*vm, 0, LF_PCONANA, 2, 16, SPP_CDC_A1, SPP_CDC_A1+10, 0x0, "S2");
|
2005-04-21 16:40:40 +00:00
|
|
|
} else
|
|
|
|
if (vm->table_code() == "PRS")
|
|
|
|
{
|
2005-07-20 14:58:52 +00:00
|
|
|
ca_create_fields(*vm, 0, LF_PCONANA, 2, 12, PRS_CDC_V1, PRS_CDC_V1+10, 0x0, "S1");
|
2005-04-21 16:40:40 +00:00
|
|
|
} else
|
|
|
|
if (vm->table_code() == "RSS")
|
|
|
|
{
|
2005-07-20 14:58:52 +00:00
|
|
|
ca_create_fields(*vm, 0, LF_PCONANA, 2, 16, RSS_CDC_V1, RSS_CDC_V1+10, 0x0, "S1");
|
2005-04-21 16:40:40 +00:00
|
|
|
}
|
|
|
|
if (vm->table_code() == "ATR")
|
|
|
|
{
|
2005-07-20 14:58:52 +00:00
|
|
|
ca_create_fields(*vm, 0, LF_PCONANA, 2, 12, ATR_CDC_V1, ATR_CDC_V1+10, 0x0, "S1");
|
2005-04-21 16:40:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m = vm;
|
1999-04-06 15:34:39 +00:00
|
|
|
}
|
|
|
|
return TTable_application::set_mask(m);
|
|
|
|
}
|
|
|
|
|
2005-04-21 16:40:40 +00:00
|
|
|
void TVendite_tabapp::init_query_mode(TMask& m)
|
|
|
|
{
|
|
|
|
if (get_tabname() == "RSS")
|
|
|
|
{
|
|
|
|
m.enable(RSS_RAGSOC);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TVendite_tabapp::init_insert_mode(TMask& m)
|
|
|
|
{
|
|
|
|
if (get_tabname() == "RSS")
|
|
|
|
{
|
|
|
|
m.disable(RSS_RAGSOC);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TVendite_tabapp::init_modify_mode(TMask& m)
|
|
|
|
{
|
|
|
|
if (get_tabname() == "RSS")
|
|
|
|
{
|
|
|
|
m.disable(RSS_RAGSOC);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-08 03:05:30 +00:00
|
|
|
int TVendite_tabapp::read(TMask& m)
|
|
|
|
{
|
|
|
|
int err = Tab_application::read(m);
|
|
|
|
const TString & table_name = get_tabname();
|
|
|
|
|
|
|
|
if (get_relation()->lfile().get_real("R10") == ZERO)
|
|
|
|
if (table_name == "SPP")
|
|
|
|
m.set(SPP_PREZZO, get_relation()->lfile().get("R0"));
|
|
|
|
else
|
|
|
|
if (table_name == "PRS")
|
|
|
|
m.set(PRS_PREZZO, get_relation()->lfile().get("R0"));
|
|
|
|
else
|
|
|
|
if (table_name == "RSS")
|
|
|
|
m.set(RSS_PREZZO, get_relation()->lfile().get("R0"));
|
|
|
|
else
|
|
|
|
if (table_name == "ATR")
|
|
|
|
m.set(ATR_PREZZO, get_relation()->lfile().get("R0"));
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
int TVendite_tabapp::write(const TMask& m)
|
|
|
|
{
|
|
|
|
const TString & table_name = get_tabname();
|
|
|
|
|
|
|
|
if (table_name == "SPP")
|
|
|
|
get_relation()->lfile().put("R0", m.get(SPP_PREZZO));
|
|
|
|
else
|
|
|
|
if (table_name == "PRS")
|
|
|
|
get_relation()->lfile().put("R0", m.get(PRS_PREZZO));
|
|
|
|
else
|
|
|
|
if (table_name == "RSS")
|
|
|
|
get_relation()->lfile().put("R0", m.get(RSS_PREZZO));
|
|
|
|
else
|
|
|
|
if (table_name == "ATR")
|
|
|
|
get_relation()->lfile().put("R0", m.get(ATR_PREZZO));
|
|
|
|
|
|
|
|
return Tab_application::write(m);
|
|
|
|
}
|
|
|
|
|
|
|
|
int TVendite_tabapp::rewrite(const TMask& m)
|
|
|
|
{
|
|
|
|
const TString & table_name = get_tabname();
|
|
|
|
|
|
|
|
if (table_name == "SPP")
|
|
|
|
get_relation()->lfile().put("R0", m.get(SPP_PREZZO));
|
|
|
|
else
|
|
|
|
if (table_name == "PRS")
|
|
|
|
get_relation()->lfile().put("R0", m.get(PRS_PREZZO));
|
|
|
|
else
|
|
|
|
if (table_name == "RSS")
|
|
|
|
get_relation()->lfile().put("R0", m.get(RSS_PREZZO));
|
|
|
|
else
|
|
|
|
if (table_name == "ATR")
|
|
|
|
get_relation()->lfile().put("R0", m.get(ATR_PREZZO));
|
|
|
|
|
|
|
|
return Tab_application::rewrite(m);
|
|
|
|
}
|
|
|
|
|
1999-04-06 15:34:39 +00:00
|
|
|
int ve0400(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
TVendite_tabapp vta;
|
|
|
|
vta.run(argc, argv, "Tabella Vendite");
|
|
|
|
return 0;
|
|
|
|
}
|