Test disattivazione licenzax delete dipendente
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="mod_adminDipendenti.ascx.cs" Inherits="GPW_Admin.WebUserControls.mod_adminDipendenti" %>
|
||||
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
|
||||
<% if (false)
|
||||
{ %>
|
||||
<link href="~/css/Style.css" rel="stylesheet" type="text/css" />
|
||||
<% } %>
|
||||
|
||||
<div class="d-flex justify-content-between text-right table-secondary">
|
||||
<div class="p-2">
|
||||
@@ -301,7 +297,7 @@
|
||||
</asp:TemplateField>
|
||||
</Columns>
|
||||
</asp:GridView>
|
||||
<asp:ObjectDataSource ID="ods" runat="server" OnInserting="recuperaFooter" DeleteMethod="deleteQuery" InsertMethod="insertQuery" OldValuesParameterFormatString="original_{0}" SelectMethod="getAttivi" TypeName="GPW_data.DS_ApplicazioneTableAdapters.DipendentiTableAdapter" UpdateMethod="updateQuery" FilterExpression=" (Cognome like '%{0}%') OR (Nome like '%{0}%') OR (CF like '%{0}%') OR (matricola like '%{0}%') OR (email like '%{0}%') " OnUpdating="ods_Updating">
|
||||
<asp:ObjectDataSource ID="ods" runat="server" OnInserting="recuperaFooter" DeleteMethod="deleteQuery" InsertMethod="insertQuery" OldValuesParameterFormatString="original_{0}" SelectMethod="getAttivi" TypeName="GPW_data.DS_ApplicazioneTableAdapters.DipendentiTableAdapter" UpdateMethod="updateQuery" FilterExpression=" (Cognome like '%{0}%') OR (Nome like '%{0}%') OR (CF like '%{0}%') OR (matricola like '%{0}%') OR (email like '%{0}%') " OnUpdating="ods_Updating" OnDeleting="ods_Deleting">
|
||||
<FilterParameters>
|
||||
<asp:SessionParameter SessionField="valoreSearch" Type="String" />
|
||||
</FilterParameters>
|
||||
|
||||
@@ -317,6 +317,50 @@ namespace GPW_Admin.WebUserControls
|
||||
showTickets = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// check licenze in fase di eliminazione...
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void ods_Deleting(object sender, ObjectDataSourceMethodEventArgs e)
|
||||
{
|
||||
if (e != null)
|
||||
{
|
||||
// cerco!
|
||||
if (e.InputParameters["Original_idxDipendente"] != null)
|
||||
{
|
||||
string origIdxDip = $"{e.InputParameters["Original_idxDipendente"]}";
|
||||
int idxDip = 0;
|
||||
int.TryParse(origIdxDip, out idxDip);
|
||||
if (idxDip > 0)
|
||||
{
|
||||
// disattivo la licenza corrente...
|
||||
var localUserList = licenzeGPW.getDipAttivi();
|
||||
var currUser = localUserList.Where(x => x.idxDipendente == idxDip).FirstOrDefault();
|
||||
|
||||
// verifico SE sia disponibile licenza...
|
||||
var activationsList = licenzeGPW.ListaAttivazioni;
|
||||
var currHash = DataProxy.DP.hashCodImpiego(currUser);
|
||||
var currAct = activationsList.Where(x => x.CodImpiego == currHash).FirstOrDefault();
|
||||
bool fatto = true;
|
||||
if (currAct != null)
|
||||
{
|
||||
// riesegue controllo ed disattiva
|
||||
Dictionary<string, string> ParamList = new Dictionary<string, string>();
|
||||
ParamList.Add(currAct.CodImpiego, currAct.Chiave);
|
||||
fatto = licenzeGPW.tryDeactivation(ParamList).Result;
|
||||
}
|
||||
licenzeGPW.resetDipAttivi();
|
||||
// se NON ha disattivato NON elimina dipendente...
|
||||
if (!fatto)
|
||||
{
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// check licenze in fase di update...
|
||||
/// </summary>
|
||||
@@ -367,20 +411,6 @@ namespace GPW_Admin.WebUserControls
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Verifica data assunzione valida = ultimi 60 anni...
|
||||
/// </summary>
|
||||
/// <param name="dtAss"></param>
|
||||
/// <returns></returns>
|
||||
public bool checkDataAssunzione(object dtAss)
|
||||
{
|
||||
bool answ = false;
|
||||
DateTime oggi = DateTime.Today;
|
||||
DateTime dataAss = oggi.AddYears(-100);
|
||||
DateTime.TryParse($"{dtAss}", out dataAss);
|
||||
answ = (oggi.Subtract(dataAss).TotalDays < 365 * 60);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// caricamento
|
||||
@@ -475,6 +505,21 @@ namespace GPW_Admin.WebUserControls
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Verifica data assunzione valida = ultimi 60 anni...
|
||||
/// </summary>
|
||||
/// <param name="dtAss"></param>
|
||||
/// <returns></returns>
|
||||
public bool checkDataAssunzione(object dtAss)
|
||||
{
|
||||
bool answ = false;
|
||||
DateTime oggi = DateTime.Today;
|
||||
DateTime dataAss = oggi.AddYears(-100);
|
||||
DateTime.TryParse($"{dtAss}", out dataAss);
|
||||
answ = (oggi.Subtract(dataAss).TotalDays < 365 * 60);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica licenza (se sia libera x modifica o prima associazione)
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user