Patch level : 4.0

Files correlati     : ve2
Ricompilazione Demo : [ ]
Commento            :
Aggiunta maschera dinamica per la gestione dei codici articoli avanzati


git-svn-id: svn://10.65.10.50/trunk@15436 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2007-06-21 14:20:08 +00:00
parent 74082e8a63
commit 6fc87139eb
6 changed files with 189 additions and 5 deletions

View File

@ -1,5 +1,5 @@
#include <checks.h>
#include <xvt.h>
#include <checks.h>
extern int ve2100(int argc, char* argv[]); // tabelle sconti (di riga/di documento/incondizionati)
extern int ve2200(int argc, char* argv[]); // testate listini/contratti/offerte

View File

@ -1,5 +1,6 @@
#include "velib.h"
#include "ve2400.h"
#include "ve2401.h"
#include "../ca/calib01.h"
#include "../cg/cglib01.h"
@ -12,7 +13,6 @@
#include <relapp.h>
#include <tabutil.h>
#include <urldefid.h>
#include <utility.h>
//---------------------------------------------------
// MASCHERA ANAGRAFICA MAGAZZINO
@ -254,6 +254,7 @@ void create_browse2(TEdit_field& kfld, int level, short key_id, short des_id, co
int create_fields(TMask& msk, int x, int y, short key_id, short des_id, const TCodart_livelli &cal, const bool chktyp)
{
const int last_level = cal.last_level();
int tab0 = x;
int i;
for (i = 1; i <= last_level; i++) //cicla su tutti i livelli del codart abilitati
@ -435,7 +436,10 @@ void TMask_anamag::create_user_fields()
if (type == 'X')
f = &add_boolean(F_USER1 + i - 1, PAGE_USER, prompt, 2, 3 + i);
if (f != NULL)
f->set_field(format("USER%d", i));
{
TString8 u; u.format("USER%d", i);
f->set_field(u);
}
disable_user_page = false;
}
}
@ -481,13 +485,20 @@ TMask_anamag::TMask_anamag(TRelation * rel) : TMask("ve2400")
create_user_fields();
if(livelli_art->enabled())
if (livelli_art->enabled())
{
create_fields(*this, 1, 1, F_LIVART1, F_DESLIVART1, *livelli_art, true);
first_focus(F_LIVART1);
}
else
{
if (advanced_codart_enabled())
{
TButton_field& bu = add_button(F_ADVANCED, 0, PR("Codice guidato"), 1, 1, 20);
bu.set_handler(advanced_codart_handler);
}
first_focus(F_CODART);
}
}
void TMask_anamag::sheetsto_put(TSheet_field &sheet_sto, int item)

View File

@ -1,6 +1,7 @@
#define F_CODART 101
#define F_DESCR 102
#define F_COPY 100
#define F_ADVANCED 108
#define F_GRMERC 103
#define F_GRMERCD1 106

161
ve/ve2401.cpp Executable file
View File

