Files
GPW/GPW_Admin/WebUserControls/cmp_vocabolario.ascx.cs
T

170 lines
4.6 KiB
C#

using SteamWare;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace GPW_Admin.WebUserControls
{
public partial class cmp_vocabolario : ApplicationUserControl
{
#region Public Events
public event EventHandler eh_resetSelezione;
public event EventHandler eh_selezioneValore;
#endregion Public Events
#region Public Properties
/// <summary>
/// dimensione pagina grid view
/// </summary>
public int pageSize
{
get
{
return grView.PageSize;
}
set
{
grView.PageSize = value;
}
}
#endregion Public Properties
#region Private Methods
/// <summary>
/// creazione nuovo lemma
/// </summary>
private void creaNuovoLemma()
{
if (!string.IsNullOrEmpty(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 = "";
try
{
// aggiorno vocabolario
DataWrap.DW.resetVocabolario();
}
catch
{ }
// riparto...
Response.Redirect(_paginaCorrente);
}
}
private void selezionatoValore()
{
SteamWare.memLayer.ML.setSessionVal("lemma_sel", grView.SelectedDataKey.Values[1]);
if (eh_selezioneValore != null)
{
eh_selezioneValore(this, new EventArgs());
}
}
#endregion Private Methods
#region Protected Methods
protected override void aggiornaControlliDataGL()
{
base.aggiornaControlliDataGL();
ods.DataBind();
}
/// <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();
}
protected void btnReset_Click(object sender, EventArgs e)
{
resetSelezione();
}
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 grView_RowEditing(object sender, GridViewEditEventArgs e)
{
// seleziono la riga corrente...
grView.SelectedIndex = e.NewEditIndex;
selezionatoValore();
}
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
{
selezionatoValore();
}
protected void ods_Updated(object sender, ObjectDataSourceStatusEventArgs e)
{
selezionatoValore();
}
protected override void traduciObj()
{
base.traduciObj();
btnNewLemma.Text = traduci("btnNewLemma");
txtNewLemma.Text = "";
}
#endregion Protected Methods
#region Public Methods
/// <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 Public Methods
}
}