222 lines
7.2 KiB
C#
222 lines
7.2 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;
|
|
using System.Globalization;
|
|
|
|
namespace GPW_Commesse.WebUserControls
|
|
{
|
|
public partial class mod_commUtMancTimbr : System.Web.UI.UserControl
|
|
{
|
|
/// <summary>
|
|
/// data selezionata
|
|
/// </summary>
|
|
protected DateTime dataRif
|
|
{
|
|
get
|
|
{
|
|
DateTime answ = DateTime.Now;
|
|
try
|
|
{
|
|
answ = Convert.ToDateTime(memLayer.ML.objSessionObj("dataRif"));
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("dataRif", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// avvio pagina
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
// imposto entrata
|
|
rblEntrata.SelectedIndex = 0;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// valore datetime selezionato!
|
|
/// </summary>
|
|
public DateTime valoreDateTime
|
|
{
|
|
get
|
|
{
|
|
DateTime answ = DateTime.Now;
|
|
try
|
|
{
|
|
int oreSel = Convert.ToInt32(ddlOra.SelectedValue);
|
|
int minSel = Convert.ToInt32(ddlMin.SelectedValue);
|
|
answ = Convert.ToDateTime(txtData.Text).AddHours(oreSel).AddMinutes(minSel);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
txtData.Text = value.Date.ToString("dd/MM/yyyy");
|
|
ddlOra.SelectedValue = value.Hour.ToString();
|
|
ddlMin.SelectedValue = value.Minute.ToString();
|
|
}
|
|
}
|
|
/// <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;
|
|
}
|
|
/// <summary>
|
|
/// evento riga caricata...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grView_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
// controllo la riga
|
|
GridViewRow riga = e.Row;
|
|
// se la data è quella rif...
|
|
Label data = new Label();
|
|
bool trovato = false;
|
|
try
|
|
{
|
|
data = (Label)riga.FindControl("lblDataLav");
|
|
trovato = (data.Text == Convert.ToDateTime(memLayer.ML.StringSessionObj("dataRif")).ToString("dd-MM"));
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
/// <summary>
|
|
/// sistemo post eliminazione
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grView_RowUpdated(object sender, GridViewUpdatedEventArgs e)
|
|
{
|
|
checkFixOds();
|
|
// sollevo evento nuovo valore...
|
|
if (eh_nuovoValore != null)
|
|
{
|
|
eh_nuovoValore(this, new EventArgs());
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// update post cancellazione
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grViewRichieste_RowDeleted(object sender, GridViewDeletedEventArgs e)
|
|
{
|
|
checkFixOds();
|
|
// sollevo evento nuovo valore...
|
|
if (eh_nuovoValore != null)
|
|
{
|
|
eh_nuovoValore(this, new EventArgs());
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// effettua fix dell'ods
|
|
/// </summary>
|
|
private void checkFixOds()
|
|
{
|
|
grViewRichieste.DataBind();
|
|
}
|
|
/// <summary>
|
|
/// salvo richiesta
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnRichMT_Click(object sender, EventArgs e)
|
|
{
|
|
logger.lg.scriviLog("Richiesta registrazione timbratura manuale", tipoLog.INFO);
|
|
// salva una richiesta di timbratura (ovvero approvata = FALSE!!!)
|
|
DateTime richiesta = DateTime.Now;
|
|
try
|
|
{
|
|
CultureInfo ita = new CultureInfo("it-IT");
|
|
logger.lg.scriviLog(string.Format("Data: {0}", txtData.Text));
|
|
richiesta = Convert.ToDateTime(txtData.Text, ita);
|
|
double ora = Convert.ToDouble(ddlOra.SelectedValue);
|
|
double minuto = Convert.ToDouble(ddlMin.SelectedValue);
|
|
richiesta = richiesta.AddHours(ora).AddMinutes(minuto);
|
|
bool isEntrata = Convert.ToBoolean(rblEntrata.SelectedValue);
|
|
registraTimbraturaNonApp(isEntrata, richiesta);
|
|
// aggiorno gridview
|
|
checkFixOds();
|
|
}
|
|
catch
|
|
{
|
|
logger.lg.scriviLog("Errore conversione datetime!");
|
|
}
|
|
// sollevo evento nuovo valore...
|
|
if (eh_nuovoValore != null)
|
|
{
|
|
eh_nuovoValore(this, new EventArgs());
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// registro timbratura NON APPROVATA
|
|
/// </summary>
|
|
/// <param name="isEntrata"></param>
|
|
/// <returns></returns>
|
|
private void registraTimbraturaNonApp(bool isEntrata, DateTime dataOra)
|
|
{
|
|
// salvo evento entrata...
|
|
string IPv4 = "";
|
|
bool approvata = false; // è una richiesta!!!!
|
|
if (DataProxy.idxDipendente > 0)
|
|
{
|
|
// recupero IP
|
|
IPv4 = Request.UserHostName;
|
|
DataProxy.DP.taTimb.stp_insTimbMan(DataProxy.idxDipendente, dataOra, isEntrata, IPv4, "NoTim", approvata);
|
|
logger.lg.scriviLog(string.Format("Richiesta timbratura per il dipendente:{0} in data:{1} isEntrata:{2}", DataProxy.idxDipendente, dataOra, isEntrata), tipoLog.INFO);
|
|
}
|
|
else
|
|
{
|
|
logger.lg.scriviLog("IdxDipendente non trovato! inserimento timbratura mancante impossibile", tipoLog.INFO);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// calcola cognome-nome da idx
|
|
/// </summary>
|
|
/// <param name="idxDip"></param>
|
|
/// <returns></returns>
|
|
public string cognomeNome(object idxDip)
|
|
{
|
|
string answ = "";
|
|
int IdxDipendente = 0;
|
|
if (int.TryParse($"{idxDip}", out IdxDipendente))
|
|
{
|
|
answ = DataProxy.DP.cognomeNomeByIdx(IdxDipendente);
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// evento update valori
|
|
/// </summary>
|
|
public event EventHandler eh_nuovoValore;
|
|
|
|
}
|
|
} |