Files
NKC/NKC_WF/WebUserControls/cmp_BatchStatsList.ascx.cs
T
2021-10-05 15:33:38 +02:00

342 lines
8.9 KiB
C#

using AppData;
using NKC_SDK;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace NKC_WF.WebUserControls
{
public partial class cmp_BatchStatsList : BaseUserControl
{
#region Protected Properties
/// <summary>
/// BatchId selezionato
/// </summary>
protected int BatchIdSel
{
get
{
int answ = 0;
if (grView.SelectedValue != null)
{
int.TryParse(grView.SelectedValue.ToString(), out answ);
}
return answ;
}
}
/// <summary>
/// Status corrente del batch
/// </summary>
protected BatchStatus CurrBatchStatus
{
get
{
return ComLib.BStatus(BatchIdSel);
}
}
protected int currSelRow
{
get
{
return grView.SelectedIndex;
}
set
{
grView.SelectedIndex = value;
}
}
protected int ShowLast
{
get
{
int answ = 100;
int.TryParse(txtNumShow.Text, out answ);
return answ;
}
set
{
txtNumShow.Text = $"{value}";
}
}
#endregion Protected Properties
#region Public Properties
/// <summary>
/// modalità funzionamento controllo
/// </summary>
public BatchListMode listMode { get; set; } = BatchListMode.Standard;
#endregion Public Properties
#region Private Methods
private void Cmp_batchDetail_eh_doRefresh(object sender, EventArgs e)
{
resetSelezione();
}
private void Cmp_numRow_eh_doRefresh(object sender, EventArgs e)
{
// recupero num righe ed aggiorno...
grView.PageSize = cmp_numRow.numRow;
grView.DataBind();
}
private void resetSelezione()
{
grView.SelectedIndex = -1;
grView.DataBind();
raiseReset();
}
private void updateGraph()
{
cmp_BatchStatsPlot.PlotType = ddlType.SelectedValue;
cmp_BatchStatsPlot.ShowLast = ShowLast;
cmp_BatchStatsPlot.Legend = traduci($"rep_{ddlType.SelectedValue}");
}
#endregion Private Methods
#region Protected Methods
protected void chkPlotGraph_CheckedChanged(object sender, EventArgs e)
{
doUpdate();
}
protected void chkShowSplit_CheckedChanged(object sender, EventArgs e)
{
// deseleziono...
resetSelezione();
}
protected void ddlPlaces_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void ddlStatus_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void ddlType_SelectedIndexChanged(object sender, EventArgs e)
{
doUpdate();
}
protected void grView_PageIndexChanged(object sender, EventArgs e)
{
}
protected void lbRedoEval_Click(object sender, EventArgs e)
{
LinkButton lbt = (LinkButton)sender;
if (!string.IsNullOrEmpty(lbt.CommandArgument))
{
// eseguo richiesta reset
DLMan.taBL.redoPartValid(lbt.CommandArgument);
// eventualmente mando primo batch da validare...
bool newValidSent = ComLib.sendFirstValidationBatch();
// refresh!
resetSelezione();
}
}
/// <summary>
/// comando reset
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbtReset_Click(object sender, EventArgs e)
{
resetSelezione();
}
/// <summary>
/// Caricamento pagina
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
cmp_numRow.numRow = 10;
grView.PageSize = cmp_numRow.numRow;
divGraph.Visible = false;
ddlType.Visible = false;
}
cmp_numRow.eh_doRefresh += Cmp_numRow_eh_doRefresh;
}
protected void txtNumShow_TextChanged(object sender, EventArgs e)
{
doUpdate();
}
#endregion Protected Methods
#region Public Methods
/// <summary>
/// Converte il codice stato in effettivo campo
/// </summary>
/// <param name="_status"></param>
/// <returns></returns>
public string BStatus(object _status)
{
string answ = ComLib.BatchStatusDescr(_status);
return answ;
}
/// <summary>
/// Codice CSS in base a status...
/// </summary>
/// <param name="_status"></param>
/// <returns></returns>
public string cssByStatus(object _status)
{
string answ = "text-muted";
int status = -1;
int.TryParse(_status.ToString(), out status);
switch (status)
{
case 1:
answ = "font-weight-bold text-info";
break;
case 2:
answ = "font-weight-bold text-primary";
break;
case 3:
answ = "font-weight-bold text-warning";
break;
case 4:
answ = "font-weight-bold text-danger";
break;
case 5:
answ = "font-weight-bold text-success";
break;
case 6:
answ = "font-weight-bold text-secondary";
break;
default:
break;
}
return answ;
}
/// <summary>
/// Codice CSS in base a BatchType...
/// </summary>
/// <param name="_BatchType"></param>
/// <returns></returns>
public string cssIconByType(object _BatchType)
{
string answ = "fa fa-circle-thin";
int status = -1;
int.TryParse(_BatchType.ToString(), out status);
switch (status)
{
case 0:
answ = "fa fa-file-text-o";
break;
case 1:
answ = "fa fa-file-text";
break;
case 2:
answ = "fa fa-scissors";
break;
default:
break;
}
return answ;
}
public void doUpdate()
{
divGraph.Visible = chkPlotGraph.Checked;
ddlType.Visible = chkPlotGraph.Checked;
if (chkPlotGraph.Checked)
{
updateGraph();
}
grView.DataBind();
}
/// <summary>
/// Determina se sia visibile previewin base a BatchType...
/// </summary>
/// <param name="_BatchType"></param>
/// <returns></returns>
public bool hasPreviewByType(object _BatchType)
{
bool answ = false;
int status = -1;
int.TryParse(_BatchType.ToString(), out status);
switch (status)
{
case 0:
case 2:
answ = true;
break;
case 1:
default:
answ = false;
break;
}
return answ;
}
/// <summary>
/// Verifica se sia visualizzabile preview dato stato
/// </summary>
/// <param name="_status"></param>
/// <returns></returns>
public bool isPreviewVisible(object _status)
{
bool answ = false;
int status = -1;
int.TryParse(_status.ToString(), out status);
// solo stati 4 (nesting done), 5 (approvato), 6 (eliminazione logica)
if (status > 3 && status < 7)
{
answ = true;
}
return answ;
}
/// <summary>
/// Tooltip in base a BatchType...
/// </summary>
/// <param name="_BatchType"></param>
/// <returns></returns>
public string tooltipByType(object _BatchType)
{
string answ = "-";
answ = traduci($"tooltipBatchType_{_BatchType}");
return answ;
}
#endregion Public Methods
}
}