372 lines
15 KiB
C#
372 lines
15 KiB
C#
using GPW_data;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace GPW_Admin.WebUserControls
|
|
{
|
|
public partial class cmp_gestMalattia : BaseUserControl
|
|
{
|
|
#region Public Methods
|
|
|
|
public void doUpdate()
|
|
{
|
|
// aggiorno!
|
|
grView.PageSize = utils.pageSize;
|
|
grView.DataBind();
|
|
}
|
|
|
|
#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.RegistroMalattieRow> listRM { get; set; }
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected void chkShowAll_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
chkShowAll.Text = chkShowAll.Checked ? "Mostra Tutti" : "Da Confermare";
|
|
cmp_calAnnuale.showAlsoConf = chkShowAll.Checked;
|
|
}
|
|
|
|
protected string datiDip(object idxDip)
|
|
{
|
|
int idxDipendente = 0;
|
|
int.TryParse($"{idxDip}", out idxDipendente);
|
|
string answ = "NA";
|
|
var rigaDip = listaDip.FirstOrDefault(x => x.idxDipendente == idxDipendente);
|
|
if (rigaDip != null)
|
|
{
|
|
answ = $"{rigaDip.Cognome} {rigaDip.Nome}";
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
protected void doUpdateCal()
|
|
{
|
|
listRM = RMListByAnno(anno);
|
|
}
|
|
|
|
protected void ods_Deleted(object sender, System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs e)
|
|
{
|
|
doUpdateCal();
|
|
}
|
|
|
|
/// <summary>
|
|
/// check licenze in fase di eliminazione...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ods_Deleting(object sender, ObjectDataSourceMethodEventArgs e)
|
|
{
|
|
if (e != null)
|
|
{
|
|
if (!licenzeGPW.checkLicenze)
|
|
{
|
|
// annullo update se licenze sforate...
|
|
e.Cancel = true;
|
|
grView.EditIndex = -1;
|
|
grView.DataBind();
|
|
}
|
|
else
|
|
{
|
|
// cerco!
|
|
if (e.InputParameters["Original_IdxRegMal"] != null)
|
|
{
|
|
string sIdxRegMal = $"{e.InputParameters["Original_IdxRegMal"]}";
|
|
int IdxRegMal = 0;
|
|
int.TryParse(sIdxRegMal, out IdxRegMal);
|
|
if (IdxRegMal > 0)
|
|
{
|
|
// recupero richiesta x i dati utente
|
|
if (listRM == null || listRM.Count == 0)
|
|
{
|
|
listRM = RMListByAnno(anno);
|
|
}
|
|
var richDip = listRM.Where(x => x.IdxRegMal == IdxRegMal).FirstOrDefault();
|
|
if (richDip != null)
|
|
{
|
|
// recupero dipendente...
|
|
var currUser = listaDip.Where(x => x.idxDipendente == richDip.IdxDipendente).FirstOrDefault();
|
|
string destEmail = currUser.email;
|
|
string fromEmail = memLayer.ML.CRS("_fromEmail");
|
|
string adminEmail = memLayer.ML.CRS("adminRichDip");
|
|
// calcolo il responsabile
|
|
if (currUser.idxResp > 0)
|
|
{
|
|
string mailResp = emailResp(currUser.idxResp);
|
|
if (!string.IsNullOrEmpty(mailResp) && !adminEmail.Contains(mailResp))
|
|
{
|
|
adminEmail += $",{mailResp}";
|
|
}
|
|
}
|
|
string subjMess = $"ELIMINAZIONE richiesta Malattia n.{IdxRegMal}";
|
|
DateTime adesso = DateTime.Now;
|
|
StringBuilder sbMain = new StringBuilder();
|
|
sbMain.AppendLine($"Il giorno {adesso:yyyy.MM.dd} alle ore {adesso:HH:mm:ss} è stata <b>ELIMINATA</b> la richiesta in oggetto.");
|
|
sbMain.AppendLine("");
|
|
sbMain.Append("<div style=\"font-size: 1.3em; color: #CC0066;\">");
|
|
sbMain.Append($"<b>{currUser.Cognome}</b> {currUser.Nome} ({currUser.matricola})");
|
|
sbMain.Append("</div>");
|
|
sbMain.AppendLine("<hr/>");
|
|
sbMain.AppendLine($"Richiesta: <b>MAL</b>");
|
|
string sConf = $"{e.InputParameters["Conf"]}";
|
|
bool isConf = false;
|
|
bool.TryParse(sConf, out isConf);
|
|
string stato = isConf ? "CONFERMATA" : "RIFIUTATA";
|
|
sbMain.AppendLine($"Stato: <b>{stato}</b>");
|
|
sbMain.AppendLine($"Inizio: <b>{richDip.DtInizio}</b>");
|
|
string NumGG = $"{e.InputParameters["NumGG"]}";
|
|
sbMain.AppendLine($"Num gg: <b>{NumGG}</b>");
|
|
string CodCert = $"{e.InputParameters["CodCert"]}";
|
|
sbMain.AppendLine($"Certificato INPS: <b>{CodCert}</b>");
|
|
sbMain.AppendLine("<hr/>");
|
|
string bodyMess = sbMain.ToString().Replace($"{Environment.NewLine}", "<br/>");
|
|
// invio email!
|
|
gestEmail.geAuth.mandaEmail(fromEmail, destEmail, subjMess, bodyMess);
|
|
// ora sistemo x admin
|
|
var adminList = adminEmail.Split(',');
|
|
string urlRedir = memLayer.ML.CRS("urlRedirMal");
|
|
bodyMess += $"<hr/><br/>Cliccare sul <a href=\"{urlRedir}\">seguente link</a> per accedere alla pagina di gestione";
|
|
foreach (var dest in adminList)
|
|
{
|
|
gestEmail.geAuth.mandaEmail(fromEmail, dest, subjMess, bodyMess);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void ods_Updated(object sender, System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs e)
|
|
{
|
|
doUpdateCal();
|
|
}
|
|
|
|
/// <summary>
|
|
/// check licenze in fase di update...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ods_Updating(object sender, ObjectDataSourceMethodEventArgs e)
|
|
{
|
|
if (e != null)
|
|
{
|
|
if (!licenzeGPW.checkLicenze)
|
|
{
|
|
// annullo update se licenze sforate...
|
|
e.Cancel = true;
|
|
grView.EditIndex = -1;
|
|
grView.DataBind();
|
|
}
|
|
else
|
|
{
|
|
// cerco!
|
|
if (e.InputParameters["Original_IdxRegMal"] != null)
|
|
{
|
|
string sIdxRegMal = $"{e.InputParameters["Original_IdxRegMal"]}";
|
|
int IdxRegMal = 0;
|
|
int.TryParse(sIdxRegMal, out IdxRegMal);
|
|
if (IdxRegMal > 0)
|
|
{
|
|
// recupero richiesta x i dati utente
|
|
if (listRM == null || listRM.Count == 0)
|
|
{
|
|
listRM = RMListByAnno(anno);
|
|
}
|
|
var richDip = listRM.Where(x => x.IdxRegMal == IdxRegMal).FirstOrDefault();
|
|
if (richDip != null)
|
|
{
|
|
// recupero dipendente...
|
|
var currUser = listaDip.Where(x => x.idxDipendente == richDip.IdxDipendente).FirstOrDefault();
|
|
string destEmail = currUser.email;
|
|
string fromEmail = memLayer.ML.CRS("_fromEmail");
|
|
string adminEmail = memLayer.ML.CRS("adminRichDip");
|
|
// calcolo il responsabile
|
|
if (currUser.idxResp > 0)
|
|
{
|
|
string mailResp = emailResp(currUser.idxResp);
|
|
if (!string.IsNullOrEmpty(mailResp) && !adminEmail.Contains(mailResp))
|
|
{
|
|
adminEmail += $",{mailResp}";
|
|
}
|
|
}
|
|
string subjMess = $"Aggiornamento richiesta Malattia n.{IdxRegMal}";
|
|
DateTime adesso = DateTime.Now;
|
|
StringBuilder sbMain = new StringBuilder();
|
|
sbMain.AppendLine($"Il giorno {adesso:yyyy.MM.dd} alle ore {adesso:HH:mm:ss} è stata <b>modificata</b> la richiesta in oggetto.");
|
|
sbMain.AppendLine("");
|
|
sbMain.Append("<div style=\"font-size: 1.3em; color: #CC0066;\">");
|
|
sbMain.Append($"<b>{currUser.Cognome}</b> {currUser.Nome} ({currUser.matricola})");
|
|
sbMain.Append("</div>");
|
|
sbMain.AppendLine("<hr/>");
|
|
sbMain.AppendLine($"Richiesta: <b>MAL</b>");
|
|
string sConf = $"{e.InputParameters["Conf"]}";
|
|
bool isConf = false;
|
|
bool.TryParse(sConf, out isConf);
|
|
string stato = isConf ? "CONFERMATA" : "RIFIUTATA";
|
|
sbMain.AppendLine($"Stato: <b>{stato}</b>");
|
|
sbMain.AppendLine($"Inizio: <b>{richDip.DtInizio}</b>");
|
|
string NumGG = $"{e.InputParameters["NumGG"]}";
|
|
sbMain.AppendLine($"Num gg: <b>{NumGG}</b>");
|
|
string CodCert = $"{e.InputParameters["CodCert"]}";
|
|
sbMain.AppendLine($"Certificato INPS: <b>{CodCert}</b>");
|
|
sbMain.AppendLine("<hr/>");
|
|
string bodyMess = sbMain.ToString().Replace($"{Environment.NewLine}", "<br/>");
|
|
// invio email!
|
|
gestEmail.geAuth.mandaEmail(fromEmail, destEmail, subjMess, bodyMess);
|
|
// ora sistemo x admin
|
|
var adminList = adminEmail.Split(',');
|
|
string urlRedir = memLayer.ML.CRS("urlRedirMal");
|
|
bodyMess += $"<hr/><br/>Cliccare sul <a href=\"{urlRedir}\">seguente link</a> per accedere alla pagina di gestione";
|
|
foreach (var dest in adminList)
|
|
{
|
|
gestEmail.geAuth.mandaEmail(fromEmail, dest, subjMess, bodyMess);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
grView.PageSize = utils.pageSize;
|
|
if (!Page.IsPostBack)
|
|
{
|
|
anno = DateTime.Now.Year;
|
|
cmp_calAnnuale.anno = anno;
|
|
reportAnno();
|
|
doUpdateCal();
|
|
}
|
|
listaDip = licenzeGPW.getDipAttivi();
|
|
grView.Visible = chkLicOk;
|
|
cmp_selettoreMesi.eh_doRefresh += Cmp_selettoreMesi_eh_doRefresh;
|
|
}
|
|
|
|
protected void repCal_PreRender(object sender, EventArgs e)
|
|
{
|
|
doUpdateCal();
|
|
}
|
|
|
|
protected void txtAnno_TextChanged(object sender, EventArgs e)
|
|
{
|
|
reportAnno();
|
|
doUpdateCal();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Methods
|
|
|
|
private void Cmp_selettoreMesi_eh_doRefresh(object sender, EventArgs e)
|
|
{
|
|
Inizio = cmp_selettoreMesi.inizio;
|
|
Fine = cmp_selettoreMesi.fine;
|
|
doUpdate();
|
|
}
|
|
|
|
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_selettoreMesi.anno = anno;
|
|
cmp_selettoreMesi.intervalloAnalisi = currAnno;
|
|
cmp_calAnnuale.anno = anno;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Elenco Richieste Malattie (anno indicato + precedente...)
|
|
/// </summary>
|
|
/// <param name="reqYear"></param>
|
|
private List<DS_Applicazione.RegistroMalattieRow> RMListByAnno(int reqYear)
|
|
{
|
|
DateTime inizio = new DateTime(reqYear - 1, 1, 1);
|
|
DateTime fine = new DateTime(reqYear + 1, 1, 1);
|
|
List<DS_Applicazione.RegistroMalattieRow> result = DataProxy.DP.taRM.getPeriod(0, inizio, fine).ToList();
|
|
return result;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |