Files
WebGIM/GIM_site/WebUserControls/mod_mtzPrevPending.ascx.cs

157 lines
4.1 KiB
C#

using SteamWare;
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class mod_mtzPrevPending : 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 = "";
}
}
protected override void Page_Load(object sender, EventArgs e)
{
base.Page_Load(sender, e);
if (!Page.IsPostBack)
{
chkAnticipaEnabled.DataBind();
btnCreateInt.DataBind();
hlExportExcel.Text = traduci("hlExportExcel");
hlExportExcel.NavigateUrl = "~/ExcelExportMtzPrevPending";
// verifico se devo generare degli interventi di MTZ programmata..
try
{
mtzProgr.obj.processaCodaMtzPro();
}
catch (Exception errore)
{
SteamWare.logger.lg.scriviLog(string.Format("Non sono riuscito ad accodare gli interventi di mtz preventiva pending, errore:\r\n {0}", errore), SteamWare.tipoLog.EXCEPTION);
}
}
}
/// <summary>
/// aggiorno il controllo
/// </summary>
public void doUpdate()
{
checkFixOds();
//grView.DataBind();
}
/// <summary>
/// sistemo filtraggio con valori selezionati
/// </summary>
private void checkFixOds()
{
ods.DataBind();
}
/// <summary>
/// fix filtro post cambio pagina
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void grView_PageIndexChanged(object sender, EventArgs e)
{
doUpdate();
}
/// <summary>
/// seleziona/deseleziona le righe indicate...
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSelAll_Click(object sender, EventArgs e)
{
// seleziono tutti i valori visibili nel datagrid
CheckBox chkbox = ((CheckBox)sender);
bool isChecked = chkbox.Checked;
if (!isChecked)
{
chkbox.ToolTip = traduci("btnSelAll");
}
else
{
chkbox.ToolTip = traduci("btnDeselAll");
}
foreach (GridViewRow riga in grView.Rows)
{
((CheckBox)riga.FindControl("chkSelect")).Checked = isChecked;
}
}
/// <summary>
/// Gestione click pulsante "abilita anticipo"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void chkAnticipaEnabled_CheckedChanged(object sender, EventArgs e)
{
// seleziono tutti i valori visibili nel datagrid
CheckBox chkbox = ((CheckBox)sender);
bool isChecked = chkbox.Checked;
btnCreateInt.Visible = isChecked;
if (!isChecked)
{
chkbox.Text = traduci("AbilitaAnticipo");
}
else
{
chkbox.Text = traduci("DisabilitaAnticipo");
}
// aggiorno il gridview...
grView.DataBind();
}
/// <summary>
/// Richiesta generazione anticipo interventi selezionati
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnCreateInt_Click(object sender, EventArgs e)
{
int idxIntervento = 0;
foreach (GridViewRow riga in grView.Rows)
{
if (((CheckBox)riga.FindControl("chkSelect")).Checked)
{
try
{
idxIntervento = Convert.ToInt32(((Label)riga.FindControl("lblidxPending")).Text);
}
catch
{ }
if (idxIntervento > 0)
{
// genero intervento selezionato e predispongo NUOVA schedulazione..
mtzProgr.obj.anticipaIntervento(idxIntervento);
}
}
}
grView.DataBind();
}
}