@ -0,0 +1,161 @@
#include "ve2400.h"
#include "ve2401.h"
#include <automask.h>
#include <diction.h>
#include <recarray.h>
#include <recset.h>
///////////////////////////////////////////////////////////
// Utility per gestione struttura codice avanzato
///////////////////////////////////////////////////////////
const TString& root_code()
{
static TString4 _root_code;
if (_root_code.empty())
{
const TString query = "USE FSA SELECT B0='X'";
TISAM_recordset set(query);
if (set.move_first())
_root_code = set.get("CODTAB").as_string();
else
_root_code = " "; // Evito riletture inutili
}
return _root_code;
}
static const TRectype& get_sublevel_info(const TString& code)
{
return cache().get("FSA", code.full() ? code : root_code());
}
///////////////////////////////////////////////////////////
// Maschera dianamica per inserimento codici
///////////////////////////////////////////////////////////
class TCodart_mask : public TAutomask
{
protected:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
void create_level(int level, const TString& subcode);
void rebuild();
public:
TCodart_mask();
};
bool TCodart_mask::on_field_event(TOperable_field& o, TField_event e, long jolly)
{
switch (o.dlg())
{
case 101:
if (e == fe_modify) // Se cambio il contenuto del primo livello ...
rebuild(); // Ricostruisco la maschera
break;
default:
break;
}
return true;
}
void TCodart_mask::create_level(int level, const TString& subcode)
{
const TRectype& fsa = get_sublevel_info(subcode);
if (!fsa.empty())
{
const TString4 code = fsa.get("CODTAB"); // Puo' essere diverso da subcode!
TString80 prompt = fsa.get("S0"); prompt.left_just(21);
const TString& picture = fsa.get("S1");
const int length = picture.len();
TEdit_field& kfld = add_string(100+level, 0, prompt, 1, level, length, "B");
TEdit_field& dfld = add_string(200+level, 0, "", 40, level, 36, "D");
TFilename tmp; tmp.temp();
ofstream out(tmp);
out << "USE GSA" << endl; //usa la tabella dei sottolivelli articolo
out << "IN CODTAB[1,3] \"" << code << "\" SELECT" << endl;
out << "IN CODTAB[4,0] " << kfld.dlg() << endl;
out << "DI \"" << prompt;
if (length > prompt.len())
out << '@' << length;
out << "\" CODTAB[4,0]" << endl;
out << "DI \"" << HR("Descrizione") << "@50\" S0" << endl;
out << "OU " << kfld.dlg() << " CODTAB[4,0]" << endl;
out << "OU " << dfld.dlg() << " S0" << endl;
out << "CH RE" << endl;
out << "EN" << endl;
out.close();
TScanner scan(tmp);
while (scan.pop() != "EN")
kfld.parse_item(scan);
xvt_fsys_removefile(tmp);
set_handlers();
}
}
void TCodart_mask::rebuild()
{
TArray& a = fields_array();
for (int i = a.last(); i > 3; i--)
a.destroy(i);
TString8 code = root_code();
code << get(101);
const TString& children = cache().get("GSA", code, "S1");
for (int i = 0; i < 8; i++)
{
const TString& subcode = children.mid(i*3, 3);
if (subcode.full())
create_level(i+2, subcode);
else
break;
}
force_update();
}
TCodart_mask::TCodart_mask() : TAutomask(TR("Articolo guidato"), 1, 78, 13)
{
add_button(DLG_OK, 0, "", -12, -1, 10, 2);
add_button(DLG_CANCEL, 0, "", -22, -1, 10, 2);
create_level(1, EMPTY_STRING);
}
const TString& advanced_get_codart()
{
TCodart_mask m;
if (m.run() == K_ENTER)
{
TString& tmp = get_tmp_string();
for (short id = 101; m.id2pos(id) >= 0; id++)
tmp << m.get(id);
return tmp;
}
return EMPTY_STRING;
}
///////////////////////////////////////////////////////////
// Essenzialissima interfaccia pubblica
///////////////////////////////////////////////////////////
bool advanced_codart_enabled()
{
return root_code().full();
}
bool advanced_codart_handler(TMask_field& fld, KEY key)
{
if (key == K_SPACE)
{
TMask& msk = fld.mask();
msk.set(F_CODART, advanced_get_codart(), true);
}
return true;
}

11
ve/ve2401.h Executable file
View File

@ -0,0 +1,11 @@
#ifndef __VE2401_H
#define __VE2401_H
#ifndef __MASKFLD_H
#include <maskfld.h>
#endif
bool advanced_codart_enabled();
bool advanced_codart_handler(TMask_field& fld, KEY key);
#endif

View File

@ -167,7 +167,7 @@ void TDocumento::init()
check_modules();
TConfig c(CONFIG_DITTA, "ve");
//TConfig c(CONFIG_DITTA, "ve"); // A cosa serviva questo ennesimo rallentamento?
}
TDocumento::TDocumento()