160 lines
4.4 KiB
C#
160 lines
4.4 KiB
C#
using GPW_data;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace GPW_Admin.WebUserControls
|
|
{
|
|
public partial class mod_gestCalendario : BaseUserControl
|
|
{
|
|
#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 Protected Properties
|
|
|
|
/// <summary>
|
|
/// Anno corrente
|
|
/// </summary>
|
|
protected int anno
|
|
{
|
|
get
|
|
{
|
|
int answ = 0;
|
|
_ = int.TryParse(txtAnno.Text, out answ);
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
txtAnno.Text = value.ToString();
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Private Methods
|
|
|
|
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
|
|
|
|
#region Protected Methods
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
grView.PageSize = utils.pageSize;
|
|
if (!Page.IsPostBack)
|
|
{
|
|
anno = DateTime.Now.Year;
|
|
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);
|
|
}
|
|
lbtSetupYear.Visible = chkLicOk;
|
|
lbtShowFerie.Visible = chkLicOk;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Public Methods
|
|
|
|
public void doUpdate()
|
|
{
|
|
// aggiorno!
|
|
grView.PageSize = utils.pageSize;
|
|
grView.DataBind();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |