209 lines
6.0 KiB
C#
209 lines
6.0 KiB
C#
using GPW_data;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Data;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace GPW_Admin.WebUserControls
|
|
{
|
|
public partial class cmp_elencoGruppi : BaseUserControl
|
|
{
|
|
#region Public Properties
|
|
|
|
public string gruppoSel
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
if (grView.SelectedIndex >= 0)
|
|
{
|
|
answ = $"{grView.SelectedValue}";
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Methods
|
|
|
|
/// <summary>
|
|
/// gestione evento richiesta nuovo valore (mostra footer, ...)
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnNew_Click(object sender, EventArgs e)
|
|
{
|
|
DataProxy.DP.taGruppi.insertQuery("_New GROUP", "Descrizione", "", true);
|
|
resetSelezione();
|
|
}
|
|
|
|
/// <summary>
|
|
/// reset della selezione
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnReset_Click(object sender, EventArgs e)
|
|
{
|
|
resetSelezione();
|
|
}
|
|
|
|
/// <summary>
|
|
/// elenco colonne del datagrid
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected DataColumnCollection colonneObj()
|
|
{
|
|
DataColumnCollection colonne = null;
|
|
using (
|
|
DS_Applicazione.AnagClientiDataTable tabella = new DS_Applicazione.AnagClientiDataTable())
|
|
{
|
|
colonne = tabella.Columns;
|
|
}
|
|
return colonne;
|
|
}
|
|
|
|
/// <summary>
|
|
/// traduce gli header delle colonne
|
|
/// </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 void grView_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
raiseEvent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// annulla inserimento nuovo valore da footer
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lblCanc_click(object sender, EventArgs e)
|
|
{
|
|
// annullo inserimento: nascondo footer, bind controlli...
|
|
grView.FooterRow.Visible = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// inserisce nuovo valore da footer
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lblIns_click(object sender, EventArgs e)
|
|
{
|
|
// click su inserimento, chiamo il metodo insert dell'ObjectDataSource
|
|
ods.Insert();
|
|
}
|
|
|
|
/// <summary>
|
|
/// check licenze in fase di update...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ods_Updating(object sender, ObjectDataSourceMethodEventArgs e)
|
|
{
|
|
if (!licenzeGPW.checkLicenze)
|
|
{
|
|
if (e != null)
|
|
{
|
|
// annullo insert se licenze sforate...
|
|
e.Cancel = true;
|
|
grView.EditIndex = -1;
|
|
grView.DataBind();
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
grView.PageSize = utils.pageSize;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// determina se sia eliminabile il record (=non usato)
|
|
/// </summary>
|
|
/// <param name="idxMaker"></param>
|
|
/// <returns></returns>
|
|
public bool delEnabled(object gruppo)
|
|
{
|
|
bool answ = true;
|
|
// solo se ha diritti scrittura controllo
|
|
if (gruppo != null)
|
|
{
|
|
answ = !hasChildObj($"{gruppo}");
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
public void doUpdate()
|
|
{
|
|
grView.PageSize = utils.pageSize;
|
|
grView.DataBind();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Determina se abbia child obj --> NON eliminabile
|
|
/// </summary>
|
|
/// <param name="gruppo"></param>
|
|
/// <returns></returns>
|
|
public bool hasChildObj(string gruppo)
|
|
{
|
|
bool answ = false;
|
|
string redKey = memLayer.ML.redHash($"gruppoHasChildObj:{gruppo}");
|
|
// cerco inc ache redis...
|
|
string rawData = memLayer.ML.getRSV(redKey);
|
|
if (rawData == null)
|
|
{
|
|
int trovati = DataProxy.DP.taVSD.getByGruppo(gruppo, false).Rows.Count;
|
|
answ = (trovati > 0);
|
|
memLayer.ML.setRSV(redKey, $"{answ}", 60 * 5);
|
|
}
|
|
else
|
|
{
|
|
bool.TryParse(rawData, out answ);
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// resetta la selezione dei valori in caso di modifiche su altri controlli
|
|
/// </summary>
|
|
public void resetSelezione()
|
|
{
|
|
grView.SelectedIndex = -1;
|
|
grView.DataBind();
|
|
raiseReset();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |