COmpletata review ADM x ridurre chiamate DB

This commit is contained in:
Samuele Locatelli
2022-01-13 12:03:00 +01:00
parent 9eff559e8a
commit f82dcb7aa4
3 changed files with 39 additions and 15 deletions
+2 -2
View File
@@ -34,7 +34,7 @@
</div>
</div>
<div class="card-body">
<asp:GridView ID="grView" runat="server" AllowSorting="True" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="idxFase" DataSourceID="ods" CssClass="table table-sm table-striped" OnDataBound="grView_DataBound" OnSelectedIndexChanged="grView_SelectedIndexChanged">
<asp:GridView ID="grView" runat="server" AllowSorting="True" AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="idxFase" DataSourceID="ods" CssClass="table table-sm table-striped textCondens" OnDataBound="grView_DataBound" OnSelectedIndexChanged="grView_SelectedIndexChanged">
<EditRowStyle CssClass="table-primary" />
<SelectedRowStyle CssClass="table-info" />
<HeaderStyle CssClass="default" />
@@ -187,7 +187,7 @@
</asp:TemplateField>
<asp:TemplateField ShowHeader="False" ItemStyle-HorizontalAlign="Right">
<ItemTemplate>
<asp:LinkButton runat="server" ID="lbtDelete" CssClass="btn btn-sm btn-danger" CausesValidation="False" CommandArgument='<%# Eval("idxFase") %>' CommandName="Delete" ToolTip='<%# traduci("Delete") %>' Visible='<%# delEnabled(Eval("idxFase")) && chkLicOk %>'><i class="fa fa-trash" aria-hidden="true"></i></asp:LinkButton>
<asp:LinkButton runat="server" ID="lbtDelete" CssClass="btn btn-sm btn-danger" CausesValidation="False" CommandArgument='<%# Eval("idxFase") %>' CommandName="Delete" ToolTip='<%# traduci("Delete") %>' Visible='<%# delEnabled(Eval("totOre"),Eval("idxFase")) && chkLicOk %>'><i class="fa fa-trash" aria-hidden="true"></i></asp:LinkButton>
<asp:ConfirmButtonExtender ID="cbeDelete" runat="server" ConfirmText='<%# traduci("confermaDel")%>' TargetControlID="lbtDelete"></asp:ConfirmButtonExtender>
</ItemTemplate>
<EditItemTemplate>
+36 -12
View File
@@ -524,32 +524,56 @@ namespace GPW_Admin.WebUserControls
}
/// <summary>
/// determina se sia eliminabile il record (=non usato)
/// Determina se sia eliminabile il record (=non ha ore caricate ne fasi)
/// </summary>
/// <param name="idxMaker"></param>
/// <param name="_totOre"></param>
/// <param name="_idxFase"></param>
/// <returns></returns>
public bool delEnabled(object idxObj)
public bool delEnabled(object _totOre, object _idxFase)
{
bool answ = isWritable();
// solo se ha diritti scrittura controllo
if (idxObj != null)
if (answ && _totOre != null && _idxFase != null)
{
double numOre = 0;
_ = Double.TryParse($"{_totOre}", out numOre);
answ = (numOre == 0);
// se fosse true --> procedo con controllo fasi
if (answ)
{
int trovati = 0;
int idxFase = 0;
_ = int.TryParse(idxObj.ToString(), out idxFase);
trovati = DataProxy.DP.taRA.getByFase(idxFase).Count;
// controllo se ci sono record correlati...
if (trovati > 0)
{
answ = false;
}
_ = int.TryParse($"{_idxFase}", out idxFase);
answ = !hasChildObj(idxFase);
}
}
return answ;
}
/// <summary>
/// Determina se abbia child obj --> NON eliminabile
/// </summary>
/// <param name="idxFase"></param>
/// <returns></returns>
public bool hasChildObj(int idxFase)
{
bool answ = false;
string redKey = memLayer.ML.redHash($"faseHasChildObj:{idxFase}");
// cerco inc ache redis...
string rawData = memLayer.ML.getRSV(redKey);
if (rawData == null)
{
int trovati = DataProxy.DP.taRA.getByFase(this.idxFase).Count;
answ = (trovati > 0);
memLayer.ML.setRSV(redKey, $"{answ}", 60 * 5);
}
else
{
bool.TryParse(rawData, out answ);
}
return answ;
}
/// <summary>
/// effettua update controllo
/// </summary>
@@ -634,7 +634,7 @@ namespace GPW_Admin.WebUserControls
{
bool answ = isWritable();
// solo se ha diritti scrittura controllo
if (totOre != null && answ)
if (answ && totOre != null && idxProj !=null)
{
double numOre = 0;
_ = Double.TryParse($"{totOre}", out numOre);