c5b4cb4a30
- chiusure aziendali - malattia - richeiste dip
307 lines
8.9 KiB
C#
307 lines
8.9 KiB
C#
using GPW_data;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web.UI;
|
|
|
|
namespace GPW_Admin.WebUserControls
|
|
{
|
|
public partial class mod_gestCalendario : BaseUserControl
|
|
{
|
|
#region Public Properties
|
|
|
|
public string testoFerie
|
|
{
|
|
get => divInsFerie.Visible ? "NASCONDI ADD Ferie" : "MOSTRA ADD Ferie";
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public void doUpdate()
|
|
{
|
|
// aggiorno!
|
|
grView.PageSize = utils.pageSize;
|
|
grView.DataBind();
|
|
}
|
|
|
|
public List<DateTime> elencoMesi()
|
|
{
|
|
List<DateTime> listaMesi = new List<DateTime>();
|
|
for (int i = 0; i < 12; i++)
|
|
{
|
|
listaMesi.Add(new DateTime(anno, 1 + i, 1));
|
|
}
|
|
return listaMesi;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Properties
|
|
|
|
/// <summary>
|
|
/// Anno corrente
|
|
/// </summary>
|
|
protected int anno
|
|
{
|
|
get
|
|
{
|
|
int answ = 0;
|
|
if (txtAnno != null && !string.IsNullOrEmpty(txtAnno.Text))
|
|
{
|
|
_ = int.TryParse(txtAnno.Text, out answ);
|
|
}
|
|
else
|
|
{
|
|
answ = DateTime.Today.Year;
|
|
}
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
txtAnno.Text = value.ToString();
|
|
}
|
|
}
|
|
|
|
protected DateTime Fine
|
|
{
|
|
get
|
|
{
|
|
DateTime answ = new DateTime(anno + 1, 1, 1);
|
|
if (!string.IsNullOrEmpty(hfFine.Value))
|
|
{
|
|
DateTime.TryParse(hfFine.Value, out answ);
|
|
}
|
|
else
|
|
{
|
|
hfFine.Value = $"{answ}";
|
|
}
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
hfFine.Value = $"{value}";
|
|
}
|
|
}
|
|
|
|
protected DateTime Inizio
|
|
{
|
|
get
|
|
{
|
|
DateTime answ = new DateTime(anno, 1, 1);
|
|
if (!string.IsNullOrEmpty(hfInizio.Value))
|
|
{
|
|
DateTime.TryParse(hfInizio.Value, out answ);
|
|
}
|
|
else
|
|
{
|
|
hfInizio.Value = $"{answ}";
|
|
}
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
hfInizio.Value = $"{value}";
|
|
}
|
|
}
|
|
|
|
protected List<DS_Applicazione.CalendFesteFerieRow> listCFF { get; set; }
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected void calDisplay_DayRender(object sender, System.Web.UI.WebControls.DayRenderEventArgs e)
|
|
{
|
|
bool isFest = false;
|
|
// coloro se fa parte delle festività/ferie...
|
|
if (listCFF != null && listCFF.Count > 0)
|
|
{
|
|
// cerco riga...
|
|
var thisDate = listCFF.Where(x => x.data == e.Day.Date).FirstOrDefault();
|
|
if (thisDate != null && e.Cell.CssClass != "text-light")
|
|
{
|
|
isFest = true;
|
|
e.Cell.CssClass = thisDate.codGiust == "FEST" ? "bg-danger text-warning" : "bg-warning";
|
|
}
|
|
}
|
|
// se sab/dom --> grigio
|
|
if (!isFest && e.Cell.CssClass != "text-light")
|
|
{
|
|
if (e.Day.Date.DayOfWeek == DayOfWeek.Saturday || e.Day.Date.DayOfWeek == DayOfWeek.Sunday)
|
|
{
|
|
e.Cell.CssClass = "bg-secondary text-light";
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void doUpdateCal()
|
|
{
|
|
listCFF = CffListByAnno(anno);
|
|
}
|
|
|
|
protected void lbtSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (chkLicOk)
|
|
{
|
|
int numGG = (int)fineFerie.Subtract(inizioFerie).TotalDays;
|
|
DateTime currDate = inizioFerie;
|
|
int currYear = DateTime.Today.Year;
|
|
// aggiungo ferie x periodo selezionato...
|
|
for (int i = 0; i <= numGG; i++)
|
|
{
|
|
var currDay = inizioFerie.AddDays(i).DayOfWeek;
|
|
// controllo che NON SIA sabato/domenica...
|
|
if (currDay != DayOfWeek.Saturday && currDay != DayOfWeek.Sunday)
|
|
{
|
|
DataProxy.DP.taCFF.upsertQuery(inizioFerie.AddDays(i), ddlCodGiustInsNew.SelectedValue, txtDescrizione.Text);
|
|
}
|
|
}
|
|
// rieseguo insert festività x anno del periodo...
|
|
setupFestAnno(inizioFerie.Year);
|
|
}
|
|
}
|
|
|
|
protected void lbtSetupYear_Click(object sender, EventArgs e)
|
|
{
|
|
if (chkLicOk)
|
|
{
|
|
setupFestAnno(anno);
|
|
}
|
|
}
|
|
|
|
protected void lbtShowFerie_Click(object sender, EventArgs e)
|
|
{
|
|
if (chkLicOk)
|
|
{
|
|
divInsFerie.Visible = !divInsFerie.Visible;
|
|
}
|
|
lblTestoFerie.Text = testoFerie;
|
|
}
|
|
|
|
protected void ods_Deleted(object sender, System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs e)
|
|
{
|
|
doUpdateCal();
|
|
}
|
|
|
|
protected void ods_Updated(object sender, System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs e)
|
|
{
|
|
doUpdateCal();
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
grView.PageSize = utils.pageSize;
|
|
if (!Page.IsPostBack)
|
|
{
|
|
anno = DateTime.Now.Year;
|
|
cmp_calAnnuale.anno = anno;
|
|
intervalloDate currAnno = new intervalloDate
|
|
{
|
|
inizio = DateTime.Today.AddYears(-2),
|
|
fine = DateTime.Today.AddYears(1)
|
|
};
|
|
cmp_periodoAnalisi.intervalloAnalisi = currAnno;
|
|
lbtSetupYear.DataBind();
|
|
DateTime oggi = DateTime.Today;
|
|
inizioFerie = oggi.AddDays(1);
|
|
fineFerie = oggi.AddDays(2);
|
|
doUpdateCal();
|
|
}
|
|
lbtSetupYear.Visible = chkLicOk;
|
|
lbtShowFerie.Visible = chkLicOk;
|
|
lblTestoFerie.Text = testoFerie;
|
|
}
|
|
|
|
protected void repCal_PreRender(object sender, EventArgs e)
|
|
{
|
|
doUpdateCal();
|
|
}
|
|
|
|
protected void txtAnno_TextChanged(object sender, EventArgs e)
|
|
{
|
|
reportAnno();
|
|
doUpdateCal();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Properties
|
|
|
|
private DateTime fineFerie
|
|
{
|
|
get
|
|
{
|
|
DateTime answ = DateTime.Today;
|
|
_ = DateTime.TryParse(txtFine.Text, out answ);
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
txtFine.Text = value.ToString("yyyy-MM-dd");
|
|
}
|
|
}
|
|
|
|
private DateTime inizioFerie
|
|
{
|
|
get
|
|
{
|
|
DateTime answ = DateTime.Today;
|
|
_ = DateTime.TryParse(txtInizio.Text, out answ);
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
txtInizio.Text = value.ToString("yyyy-MM-dd");
|
|
}
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// Elenco Festività / Ferie x anno
|
|
/// </summary>
|
|
/// <param name="reqYear"></param>
|
|
private List<DS_Applicazione.CalendFesteFerieRow> CffListByAnno(int reqYear)
|
|
{
|
|
DateTime inizio = new DateTime(reqYear, 1, 1);
|
|
DateTime fine = inizio.AddYears(1);
|
|
List<DS_Applicazione.CalendFesteFerieRow> result = DataProxy.DP.taCFF.getPeriod(inizio, fine).ToList();
|
|
return result;
|
|
}
|
|
|
|
private void reportAnno()
|
|
{
|
|
Inizio = new DateTime(anno, 1, 1);
|
|
Fine = new DateTime(anno + 1, 1, 1);
|
|
intervalloDate currAnno = new intervalloDate
|
|
{
|
|
inizio = Inizio,
|
|
fine = Fine
|
|
};
|
|
cmp_periodoAnalisi.intervalloAnalisi = currAnno;
|
|
cmp_calAnnuale.anno = anno;
|
|
}
|
|
|
|
private void setupFestAnno(int reqYear)
|
|
{
|
|
// recupero elenco festività
|
|
List<EventDetail> elencoFest = SteamWare.calendarMan.elencoFestAnno(reqYear);
|
|
// inserisco 1:1
|
|
if (elencoFest.Count > 0)
|
|
{
|
|
foreach (var item in elencoFest)
|
|
{
|
|
DataProxy.DP.taCFF.upsertQuery(item.when, "FEST", item.what);
|
|
}
|
|
}
|
|
doUpdate();
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |