Files
SSC/CMS_SC/WebUserControls/mod_vocabolario.ascx.cs

156 lines
3.8 KiB
C#

using SteamWare;
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class mod_vocabolario : SteamWare.UserControl
{
#region gestione eventi
public event EventHandler eh_selezioneValore;
public event EventHandler eh_resetSelezione;
#endregion
#region protected
protected void Page_Load()
{
if (!Page.IsPostBack)
{
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(user_std.pagCorrente);
}
}
/// <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} ({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)
{
DataWrap.DW.resetVocabolario();
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
protected void ods_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
{
DataWrap.DW.resetVocabolario();
selezionatoValore();
}
}