Files
WebGIM/GIM_site/WebUserControls/mod_interventoOpMtz.ascx.cs
Samuele E. Locatelli 7d289a3b64 Remove & Sort Using...
pulizia codice...
2017-04-14 16:33:09 +02:00

126 lines
3.7 KiB
C#

using SteamWare;
using System;
using System.Web.UI.WebControls;
public partial class mod_interventoOpMtz : ApplicationUserControl
{
public event EventHandler eh_resetSelezione;
/// <summary>
/// evento dati associati a controllo
/// </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>
/// reset delle selezioni
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnReset_Click(object sender, EventArgs e)
{
resetSelezione();
}
/// <summary>
/// resetta la selezione dei valori in caso di modifiche su altri controlli
/// </summary>
public void resetSelezione()
{
grView.SelectedIndex = -1;
grView.DataBind();
if (eh_resetSelezione != null)
{
eh_resetSelezione(this, new EventArgs());
}
}
/// <summary>
/// seleziono valore in editing...
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void grView_RowEditing(object sender, GridViewEditEventArgs e)
{
// seleziono la riga corrente...
grView.SelectedIndex = e.NewEditIndex;
}
/// <summary>
/// gestione evento inserimento nuovo record standard (se ZERO presenti)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnNewFromEmpty_Click(object sender, EventArgs e)
{
// reset selezione...
resetSelezione();
int numIntMtz = memLayer.ML.IntSessionObj("numIntMtz_sel");
string matr = memLayer.ML.confReadString("defaultMatr");
TA_app.obj.taIntOpMtz.Insert(numIntMtz, matr, 0);
grView.DataBind();
}
/// <summary>
/// restituisce un booleano se sia abilitato inserimento nuovi valori (solo se NON C'E' GIA' un operatore con amtricola di default...)
/// </summary>
/// <returns></returns>
public bool canInsertNew()
{
bool answ = false;
int numIntMtz = memLayer.ML.IntSessionObj("numIntMtz_sel");
string matr = memLayer.ML.confReadString("defaultMatr");
try
{
answ = (TA_app.obj.taIntOpMtz.getByMatrNumIntMtz(numIntMtz, matr).Rows.Count == 0);
}
catch
{ }
return (answ && isOnEdit);
}
/// <summary>
/// restituisce true se il controllo è in modalità editing (e non selezione...)
/// </summary>
public bool isOnEdit
{
get
{
return _vistaModulo == tipoVistaMod.editing;
}
}
/// <summary>
/// traduce matricola in matr + cognome + nome
/// </summary>
/// <param name="matr"></param>
/// <returns></returns>
public string traduciMatrOp(object matr)
{
string answ = "";
try
{
answ = TA_app.obj.taSelMatrOp.getByValue(matr.ToString())[0].label;
}
catch
{ }
return answ;
}
}