Files
2021-01-04 17:48:49 +01:00

189 lines
4.3 KiB
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace MP_ADM.WebUserControls
{
public partial class cmp_ST_objView : BaseUserControl
{
#region Public Properties
public string dataCss
{
get
{
string answ = "";
if (required)
{
if (dataValue != extCode)
{
answ = " text-danger";
}
else
{
answ = " text-success";
}
}
return answ;
}
}
public string dataLabel
{
get
{
return hfLabel.Value.Trim();
}
set
{
hfLabel.Value = value.Trim();
}
}
public string dataType
{
get
{
return hfType.Value.Trim();
}
set
{
hfType.Value = value.Trim();
fixDisplay();
}
}
public string dataValue
{
get
{
return hfValue.Value.Trim();
}
set
{
hfValue.Value = value.Trim();
}
}
public string extCode
{
get
{
return hfExtCode.Value.Trim();
}
set
{
hfExtCode.Value = value.Trim();
fixDisplay();
}
}
/// <summary>
/// Url immagine SE richiesta
/// </summary>
public string imageUrl
{
get
{
string imgPath = "";
string fullPath = "";
//check type...
if (dataType == "IMG")
{
imgPath = dataValue;
if (!Path.IsPathRooted(imgPath))
{
// aggiungo base path
imgPath = $"~\\images\\ST_img\\{imgPath}";
}
fullPath = Server.MapPath(imgPath);
// verifico esistenza file...
if (!File.Exists(fullPath))
{
// metto segnaposto empty
imgPath = "~\\images\\ST_img\\Steamware.png";
}
}
return imgPath;
}
}
public bool required
{
get
{
bool answ = false;
bool.TryParse(hfRequired.Value.Trim(), out answ);
return answ;
}
set
{
hfRequired.Value = value.ToString();
fixDisplay();
}
}
public bool showCheckedData
{
get
{
bool answ = false;
if (required && (dataValue == extCode))
{
answ = true;
}
return answ;
}
}
public bool showMissingData
{
get
{
bool answ = false;
if (required && (dataValue != extCode))
{
answ = true;
}
return answ;
}
}
#endregion Public Properties
#region Private Methods
private void fixDisplay()
{
divImg.Visible = false;
divTxt.Visible = false;
switch (dataType)
{
case "IMG":
divImg.Visible = true;
break;
case "TXT":
default:
divTxt.Visible = true;
break;
}
lblError.Visible = showMissingData;
lblChecked.Visible = showCheckedData;
}
#endregion Private Methods
#region Protected Methods
protected void Page_Load(object sender, EventArgs e)
{
}
#endregion Protected Methods
}
}