271 lines
9.0 KiB
C#
271 lines
9.0 KiB
C#
using GPW_data;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Data;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace GPW_Admin.WebUserControls
|
|
{
|
|
public partial class mod_timbrMensili : BaseUserControl
|
|
{
|
|
#region Public Events
|
|
|
|
public event EventHandler eh_resetSelezione;
|
|
|
|
#endregion Public Events
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// imposto ODS
|
|
/// </summary>
|
|
private void checkFixOds()
|
|
{
|
|
memLayer.ML.setSessionVal("idxDip_sel", filtroDip.valoreInt);
|
|
grView.DataBind();
|
|
}
|
|
|
|
/// <summary>
|
|
/// seleziono
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void filtroDip_eh_selValore(object sender, EventArgs e)
|
|
{
|
|
// imposto ods
|
|
checkFixOds();
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
#region Protected Methods
|
|
|
|
/// <summary>
|
|
/// reset della selezione
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnReset_Click(object sender, EventArgs e)
|
|
{
|
|
resetSelezione();
|
|
}
|
|
|
|
/// <summary>
|
|
/// elenco colonne del datagrid
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected DataColumnCollection colonneObj()
|
|
{
|
|
DataColumnCollection colonne = null;
|
|
using (DS_Applicazione.TimbMeseExplDataTable tabella = new DS_Applicazione.TimbMeseExplDataTable())
|
|
{
|
|
colonne = tabella.Columns;
|
|
}
|
|
return colonne;
|
|
}
|
|
|
|
/// <summary>
|
|
/// traduce gli header delle colonne
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grView_DataBound(object sender, EventArgs e)
|
|
{
|
|
if (grView.Rows.Count > 0)
|
|
{
|
|
LinkButton lb;
|
|
// aggiorno gli headers
|
|
foreach (TableCell cella in grView.HeaderRow.Cells)
|
|
{
|
|
try
|
|
{
|
|
lb = (LinkButton)cella.Controls[0];
|
|
lb.Text = traduci(lb.Text);
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
int totRecord = grView.Rows.Count + grView.PageSize * (grView.PageCount - 1);
|
|
lblNumRec.Text = string.Format("{0} records of ~ {1}", grView.Rows.Count, totRecord);
|
|
}
|
|
else
|
|
{
|
|
lblNumRec.Text = "";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// annulla inserimento nuovo valore da footer
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lblCanc_click(object sender, EventArgs e)
|
|
{
|
|
// annullo inserimento: nascondo footer, bind controlli...
|
|
grView.FooterRow.Visible = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// inserisce nuovo valore da footer
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lblIns_click(object sender, EventArgs e)
|
|
{
|
|
// click su inserimento, chiamo il metodo insert dell'ObjectDataSource
|
|
ods.Insert();
|
|
}
|
|
|
|
/// <summary>
|
|
/// caricamento
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
grView.PageSize = utils.pageSize;
|
|
if (!Page.IsPostBack)
|
|
{
|
|
filtroDip.ods = odsDip;
|
|
memLayer.ML.emptySessionVal("idxDip_sel");
|
|
filtroDip.reselFirst();
|
|
// ricostruisco EVENTUALI date mancanti
|
|
DataProxy.DP.taTimbExpl.stp_timbratureExplFillDate(DateTime.Now.AddMonths(-2), DateTime.Now);
|
|
}
|
|
filtroDip.eh_selValore += new EventHandler(filtroDip_eh_selValore);
|
|
}
|
|
|
|
/// <summary>
|
|
/// fix visualizzazione x selezione compensazione richiesta
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void rblComp_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (rblComp.SelectedValue == "2")
|
|
{
|
|
txtMinRedExtra.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
txtMinRedExtra.Visible = false;
|
|
}
|
|
//// salvo in sessione il valore selezionato x passarlo alla stored...
|
|
//memLayer.ML.setSessionVal("tipoComp", rblComp.SelectedValue);
|
|
grView.DataBind();
|
|
}
|
|
|
|
/// <summary>
|
|
/// recupera i dati di un nuovo record contenuti nel footer di un gridView;
|
|
/// questi devono esses opportunamente nominati (es: txt{0}, dl{0}, ...)
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void recuperaFooter(object sender, ObjectDataSourceMethodEventArgs e)
|
|
{
|
|
if (e != null)
|
|
{
|
|
//recupero la riga footer...
|
|
DataColumnCollection colonne = colonneObj();
|
|
string nomeCol;
|
|
string tipoColonna = "";
|
|
foreach (DataColumn colonna in colonne)
|
|
{
|
|
nomeCol = colonna.ColumnName;
|
|
// cerco un textbox o quello che sia...
|
|
if (grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol)) != null)
|
|
{
|
|
tipoColonna = "textBox";
|
|
}
|
|
else if (grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol)) != null)
|
|
{
|
|
tipoColonna = "dropDownList";
|
|
}
|
|
else if (grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol)) != null)
|
|
{
|
|
tipoColonna = "checkBox";
|
|
}
|
|
// in base al tipo salvo negli inputparameters dell'ODS
|
|
switch (tipoColonna)
|
|
{
|
|
case "textBox":
|
|
e.InputParameters[nomeCol] = ((TextBox)grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol))).Text;
|
|
break;
|
|
|
|
case "dropDownList":
|
|
e.InputParameters[nomeCol] = ((DropDownList)grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol))).SelectedValue;
|
|
break;
|
|
|
|
case "checkBox":
|
|
e.InputParameters[nomeCol] = ((CheckBox)grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol))).Checked;
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
tipoColonna = "";
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// determina se sia visibile il pulsante per la compensazione permessi/strordinari
|
|
/// </summary>
|
|
/// <param name="oreStraord"></param>
|
|
/// <param name="oreAssorb"></param>
|
|
/// <returns></returns>
|
|
public bool compPermVisible(object oreStraord, object orePermessi)
|
|
{
|
|
bool answ = rblComp.SelectedValue == "1";
|
|
// solo se in fase abilitata alla modifica controllo le ore effettive
|
|
if (answ)
|
|
{
|
|
answ = (Convert.ToDouble(oreStraord) > 0) && (Convert.ToDouble(orePermessi) > 0);
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
public void doUpdate()
|
|
{
|
|
grView.PageSize = utils.pageSize;
|
|
grView.DataBind();
|
|
}
|
|
|
|
/// <summary>
|
|
/// determina se sia visibile il pulsante per la riduzione degli straordinari per il mese/dipendente
|
|
/// </summary>
|
|
/// <param name="oreStraord"></param>
|
|
/// <param name="oreAssorb"></param>
|
|
/// <returns></returns>
|
|
public bool reduceVisible(object oreStraord, object oreAssorb)
|
|
{
|
|
bool answ = rblComp.SelectedValue == "2";
|
|
// solo se in fase abilitata alla modifica controllo le ore effettive
|
|
if (answ)
|
|
{
|
|
answ = (Convert.ToDouble(oreStraord) >= Convert.ToDouble(oreAssorb)) && (Convert.ToDouble(oreAssorb) > 0);
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// resetta la selezione dei valori in caso di modifiche su altri controlli
|
|
/// </summary>
|
|
public void resetSelezione()
|
|
{
|
|
grView.SelectedIndex = -1;
|
|
grView.DataBind();
|
|
if (eh_resetSelezione != null)
|
|
{
|
|
eh_resetSelezione(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |