Files
MedAP/MedAP/WebUserControl/mod_projects.ascx.cs
T

175 lines
5.0 KiB
C#

using SteamWare;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace MedAP.WebUserControl
{
public partial class mod_projects : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
/// <summary>
/// determina se mostrare SOLO progetti starred...
/// </summary>
public bool showOnlyStarPrj
{
get
{
bool answ = false;
try
{
answ = Convert.ToBoolean(hfShowOnlyStar.Value);
}
catch
{ }
return answ;
}
set
{
hfShowOnlyStar.Value = value.ToString();
}
}
/// <summary>
/// determina se mostrare ANCHE i progetti già archiviati (non attivi)...
/// </summary>
public bool showPrjArch
{
get
{
bool answ = false;
try
{
answ = Convert.ToBoolean(hfShowPrjArch.Value);
}
catch
{ }
return answ;
}
set
{
hfShowPrjArch.Value = value.ToString();
}
}
public void doUpdate()
{
grView.DataBind();
}
/// <summary>
/// Calcola css x indicare il trend delel ore tra ultimi 30 gg e mese prec
/// </summary>
/// <param name="_valCurr"></param>
/// <param name="_valPrev"></param>
/// <returns></returns>
public string calcCssTrend(object _valCurr, object _valPrev)
{
string answ = "";
double currVal = 0;
double prevVal = 0;
try
{
currVal = Convert.ToDouble(_valCurr);
prevVal = Convert.ToDouble(_valPrev);
}
catch
{ }
// in base ai valori definisco css...
if (currVal > prevVal)
{
answ = "fa fa-arrow-up text-success";
}
else if (currVal < prevVal)
{
answ = "fa fa-arrow-down text-danger";
}
else
{
answ = "fa fa-exchange text-info";
}
return answ;
}
/// <summary>
/// Restituisce il codice CSS x indicare valore budget vs real delle ore
/// </summary>
/// <param name="_valCurr"></param>
/// <param name="_valBdgt"></param>
/// <returns></returns>
public string calcCssBudget(object _valCurr, object _valBdgt)
{
string answ = "textNoFlow text-right docStrong ";
double currVal = 0;
double bdgtVal = 0;
double limiteWarn = 1;
try
{
currVal = Convert.ToDouble(_valCurr);
bdgtVal = Convert.ToDouble(_valBdgt);
limiteWarn = memLayer.ML.CRD("limiteWarn");
}
catch
{ }
// in base ai valori definisco css...
if (currVal <= limiteWarn * bdgtVal)
{
answ += "text-success";
}
else if (currVal < bdgtVal)
{
answ += "text-warning";
}
else
{
answ += "text-danger";
}
return answ;
}
/// <summary>
/// Restituisce URL x il progetto indicato ed il periodo indicato
/// </summary>
/// <param name="_idxProj"></param>
/// <param name="_tipoPeriodo">FULL/30gg/LastMonth</param>
/// <returns></returns>
public string getUrlRepProgetto(object _idxProj, object _tipoPeriodo)
{
string answ = "textNoFlow text-right docStrong ";
int idxProj = 0;
string tipoPeriodo = "";
DateTime oggi = DateTime.Now.Date;
DateTime inizio = oggi;
DateTime fine = oggi;
try
{
idxProj = Convert.ToInt32(_idxProj);
tipoPeriodo = _tipoPeriodo.ToString();
}
catch
{ }
switch (tipoPeriodo)
{
case "LastMonth":
fine = oggi.AddDays(-oggi.Day);
inizio = fine.AddMonths(-1).AddDays(1);
break;
case "30gg":
fine = oggi;
inizio = fine.AddMonths(-1);
break;
case "Full":
default:
inizio = Convert.ToDateTime(memLayer.ML.CRS("startRepDate"));
fine = oggi;
break;
}
answ = string.Format(memLayer.ML.CRS("urlRepProgetto"), idxProj, inizio, fine);
return answ;
}
}
}