Files
b2bcondomini.it/PUB/WebUserContols/mod_anagCond.ascx.cs
T
2018-09-18 20:10:11 +02:00

222 lines
5.7 KiB
C#

using Data;
using SteamWare;
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();
checkAdd();
}
private void checkAdd()
{
int _idxAmm = 0;
int.TryParse(ddlAmmin.SelectedValue, out _idxAmm);
// controllo se mostrare add perché ho condominio + enable add..
lbtAdd.Visible = (enableAdd && isPBO && hasPBO && (_idxAmm > 0));
}
/// <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();
checkAdd();
}
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
{
// sollevo evento nuovo valore...
if (eh_selected != null)
{
eh_selected(this, new EventArgs());
}
}
protected string eaKey
{
get
{
return string.Format("enableAdd_{0}", titolo);
}
}
/// <summary>
/// Flag per permettere aggiunta nuovi record
/// </summary>
public bool enableAdd
{
get
{
return memLayer.ML.BoolSessionObj(eaKey);
}
set
{
memLayer.ML.setSessionVal(eaKey, value);
}
}
/// <summary>
/// Gestione aggiunta record
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbtAdd_Click(object sender, EventArgs e)
{
int _idxAmm = 0;
int.TryParse(ddlAmmin.SelectedValue, out _idxAmm);
if (_idxAmm > 0)
{
// creazione NUOVO condominio e messa in selezione dello stesso...
DateTime adesso = DateTime.Now;
string nomeCond = string.Format("NuovoCondominio_{0:yyyyMMddHHmmss}", adesso);
string codCond = string.Format("UNKN.{0:yyyyMMddHHmmss}", adesso);
DtProxy.man.taAC.insertQuery(codCond, nomeCond, idxAmm);
// salvo ricerca e ricarico
searchVal = "NuovoCondominio";
Response.Redirect(devicesAuthProxy.pagCorrente);
}
}
public string searchVal
{
get
{
return memLayer.ML.StringSessionObj("siteSearchVal");
}
set
{
memLayer.ML.setSessionVal("siteSearchVal", value);
}
}
protected void ods_Updating(object sender, System.Web.UI.WebControls.ObjectDataSourceMethodEventArgs e)
{
// cerco i valori vuoti...
if (e.InputParameters["indirizzo"] is null)
{
e.InputParameters["indirizzo"] = "-";
}
if (e.InputParameters["cap"] is null)
{
e.InputParameters["cap"] = "00000";
}
if (e.InputParameters["citta"] is null)
{
e.InputParameters["citta"] = "-";
}
if (e.InputParameters["cod_fisc"] is null)
{
e.InputParameters["cod_fisc"] = "0000000000";
}
if (e.InputParameters["note"] is null)
{
e.InputParameters["note"] = "-";
}
// controllo se cod_cond contiene CODICE_GRUPPO.CODICE_CONDOMINIO, sennò crea come "TUTTI"."idx"...
if (e.InputParameters["cod_cond"] is null)
{
e.InputParameters["cod_cond"] = "UNKN.0000";
}
else
{
// verifico abbia DOPPIO CODICE A.B
string currVal = e.InputParameters["cod_cond"].ToString();
if (!currVal.Contains("."))
{
currVal = "UNKN." + currVal;
}
else if (currVal.StartsWith("."))
{
currVal = "UNKN" + currVal;
}
e.InputParameters["cod_cond"] = currVal;
}
}
}
}