Files
WebGIM/WebSites/WebGIM/WebUserControls/mod_elencoMtzProg.ascx.cs
T
ermanno a350653708 ripulito codice dai commenti
git-svn-id: https://keyhammer.ath.cx/svn/WebGIM/trunk@152 3e04ef4b-3b25-4b6c-be27-bb5389ca777b
2009-11-25 16:17:12 +00:00

238 lines
7.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SteamWare;
using System.Data;
public partial class mod_elencoMtzProg : ApplicationUserControl
{
#region gestione eventi
public event EventHandler eh_newReq;
public event EventHandler eh_resetSelezione;
public event EventHandler eh_selValore;
#endregion
protected string _idxGridView;
/// <summary>
/// traduzioni
/// </summary>
protected override void traduciObj()
{
base.traduciObj();
btnShowNew.Text = traduci("btnShowNew");
//lblFiltMacchina.Text = traduci("lblFiltMacchina");
//lblFiltTipo.Text = traduci("lblFiltTipo");
}
/// <summary>
/// cambio visibilità pannello new data
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnShowNew_Click(object sender, EventArgs e)
{
if (btnShowNew.Text == traduci("btnHideNew"))
{
btnShowNew.Text = traduci("btnShowNew");
}
else
{
btnShowNew.Text = traduci("btnHideNew");
}
// chiamo evento
if (eh_newReq != null)
{
eh_newReq(this, new EventArgs());
}
}
/// <summary>
/// aggiorno il controllo
/// </summary>
public void doUpdate()
{
checkFixOds();
grView.DataBind();
}
/// <summary>
/// reset della selezione
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnReset_Click(object sender, EventArgs e)
{
resetSelezione();
}
/// <summary>
/// gestione cambio selezione valore
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
{
// salvo in session il valore selezionato...
SteamWare.memLayer.ML.setSessionVal(string.Format("{0}_sel", _idxGridView), grView.SelectedValue);
// sollevo evento nuovo valore...
if (eh_selValore != null)
{
eh_selValore(this, new EventArgs());
}
}
/// <summary>
/// resetta la selezione dei valori in caso di modifiche su altri controlli
/// </summary>
public void resetSelezione()
{
SteamWare.memLayer.ML.emptySessionVal(string.Format("{0}_sel", _idxGridView));
grView.SelectedIndex = -1;
grView.DataBind();
lblWarning.Visible = false;
if (eh_resetSelezione != null)
{
eh_resetSelezione(this, new EventArgs());
}
}
/// <summary>
/// restituisce un testo trimamto a maxChar caratteri
/// </summary>
/// <param name="testo"></param>
/// <param name="maxChar"></param>
/// <returns></returns>
public string trimmaTesto(object _testo, object _maxChar)
{
string answ = "";
string testo = _testo.ToString();
int maxChar = Convert.ToInt32(_maxChar);
if (testo.Length <= maxChar)
{
answ = testo;
}
else
{
answ = string.Format("{0}...", testo.Substring(0, maxChar));
}
return answ;
}
/// <summary>
/// traduce gli header delle colonne
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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 = "";
}
}
/// <summary>
/// setta selected alla riga il cui valore key è in session
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void grView_RowDataBound(object sender, GridViewRowEventArgs e)
{
// se riga di dati...
if (e.Row.RowType == DataControlRowType.DataRow)
{
// ottengo la riga tipizzata...
System.Data.DataRowView _drv = (System.Data.DataRowView)e.Row.DataItem;
DS_applicazione.v_mtzProgExpRow riga = (DS_applicazione.v_mtzProgExpRow)_drv.Row;
if (SteamWare.memLayer.ML.StringSessionObj(_idxGridView) == riga.idxIntPro.ToString())
{
grView.SelectedIndex = e.Row.RowIndex;
// salvo in session il valore selezionato...
SteamWare.memLayer.ML.setSessionVal(string.Format("{0}_sel", _idxGridView), SteamWare.memLayer.ML.StringSessionObj(_idxGridView));
// sollevo evento nuovo valore...
if (eh_selValore != null)
{
eh_selValore(this, new EventArgs());
}
}
}
}
/// <summary>
/// in caso di aggiornamento verifico se sia salvato un comando clona...
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void grView_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
// carico l'idx dell'oggetto
int _idx = Convert.ToInt32(e.Keys["numIntMtz"]);
string _comando = "";
if (SteamWare.memLayer.ML.isInSessionObject("nextObjCommand"))
{
_comando = SteamWare.memLayer.ML.StringSessionObj("nextObjCommand");
SteamWare.memLayer.ML.emptySessionVal("nextObjCommand");
}
// verifico il tipo di richiesta (up/down level, clona o update normale
switch (_comando)
{
case "clonaObj":
// blocco update!
e.Cancel = true;
break;
default:
// faccio update!
break;
}
}
/// <summary>
/// inizializzazione valori di default
/// </summary>
/// <param name="e"></param>
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
_idxGridView = "idxIntPro";
}
void mod_filtroMacchina_eh_selValore(object sender, EventArgs e)
{
// chiamo procedura ricostruzione ods con filtri...
checkFixOds();
}
void mod_filtroTipo_eh_selValore(object sender, EventArgs e)
{
// chiamo procedura ricostruzione ods con filtri...
checkFixOds();
}
/// <summary>
/// sistemo filtraggio con valori selezionati
/// </summary>
private void checkFixOds()
{
ods.FilterExpression = "( codMacchina LIKE '%{0}%' OR nomeMacchina LIKE '%{0}%' OR descrizione LIKE '%{0}%' )";
if (memLayer.ML.isInSessionObject("idxTipo_filt"))
{
ods.FilterExpression += " AND (idxTipo = {1})";
}
if (memLayer.ML.isInSessionObject("idxMacchina_filt"))
{
ods.FilterExpression += " AND (idxMacchina = {2})";
}
ods.DataBind();
}
}