Files

147 lines
4.2 KiB
C#

using AppData;
using SteamWare;
using System;
using System.Web.UI.WebControls;
namespace C_TRACK.WebUserControls
{
public partial class mod_btnComandi : BaseUserControl
{
/// <summary>
/// Codice TASK corrente
/// </summary>
public string CurrNumTask
{
get
{
return memLayer.ML.StringSessionObj("CurrNumTask");
}
set
{
memLayer.ML.setSessionVal("CurrNumTask", value);
}
}
/// <summary>
/// evento comando clicked
/// </summary>
public event EventHandler eh_clickComando;
protected void Page_Load(object sender, EventArgs e)
{
updateBtn();
}
/// <summary>
/// segnala click su button comando
/// </summary>
public void segnalaClick()
{
eh_clickComando?.Invoke(this, new EventArgs());
}
protected void lbtCmd_Click(object sender, EventArgs e)
{
// PROCEDO SOLO SE non ho veto...
if (!hasVeto)
{
LinkButton lb = (LinkButton)sender;
memLayer.ML.setSessionVal("btnCmdPress", lb.CommandArgument, false);
segnalaClick();
}
else
{
updateBtn();
}
}
public void updateBtn()
{
// verifico se ho comandi PREVALENTI (es: ho UNA FASE APERTA)
if (mUtils.CodOpr != "")
{
var tabTR = DLMan.taTR.getAttiveByOpr(mUtils.CodOpr);
if (tabTR.Rows.Count > 0)
{
// se NON HO una commessa attiva, SELEZIONO la PRIMA commessa aperta...
if (CurrNumTask == "")
{
CurrNumTask = tabTR[0].NumTask;
}
}
}
// controllo se HO una fase corrente...
repComandi.Visible = !hasVeto;
if (!hasVeto)
{
// altrimenti imposto fasi da postazione...
repComandi.DataBind();
}
}
/// <summary>
/// Verifica btn siano abilitati e nel caso x css aggiunge DISABLED
/// - ho una commessa
/// - la commessa NON E' chiusa...
/// </summary>
public string datiCommessa
{
get
{
string answ = "";
// controllos e ho in sessione numTask altrimenti NON E' abilitato...
if (CurrNumTask == "")
{
// se NON E' multi
if (mUtils.postIsMulti)
{
answ = "<-- Gestione commesse";
}
else
{
answ = "Manca Commessa";
}
}
else
{
answ = hasVeto ? "Commessa Chiusa: " + CurrNumTask.ToString() : "";
}
return answ;
}
}
/// <summary>
/// Verifica se la commessa sia assente/chiusa
/// </summary>
public bool hasVeto
{
get
{
bool answ = false;
bool noTask = CurrNumTask == "";
bool isChiuso = false;
try
{
isChiuso = DLMan.taTL.getByKey(CurrNumTask)[0].Concluso;
}
catch
{ }
// controllos e ho in sessione numTask altrimenti NON E' abilitato...
answ = noTask || isChiuso;
return answ;
}
}
/// <summary>
/// Verifica btn siano abilitati e nel caso x css aggiunge DISABLED
/// - ho una commessa
/// - la commessa NON E' chiusa...
/// </summary>
public string cssEnabled
{
get
{
string answ = "";
// controllos e ho in sessione numTask altrimenti NON E' abilitato...
answ = hasVeto ? "disabled" : "";
return answ;
}
}
}
}