Aggiunto mass editing approvazione timb
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
<add key="copyRight" value="SteamWare" />
|
||||
<add key="CodModulo" value="GPW" />
|
||||
<add key="_safePages" value="unauthorized#forceUser#login#login.aspx#test#Test.aspx" />
|
||||
<add key="adminRole" value="GPW_admin" />
|
||||
<!--Gestione forzatura priam timbratura ad entrata-->
|
||||
<add key="firstIsIN" value="true" />
|
||||
<!--Gestione notifiche anomalie-->
|
||||
|
||||
@@ -31,18 +31,26 @@
|
||||
</EmptyDataTemplate>
|
||||
<Columns>
|
||||
<asp:TemplateField>
|
||||
<HeaderTemplate>
|
||||
<asp:CheckBox ID="btnSelAll" runat="server" Checked="false" ToolTip="Seleziona tutti" OnCheckedChanged="btnSelAll_Click"
|
||||
AutoPostBack="true" Visible='<%# userIsAdmin %>' />
|
||||
<asp:LinkButton ID="btnApproveSelected" runat="server" CssClass="btn btn-warning py-0" ToolTip="Approva tutte selezionate" OnClick="btnApproveSelected_Click" Visible='<%# userIsAdmin %>'><i class="fa fa-thumbs-o-up" aria-hidden="true"></i> Appr</asp:LinkButton>
|
||||
</HeaderTemplate>
|
||||
<ItemTemplate>
|
||||
<asp:CheckBox ID="chkSelect" runat="server" Visible='<%# userIsAdmin %>' />
|
||||
<asp:LinkButton runat="server" ID="lbApprova" Visible='<%# userCanApprove && chkLicOk %>' Text="Approva" CommandArgument="approva" CommandName="Select" CssClass="btn btn-sm btn-success"><i class="fa fa-check" aria-hidden="true"></i></asp:LinkButton>
|
||||
</ItemTemplate>
|
||||
</asp:TemplateField>
|
||||
<asp:TemplateField ItemStyle-HorizontalAlign="Left" HeaderText="Dipendente">
|
||||
<ItemTemplate>
|
||||
<asp:Label ID="lblDip" runat="server" Text='<%# cognomeNome(Eval("idxDipendente")) %>' Visible='<%# userCanApprove %>' />
|
||||
<asp:Label ID="lblIdxDip" runat="server" Text='<%# Eval("idxDipendente") %>' Visible="false" />
|
||||
</ItemTemplate>
|
||||
</asp:TemplateField>
|
||||
<asp:TemplateField HeaderText="dataOra" SortExpression="dataOra" ItemStyle-Wrap="false" ItemStyle-HorizontalAlign="left">
|
||||
<ItemTemplate>
|
||||
<asp:Label ID="lblData" runat="server" Text='<%# Eval("dataOra", "{0:yyyy-MM-dd, ddd - HH:mm}") %>' />
|
||||
<asp:Label ID="lblDataOra" runat="server" Text='<%# Eval("dataOra", "{0:yyyy-MM-dd HH:mm}") %>' Visible="false" />
|
||||
</ItemTemplate>
|
||||
</asp:TemplateField>
|
||||
<asp:TemplateField ItemStyle-HorizontalAlign="Center">
|
||||
|
||||
@@ -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
|
||||
|
||||
/// <summary>
|
||||
/// verifica se l'utente possa approvare la modifica oraria
|
||||
/// </summary>
|
||||
public bool userCanApprove
|
||||
{
|
||||
get
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
answ = user_std.UtSn.userHasRight("GPW_admin") && chkLicOk;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// restituisce info se utente sia admin (vedi web.config x ruolo...)
|
||||
/// </summary>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// calcola cognome-nome da idx
|
||||
/// </summary>
|
||||
/// <param name="idxDip"></param>
|
||||
/// <returns></returns>
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// inverte valore booleano
|
||||
/// </summary>
|
||||
/// <param name="isEnt"></param>
|
||||
/// <returns></returns>
|
||||
public bool invBool(object valore)
|
||||
{
|
||||
bool answ = true;
|
||||
try
|
||||
{
|
||||
answ = !Convert.ToBoolean(valore);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
/// <summary>
|
||||
@@ -34,63 +125,107 @@ namespace GPW_Admin.WebUserControls
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Public Properties
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// verifica se l'utente possa approvare la modifica oraria
|
||||
/// </summary>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// imposto ODS
|
||||
/// </summary>
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// seleziono
|
||||
/// Approva + deseleziona le righe selezionate...
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
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
|
||||
/// <summary>
|
||||
/// seleziona/deseleziona le righe indicate...
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// calcola cognome-nome da idx
|
||||
/// imposto ODS
|
||||
/// </summary>
|
||||
/// <param name="idxDip"></param>
|
||||
/// <returns></returns>
|
||||
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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// inverte valore booleano
|
||||
/// seleziono
|
||||
/// </summary>
|
||||
/// <param name="isEnt"></param>
|
||||
/// <returns></returns>
|
||||
public bool invBool(object valore)
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user