459 lines
13 KiB
C#
459 lines
13 KiB
C#
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace MP_ADM.WebUserControls
|
|
{
|
|
public partial class cmp_PODL_OUT : BaseUserControl
|
|
{
|
|
#region Protected Fields
|
|
|
|
protected string _idxGridView;
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Public Fields
|
|
|
|
/// <summary>
|
|
/// Determina se sia solo readonly il controllo...
|
|
/// </summary>
|
|
public bool readOnly;
|
|
|
|
#endregion Public Fields
|
|
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// CodArt filtrato
|
|
/// </summary>
|
|
public string CodArticolo
|
|
{
|
|
get
|
|
{
|
|
return hfCodArt.Value;
|
|
}
|
|
set
|
|
{
|
|
hfCodArt.Value = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Chiave PRE selezione tipo richiesta ordine
|
|
/// </summary>
|
|
public string CodCliente
|
|
{
|
|
get
|
|
{
|
|
return hfCodCli.Value;
|
|
}
|
|
set
|
|
{
|
|
hfCodCli.Value = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gruppo selezionato
|
|
/// </summary>
|
|
public string CodGruppo
|
|
{
|
|
get
|
|
{
|
|
return hfCodGrp.Value;
|
|
}
|
|
set
|
|
{
|
|
hfCodGrp.Value = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// IdxMacchina filtrata
|
|
/// </summary>
|
|
public string IdxMacchinaFilt
|
|
{
|
|
get
|
|
{
|
|
return hfIdxMacc.Value;
|
|
}
|
|
set
|
|
{
|
|
hfIdxMacc.Value = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// dimensione pagina
|
|
/// </summary>
|
|
public int pageSize
|
|
{
|
|
get
|
|
{
|
|
int answ = 10;
|
|
try
|
|
{
|
|
answ = Convert.ToInt32(txtPageSize.Text);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
txtPageSize.Text = value.ToString();
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Private Methods
|
|
|
|
private void checkActions()
|
|
{
|
|
// calcolo visibilità (almeno 1 selezionato)
|
|
bool showActions = false;
|
|
foreach (GridViewRow riga in grView.Rows)
|
|
{
|
|
if (((CheckBox)riga.FindControl("chkSelect")).Checked && ((CheckBox)riga.FindControl("chkSelect")).Visible)
|
|
{
|
|
showActions = true;
|
|
}
|
|
if (showActions)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
divActions.Visible = showActions;
|
|
divMachine.Visible = showActions;
|
|
}
|
|
|
|
private void fixSetMachine()
|
|
{
|
|
ddlSelMacchina.Enabled = chkReassign.Checked;
|
|
lbtReassignMachine.Visible = chkReassign.Checked;
|
|
if (!chkReassign.Checked)
|
|
{
|
|
ddlSelMacchina.SelectedIndex = 0;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Imposta Promesse selezionate come attivabili secondo richiesta
|
|
/// </summary>
|
|
/// <param name="isAttivabile"></param>
|
|
private void setPromAttivabili(bool isAttivabile)
|
|
{
|
|
int IdxPromessa = 0;
|
|
foreach (GridViewRow riga in grView.Rows)
|
|
{
|
|
if (((CheckBox)riga.FindControl("chkSelect")).Checked && ((CheckBox)riga.FindControl("chkSelect")).Visible)
|
|
{
|
|
int.TryParse(((Label)riga.FindControl("lblIdxPromessa")).Text, out IdxPromessa);
|
|
// disattivo!
|
|
DataLayerObj.taPromOut.updAttiva(IdxPromessa, isAttivabile);
|
|
}
|
|
}
|
|
updateGrView();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Aggiorno Gridview
|
|
/// </summary>
|
|
private void updateGrView()
|
|
{
|
|
grView.DataBind();
|
|
checkActions();
|
|
raiseNewVal();
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
#region Protected Methods
|
|
|
|
/// <summary>
|
|
/// reset della selezione
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnReset_Click(object sender, EventArgs e)
|
|
{
|
|
resetSelezione();
|
|
}
|
|
|
|
/// <summary>
|
|
/// seleziona/deseleziona le righe indicate...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSelAll_Click(object sender, EventArgs e)
|
|
{
|
|
// seleziono tutti i valori visibili nel datagrid
|
|
CheckBox chkbox = ((CheckBox)sender);
|
|
bool isChecked = chkbox.Checked;
|
|
if (!isChecked)
|
|
{
|
|
chkbox.ToolTip = traduci("btnSelAll");
|
|
}
|
|
else
|
|
{
|
|
chkbox.ToolTip = traduci("btnDeselAll");
|
|
}
|
|
foreach (GridViewRow riga in grView.Rows)
|
|
{
|
|
((CheckBox)riga.FindControl("chkSelect")).Checked = isChecked;
|
|
}
|
|
checkActions();
|
|
}
|
|
|
|
protected void chkReassign_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
fixSetMachine();
|
|
}
|
|
|
|
protected void chkSelect_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
checkActions();
|
|
}
|
|
|
|
protected void chkUnassigned_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
updateGrView();
|
|
}
|
|
|
|
/// <summary>
|
|
/// elenco colonne del datagrid
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected DataColumnCollection colonneObj()
|
|
{
|
|
MapoDb.DS_ProdTempi.ODLDataTable tabella = new MapoDb.DS_ProdTempi.ODLDataTable();
|
|
DataColumnCollection colonne = tabella.Columns;
|
|
return colonne;
|
|
}
|
|
|
|
/// <summary>
|
|
/// salvo comando
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbt_Command(object sender, CommandEventArgs e)
|
|
{
|
|
memLayer.ML.setSessionVal("nextObjCommand", ((LinkButton)sender).CommandArgument);
|
|
}
|
|
|
|
protected void lbtAttiva_Click(object sender, EventArgs e)
|
|
{
|
|
setPromAttivabili(true);
|
|
}
|
|
|
|
protected void lbtDisattiva_Click(object sender, EventArgs e)
|
|
{
|
|
setPromAttivabili(false);
|
|
}
|
|
|
|
protected void lbtElimina_Click(object sender, EventArgs e)
|
|
{
|
|
int IdxPromessa = 0;
|
|
int IdxOdl = 0;
|
|
foreach (GridViewRow riga in grView.Rows)
|
|
{
|
|
if (((CheckBox)riga.FindControl("chkSelect")).Checked && ((CheckBox)riga.FindControl("chkSelect")).Visible)
|
|
{
|
|
int.TryParse(((Label)riga.FindControl("lblIdxOdl")).Text, out IdxOdl);
|
|
if (IdxOdl == 0)
|
|
{
|
|
int.TryParse(((Label)riga.FindControl("lblIdxPromessa")).Text, out IdxPromessa);
|
|
// ELIMINO!
|
|
DataLayerObj.taPromOut.deleteQuery(IdxPromessa);
|
|
}
|
|
}
|
|
}
|
|
updateGrView();
|
|
}
|
|
|
|
protected void lbtReassignMachine_Click(object sender, EventArgs e)
|
|
{
|
|
int IdxPromessa = 0;
|
|
int IdxOdl = 0;
|
|
string idxMacchina2Reass = ddlSelMacchina.SelectedValue;
|
|
if (!string.IsNullOrEmpty(idxMacchina2Reass))
|
|
{
|
|
foreach (GridViewRow riga in grView.Rows)
|
|
{
|
|
if (((CheckBox)riga.FindControl("chkSelect")).Checked && ((CheckBox)riga.FindControl("chkSelect")).Visible)
|
|
{
|
|
int.TryParse(((Label)riga.FindControl("lblIdxOdl")).Text, out IdxOdl);
|
|
if (IdxOdl == 0)
|
|
{
|
|
int.TryParse(((Label)riga.FindControl("lblIdxPromessa")).Text, out IdxPromessa);
|
|
// riassegno!
|
|
DataLayerObj.taPromOut.updMacchina(IdxPromessa, idxMacchina2Reass);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
updateGrView();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Richiesto abbassamento priorità = RITARDA
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lnkMoveDown_Click(object sender, EventArgs e)
|
|
{
|
|
LinkButton lb = (LinkButton)sender;
|
|
// imposto articolo, splittando
|
|
int IdxPromessa = 0;
|
|
int.TryParse(lb.CommandArgument, out IdxPromessa);
|
|
// chiamo stored
|
|
DataLayerObj.taPromOut.movePrio(IdxPromessa, -1);
|
|
//update!
|
|
updateGrView();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Richiesto aumento priorità = ANTICIPA
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lnkMoveUp_Click(object sender, EventArgs e)
|
|
{
|
|
LinkButton lb = (LinkButton)sender;
|
|
// imposto articolo, splittando
|
|
int IdxPromessa = 0;
|
|
int.TryParse(lb.CommandArgument, out IdxPromessa);
|
|
// chiamo stored
|
|
DataLayerObj.taPromOut.movePrio(IdxPromessa, 1);
|
|
//update!
|
|
updateGrView();
|
|
}
|
|
|
|
/// <summary>
|
|
/// inizializzazione valori di default
|
|
/// </summary>
|
|
/// <param name="e"></param>
|
|
protected override void OnInit(EventArgs e)
|
|
{
|
|
base.OnInit(e);
|
|
_idxGridView = "IdxPromessa";
|
|
fixSetMachine();
|
|
}
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
base.OnLoad(e);
|
|
if (!Page.IsPostBack)
|
|
{
|
|
grView.PageSize = pageSize;
|
|
divActions.Visible = false;
|
|
divMachine.Visible = false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// cambio dim pagina
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void txtPageSize_TextChanged(object sender, EventArgs e)
|
|
{
|
|
grView.PageSize = pageSize;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// Verifica se sia permesso cambio priorità (NON può andare a 0 ne oltre il max x macchina)
|
|
/// </summary>
|
|
/// <param name="IdxMacchina"></param>
|
|
/// <param name="priorStr"></param>
|
|
/// <param name="delta"></param>
|
|
/// <returns></returns>
|
|
public bool checkChgPrio(string IdxMacchina, string priorStr, int delta)
|
|
{
|
|
bool enableChgPrio = false;
|
|
int priorita = 0;
|
|
int.TryParse(priorStr, out priorita);
|
|
// calcolo i limiti priorità x macchina (0 --> max x macchina)... LPI/LPS liminte priorità inferiore / superiore
|
|
int LPI = 1;
|
|
int LPS = 1;
|
|
var tabella = DataLayerObj.taPromOut.getMaxPrioByMacc(IdxMacchina, true);
|
|
if (tabella.Rows.Count > 0)
|
|
{
|
|
LPS = tabella[0].Priorita;
|
|
}
|
|
// è ok SE sono ENTRO i 2 limiti
|
|
enableChgPrio = ((priorita + delta) >= LPI && (priorita + delta) <= LPS);
|
|
|
|
bool singleMachine = !string.IsNullOrEmpty(IdxMacchinaFilt) && IdxMacchinaFilt == IdxMacchina;
|
|
|
|
return enableChgPrio && singleMachine;
|
|
}
|
|
|
|
public string cssByAtt(object currAtt)
|
|
{
|
|
string answ = "";
|
|
bool attivabile = false;
|
|
bool.TryParse($"{currAtt}", out attivabile);
|
|
answ = attivabile ? "text-primary" : "text-secondary";
|
|
return answ;
|
|
}
|
|
|
|
public bool delEnabled(object _idxOdl)
|
|
{
|
|
bool answ = false;
|
|
int idxOdl = 0;
|
|
// controllo non sia già stata iniziata la produzione sennò non posso cancellare...
|
|
try
|
|
{
|
|
idxOdl = Convert.ToInt32(_idxOdl);
|
|
answ = (DataLayerObj.taODL.getByIdx(idxOdl, true).Count > 0);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
|
|
public void doUpdate()
|
|
{
|
|
grView.DataBind();
|
|
checkActions();
|
|
}
|
|
|
|
/// <summary>
|
|
/// formatot url x stampa ODL
|
|
/// </summary>
|
|
/// <param name="idx"></param>
|
|
/// <returns></returns>
|
|
public string formattaUrlOdl(object idx)
|
|
{
|
|
string answ = String.Format(memLayer.ML.CRS("exportFormat1"), Convert.ToInt32(reportRichiesto.SchedaODL), idx);
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// resetta la selezione dei valori in caso di modifiche su altri controlli
|
|
/// </summary>
|
|
public void resetSelezione()
|
|
{
|
|
divActions.Visible = false;
|
|
divMachine.Visible = false;
|
|
memLayer.ML.emptySessionVal(string.Format("{0}_sel", _idxGridView));
|
|
grView.SelectedIndex = -1;
|
|
grView.DataBind();
|
|
lblWarning.Visible = false;
|
|
raiseReset();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |