Files
b2bcondomini.it/PUB/WebUserContols/mod_anagCond.ascx.cs
T
Samuele E. Locatelli 0ddb3b9aa5 fix selezione condomini
2018-08-14 17:28:16 +02:00

109 lines
2.7 KiB
C#

using Data;
using System;
using System.Web.UI;
namespace PUB.WebUserContols
{
public partial class mod_anagCond : BaseUserControl
{
/// <summary>
/// indicato (nuovo) numero righe x pagina
/// </summary>
public event EventHandler eh_selected;
/// <summary>
/// indicato (nuovo) numero righe x pagina
/// </summary>
public event EventHandler eh_reset;
/// <summary>
/// caricamento pagina
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
grView.PageSize = cmp_numRow.numRowPag;
hfIdxCond.Value = mod_ER_selCondominio.condSelected;
}
cmp_numRow.eh_newNum += Cmp_numRow_eh_newNum;
mod_ER_selCondominio.eh_selected += Mod_ER_selCondominio_eh_selected;
checkAuth();
}
/// <summary>
/// verifica autorizzaizoni (PBO / PAM...)
/// </summary>
private void checkAuth()
{
ddlAmmin.Enabled = (isPBO && hasPBO);
if (isPAM) ddlAmmin.SelectedValue = idxAmm.ToString();
}
private void Mod_ER_selCondominio_eh_selected(object sender, EventArgs e)
{
hfIdxCond.Value = mod_ER_selCondominio.condSelected;
}
private void Cmp_numRow_eh_newNum(object sender, EventArgs e)
{
grView.PageSize = cmp_numRow.numRowPag;
}
/// <summary>
/// Update num righe selezionate
/// </summary>
private void updNumRows()
{
int rowCount = 0;
rowCount = grView.PageSize * grView.PageCount;
lblNumRecords.Text = string.Format("~{0} rec", rowCount);
}
protected void lbtReset_Click(object sender, EventArgs e)
{
grView.SelectedIndex = -1;
grView.DataBind();
// sollevo evento nuovo valore...
if (eh_reset != null)
{
eh_reset(this, new EventArgs());
}
}
public void doUpdate()
{
grView.DataBind();
}
public int idxCond
{
get
{
int answ = 0;
int.TryParse(grView.SelectedValue.ToString(), out answ);
return answ;
}
}
protected void grView_DataBound(object sender, EventArgs e)
{
updNumRows();
}
protected void ddlAmmin_SelectedIndexChanged(object sender, EventArgs e)
{
// salvo amministratore
int _idxAmm = 0;
int.TryParse(ddlAmmin.SelectedValue, out _idxAmm);
idxAmm = _idxAmm;
// aggiorno...
doUpdate();
}
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
{
// sollevo evento nuovo valore...
if (eh_selected != null)
{
eh_selected(this, new EventArgs());
}
}
}
}