Files
SSC/CMS_SC/WebUserControls/mod_collaudi.ascx.cs
2018-03-27 14:31:41 +02:00

404 lines
10 KiB
C#

using CMS_SC_Data;
using SteamWare;
using System;
using System.Web.UI.WebControls;
namespace CMS_SC.WebUserControls
{
public partial class mod_collaudi : SteamWare.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
/// <summary>
/// dimensione pagina grid view
/// </summary>
public int pageSize
{
get
{
return grView.PageSize;
}
set
{
grView.PageSize = value;
}
}
public int IdxDossier
{
get
{
int answ = -1;
try
{
answ = Convert.ToInt32(hfIdxDossier.Value);
}
catch
{ }
return answ;
}
set
{
hfIdxDossier.Value = value.ToString();
}
}
public string CodSchedaVers
{
get
{
string answ = "-";
try
{
answ = hfCodSchedaVers.Value;
}
catch
{ }
return answ;
}
set
{
hfCodSchedaVers.Value = value;
}
}
public string Fase
{
get
{
string answ = "-";
try
{
answ = hfFase.Value;
}
catch
{ }
return answ;
}
set
{
hfFase.Value = value;
}
}
public int Rev
{
get
{
int answ = 0;
try
{
int.TryParse(hfRev.Value, out answ);
}
catch
{ }
return answ;
}
set
{
hfRev.Value = value.ToString();
}
}
public void doUpdate()
{
try
{
grView.DataBind();
}
catch (Exception exc)
{
logger.lg.scriviLog(string.Format("Eccezione in databind, valori filtro{0}Dossier: [{1}]{0}CodScheda: [{2}]{0}Fase: [{3}]{0}Rev: [{4}]{0}Eccezione:{0}{5}", Environment.NewLine, IdxDossier, CodSchedaVers, Fase, Rev, exc));
}
}
/// <summary>
/// intercetto valori...
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ods_Updating(object sender, ObjectDataSourceMethodEventArgs e)
{
// aggiungo operatore...
e.InputParameters["Operatore"] = user_std.UtSn.utente;
// fix eventuali null x misura...
if (e.InputParameters["ValoreMis"] == null) e.InputParameters["ValoreMis"] = "";
// ...e parametro
if (e.InputParameters["ValorePar"] == null) e.InputParameters["ValorePar"] = "0";
}
/// <summary>
/// verifica se l'utente sia un SuperUser (e possa di conseguenza operare...)
/// </summary>
protected bool userCanDerogate
{
get
{
// 2018.02.21 SOLO chi ah deroga può procedere...
//return (userIsCapoOfficina || userIsCapoGruppo || userIsDerogator);
return userIsDerogator;
}
}
/// <summary>
/// verifica se utente sia SuperUser
/// </summary>
public bool userIsCapoOfficina
{
get
{
return devicesAuthProxy.stObj.userHasRight(memLayer.ML.CRS("CapoOfficinaRole"));
}
}
/// <summary>
/// verifica se utente sia SuperUser
/// </summary>
public bool userIsCapoGruppo
{
get
{
return devicesAuthProxy.stObj.userHasRight(memLayer.ML.CRS("CapoGruppo"));
}
}
/// <summary>
/// verifica se utente sia SuperUser
/// </summary>
public bool userIsDerogator
{
get
{
return devicesAuthProxy.stObj.userHasRight(memLayer.ML.CRS("DerogaRole"));
}
}
/// <summary>
/// verifica la possibilità di deroga utente: se
/// - è KO la misura
/// - è utente admin
/// - in base al tipo di action (add/rem), dipende se ci sia deroga...
/// </summary>
/// <param name="actionType">azione x deroga: ADD / REM</param>
/// <param name="CodDeroga">valore attuale deroga</param>
/// <param name="OkValMis">valore di OK/KO misura</param>
/// <returns></returns>
public bool hasDeroga(string actionType, object CodDeroga, object OkValMis)
{
bool answ = false;
bool okAddRem = ((CodDeroga.ToString() == "" && actionType == "ADD") || (CodDeroga.ToString() != "" && actionType == "REM"));
try
{
answ = userCanDerogate && !Convert.ToBoolean(OkValMis) && okAddRem;
}
catch
{ }
return answ;
}
/// <summary>
/// ultimo comando letto da link button
/// </summary>
public string lastCmd { get; set; }
/// <summary>
/// selezione comando (x intercettare deroghe)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
{
int IdxDossier = 0;
string CodScheda = "";
int Vers = 0;
int NumScheda = 0;
string CodMisura = "";
string Fase = "";
int Rev = 0;
try
{
IdxDossier = Convert.ToInt32(grView.SelectedDataKey["IdxDossier"]);
CodScheda = grView.SelectedDataKey["CodScheda"].ToString();
Vers = Convert.ToInt32(grView.SelectedDataKey["Vers"]);
NumScheda = Convert.ToInt32(grView.SelectedDataKey["NumScheda"]);
CodMisura = grView.SelectedDataKey["CodMisura"].ToString();
Fase = grView.SelectedDataKey["Fase"].ToString();
int.TryParse(grView.SelectedDataKey["Rev"].ToString(), out Rev);
}
catch
{ }
// verifico se ho cmd argumento x fare ADD/DEL...
switch (lastCmd)
{
case "ADD":
DtProxy.man.taMis.deroga(IdxDossier, CodScheda, Vers, NumScheda, CodMisura, Fase, Rev, string.Format("{0} - {1:yyyy/MM/dd HH:mm}", user_std.UtSn.utente, DateTime.Now));
break;
case "REM":
DtProxy.man.taMis.deroga(IdxDossier, CodScheda, Vers, NumScheda, CodMisura, Fase, Rev, "");
break;
case "HIDE":
DtProxy.man.taMis.SetVisib(IdxDossier, CodScheda, Vers, NumScheda, CodMisura, Fase, Rev, "X");
break;
case "SHOW":
DtProxy.man.taMis.SetVisib(IdxDossier, CodScheda, Vers, NumScheda, CodMisura, Fase, Rev, "FCS");
break;
}
grView.SelectedIndex = -1;
grView.DataBind();
raiseEvent(ucEvType.ReqUpdateParent);
}
protected void grView_RowCommand(object sender, GridViewCommandEventArgs e)
{
// salvo il command argument...
lastCmd = e.CommandArgument.ToString();
}
public bool editEnabled
{
get
{
bool answ = false;
try
{
answ = Convert.ToBoolean(hfEditEnabled.Value);
}
catch
{ }
return answ;
}
set
{
hfEditEnabled.Value = value.ToString();
}
}
/// <summary>
/// formatta URL x mostrare i file associati al record
/// </summary>
/// <param name="_filter"></param>
/// <param name="_enableMod"></param>
/// <returns></returns>
public string fileTarget(object _filter, object _enableMod)
{
string answ = "FileManager";
try
{
answ = string.Format(memLayer.ML.CRS("fileManUrl"), _filter, _enableMod);
}
catch
{ }
return answ;
}
public string contaAllegati(object filtro)
{
string answ = traduci("FileAllegati");
try
{
int numFile = DtProxy.man.taFiles.getByFiltKey(filtro.ToString()).Rows.Count;
answ = string.Format("{0} {1}", numFile, answ);
}
catch
{ }
return answ;
}
/// <summary>
/// save del record
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
//// salvo
//int idxEdit = grView.EditIndex;
//grView.UpdateRow(grView.EditIndex, false);
//grView.EditIndex = -1;
//grView.DataBind();
// verifico SE sia in editing...
if (grView.EditIndex >= 0)
{
// salvo
grView.UpdateRow(grView.EditIndex, false);
grView.EditIndex = -1;
grView.DataBind();
}
}
/// <summary>
/// recupera codice scheda/vers da scheda/vers/num
/// </summary>
/// <param name="codSchedaVers"></param>
/// <returns></returns>
protected string getPathDoc(string codSchedaVers)
{
string answ = "";
string codScheda = "";
if (codSchedaVers != "")
{
try
{
codScheda = codSchedaVers.Substring(0, codSchedaVers.LastIndexOf("."));
}
catch
{ }
if (codScheda != "")
{
try
{
answ = DtProxy.man.taASC.getByCodScheda(codScheda)[0].Path;
}
catch
{
answ = "";
}
}
}
return answ;
}
/// <summary>
/// verifica se ci sia un doc da mostrare...
/// </summary>
/// <param name="codSchedaVers"></param>
/// <returns></returns>
public bool hasDoc(object _currCodSchedaVers)
{
bool answ = false;
string pathDoc = getPathDoc(_currCodSchedaVers.ToString());
if (pathDoc != "")
{
answ = DtProxy.notNullDocPath(pathDoc);
}
return answ;
}
/// <summary>
/// link URL doc da mostrare...
/// </summary>
/// <param name="codSchedaVers"></param>
/// <returns></returns>
public string urlDoc(object _currCodSchedaVers)
{
string answ = "";
string pathDoc = getPathDoc(_currCodSchedaVers.ToString());
if (pathDoc != "")
{
answ = DtProxy.getDocPath(pathDoc);
}
return answ;
}
protected void ods_Updated(object sender, ObjectDataSourceStatusEventArgs e)
{
// segnalo update
raiseEvent(ucEvType.ReqUpdateParent);
}
/// <summary>
/// Calcolo il TextBoxMode dato il valore del parametro TipoValMisura
/// </summary>
/// <param name="TipoValMis"></param>
/// <returns></returns>
public TextBoxMode tModeByTipo(object TipoValMis)
{
TextBoxMode answ = TextBoxMode.SingleLine;
if (TipoValMis.ToString() == "TEXTAREA") answ = TextBoxMode.MultiLine;
return answ;
}
public string isHidden(object codVisib)
{
string answ = "";
// verifico, se ha "X" nei cod visib è HIDDEN...
if (codVisib.ToString().ToUpper() == "X") answ = "textStrike";
return answ;
}
}
}