From 9148c42793c226ccae0b05c02cc6b2ca52ae87a5 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 17 Feb 2022 20:13:53 +0100 Subject: [PATCH] Test disattivazione licenzax delete dipendente --- .../WebUserControls/mod_adminDipendenti.ascx | 6 +- .../mod_adminDipendenti.ascx.cs | 73 +++++++++++++++---- 2 files changed, 60 insertions(+), 19 deletions(-) diff --git a/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx b/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx index 9db66d5..4b03a22 100644 --- a/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx +++ b/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx @@ -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) - { %> - -<% } %>
@@ -301,7 +297,7 @@ - + diff --git a/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx.cs b/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx.cs index 29ce6f2..740c8f5 100644 --- a/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx.cs +++ b/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx.cs @@ -317,6 +317,50 @@ namespace GPW_Admin.WebUserControls showTickets = false; } + /// + /// check licenze in fase di eliminazione... + /// + /// + /// + 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 ParamList = new Dictionary(); + 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; + } + } + } + } + } + /// /// check licenze in fase di update... /// @@ -367,20 +411,6 @@ namespace GPW_Admin.WebUserControls } } } - /// - /// Verifica data assunzione valida = ultimi 60 anni... - /// - /// - /// - 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; - } /// /// caricamento @@ -475,6 +505,21 @@ namespace GPW_Admin.WebUserControls #region Public Methods + /// + /// Verifica data assunzione valida = ultimi 60 anni... + /// + /// + /// + 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; + } + /// /// Verifica licenza (se sia libera x modifica o prima associazione) ///