176 lines
5.4 KiB
C#
176 lines
5.4 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)
|
|
{
|
|
setButtons();
|
|
//setDate();
|
|
}
|
|
/// <summary>
|
|
/// imposta date da visualizzare
|
|
/// </summary>
|
|
private void setDate()
|
|
{
|
|
//lblInizio.Text = DateTime.Now.AddDays(-11).ToShortDateString();
|
|
//lblFine.Text = DateTime.Now.ToShortDateString();
|
|
}
|
|
/// <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..
|
|
//DS_Applicazione.TimbratureRow rigaTimb = DataProxy.DP.taTimb.getLastByDip(IdxDipendente)[0];
|
|
//if (rigaTimb != null)
|
|
//{
|
|
// nextIsEntrata = !rigaTimb.entrata;
|
|
//}
|
|
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 entrambi i buttons...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAbilitaFull_Click(object sender, EventArgs e)
|
|
{
|
|
forceButtons = false;
|
|
setButtons();
|
|
}
|
|
/// <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;
|
|
}
|
|
}
|
|
} |