From 2af2e1edafa18c95c65bde25d4af81608cce3114 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 25 Mar 2024 18:51:00 +0100 Subject: [PATCH] Aggiunto mass editing approvazione timb --- GPW_Admin/Web.config | 1 + .../WebUserControls/mod_approvaTimbr.ascx | 8 + .../WebUserControls/mod_approvaTimbr.ascx.cs | 285 +++++++++++++----- GPW_Admin/tags.aspx.cs | 3 - 4 files changed, 212 insertions(+), 85 deletions(-) diff --git a/GPW_Admin/Web.config b/GPW_Admin/Web.config index 93f3da9..aa72fd0 100644 --- a/GPW_Admin/Web.config +++ b/GPW_Admin/Web.config @@ -45,6 +45,7 @@ + diff --git a/GPW_Admin/WebUserControls/mod_approvaTimbr.ascx b/GPW_Admin/WebUserControls/mod_approvaTimbr.ascx index 006ecc8..79c1e59 100644 --- a/GPW_Admin/WebUserControls/mod_approvaTimbr.ascx +++ b/GPW_Admin/WebUserControls/mod_approvaTimbr.ascx @@ -31,18 +31,26 @@ + + + Appr + + + + diff --git a/GPW_Admin/WebUserControls/mod_approvaTimbr.ascx.cs b/GPW_Admin/WebUserControls/mod_approvaTimbr.ascx.cs index 579156f..8e7c1b3 100644 --- a/GPW_Admin/WebUserControls/mod_approvaTimbr.ascx.cs +++ b/GPW_Admin/WebUserControls/mod_approvaTimbr.ascx.cs @@ -1,6 +1,8 @@ using GPW_data; using SteamWare; using System; +using System.Data; +using System.Web; using System.Web.UI; using System.Web.UI.WebControls; @@ -8,6 +10,95 @@ namespace GPW_Admin.WebUserControls { public partial class mod_approvaTimbr : BaseUserControl { + #region Public Properties + + /// + /// verifica se l'utente possa approvare la modifica oraria + /// + public bool userCanApprove + { + get + { + bool answ = false; + try + { + answ = user_std.UtSn.userHasRight("GPW_admin") && chkLicOk; + } + catch + { } + return answ; + } + } + + /// + /// restituisce info se utente sia admin (vedi web.config x ruolo...) + /// + public bool userIsAdmin + { + get + { + bool answ = false; + try + { + string adminRole = memLayer.ML.confReadString("adminRole"); + answ = user_std.UtSn.userHasRight(adminRole); + } + catch + { } + return answ; + } + } + + #endregion Public Properties + + #region Public Methods + + /// + /// calcola cognome-nome da idx + /// + /// + /// + public string cognomeNome(object idxDip) + { + string answ = ""; + try + { + int IdxDipendente = 0; + if (int.TryParse($"{idxDip}", out IdxDipendente)) + { + answ = DataProxy.DP.cognomeNomeByIdx(IdxDipendente); + } + } + catch + { } + return answ; + } + + public void doUpdate() + { + grView.PageSize = utils.pageSize; + grView.DataBind(); + } + + /// + /// inverte valore booleano + /// + /// + /// + public bool invBool(object valore) + { + bool answ = true; + try + { + answ = !Convert.ToBoolean(valore); + } + catch + { } + return answ; + } + + #endregion Public Methods + #region Protected Properties /// @@ -34,63 +125,107 @@ namespace GPW_Admin.WebUserControls #endregion Protected Properties - #region Public Properties + #region Protected Methods /// - /// verifica se l'utente possa approvare la modifica oraria - /// - public bool userCanApprove - { - get - { - bool answ = false; - try - { - answ = user_std.UtSn.userHasRight("GPW_admin") && chkLicOk; - } - catch - { } - return answ; - } - } - - #endregion Public Properties - - #region Private Methods - - /// - /// imposto ODS - /// - private void checkFixOds() - { - if (filtroDip.valoreInt != -1) - { - IdxDipSel = filtroDip.valoreInt; - ods.SelectMethod = "getNonApprByDip"; - } - else - { - //memLayer.ML.emptySessionVal("idxDip_sel"); - IdxDipSel = -1; - ods.SelectMethod = "getNonAppr"; - } - grView.DataBind(); - } - - /// - /// seleziono + /// Approva + deseleziona le righe selezionate... /// /// /// - private void filtroDip_eh_selValore(object sender, EventArgs e) + protected void btnApproveSelected_Click(object sender, EventArgs e) { - // imposto ods - checkFixOds(); + if (sender != null) + { + // salvo approvazione + DateTime dataOra = DateTime.Today; + int idxDip = 0; + foreach (GridViewRow riga in grView.Rows) + { + if (((CheckBox)riga.FindControl("chkSelect")).Checked) + { + idxDip = 0; + try + { + dataOra = Convert.ToDateTime(((Label)riga.FindControl("lblDataOra")).Text); + idxDip = Convert.ToInt32(((Label)riga.FindControl("lblIdxDip")).Text); + logger.lg.scriviLog(string.Format("Approvazione per dip {0} in data/ora {1}", idxDip, dataOra), tipoLog.INFO); + } + catch (Exception exc) + { + logger.lg.scriviLog($"Eccezione durante recupero dati dip/data-ora in approva timbr{Environment.NewLine}{exc}"); + } + if (idxDip > 0) + { + // recupero tab timbr non approvate x dip + DS_Applicazione.TimbratureRow rigaTimb = DataProxy.DP.taTimb.getByDipDataOra(idxDip, dataOra)[0]; + // effettua arrotondamento (aggiunge/toglie) + int minOrig = dataOra.Minute; + int secOrig = dataOra.Second; + int minArr = 0; + int step = Convert.ToInt32(txtArrot.Text); + if (rigaTimb.entrata) + { + minArr = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(minOrig / step))) * step; + } + else + { + minArr = Convert.ToInt32(Math.Floor(Convert.ToDouble(minOrig / step))) * step; + } + try + { + // modifico data del record + DataProxy.DP.taTimb.stp_Timbr_modifica(idxDip, dataOra, dataOra.AddMinutes(minArr - minOrig).AddSeconds(-secOrig)); + } + catch (Exception exc) + { + logger.lg.scriviLog($"Eccezione durante approva timbr{Environment.NewLine}{exc}"); + } + try + { + // approvo con data modificata + DataProxy.DP.taTimb.stp_Timbr_Approva(idxDip, dataOra.AddMinutes(minArr - minOrig).AddSeconds(-secOrig)); + ((CheckBox)riga.FindControl("chkSelect")).Checked = false; + } + catch (Exception exc) + { + logger.lg.scriviLog($"Eccezione durante approva timbr{Environment.NewLine}{exc}"); + } + } + } + } + + // update! + grView.SelectedIndex = -1; + checkFixOds(); + } } - #endregion Private Methods - - #region Protected Methods + /// + /// seleziona/deseleziona le righe indicate... + /// + /// + /// + protected void btnSelAll_Click(object sender, EventArgs e) + { + if (sender != null) + { + // seleziono tutti i valori visibili nel datagrid + CheckBox chkbox = ((CheckBox)sender); + bool isChecked = chkbox.Checked; + if (!isChecked) + { + chkbox.ToolTip = "Seleziona tutti"; + } + else + { + chkbox.ToolTip = "Deseleziona tutti"; + } + foreach (GridViewRow riga in grView.Rows) + { + ((CheckBox)riga.FindControl("chkSelect")).Checked = isChecked; + } + } + } protected void chkshowAll_CheckedChanged(object sender, EventArgs e) { @@ -192,52 +327,38 @@ namespace GPW_Admin.WebUserControls #endregion Protected Methods - #region Public Methods + #region Private Methods /// - /// calcola cognome-nome da idx + /// imposto ODS /// - /// - /// - public string cognomeNome(object idxDip) + private void checkFixOds() { - string answ = ""; - try + if (filtroDip.valoreInt != -1) { - int IdxDipendente = 0; - if (int.TryParse($"{idxDip}", out IdxDipendente)) - { - answ = DataProxy.DP.cognomeNomeByIdx(IdxDipendente); - } + IdxDipSel = filtroDip.valoreInt; + ods.SelectMethod = "getNonApprByDip"; + } + else + { + //memLayer.ML.emptySessionVal("idxDip_sel"); + IdxDipSel = -1; + ods.SelectMethod = "getNonAppr"; } - catch - { } - return answ; - } - - public void doUpdate() - { - grView.PageSize = utils.pageSize; grView.DataBind(); } /// - /// inverte valore booleano + /// seleziono /// - /// - /// - public bool invBool(object valore) + /// + /// + private void filtroDip_eh_selValore(object sender, EventArgs e) { - bool answ = true; - try - { - answ = !Convert.ToBoolean(valore); - } - catch - { } - return answ; + // imposto ods + checkFixOds(); } - #endregion Public Methods + #endregion Private Methods } } \ No newline at end of file diff --git a/GPW_Admin/tags.aspx.cs b/GPW_Admin/tags.aspx.cs index a3c7549..4f534c0 100644 --- a/GPW_Admin/tags.aspx.cs +++ b/GPW_Admin/tags.aspx.cs @@ -14,9 +14,6 @@ namespace GPW_Admin private void Mod_pageSize_eh_nuovaSize(object sender, EventArgs e) { -#if false - mod_adminOrario1.doUpdate(); -#endif } #endregion Private Methods