156 lines
3.5 KiB
C#
156 lines
3.5 KiB
C#
using SteamWare;
|
|
using System;
|
|
using System.Web.UI.WebControls;
|
|
|
|
|
|
namespace NKC_WF.WebUserControls
|
|
{
|
|
public partial class mod_vocabolario : ApplicationUserControl
|
|
{
|
|
|
|
#region gestione eventi
|
|
|
|
public event EventHandler eh_selezioneValore;
|
|
public event EventHandler eh_resetSelezione;
|
|
|
|
#endregion
|
|
|
|
#region protected
|
|
|
|
protected override void traduciObj()
|
|
{
|
|
base.traduciObj();
|
|
btnNewLemma.Text = user_std.UtSn.Traduci("btnNewLemma");
|
|
txtNewLemma.Text = "";
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// inserisco nel db il nuovo lemma...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnNewLemma_Click(object sender, EventArgs e)
|
|
{
|
|
creaNuovoLemma();
|
|
}
|
|
/// <summary>
|
|
/// creazione nuovo lemma
|
|
/// </summary>
|
|
private void creaNuovoLemma()
|
|
{
|
|
if (txtNewLemma.Text != "")
|
|
{
|
|
// inserisco
|
|
DataWrap.DW.creaNuovoLemmaVoc(txtNewLemma.Text.Trim());
|
|
// metto in campo ricerca...
|
|
memLayer.ML.setSessionVal("valoreCercato", txtNewLemma.Text.Trim());
|
|
// svuoto campo text
|
|
txtNewLemma.Text = "";
|
|
// aggiorno il vocabolario in memoria...
|
|
DataWrap.DW.resetVocabolario();
|
|
// riparto...
|
|
Response.Redirect(_paginaCorrente);
|
|
}
|
|
}
|
|
|
|
protected override void aggiornaControlliDataGL()
|
|
{
|
|
base.aggiornaControlliDataGL();
|
|
ods.DataBind();
|
|
}
|
|
/// <summary>
|
|
/// dimensione pagina grid view
|
|
/// </summary>
|
|
public int pageSize
|
|
{
|
|
get
|
|
{
|
|
return grView.PageSize;
|
|
}
|
|
set
|
|
{
|
|
grView.PageSize = value;
|
|
}
|
|
}
|
|
|
|
protected void grView_DataBound(object sender, EventArgs e)
|
|
{
|
|
if (grView.Rows.Count > 0)
|
|
{
|
|
LinkButton lb;
|
|
// aggiorno gli headers
|
|
foreach (TableCell cella in grView.HeaderRow.Cells)
|
|
{
|
|
try
|
|
{
|
|
lb = (LinkButton)cella.Controls[0];
|
|
lb.Text = traduci(lb.Text);
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
int totRecord = grView.Rows.Count + grView.PageSize * (grView.PageCount - 1);
|
|
lblNumRec.Text = string.Format("{0} records of ~ {1}", grView.Rows.Count, totRecord);
|
|
}
|
|
else
|
|
{
|
|
lblNumRec.Text = "";
|
|
}
|
|
}
|
|
|
|
protected void btnReset_Click(object sender, EventArgs e)
|
|
{
|
|
resetSelezione();
|
|
}
|
|
|
|
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
selezionatoValore();
|
|
}
|
|
|
|
private void selezionatoValore()
|
|
{
|
|
SteamWare.memLayer.ML.setSessionVal("lemma_sel", grView.SelectedDataKey.Values[1]);
|
|
if (eh_selezioneValore != null)
|
|
{
|
|
eh_selezioneValore(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
protected void grView_RowEditing(object sender, GridViewEditEventArgs e)
|
|
{
|
|
// seleziono la riga corrente...
|
|
grView.SelectedIndex = e.NewEditIndex;
|
|
selezionatoValore();
|
|
}
|
|
|
|
protected void ods_Updated(object sender, ObjectDataSourceStatusEventArgs e)
|
|
{
|
|
selezionatoValore();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region area public
|
|
|
|
/// <summary>
|
|
/// resetta la selezione dei valori in caso di modifiche su altri controlli
|
|
/// </summary>
|
|
public void resetSelezione()
|
|
{
|
|
SteamWare.memLayer.ML.emptySessionVal("lemma_sel");
|
|
grView.SelectedIndex = -1;
|
|
grView.DataBind();
|
|
if (eh_resetSelezione != null)
|
|
{
|
|
eh_resetSelezione(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
|