Files
SSC/CMS_SC/Collaudi.aspx.cs
T
2015-09-16 18:07:04 +02:00

322 lines
10 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CMS_SC_Data;
using SteamWare;
namespace CMS_SC
{
public partial class Collaudi : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
((Bootstrap)this.Master).showSearch = true;
memLayer.ML.setSessionVal("showHist", false);
// pannello principale
mod_righePag.numRowPag = 10;
mod_collaudi.pageSize = mod_righePag.numRowPag;
// pannello secondario
mod_righePagPrev.numRowPag = 20;
mod_collaudiPrev.pageSize = mod_righePagPrev.numRowPag;
// collego ed aggiorno resto...
ddlFase.DataBind();
ddlDossier.DataBind();
ddlSelScheda.DataBind();
fixControls();
fixControlsPrev();
}
mod_righePag.eh_newNum += mod_righePag_eh_newNum;
mod_righePagPrev.eh_newNum += mod_righePagPrev_eh_newNum;
}
void mod_righePag_eh_newNum(object sender, EventArgs e)
{
mod_collaudi.pageSize = mod_righePag.numRowPag;
}
void mod_righePagPrev_eh_newNum(object sender, EventArgs e)
{
mod_collaudiPrev.pageSize = mod_righePagPrev.numRowPag;
}
void mod_collaudi_eh_selezioneValore(object sender, EventArgs e)
{
fixControls();
}
/// <summary>
/// sistema DropDownList
/// </summary>
private void fixControls()
{
btnShowHideHist.DataBind();
btnAddNewSetMis.DataBind();
btnAddNewSetMis.Visible = addNewVisible;
btnRemSetMis.DataBind();
btnRemSetMis.Visible = !addNewVisible && remMisVisible; // non devo inserire nulla e non ho nessuna misura inserita...
mod_collaudi.IdxDossier = IdxDossier;
mod_collaudi.CodSchedaVers = CodSchedaVers;
mod_collaudi.Fase = Fase;
mod_collaudi.doUpdate();
// se ho schema mostro link (eventuale) al doc...
hlDoc.Visible = false;
if (CodSchedaVers != "")
{
string path = "";
try
{
string CodScheda = CodSchedaVers.Substring(0, CodSchedaVers.LastIndexOf("."));
path = DtProxy.man.taASC.getByCodScheda(CodScheda)[0].Path;
}
catch
{
path = "";
}
if (path != "")
{
hlDoc.ToolTip = path;
hlDoc.NavigateUrl = DtProxy.getDocPath(path);
hlDoc.Visible = DtProxy.notNullDocPath(path);
}
}
}
private void fixControlsPrev()
{
// tolgo css a blococ main
divMain.Attributes.Remove("class");
// verifico SE devo mostrare storico...
if (showHist)
{
// imposto css x mostrare 2 blocchi
divMain.Attributes.Add("class", "col-xs-7");
btnShowHideHist.Text = traduci("btnHideHist");
divHist.Visible = true;
// sistemo dati storici
mod_collaudiPrev.IdxDossier = IdxDossier;
mod_collaudiPrev.CodSchedaVers = CodSchedaVersPrev;
mod_collaudiPrev.Fase = FasePrev;
mod_collaudiPrev.doUpdate();
}
else
{
// imposto css x mostrare solo blocco corrente e nascondo altro...
divMain.Attributes.Add("class", "col-xs-12");
btnShowHideHist.Text = traduci("btnShowHist");
divHist.Visible = false;
}
}
protected int IdxDossier
{
get
{
int answ = -1;
try
{
answ = Convert.ToInt32(ddlDossier.SelectedValue);
}
catch
{ }
return answ;
}
}
protected string CodSchedaVers
{
get
{
string answ = "-";
try
{
answ = ddlSelScheda.SelectedValue;
}
catch
{
answ = "-";
}
return answ;
}
}
protected string Fase
{
get
{
string answ = "-";
try
{
answ = ddlFase.SelectedValue;
}
catch
{
answ = "-";
}
return answ;
}
}
protected string CodSchedaVersPrev
{
get
{
string answ = "-";
try
{
answ = ddlSelSchedaPrev.SelectedValue;
}
catch
{
answ = "-";
}
return answ;
}
}
protected string FasePrev
{
get
{
string answ = "-";
try
{
answ = ddlFasePrev.SelectedValue;
}
catch
{
answ = "-";
}
return answ;
}
}
protected void ddlDossier_SelectedIndexChanged(object sender, EventArgs e)
{
ddlSelScheda.DataBind();
fixControls();
ddlSelSchedaPrev.DataBind();
fixControlsPrev();
}
protected void ddlSelScheda_SelectedIndexChanged(object sender, EventArgs e)
{
fixControls();
}
protected void ddlFase_SelectedIndexChanged(object sender, EventArgs e)
{
ddlDossier.DataBind();
ddlSelScheda.DataBind();
fixControls();
}
protected void ddlSelSchedaPrev_SelectedIndexChanged(object sender, EventArgs e)
{
fixControlsPrev();
}
protected void ddlFasePrev_SelectedIndexChanged(object sender, EventArgs e)
{
ddlSelSchedaPrev.DataBind();
fixControlsPrev();
}
/// <summary>
/// wrapper traduzione
/// </summary>
/// <param name="lemma"></param>
/// <returns></returns>
public string traduci(string lemma)
{
return user_std.UtSn.Traduci(lemma);
}
/// <summary>
/// aggiungo set misure (eventualmente) mancanti
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAddNewSetMis_click(object sender, EventArgs e)
{
int idxDossier = Convert.ToInt32(ddlDossier.SelectedValue);
DtProxy.man.taMis.insMissing(idxDossier, ddlSelScheda.SelectedValue, ddlFase.SelectedValue);
mod_collaudi.doUpdate();
fixControls();
}
/// <summary>
/// elimina set misure poiché VUOTE
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnRemSetMis_click(object sender, EventArgs e)
{
int idxDossier = Convert.ToInt32(ddlDossier.SelectedValue);
DtProxy.man.taMis.remSetMis(idxDossier, ddlSelScheda.SelectedValue, ddlFase.SelectedValue);
mod_collaudi.doUpdate();
fixControls();
}
/// <summary>
/// verifico se sia possibile aggiungere records (= mancano misure x lo stato indicato...)
/// </summary>
public bool addNewVisible
{
get
{
bool answ = false;
try
{
int idxDossier = Convert.ToInt32(ddlDossier.SelectedValue);
answ = DtProxy.man.taMis.getNum2Ins(idxDossier, ddlSelScheda.SelectedValue, ddlFase.SelectedValue).Rows.Count > 0;
}
catch (Exception exc)
{
logger.lg.scriviLog(string.Format("{0}", exc));
}
return answ;
}
}
/// <summary>
/// verifico se sia possibile rimuovere records (= NESSUNA misura INSERITA x lo stato indicato...)
/// </summary>
public bool remMisVisible
{
get
{
bool answ = false;
// in primis: deve essere selezionata SINGOLA scheda...
if (ddlSelScheda.SelectedValue != "")
{
try
{
int idxDossier = Convert.ToInt32(ddlDossier.SelectedValue);
answ = DtProxy.man.taMis.getDataFilt(idxDossier, ddlSelScheda.SelectedValue, ddlFase.SelectedValue).Select("Valoremis <> ''").Length == 0;
}
catch (Exception exc)
{
logger.lg.scriviLog(string.Format("{0}", exc));
}
}
return answ;
}
}
protected void ddlFase_DataBound(object sender, EventArgs e)
{
fixControls();
}
/// <summary>
/// show/hide archivio collaudi
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnShowHideHist_Click(object sender, EventArgs e)
{
// toggle visibilità
showHist = !showHist;
//fixControls();
fixControlsPrev();
}
public bool showHist
{
get
{
return memLayer.ML.BoolSessionObj("showHist");
}
set
{
memLayer.ML.setSessionVal("showHist", value);
}
}
}
}