2010-11-26 11:19:09 +00:00
|
|
|
|
#include <applicat.h>
|
|
|
|
|
#include <automask.h>
|
|
|
|
|
#include <defmask.h>
|
|
|
|
|
#include <recset.h>
|
|
|
|
|
#include <relation.h>
|
|
|
|
|
#include <tabmod.h>
|
|
|
|
|
#include <tabutil.h>
|
|
|
|
|
|
|
|
|
|
#include "pd0610100a.h"
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// Tabella clienti/articoli/fornitori
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TTabmod_caf_msk: public TAutomask
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
void riempi_sheet();
|
|
|
|
|
void aggiungi_riga();
|
|
|
|
|
void registra();
|
|
|
|
|
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
|
|
|
|
public:
|
|
|
|
|
TTabmod_caf_msk();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void TTabmod_caf_msk::riempi_sheet()
|
|
|
|
|
{
|
|
|
|
|
const long cliente = get_long(F_CLIENTE);
|
2011-05-06 09:29:09 +00:00
|
|
|
|
const int indsp = get_int(F_INDSPED);
|
2010-11-26 11:19:09 +00:00
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET);
|
|
|
|
|
sheet.destroy();
|
|
|
|
|
if (cliente <= 0)
|
|
|
|
|
{
|
|
|
|
|
sheet.force_update();
|
|
|
|
|
return;
|
|
|
|
|
}
|
2011-05-06 09:29:09 +00:00
|
|
|
|
TString8 codcf; codcf.format("%06ld", cliente);
|
|
|
|
|
TString4 indsped; indsped.format("%03d", indsp);
|
|
|
|
|
TString16 key; key << codcf << indsped;
|
2010-11-26 11:19:09 +00:00
|
|
|
|
TString query;
|
|
|
|
|
query << "USE &CAF\n"
|
2011-05-06 09:29:09 +00:00
|
|
|
|
<< "FROM CODTAB=\"" << key << "\"\n"
|
|
|
|
|
<< "TO CODTAB=\"" << key << "\"";
|
2010-11-26 11:19:09 +00:00
|
|
|
|
TISAM_recordset caf_query(query);
|
|
|
|
|
for (bool ok = caf_query.move_first(); ok; ok = caf_query.move_next())
|
|
|
|
|
{
|
|
|
|
|
const TRectype& caf = caf_query.cursor()->curr();
|
|
|
|
|
const TString80 codtab = caf.get("CODTAB");
|
|
|
|
|
const TString8 forn1 = caf.get("I0");
|
2011-05-06 09:29:09 +00:00
|
|
|
|
const TString4 lis1 = caf.get("S4");
|
|
|
|
|
const TString4 con1 = caf.get("S5");
|
|
|
|
|
const TString8 forn2 = caf.get("I1");
|
|
|
|
|
const TString4 lis2 = caf.get("S6");
|
|
|
|
|
const TString4 con2 = caf.get("S7");
|
|
|
|
|
|
2010-11-26 11:19:09 +00:00
|
|
|
|
TToken_string& row = sheet.row(-1);
|
2011-05-06 09:29:09 +00:00
|
|
|
|
row.add(codtab.left(6), sheet.cid2index(S_CLIENTE));
|
|
|
|
|
row.add(codtab.mid(6, 3), sheet.cid2index(S_INDSPED));
|
|
|
|
|
row.add(codtab.mid(9), sheet.cid2index(S_ARTICOLO));
|
|
|
|
|
row.add(forn1, sheet.cid2index(S_FORN1));
|
|
|
|
|
row.add(lis1, sheet.cid2index(S_LIS1));
|
|
|
|
|
row.add(con1, sheet.cid2index(S_CON1));
|
|
|
|
|
row.add(forn2, sheet.cid2index(S_FORN2));
|
|
|
|
|
row.add(lis2, sheet.cid2index(S_LIS2));
|
|
|
|
|
row.add(con2, sheet.cid2index(S_CON2));
|
|
|
|
|
|
2010-12-22 01:37:42 +00:00
|
|
|
|
sheet.disable_cell(sheet.items()-1 , sheet.cid2index(S_ARTICOLO));
|
|
|
|
|
sheet.disable_cell(sheet.items()-1 , sheet.cid2index(S_DESART));
|
2010-11-26 11:19:09 +00:00
|
|
|
|
sheet.check_row(sheet.items()-1);
|
|
|
|
|
}
|
|
|
|
|
sheet.force_update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TTabmod_caf_msk::aggiungi_riga()
|
|
|
|
|
{
|
|
|
|
|
const TString8 cliente = get(F_CLIENTE);
|
2011-05-06 09:29:09 +00:00
|
|
|
|
const TString4 indsped = get(F_INDSPED);
|
2010-11-26 11:19:09 +00:00
|
|
|
|
if (cliente.empty())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET);
|
|
|
|
|
TToken_string& row = sheet.row(-1);
|
2010-12-22 01:37:42 +00:00
|
|
|
|
|
|
|
|
|
row.add(cliente, sheet.cid2index(S_CLIENTE));
|
2011-05-06 09:29:09 +00:00
|
|
|
|
row.add(indsped, sheet.cid2index(S_INDSPED));
|
|
|
|
|
|
2010-12-22 01:37:42 +00:00
|
|
|
|
sheet.enable_cell(sheet.items() - 1, sheet.cid2index(S_ARTICOLO));
|
|
|
|
|
sheet.enable_cell(sheet.items() - 1, sheet.cid2index(S_DESART));
|
2010-11-26 11:19:09 +00:00
|
|
|
|
sheet.force_update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TTabmod_caf_msk::registra()
|
|
|
|
|
{
|
|
|
|
|
TModule_table caf("&CAF");
|
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET);
|
|
|
|
|
|
|
|
|
|
FOR_EACH_SHEET_ROW(sheet, r, riga)
|
|
|
|
|
{
|
2011-01-31 16:13:59 +00:00
|
|
|
|
caf.zero();
|
2010-11-26 11:19:09 +00:00
|
|
|
|
TToken_string& row = *(TToken_string*)riga;
|
2011-05-06 09:29:09 +00:00
|
|
|
|
TString8 codcf; codcf.format("%06d", row.get_long(sheet.cid2index(S_CLIENTE)));
|
|
|
|
|
TString4 indsped; indsped.format("%03d", row.get_int(sheet.cid2index(S_INDSPED)));
|
2010-11-26 11:19:09 +00:00
|
|
|
|
TString80 codtab;
|
2011-05-06 09:29:09 +00:00
|
|
|
|
codtab << codcf;
|
|
|
|
|
codtab << indsped;
|
2010-11-26 11:19:09 +00:00
|
|
|
|
codtab << row.get(sheet.cid2index(S_ARTICOLO));
|
2011-01-31 16:13:59 +00:00
|
|
|
|
|
|
|
|
|
const long forn1 = row.get_long(sheet.cid2index(S_FORN1));
|
|
|
|
|
const long forn2 = row.get_long(sheet.cid2index(S_FORN2));
|
2011-05-06 09:29:09 +00:00
|
|
|
|
const TString4 list1 = row.get(sheet.cid2index(S_LIS1));
|
|
|
|
|
const TString4 list2 = row.get(sheet.cid2index(S_LIS2));
|
|
|
|
|
const TString4 cont1 = row.get(sheet.cid2index(S_CON1));
|
|
|
|
|
const TString4 cont2 = row.get(sheet.cid2index(S_CON2));
|
|
|
|
|
|
2011-01-31 16:13:59 +00:00
|
|
|
|
caf.put("CODTAB", codtab);
|
|
|
|
|
if (forn1 > 0 || forn2 > 0)
|
2010-11-26 11:19:09 +00:00
|
|
|
|
{
|
2011-05-06 09:29:09 +00:00
|
|
|
|
caf.put("S4", list1);
|
|
|
|
|
caf.put("S5", cont1);
|
|
|
|
|
caf.put("S6", list2);
|
|
|
|
|
caf.put("S7", cont2);
|
|
|
|
|
caf.put("I0", forn1);
|
|
|
|
|
caf.put("I1", forn2);
|
2011-01-31 16:13:59 +00:00
|
|
|
|
caf.rewrite_write();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
caf.remove();
|
2010-11-26 11:19:09 +00:00
|
|
|
|
}
|
|
|
|
|
riempi_sheet();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool TTabmod_caf_msk::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
|
|
|
|
{
|
|
|
|
|
switch(o.dlg())
|
|
|
|
|
{
|
|
|
|
|
case DLG_CANCEL:
|
|
|
|
|
if(e == fe_button && jolly == 0)
|
|
|
|
|
{
|
|
|
|
|
reset(F_CLIENTE);
|
|
|
|
|
reset(F_RAGSOC);
|
2011-05-06 09:29:09 +00:00
|
|
|
|
reset(F_INDSPED);
|
2010-11-26 11:19:09 +00:00
|
|
|
|
sfield(F_SHEET).destroy();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case DLG_SAVEREC:
|
|
|
|
|
if(e == fe_button)
|
|
|
|
|
registra();
|
|
|
|
|
break;
|
|
|
|
|
case DLG_DELREC:
|
|
|
|
|
if(e == fe_button && jolly == 1)
|
|
|
|
|
{
|
|
|
|
|
TMask& msk = sfield(F_SHEET).sheet_mask();
|
|
|
|
|
msk.reset(S_FORN1);
|
|
|
|
|
msk.reset(S_RAGSOC1);
|
|
|
|
|
msk.reset(S_FORN2);
|
|
|
|
|
msk.reset(S_RAGSOC2);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case F_CLIENTE:
|
2011-05-06 09:29:09 +00:00
|
|
|
|
case F_INDSPED:
|
2010-11-26 11:19:09 +00:00
|
|
|
|
if(e == fe_modify)
|
|
|
|
|
riempi_sheet();
|
|
|
|
|
break;
|
|
|
|
|
case F_SHEET:
|
|
|
|
|
if(e == se_query_add)
|
|
|
|
|
{
|
|
|
|
|
aggiungi_riga();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-12-22 01:37:42 +00:00
|
|
|
|
else
|
|
|
|
|
if (e == se_query_del)
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& sheet = (TSheet_field&)o;
|
|
|
|
|
TToken_string& row = sheet.row(jolly);
|
|
|
|
|
row.add("0", sheet.cid2index(S_FORN1));
|
|
|
|
|
row.add("0", sheet.cid2index(S_FORN2));
|
|
|
|
|
sheet.force_update(jolly);
|
|
|
|
|
TButton_field& button = (TButton_field&)sheet.sheet_mask().field(DLG_DELREC);
|
|
|
|
|
return on_field_event(button, fe_button, 1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (e == se_leave)
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& sheet = (TSheet_field&)o;
|
|
|
|
|
|
|
|
|
|
sheet.disable_cell(jolly , sheet.cid2index(S_ARTICOLO));
|
|
|
|
|
sheet.disable_cell(jolly , sheet.cid2index(S_DESART));
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-26 11:19:09 +00:00
|
|
|
|
break;
|
|
|
|
|
case S_ARTICOLO:
|
|
|
|
|
if(e == fe_modify)
|
|
|
|
|
{
|
|
|
|
|
TSheet_field& sheet = sfield(F_SHEET);
|
|
|
|
|
const int rsel = sheet.selected();
|
|
|
|
|
const TString& codart = o.get();
|
|
|
|
|
|
|
|
|
|
FOR_EACH_SHEET_ROW(sheet, r, riga)
|
|
|
|
|
{
|
|
|
|
|
if (r == rsel)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
TToken_string& row = *(TToken_string*)riga;
|
|
|
|
|
if (row.get(sheet.cid2index(S_ARTICOLO)) == codart)
|
|
|
|
|
{
|
|
|
|
|
TString msg;
|
|
|
|
|
msg << "Attenzione: esiste gi<67> una riga con articolo " << codart;
|
|
|
|
|
warning_box(msg);
|
|
|
|
|
|
|
|
|
|
sheet.select(rsel);
|
|
|
|
|
TMask& rmsk = sheet.sheet_mask();
|
|
|
|
|
rmsk.set(S_ARTICOLO, "");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TTabmod_caf_msk::TTabmod_caf_msk() : TAutomask("pd0610100a")
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
// TTabmod_caf_app
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class TTabmod_caf_app: public TSkeleton_application
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
virtual bool check_autorization() const {return false;}
|
|
|
|
|
virtual const char * extra_modules() const {return "ve";}
|
|
|
|
|
virtual void main_loop();
|
|
|
|
|
void elabora();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void TTabmod_caf_app::elabora()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TTabmod_caf_app::main_loop()
|
|
|
|
|
{
|
|
|
|
|
TTabmod_caf_msk m;
|
|
|
|
|
while (m.run() == K_ENTER)
|
|
|
|
|
{
|
|
|
|
|
elabora();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int pd0610100(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
TTabmod_caf_app app;
|
|
|
|
|
app.run(argc, argv, TR("Tabella Clienti/Articoli/Fornitori"));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|