266 lines
7.1 KiB
C#
266 lines
7.1 KiB
C#
using MagData;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace MP_MAG.WebUserControls
|
|
{
|
|
public partial class cmp_elencoPedane : BaseUserControl
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// AL selezionato
|
|
/// </summary>
|
|
public string AlSel
|
|
{
|
|
get
|
|
{
|
|
return grView.SelectedValue.ToString();
|
|
}
|
|
}
|
|
|
|
public string lastCmd
|
|
{
|
|
get
|
|
{
|
|
return hfLastCmd.Value;
|
|
}
|
|
set
|
|
{
|
|
hfLastCmd.Value = value;
|
|
}
|
|
}
|
|
|
|
public int PackListID
|
|
{
|
|
get
|
|
{
|
|
int answ = 0;
|
|
int.TryParse(hfPackListID.Value, out answ);
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
hfPackListID.Value = $"{value}";
|
|
doUpdate();
|
|
checkBtn();
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Private Methods
|
|
|
|
private void checkBtn()
|
|
{
|
|
// verifica buttons secondo stato PackList...
|
|
var tabPL = MagDataLayerObj.taPList.getByKey(PackListID);
|
|
bool showStart = false;
|
|
bool showEnd = false;
|
|
if (tabPL.Rows.Count > 0)
|
|
{
|
|
showStart = (tabPL[0].PackStatus == 1);
|
|
showEnd = (tabPL[0].PackStatus == 2);
|
|
}
|
|
lbtSetStarted.Visible = showStart;
|
|
lbtSetCompleted.Visible = showEnd;
|
|
}
|
|
|
|
private void Cmp_numRow_eh_doRefresh(object sender, EventArgs e)
|
|
{
|
|
grView.PageSize = cmp_numRow.numRow;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Toggle buttons x add new pedana
|
|
/// </summary>
|
|
private void toggleAddNew()
|
|
{
|
|
divAddNew.Visible = !divAddNew.Visible;
|
|
lbtShowAdd.Text = divAddNew.Visible ? "Nascondi" : "Aggiungi";
|
|
int newNum = 0;
|
|
// calcolo quante pedane ho...
|
|
try
|
|
{
|
|
var tabAL = MagDataLayer.man.taEAL.getByPackList(PackListID);
|
|
newNum = tabAL.Count + 1;
|
|
}
|
|
catch
|
|
{ }
|
|
// descrizione
|
|
txtDescr.Text = $"{newNum}";
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
#region Protected Methods
|
|
|
|
protected void grView_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
|
|
{
|
|
raiseReset();
|
|
}
|
|
|
|
protected void grView_RowCommand(object sender, GridViewCommandEventArgs e)
|
|
{
|
|
if (e.CommandArgument != null)
|
|
{
|
|
lastCmd = $"{e.CommandArgument}";
|
|
}
|
|
else
|
|
{
|
|
lastCmd = "";
|
|
}
|
|
}
|
|
|
|
protected void grView_RowEditing(object sender, GridViewEditEventArgs e)
|
|
{
|
|
raiseEditing();
|
|
}
|
|
|
|
protected void grView_RowUpdated(object sender, GridViewUpdatedEventArgs e)
|
|
{
|
|
raiseEvent();
|
|
}
|
|
|
|
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
// esegue stampa...
|
|
if (lastCmd == "print")
|
|
{
|
|
// metto in coda di stampa...
|
|
tipoDocumento tipoDoc = tipoDocumento.docPedana;
|
|
string keyParam = $"{grView.SelectedValue}";
|
|
MagDataLayerObj.taPJQ.insertQuery($"{tipoDoc}", keyParam, ddlCartPedane.SelectedValue);
|
|
lastCmd = "";
|
|
}
|
|
// se qualcuno ascolta sollevo evento nuovo valore...
|
|
raiseEvent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creazione nuova pedana
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbkAddNew_Click(object sender, EventArgs e)
|
|
{
|
|
// FIX ME / TODO: se manca cod opr lo recupera da default
|
|
string currCodOpr = "OPR.01";
|
|
if (currProdData != null)
|
|
{
|
|
try
|
|
{
|
|
currCodOpr = currProdData.CodOpr;
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
int TaraAL = 0;
|
|
try
|
|
{
|
|
TaraAL = SteamWare.memLayer.ML.CRI("TaraAL");
|
|
}
|
|
catch
|
|
{ }
|
|
// chiamo insert
|
|
MagDataLayer.man.taEAL.insertQuery(DateTime.Today, "PED", currCodOpr, txtDescr.Text.Trim(), PackListID, TaraAL);
|
|
// nascondo add...
|
|
toggleAddNew();
|
|
// update!!!
|
|
grView.DataBind();
|
|
}
|
|
|
|
#if false
|
|
/// <summary>
|
|
/// Avvia stampa report pedana
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbtPrintReport_Click(object sender, EventArgs e)
|
|
{
|
|
// lancio il report x l'elenco pedane + contenuto
|
|
MagDataLayerObj.taPJQ.insertQuery($"{tipoDocumento.docPackList}", $"{PackListID}", ddlPost.SelectedValue);
|
|
}
|
|
#endif
|
|
|
|
/// <summary>
|
|
/// comando reset
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbtReset_Click(object sender, EventArgs e)
|
|
{
|
|
resetSelezione();
|
|
}
|
|
|
|
protected void lbtSetCompleted_Click(object sender, EventArgs e)
|
|
{
|
|
MagDataLayerObj.taPList.updateStatus(PackListID, 3);
|
|
checkBtn();
|
|
resetSelezione();
|
|
}
|
|
|
|
protected void lbtSetStarted_Click(object sender, EventArgs e)
|
|
{
|
|
MagDataLayerObj.taPList.updateStatus(PackListID, 2);
|
|
checkBtn();
|
|
resetSelezione();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Mostra btn add new
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbtShowAdd_Click(object sender, EventArgs e)
|
|
{
|
|
toggleAddNew();
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
cmp_numRow.numRow = 10;
|
|
grView.PageSize = cmp_numRow.numRow;
|
|
divAddNew.Visible = false;
|
|
lastCmd = "";
|
|
lbtSetStarted.DataBind();
|
|
lbtSetCompleted.DataBind();
|
|
}
|
|
cmp_numRow.eh_doRefresh += Cmp_numRow_eh_doRefresh;
|
|
checkBtn();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Public Methods
|
|
|
|
public bool canDelete(object _numUdc)
|
|
{
|
|
int numUdc = 999;
|
|
int.TryParse(_numUdc.ToString(), out numUdc);
|
|
return numUdc == 0;
|
|
}
|
|
|
|
public void doUpdate()
|
|
{
|
|
grView.DataBind();
|
|
}
|
|
|
|
public void resetSelezione()
|
|
{
|
|
lastCmd = "";
|
|
grView.SelectedIndex = -1;
|
|
doUpdate();
|
|
raiseReset();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |