229 lines
5.1 KiB
C#
229 lines
5.1 KiB
C#
using System;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace PUB.WebUserContols
|
|
{
|
|
public partial class mod_ER_grid : System.Web.UI.UserControl
|
|
{
|
|
public event EventHandler eh_selCond;
|
|
/// <summary>
|
|
/// ultimo comando letto da link button
|
|
/// </summary>
|
|
public string lastCmd { get; set; }
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
}
|
|
/// <summary>
|
|
/// Impostazione dimensione pagina
|
|
/// </summary>
|
|
public int pageSize
|
|
{
|
|
get
|
|
{
|
|
return grViewElRich.PageSize;
|
|
}
|
|
set
|
|
{
|
|
grViewElRich.PageSize = value;
|
|
}
|
|
}
|
|
protected void lbtReset_Click(object sender, EventArgs e)
|
|
{
|
|
grViewElRich.EditIndex = -1;
|
|
grViewElRich.SelectedIndex = -1;
|
|
grViewElRich.DataBind();
|
|
}
|
|
|
|
protected void grViewElRich_RowEditing(object sender, GridViewEditEventArgs e)
|
|
{
|
|
// imposto selezione a riga in edit
|
|
grViewElRich.SelectedIndex = -1;
|
|
}
|
|
|
|
protected void grViewElRich_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
|
|
{
|
|
grViewElRich.EditIndex = -1;
|
|
}
|
|
|
|
protected void grViewElRich_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
|
|
{
|
|
grViewElRich.EditIndex = -1;
|
|
grViewElRich.SelectedIndex = -1;
|
|
}
|
|
/// <summary>
|
|
/// Gestione condominio
|
|
/// </summary>
|
|
public string idxCond
|
|
{
|
|
get
|
|
{
|
|
return hfCondominio.Value;
|
|
}
|
|
set
|
|
{
|
|
hfCondominio.Value = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Min stato filtraggio
|
|
/// </summary>
|
|
public string StatoMin
|
|
{
|
|
get
|
|
{
|
|
return hfStatoMin.Value;
|
|
}
|
|
set
|
|
{
|
|
hfStatoMin.Value = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Max stato filtraggio
|
|
/// </summary>
|
|
public string StatoMax
|
|
{
|
|
get
|
|
{
|
|
return hfStatoMax.Value;
|
|
}
|
|
set
|
|
{
|
|
hfStatoMax.Value = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// mostrare SOLO lo stato freezed
|
|
/// -1 = TUTTI, 0 = aperti, 1 = scaduti
|
|
/// </summary>
|
|
public int onlyFreezed
|
|
{
|
|
get
|
|
{
|
|
int answ = -1;
|
|
Int32.TryParse(hfFreezed.Value, out answ);
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
hfFreezed.Value = value.ToString();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// mostrare SOLO lo stato SCADUTO
|
|
/// -1 = TUTTI, 0 = aperti, 1 = scaduti
|
|
/// </summary>
|
|
public int onlyScaduti
|
|
{
|
|
get
|
|
{
|
|
int answ = -1;
|
|
Int32.TryParse(hfScaduto.Value, out answ);
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
hfScaduto.Value = value.ToString();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Selezionato un condominio --> riporto selezione
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbtSelCond_Click(object sender, EventArgs e)
|
|
{
|
|
LinkButton lb = (LinkButton)sender;
|
|
int idxCond = 0;
|
|
int.TryParse(lb.CommandArgument, out idxCond);
|
|
// sollevo evento selezione condominio...
|
|
eh_selCond?.Invoke(this, new SelCondEventArgs(idxCond));
|
|
}
|
|
/// <summary>
|
|
/// Verifica se sia scaduta
|
|
/// </summary>
|
|
/// <param name="_dataScad"></param>
|
|
/// <returns></returns>
|
|
public bool isScad(object _dataScad)
|
|
{
|
|
bool answ = true;
|
|
DateTime dataScad;
|
|
//dataRich = DateTime.Today;
|
|
//dataScad = dataRich;
|
|
try
|
|
{
|
|
DateTime.TryParse(_dataScad.ToString(), out dataScad);
|
|
if (dataScad >= DateTime.Now)
|
|
{
|
|
answ = false;
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// Css x colorazione in base a scadenza
|
|
/// </summary>
|
|
/// <param name="_scaduto"></param>
|
|
/// <returns></returns>
|
|
public string getCssScad(object _scaduto)
|
|
{
|
|
string answ = "text-danger";
|
|
bool scaduto = (_scaduto.ToString() == "1");
|
|
if (!scaduto)
|
|
{
|
|
answ = "text-success";
|
|
}
|
|
#if false
|
|
DateTime dataScad;
|
|
//dataRich = DateTime.Today;
|
|
//dataScad = dataRich;
|
|
try
|
|
{
|
|
DateTime.TryParse(_dataScad.ToString(), out dataScad);
|
|
if (dataScad >= DateTime.Now)
|
|
{
|
|
answ = "text-success";
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
#endif
|
|
return answ;
|
|
}
|
|
|
|
protected void grViewElRich_RowCommand(object sender, GridViewCommandEventArgs e)
|
|
{
|
|
// verifico se sia riassegnazione...
|
|
lastCmd = e.CommandArgument.ToString();
|
|
}
|
|
|
|
protected void grViewElRich_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
// ora verifico se fare redirect...
|
|
switch (lastCmd)
|
|
{
|
|
case "ShowDetail":
|
|
// --> pagina riassegnazione con dettagli...
|
|
Response.Redirect(string.Format("DettaglioIntervento?idxRichiesta={0}", grViewElRich.SelectedDataKey["idxRichiesta"]));
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Evento parametrico sel condominio
|
|
/// </summary>
|
|
public class SelCondEventArgs : EventArgs
|
|
{
|
|
public SelCondEventArgs(int newIdxCond)
|
|
{ idxCond = newIdxCond; }
|
|
public int idxCond { get; set; }
|
|
}
|
|
} |