Patch level : 12.0 560

Files correlati     : sy
Commento            : Modificata manutenzione archivi, aggiunto bottone per aggiornamento di più records

git-svn-id: svn://10.65.10.50/branches/R_10_00@24457 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
mtollari 2018-04-11 07:07:20 +00:00
parent d8eed865bf
commit ece02e7c2d
2 changed files with 76 additions and 3 deletions

View File

@ -1038,6 +1038,8 @@ TSheet::TSheet(short x, short y, short dx, short dy,
{
add_button(DLG_EDIT, TR("~Filtro"), K_CTRL+'F', TOOL_ELABORA);
set_handler(DLG_EDIT, filtro_handler);
add_button(DLG_ARCHIVE, TR("~Modifica"), K_CTRL + 'M', TOOL_WARNING);
set_handler(DLG_ARCHIVE, update_handler);
}
if (buttons & 0x08) add_button(DLG_QUIT, "Fine", K_ESC, TOOL_QUIT);
@ -1494,6 +1496,22 @@ bool TSheet::filtro_handler(TMask_field& f, KEY k)
return true;
}
bool TSheet::update_dialog()
{
return sorry_box("Update non attivabile");
}
bool TSheet::update_handler(TMask_field& f, KEY k)
{
if (k == K_SPACE)
{
TSheet& s = (TSheet&)f.mask();
s.update_dialog();
return false;
}
return true;
}
void TSheet::save_columns_order(const TEdit_field& field)
{ sheet().save_columns_order(field); }
@ -1754,6 +1772,56 @@ bool TCursor_sheet::filter_dialog()
return true;
}
bool TCursor_sheet::update_dialog()
{
TRectype rec = _cursor->curr();
const RecDes& rd = rec.rec_des();
TMask m(TR("Modifica bulk"), 1, 78, 4);
m.add_button_tool(DLG_OK, "", TOOL_OK);
m.add_button_tool(DLG_CANCEL, "", TOOL_CANCEL);
m.add_list(101, 0, "Campo da modificare", 1, 1, 20);
TList_field& lst = m.lfield(101);
int maxsize = 0;
for (int i = 0; i < rd.NFields; i++)
{
const char* fldName = rd.Fd[i].Name;
const int fldSize = rd.Fd[i].Len;
maxsize = maxsize < fldSize ? fldSize : maxsize;
static TString fname;
fname.cut(0) << fldName << "|" << fldName;
lst.add_item(fname);
}
m.add_string(102, 0, "Valore", 1, 2, maxsize, "", 25);
if (m.run() == K_ENTER)
{
TToken_string v;
const long chk = checked();
if (chk && yesno_box(FR("Modificare %ld record?"), chk))
{
const long i = items();
_cursor->freeze();
TString fld = m.get(101);
TString val = m.get(102);
for (TRecnotype j = 0; j < i; j++) if (checked(j))
{
_cursor->operator=(j);
TRectype row = _cursor->curr();
row.put(fld, val);
row.rewrite(_cursor->file());
uncheck(j);
}
_cursor->freeze(false);
// Forza update del cursore
_cursor->set_filterfunction(NULL, true);
if (_cursor->items() > 0)
select(1);
}
}
return true;
}
///////////////////////////////////////////////////////////
// TBrowse_sheet
///////////////////////////////////////////////////////////

View File

@ -32,6 +32,7 @@ protected: // TMask
static bool tutti_handler(TMask_field& f, KEY k);
static bool export_handler(TMask_field& f, KEY k);
static bool filtro_handler(TMask_field& f, KEY k);
static bool update_handler(TMask_field& f, KEY k);
protected:
void reset_parked() { _parked = -1; }
@ -39,9 +40,10 @@ protected:
virtual long get_items() const { return 0L; }
virtual bool get_ini_paragraph(const TEdit_field& owner, TString& parag) const;
virtual bool filter_dialog();
virtual bool update_dialog();
TSheet_control& sheet();
TSheet_control& sheet();
// @cmember Permette di riposizionare i bottoni all'interno della pagina
virtual void repos_buttons() const;
virtual bool get_cell_colors(int row, int col, COLOR& fore, COLOR& back) const;
@ -193,7 +195,6 @@ protected: // TSheet
bool in_key(const TFieldref& fr) const;
virtual bool get_cell_colors(int row, int col, COLOR& fore, COLOR& back) const;
virtual bool filter_dialog();
// @access Public Member
public: // TSheet
@ -203,6 +204,10 @@ public: // TSheet
// @access Public Member
public:
// Valori per modifiche bulk
TToken_string& get_update_val() { return _change_val; }
void set_update_val(TToken_string val) { _change_val = val; }
// @cmember Ritorna il cursore
TCursor* cursor() const
{ return _cursor; }