Files
NKC/NKC_WF/WebUserControls/cmp_batchList.ascx.cs
T
2019-08-22 17:20:43 +02:00

117 lines
2.8 KiB
C#

using AppData;
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_batchList : System.Web.UI.UserControl
{
public event EventHandler eh_doRefresh;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
divDetail.Visible = false;
}
cmp_batchDetail.eh_doRefresh += Cmp_batchDetail_eh_doRefresh;
cmp_numRow.eh_doRefresh += Cmp_numRow_eh_doRefresh;
}
private void Cmp_numRow_eh_doRefresh(object sender, EventArgs e)
{
// recupero num righe ed aggiorno...
grView.PageSize = cmp_numRow.numRow;
grView.DataBind();
}
private void Cmp_batchDetail_eh_doRefresh(object sender, EventArgs e)
{
resetSelezione();
}
/// <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>
/// 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>
/// comando reset
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbtReset_Click(object sender, EventArgs e)
{
resetSelezione();
}
private void resetSelezione()
{
grView.SelectedIndex = -1;
grView.DataBind();
divDetail.Visible = false;
}
/// <summary>
/// BatchId selezionato
/// </summary>
protected int BatchIdSel
{
get
{
int answ = 0;
int.TryParse(grView.SelectedValue.ToString(), out answ);
return answ;
}
}
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
{
divDetail.Visible = true;
// recupero BatchId selezionato
cmp_batchDetail.BatchId = BatchIdSel;
}
}
}