Modifiche alla manutenzione files per editare anche files esterni a quelli PRASSI
git-svn-id: svn://10.65.10.50/trunk@4880 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
6ebc12bbb2
commit
bff58ab7e5
@ -55,6 +55,7 @@ protected:
|
||||
virtual bool destroy();
|
||||
void insert_riga(long, TToken_string&);
|
||||
void edit_riga(long, TToken_string&);
|
||||
void edit_riga(const TString&);
|
||||
void delete_riga();
|
||||
virtual bool extended_firm() const { return TRUE; }
|
||||
void update();
|
||||
@ -74,6 +75,30 @@ public:
|
||||
TManutenzione_app();
|
||||
};
|
||||
|
||||
HIDDEN bool browse_file_handler(TMask_field& f, KEY k)
|
||||
{
|
||||
if (k == K_F9)
|
||||
{
|
||||
FILE_SPEC fs; memset(&fs, 0, sizeof(FILE_SPEC));
|
||||
strcpy(fs.type, "DBF");
|
||||
strcpy(fs.name, f.get());
|
||||
strcpy(fs.creator, "PRASSI");
|
||||
xvt_fsys_get_default_dir(&fs.dir);
|
||||
xvt_fsys_save_dir();
|
||||
if (xvt_dm_post_file_open(&fs, "Selezione file") == FL_OK)
|
||||
{
|
||||
TFilename n;
|
||||
xvt_fsys_convert_dir_to_str(&fs.dir, n.get_buffer(n.size()), n.size());
|
||||
n.add(fs.name);
|
||||
f.set(n);
|
||||
xvt_fsys_restore_dir();
|
||||
}
|
||||
f.set_focus();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
HIDDEN void build_filelist(const char *path, TArray & list)
|
||||
{
|
||||
#if XVT_OS==XVT_OS_SCOUNIX
|
||||
@ -382,6 +407,7 @@ bool TManutenzione_app::create() // initvar e arrmask
|
||||
|
||||
_mask->enable(-1); // Abilita campi privilegiati
|
||||
}
|
||||
_browse->add_button(DLG_OTHERFILE, "A~ltri", K_F5);
|
||||
|
||||
dispatch_e_menu(BAR_ITEM(1));
|
||||
}
|
||||
@ -536,6 +562,46 @@ const char* TManutenzione_app::dumpfilename(const FileDes& dep) const
|
||||
return __tmp_string;
|
||||
}
|
||||
|
||||
void TManutenzione_app::edit_riga (const TString& name)
|
||||
{
|
||||
TExternisamfile* f = new TExternisamfile(name);
|
||||
TFilename n(name);
|
||||
KEY tasto;
|
||||
|
||||
const bool superprassi = user() == "PRASSI";
|
||||
_mask->set (FLD_NUM, "");
|
||||
_mask->set (FLD_NOME, n);
|
||||
_mask->set (FLD_EOD, f->items());
|
||||
_mask->set (FLD_EOX, f->items());
|
||||
_mask->set (F_LEN, f->curr().len());
|
||||
_mask->set (FLD_DESC, f->description());
|
||||
_mask->set (FLD_FORMULA, "");
|
||||
_mask->set (FLD_FLAG, "");
|
||||
_mask->reset (FLD_EXTEND);
|
||||
_mask->reset (F_TAB);
|
||||
_mask->disable(-1);
|
||||
_mask->enable(DLG_RECORD, superprassi);
|
||||
tasto = _mask->run();
|
||||
switch (tasto)
|
||||
{
|
||||
case K_F4:
|
||||
{
|
||||
TEdit_file ef;
|
||||
ef.browse(f,n);
|
||||
break;
|
||||
}
|
||||
case K_F6:
|
||||
_rec = new TRec_sheet(f);
|
||||
_rec->edit();
|
||||
delete _rec;
|
||||
_rec = NULL;
|
||||
delete f; // La delete di TExternisamfile va fatta solo qui perche' in K_F4 viene fatta dalla TRelation interna
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void TManutenzione_app::edit_riga (long riga_sel, TToken_string& riga)
|
||||
|
||||
{
|
||||
@ -1398,6 +1464,14 @@ bool TManutenzione_app::menu(MENU_TAG m)
|
||||
riga = _browse->row(riga_selezionata);
|
||||
edit_riga (riga_selezionata, riga);
|
||||
break;
|
||||
case K_F5: // Other file
|
||||
{
|
||||
TMask other("ba1100g");
|
||||
other.set_handler(101, browse_file_handler);
|
||||
if (other.run() == K_ENTER)
|
||||
edit_riga(other.get(101));
|
||||
}
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ class TRec_sheet : public TObject
|
||||
static TMask *_mask;
|
||||
TFilename _descfname;
|
||||
TString16 _tab;
|
||||
bool _external;
|
||||
|
||||
protected:
|
||||
bool check_key_expr(int key, const char* key_expr);
|
||||
@ -71,6 +72,7 @@ public:
|
||||
void edit();
|
||||
|
||||
TRec_sheet(int logicnum, const char * tab);
|
||||
TRec_sheet(TExternisamfile* file);
|
||||
virtual ~TRec_sheet();
|
||||
};
|
||||
|
||||
@ -78,9 +80,10 @@ class TEdit_file : public TObject
|
||||
{
|
||||
protected:
|
||||
KEY edit_record(TRectype& rec, bool readonly = FALSE);
|
||||
|
||||
bool _browse(TCursor& cur, const TFilename& name);
|
||||
public:
|
||||
bool browse(int logicnum, const TFilename& name, const TString& tab);
|
||||
bool browse(TExternisamfile* file, const TFilename& name);
|
||||
TEdit_file() {}
|
||||
virtual ~TEdit_file() {}
|
||||
};
|
||||
|
@ -48,6 +48,6 @@
|
||||
#define DLG_CONVERT 608
|
||||
#define DLG_ADDFILE 609
|
||||
#define DLG_INSFILE 610
|
||||
|
||||
#define DLG_OTHERFILE 611
|
||||
|
||||
#endif
|
||||
|
@ -115,6 +115,7 @@ BUTTON DLG_DUMP 9 2
|
||||
BEGIN
|
||||
PROMPT -14 -1 "Scarica"
|
||||
MESSAGE EXIT,K_F7
|
||||
GROUP 1
|
||||
END
|
||||
|
||||
BUTTON DLG_LOAD 9 2
|
||||
|
@ -95,6 +95,7 @@ TRec_sheet::TRec_sheet(int logicnum, const char * tab)
|
||||
: _descr(NULL), _tab(tab)
|
||||
|
||||
{
|
||||
_external = FALSE;
|
||||
_dir = new TDir;
|
||||
_rec = new TTrec;
|
||||
_rec_old = new TTrec;
|
||||
@ -125,9 +126,26 @@ TRec_sheet::TRec_sheet(int logicnum, const char * tab)
|
||||
}
|
||||
}
|
||||
|
||||
TRec_sheet::TRec_sheet(TExternisamfile* file)
|
||||
: _descr(NULL), _tab("")
|
||||
|
||||
{
|
||||
_external = TRUE;
|
||||
_dir = new TDir;
|
||||
_rec = new TTrec;
|
||||
_rec_old = new TTrec;
|
||||
_mask = new TMask("ba1100d");
|
||||
memcpy(_dir->filedesc(),file->filehnd()->d,sizeof(FileDes));
|
||||
memcpy(_rec->rec(),file->filehnd()->r,sizeof(RecDes));
|
||||
if (_dir->len() == 0)
|
||||
_rec->zero();
|
||||
*_rec_old = *_rec;
|
||||
}
|
||||
|
||||
TRec_sheet::~TRec_sheet()
|
||||
{
|
||||
_dir->get(_dir->num(), _unlock, _nordir, _sysdirop);
|
||||
if (!_external)
|
||||
_dir->get(_dir->num(), _unlock, _nordir, _sysdirop);
|
||||
delete _dir;
|
||||
delete _rec;
|
||||
delete _rec_old;
|
||||
@ -232,9 +250,17 @@ void TRec_sheet::edit()
|
||||
bool import_dirty = FALSE;
|
||||
TSheet_field& f1 = (TSheet_field&) _mask->field(F_FIELDS);
|
||||
TSheet_field& f2 = (TSheet_field&) _mask->field(F_KEYS);
|
||||
|
||||
_mask->set (F_NUM, _dir->num());
|
||||
_mask->set (F_DES, _dir->des());
|
||||
|
||||
if (!_external)
|
||||
{
|
||||
_mask->set (F_NUM, _dir->num());
|
||||
_mask->set (F_DES, _dir->des());
|
||||
}
|
||||
else
|
||||
{
|
||||
_mask->set (F_DES, _dir->name());
|
||||
_mask->disable(-1);
|
||||
}
|
||||
f1.sheet_mask().field(FLD_LEN).set_handler(len_handler);
|
||||
f1.set_notify(fld_notify);
|
||||
f1.set_append(FALSE);
|
||||
|
@ -6,25 +6,14 @@
|
||||
|
||||
#include "ba1100.h"
|
||||
|
||||
bool TEdit_file::browse(int logicnum, const TFilename& name, const TString& tab)
|
||||
bool TEdit_file::_browse(TCursor& cursor, const TFilename& name)
|
||||
{
|
||||
TRelation relation(logicnum);
|
||||
TCursor cursor(&relation);
|
||||
TRectype& curr = cursor.curr();
|
||||
TRectype svrec(cursor.curr());
|
||||
|
||||
TToken_string head(256);
|
||||
TToken_string trac(256);
|
||||
|
||||
if (logicnum == LF_TAB || logicnum == LF_TABCOM || logicnum == LF_TABGEN)
|
||||
{
|
||||
if (tab.len() == 3) // Filtra la tabella interessata
|
||||
{
|
||||
TRectype filter(logicnum);
|
||||
filter.put("COD", tab);
|
||||
cursor.setregion(filter, filter);
|
||||
}
|
||||
}
|
||||
|
||||
const char* n;
|
||||
trac.add("");
|
||||
@ -147,6 +136,30 @@ bool TEdit_file::browse(int logicnum, const TFilename& name, const TString& tab)
|
||||
return K_ESC;
|
||||
}
|
||||
|
||||
bool TEdit_file::browse(int logicnum, const TFilename& name, const TString& tab)
|
||||
{
|
||||
TRelation relation(logicnum);
|
||||
TCursor cursor(&relation);
|
||||
if (logicnum == LF_TAB || logicnum == LF_TABCOM || logicnum == LF_TABGEN)
|
||||
{
|
||||
if (tab.len() == 3) // Filtra la tabella interessata
|
||||
{
|
||||
TRectype filter(logicnum);
|
||||
filter.put("COD", tab);
|
||||
cursor.setregion(filter, filter);
|
||||
}
|
||||
}
|
||||
return _browse(cursor,name);
|
||||
}
|
||||
|
||||
bool TEdit_file::browse(TExternisamfile* file, const TFilename& name)
|
||||
{
|
||||
TRelation relation(file);
|
||||
TCursor cursor(&relation);
|
||||
|
||||
return _browse(cursor,name);
|
||||
}
|
||||
|
||||
KEY TEdit_file::edit_record(TRectype& rec, bool readonly)
|
||||
{
|
||||
for(int recs = 0; rec.fieldname(recs) != NULL; recs++);
|
||||
|
Loading…
x
Reference in New Issue
Block a user