Patch level :
Files correlati : ve0.exe Ricompilazione Demo : [ ] Commento : Aggiunto supporto per lettore codici a barre Implementata proposta automaica contratto git-svn-id: svn://10.65.10.50/branches/R_10_00@22408 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
3584dfc728
commit
9917f94cb6
@ -1016,6 +1016,7 @@ public:
|
||||
static bool datacambio_handler( TMask_field& f, KEY key );
|
||||
static bool codval_handler( TMask_field& f, KEY key );
|
||||
static bool confirm_handler( TMask_field& f, KEY key );
|
||||
static bool barcode_handler( TMask_field& f, KEY key );
|
||||
static bool sort_row_handler( TMask_field& f, KEY key );
|
||||
static bool ss_notify(TSheet_field& ss, int r, KEY key);
|
||||
static bool ss_handler(TMask_field& f, KEY key);
|
||||
|
198
ve/velib06.cpp
198
ve/velib06.cpp
@ -8,6 +8,7 @@
|
||||
#include <recset.h>
|
||||
#include <smartcard.h>
|
||||
#include <treectrl.h>
|
||||
#include <toolfld.h>
|
||||
#include <urldefid.h>
|
||||
#include <utility.h>
|
||||
|
||||
@ -25,8 +26,9 @@
|
||||
#include "veini.h"
|
||||
|
||||
#include "../cg/cfban.h"
|
||||
#include "../ca/cfcms.h"
|
||||
#include "rcondv.h"
|
||||
#include "../ca/cfcms.h"
|
||||
#include "condv.h"
|
||||
#include "rcondv.h"
|
||||
#include "sconti.h"
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
@ -156,15 +158,15 @@ TDocumento_mask::TDocumento_mask(const char* td)
|
||||
set_field_handler( F_CODVAL1, codval_handler );
|
||||
set_field_handler( F_NUMDOCRIF, datadocrif_handler);
|
||||
set_field_handler( F_DATADOCRIF, datadocrif_handler);
|
||||
set_handler( DLG_ELABORA, elabora_handler );
|
||||
|
||||
set_handler( DLG_ELABORA, elabora_handler );
|
||||
set_handler( DLG_PRINT, print_handler );
|
||||
set_handler( DLG_PREVIEW, print_handler );
|
||||
set_handler( DLG_EMAIL, print_handler );
|
||||
set_handler( DLG_CONFERMA, confirm_handler );
|
||||
if (id2pos(DLG_SORT) > 0)
|
||||
set_handler( DLG_SORT, sort_row_handler );
|
||||
|
||||
|
||||
set_handler( DLG_SORT, sort_row_handler );
|
||||
set_handler( DLG_BARCODE, barcode_handler );
|
||||
|
||||
const TString_array& handlers = tdoc.handlers();
|
||||
FOR_EACH_ARRAY_ROW(handlers, r, riga)
|
||||
user_set_handler( riga->get_int(0), riga->get_int(1) );
|
||||
@ -278,7 +280,7 @@ TDocumento_mask::TDocumento_mask(const char* td)
|
||||
}
|
||||
}
|
||||
|
||||
const bool gescontr = cfg.get_bool("GES", "ve", 2);
|
||||
const bool gescontr = cfg.get_bool("GES", "ve", 2);
|
||||
|
||||
show(F_CODCONT, gescontr);
|
||||
show(F_DESCONT, gescontr);
|
||||
@ -974,7 +976,7 @@ void TDocumento_mask::cli2mask(bool force_load)
|
||||
|
||||
const TRectype & ven_rec = c.vendite();
|
||||
|
||||
if(force_load || !onload)
|
||||
if (force_load || !onload)
|
||||
{
|
||||
short pos = id2pos(F_CODVAL);
|
||||
const TString4 codval = c.get(CLI_CODVAL); // Attenzione: Non usare TString& qui!
|
||||
@ -1203,10 +1205,31 @@ void TDocumento_mask::cli2mask(bool force_load)
|
||||
check_field( F_CODZON );
|
||||
|
||||
//gestione contratti
|
||||
bool gescontr = ven_rec.get_bool(CFV_GESTCONTR) && ini_get_bool(CONFIG_DITTA, "ve", "GES", false, 2);
|
||||
|
||||
const bool gescontr = ven_rec.get_bool(CFV_GESTCONTR) && ini_get_bool(CONFIG_DITTA, "ve", "GES", false, 2);
|
||||
enable(F_CODCONT, gescontr);
|
||||
enable(F_DESCONT, gescontr);
|
||||
if (gescontr && insert_mode())
|
||||
{
|
||||
const TDate datadoc = get(F_DATADOC);
|
||||
TString str;
|
||||
str << CONDV_TIPO << "=C " << CONDV_TIPOCF << '=' << c.tipo() << ' ' << CONDV_CODCF << '=' << c.codice();
|
||||
TString query;
|
||||
query << "USE CONDV\nFROM " << str << "\nTO " << str;
|
||||
TISAM_recordset contr(query);
|
||||
|
||||
str.cut(0);
|
||||
for (bool ok = contr.move_first(); ok; ok = contr.move_next())
|
||||
{
|
||||
const TDate data_ini = contr.get(CONDV_VALIN).as_date();
|
||||
const TDate data_fin = contr.get(CONDV_VALFIN).as_date();
|
||||
if (datadoc.between(data_ini, data_fin))
|
||||
{
|
||||
str = contr.get(CONDV_COD).as_string();
|
||||
break;
|
||||
}
|
||||
}
|
||||
set(F_CODCONT, str, 0x3);
|
||||
}
|
||||
|
||||
// Accendi bottone mail se possibile
|
||||
const TString& email = c.get(CLI_DOCMAIL);
|
||||
@ -2054,7 +2077,6 @@ bool TDocumento_mask::clifo_handler( TMask_field& f, KEY key )
|
||||
if (m.id2pos(F_CODCONT) >= 0)
|
||||
{
|
||||
TEdit_field & e = m.efield(F_CODCONT);
|
||||
|
||||
if (e.active())
|
||||
{
|
||||
e.set_dirty();
|
||||
@ -3796,10 +3818,10 @@ bool TDocumento_mask::codcont_handler( TMask_field& f, KEY key )
|
||||
TDocumento_mask& m = (TDocumento_mask&)f.mask();
|
||||
TLocalisamfile & cont = ((TEdit_field &) f).browse()->cursor()->file();
|
||||
const TDate datadoc(f.mask().get(F_DATADOC));
|
||||
const TDate datascad(cont.get_date("VALFIN"));
|
||||
const TDate datascad(cont.get_date(CONDV_VALFIN));
|
||||
|
||||
if (datascad.ok() && datadoc > datascad)
|
||||
return error_box("Contratto scaduto il %s", datascad.string());
|
||||
return error_box(FR("Contratto scaduto il %s"), datascad.string());
|
||||
|
||||
static bool __gesconcc = false;
|
||||
static long __cntr_firm = -1L;
|
||||
@ -4190,7 +4212,7 @@ bool TDocumento_mask::sort_row_handler( TMask_field& f, KEY key )
|
||||
else
|
||||
{
|
||||
rows = saved_rows;
|
||||
return message_box("L'ordinamento non ha avuto un esito positivo");
|
||||
return message_box(TR("L'ordinamento non ha avuto un esito positivo"));
|
||||
}
|
||||
|
||||
}
|
||||
@ -4225,3 +4247,149 @@ bool TDocumento_mask::gestione_note_per_articolo() const
|
||||
{
|
||||
return id2pos(F_NAR) > 0;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Gestione lettore codice a barre
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
class TBarcode_mask : public TAutomask
|
||||
{
|
||||
TDocumento_mask& _dm;
|
||||
clock_t _last_key;
|
||||
|
||||
protected:
|
||||
virtual void on_idle();
|
||||
virtual bool on_key(KEY k);
|
||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long joly);
|
||||
virtual bool on_code_entered(const TString& code);
|
||||
const TString& barcode2codart(const TString& code) const;
|
||||
|
||||
public:
|
||||
TBarcode_mask(TDocumento_mask& dm);
|
||||
};
|
||||
|
||||
const TString& TBarcode_mask::barcode2codart(const TString& code) const
|
||||
{
|
||||
TLocalisamfile codcorr(LF_CODCORR);
|
||||
codcorr.setkey(2);
|
||||
codcorr.put(ANAMAG_CODARTALT, code);
|
||||
if (codcorr.read() == NOERR)
|
||||
return codcorr.get(ANAMAG_CODART);
|
||||
return code;
|
||||
}
|
||||
|
||||
bool TBarcode_mask::on_code_entered(const TString& code)
|
||||
{
|
||||
TCodice_articolo codart;
|
||||
real qta = UNO;
|
||||
TString16 livello;
|
||||
|
||||
const int codelen = code.len();
|
||||
if (codelen >= 16)
|
||||
{
|
||||
for (int i = 0; i < codelen; )
|
||||
{
|
||||
const int ctrl = atoi(code.mid(i, 2)); i += 2;
|
||||
switch (ctrl)
|
||||
{
|
||||
case 2: codart = barcode2codart(code.mid(i, 14)); i +=14; break;
|
||||
case 10: livello = code.mid(i, 4); i += 4; break;
|
||||
case 37: qta = real(code.mid(i, 4)); i += 4; break;
|
||||
default: i += 4; break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
codart = barcode2codart(code);
|
||||
|
||||
if (codart.full())
|
||||
{
|
||||
TSheet_field& s = _dm.sheet();
|
||||
|
||||
TDocumento& doc = _dm.doc();
|
||||
FOR_EACH_PHYSICAL_RDOC_BACK(doc, i, rdoc)
|
||||
{
|
||||
if (rdoc->get(RDOC_CODART) == codart && rdoc->get(RDOC_LIVELLO) == livello)
|
||||
{
|
||||
rdoc->add(RDOC_QTA, qta);
|
||||
s.row(i-1).add(rdoc->get(RDOC_QTA), s.cid2index(FR_QTA));
|
||||
s.force_update(i-1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
TRiga_documento& r = doc.new_row(_dm.get(F_LBTIPORIGA));
|
||||
r.put(RDOC_CODART, codart);
|
||||
r.put(RDOC_LIVELLO, livello);
|
||||
r.put(RDOC_QTA, qta);
|
||||
r.autoload(s);
|
||||
const int i = r.get_int(RDOC_NRIGA)-1;
|
||||
_dm.ss_notify(s, i, K_CTRL+K_INS); // Propone magazzino
|
||||
s.check_row(i, 0x3);
|
||||
s.force_update();
|
||||
}
|
||||
|
||||
return codart.full();
|
||||
}
|
||||
|
||||
bool TBarcode_mask::on_key(KEY k)
|
||||
{
|
||||
static KEY _barcode_newline = ini_get_int(CONFIG_INSTALL, "Main", "BarcodeNewline");
|
||||
|
||||
if (k == _barcode_newline)
|
||||
{
|
||||
const TString& code = efield(DLG_USER).get_window_data();
|
||||
on_code_entered(code);
|
||||
reset(DLG_USER);
|
||||
}
|
||||
|
||||
return TAutomask::on_key(k);
|
||||
}
|
||||
|
||||
void TBarcode_mask::on_idle()
|
||||
{
|
||||
if (_last_key > 0 && (clock() - _last_key) > 500)
|
||||
{
|
||||
_last_key = 0;
|
||||
const TString& code = efield(DLG_USER).get_window_data();
|
||||
if (code.len() >= 8)
|
||||
{
|
||||
if (on_code_entered(code))
|
||||
reset(DLG_USER);
|
||||
}
|
||||
}
|
||||
return TAutomask::on_idle();
|
||||
}
|
||||
|
||||
bool TBarcode_mask::on_field_event(TOperable_field& o, TField_event e, long joly)
|
||||
{
|
||||
if (e == fe_edit && o.dlg() == DLG_USER)
|
||||
{
|
||||
_last_key = clock();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
TBarcode_mask::TBarcode_mask(TDocumento_mask& dm) : TAutomask("BAR CODE READER", 1, 40, 3, -1, 4), _dm(dm), _last_key(0)
|
||||
{
|
||||
TButton_tool& bt = add_button_tool(DLG_QUIT, TR("Fine"), TOOL_QUIT);
|
||||
add_button_tool(DLG_INFO, TR("Info"), TOOL_INFO);
|
||||
add_string(DLG_USER, 0, PR("Codice "), 1, 1, 128, "", 30);
|
||||
set_handlers();
|
||||
}
|
||||
|
||||
bool TDocumento_mask::barcode_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
if (k == K_SPACE)
|
||||
{
|
||||
TDocumento_mask& mask = (TDocumento_mask&)f.mask();
|
||||
TSheet_field& s = mask.sheet();
|
||||
if (mask.curr_win() != s.parent())
|
||||
s.set_focus();
|
||||
|
||||
TBarcode_mask bcm(mask);
|
||||
bcm.run();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user