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; /// /// ultimo comando letto da link button /// public string lastCmd { get; set; } protected void Page_Load(object sender, EventArgs e) { } /// /// Impostazione dimensione pagina /// 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; } /// /// Gestione condominio /// public string idxCond { get { return hfCondominio.Value; } set { hfCondominio.Value = value; } } /// /// Min stato filtraggio /// public string StatoMin { get { return hfStatoMin.Value; } set { hfStatoMin.Value = value; } } /// /// Max stato filtraggio /// public string StatoMax { get { return hfStatoMax.Value; } set { hfStatoMax.Value = value; } } /// /// Selezionato un condominio --> riporto selezione /// /// /// 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)); } /// /// Verifica se sia scaduta /// /// /// 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; } /// /// Css x colorazione in abse a scadenza /// /// /// public string getCssScad(object _dataScad) { string answ = "text-danger"; DateTime dataScad; //dataRich = DateTime.Today; //dataScad = dataRich; try { DateTime.TryParse(_dataScad.ToString(), out dataScad); if (dataScad >= DateTime.Now) { answ = "text-success"; } } catch { } 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; } } } /// /// Evento parametrico sel condominio /// public class SelCondEventArgs : EventArgs { public SelCondEventArgs(int newIdxCond) { idxCond = newIdxCond; } public int idxCond { get; set; } } }