230 lines
6.8 KiB
C#
230 lines
6.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using SteamWare;
|
|
using GPW_data;
|
|
|
|
namespace GPW.WebUserControls
|
|
{
|
|
public partial class mod_timbrature : System.Web.UI.UserControl
|
|
{
|
|
protected bool forceButtons = true;
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
// verifico se ci sia un numero di righe selezionate altrimenti lo imposto...
|
|
if (!memLayer.ML.isInSessionObject("numColEU")) numColEU = 2;
|
|
if (!memLayer.ML.isInSessionObject("numRowTimb")) numRowTimb = 10;
|
|
memLayer.ML.setSessionVal("dataRif", DateTime.Today);
|
|
}
|
|
setButtons();
|
|
}
|
|
|
|
public int numColEU
|
|
{
|
|
get
|
|
{
|
|
int answ = 2;
|
|
try
|
|
{
|
|
answ = memLayer.ML.IntSessionObj("numColEU");
|
|
}
|
|
catch
|
|
{ }
|
|
if (answ <= 0) answ = 2;
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("numColEU", value);
|
|
}
|
|
}
|
|
public int numRowTimb
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.IntSessionObj("numRowTimb");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("numRowTimb", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// imposto highlight di un area intorno al button
|
|
/// </summary>
|
|
private void setButtons()
|
|
{
|
|
// controllo SE voglio inibire i buttons...
|
|
if (forceButtons)
|
|
{
|
|
// controllo se il prox comando DOVREBBE essere entrata o uscita
|
|
bool nextIsEntrata = true;
|
|
// controllo dipendente
|
|
if (IdxDipendente > 0)
|
|
{
|
|
// ricavo ultima timbratura..
|
|
nextIsEntrata = timbratrice.nextIsEntrata(IdxDipendente);
|
|
// di conseguenza cambio abilitazione ad un buttons
|
|
if (nextIsEntrata)
|
|
{
|
|
btnEntrata.Enabled = true;
|
|
btnUscita.Enabled = false;
|
|
}
|
|
else
|
|
{
|
|
btnEntrata.Enabled = false;
|
|
btnUscita.Enabled = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
btnEntrata.Enabled = false;
|
|
btnUscita.Enabled = false;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
btnEntrata.Enabled = true;
|
|
btnUscita.Enabled = true;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// timbro entrata...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnEntrata_Click(object sender, EventArgs e)
|
|
{
|
|
bool isEntrata = true;
|
|
registraTimbratura(isEntrata);
|
|
}
|
|
/// <summary>
|
|
/// uscita...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnUscita_Click(object sender, EventArgs e)
|
|
{
|
|
bool isEntrata = false;
|
|
registraTimbratura(isEntrata);
|
|
}
|
|
/// <summary>
|
|
/// Abilita tutti i buttons
|
|
/// </summary>
|
|
public void abilitaAll()
|
|
{
|
|
forceButtons = false;
|
|
}
|
|
/// <summary>
|
|
/// Aggiorno visualizzazione
|
|
/// </summary>
|
|
public void doUpdate()
|
|
{
|
|
setButtons();
|
|
grView.DataBind();
|
|
}
|
|
/// <summary>
|
|
/// update elenco ultime timbrature
|
|
/// </summary>
|
|
private void updateTimbrature()
|
|
{
|
|
// aggiorno datagrid
|
|
}
|
|
/// <summary>
|
|
/// registro timbratura
|
|
/// </summary>
|
|
/// <param name="isEntrata"></param>
|
|
/// <returns></returns>
|
|
private int registraTimbratura(bool isEntrata)
|
|
{
|
|
// salvo evento entrata...
|
|
string IPv4 = "";
|
|
bool approvata = false;
|
|
if (IdxDipendente > 0)
|
|
{
|
|
// recupero IP
|
|
IPv4 = Request.UserHostName;
|
|
// controllo se IP locale = approvata...
|
|
if (IPv4.Contains(memLayer.ML.confReadString("localNet")))
|
|
{
|
|
approvata = true;
|
|
}
|
|
timbratrice.registraTimbratura(IdxDipendente, DateTime.Now, isEntrata, IPv4, "Web", approvata);
|
|
lblWarning.Visible = false;
|
|
//aggiorno timbrature visualizzate
|
|
setButtons();
|
|
updateTimbrature();
|
|
grView.DataBind();
|
|
}
|
|
else
|
|
{
|
|
lblWarning.Text = "IdxDipendente non trovato! timbratura impossibile";
|
|
lblWarning.Visible = true;
|
|
}
|
|
return IdxDipendente;
|
|
}
|
|
/// <summary>
|
|
/// idx dipendente loggato
|
|
/// </summary>
|
|
protected int IdxDipendente
|
|
{
|
|
get
|
|
{
|
|
int idx = 0;
|
|
try
|
|
{
|
|
idx = memLayer.ML.IntSessionObj("IdxDipendente");
|
|
}
|
|
catch
|
|
{ }
|
|
return idx;
|
|
}
|
|
}
|
|
/// <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;
|
|
}
|
|
|
|
protected void grView_RowCreated(object sender, GridViewRowEventArgs e)
|
|
{
|
|
int maxNum = e.Row.Cells.Count - 2;
|
|
for (int i = numColEU * 2 + 1; i < maxNum; i++)
|
|
{
|
|
e.Row.Cells[i].Visible = false;
|
|
}
|
|
}
|
|
|
|
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
// rimando ai progetti sulla data indicata...
|
|
DateTime dataRif = DateTime.Today;
|
|
try
|
|
{
|
|
dataRif = Convert.ToDateTime(grView.SelectedDataKey["dataLav"]);
|
|
}
|
|
catch
|
|
{ }
|
|
// salvo in sessione...
|
|
memLayer.ML.setSessionVal("dataRif", dataRif);
|
|
// reinvio
|
|
Response.Redirect(string.Format("Progetti?dataRif={0:yyyy-MM-dd}", dataRif));
|
|
}
|
|
}
|
|
} |