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 { /// /// data selezionata /// 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); } } /// /// avvio pagina /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { // imposto entrata rblEntrata.SelectedIndex = 0; } } /// /// valore datetime selezionato! /// 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(); } } /// /// inverte valore booleano /// /// /// public bool invBool(object valore) { bool answ = true; try { answ = !Convert.ToBoolean(valore); } catch { } return answ; } /// /// evento riga caricata... /// /// /// 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 { } } /// /// sistemo post eliminazione /// /// /// protected void grView_RowUpdated(object sender, GridViewUpdatedEventArgs e) { checkFixOds(); // sollevo evento nuovo valore... if (eh_nuovoValore != null) { eh_nuovoValore(this, new EventArgs()); } } /// /// update post cancellazione /// /// /// protected void grViewRichieste_RowDeleted(object sender, GridViewDeletedEventArgs e) { checkFixOds(); // sollevo evento nuovo valore... if (eh_nuovoValore != null) { eh_nuovoValore(this, new EventArgs()); } } /// /// effettua fix dell'ods /// private void checkFixOds() { grViewRichieste.DataBind(); } /// /// salvo richiesta /// /// /// 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()); } } /// /// registro timbratura NON APPROVATA /// /// /// 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); } } /// /// calcola cognome-nome da idx /// /// /// public string cognomeNome(object idxDip) { string answ = ""; int IdxDipendente = 0; if (int.TryParse($"{idxDip}", out IdxDipendente)) { answ = DataProxy.DP.cognomeNomeByIdx(IdxDipendente); } return answ; } /// /// evento update valori /// public event EventHandler eh_nuovoValore; } }