230 lines
8.6 KiB
C#
230 lines
8.6 KiB
C#
using Microsoft.Ajax.Utilities;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace MoonProTablet.WebUserControls
|
|
{
|
|
public partial class cmp_ST_objCheck : BaseUserControl
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Valore BCode acquisito
|
|
/// </summary>
|
|
public string BCodeVal
|
|
{
|
|
get
|
|
{
|
|
return txtInput.Text.Trim().ToUpper();
|
|
}
|
|
set
|
|
{
|
|
txtInput.Text = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Cod Articolo selezionato
|
|
/// </summary>
|
|
public string CodArticolo
|
|
{
|
|
get
|
|
{
|
|
return hfCodArticolo.Value.Trim();
|
|
}
|
|
set
|
|
{
|
|
hfCodArticolo.Value = value.Trim();
|
|
checkInputData();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// oggetto comando locale alla classe formato RAW
|
|
/// </summary>
|
|
public string rawInput
|
|
{
|
|
get
|
|
{
|
|
string answ;
|
|
if (memLayer.ML.isInSessionObject("barcodeRaw"))
|
|
{
|
|
answ = memLayer.ML.StringSessionObj("barcodeRaw");
|
|
}
|
|
else
|
|
{
|
|
answ = "";
|
|
}
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("barcodeRaw", value, false);
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// procedura pricipale decodifica Barcode
|
|
/// </summary>
|
|
private void processInput()
|
|
{
|
|
bool found = false;
|
|
bool batchOk = false;
|
|
MapoDb.DS_Arca.GiacenzeDataTable tabGiacenzeLotto = new MapoDb.DS_Arca.GiacenzeDataTable();
|
|
MapoDb.DS_SheetTech.ST_ActualRowDataTable tabRichieste = new MapoDb.DS_SheetTech.ST_ActualRowDataTable();
|
|
MapoDb.DS_SheetTech.ST_ActualRowRow datiBatchCheck;
|
|
MapoDb.DS_Arca.GiacenzeRow datiLotto;
|
|
// per prima cosa recupero i valori "Pending" da leggere come candidati...
|
|
tabRichieste = DataLayerObj.taSTAR.getPendingByOdl(idxOdl);
|
|
if (tabRichieste != null && tabRichieste.Count > 0)
|
|
{
|
|
// cerco per EQ come primo step...
|
|
var trovatoEq = tabRichieste.Where(x => x.CheckType == "EQ" && x.Value == BCodeVal);
|
|
if (trovatoEq != null && trovatoEq.Count() > 0)
|
|
{
|
|
// recupero record..
|
|
var datiEqCheck = trovatoEq.FirstOrDefault();
|
|
// registro trovato
|
|
found = true;
|
|
lblMessage.Text = $"Parametro acquisito: {BCodeVal}";
|
|
lblMessage.CssClass = "text-success";
|
|
// upsert controllo
|
|
DataLayerObj.taSTChk.upsertQuery(idxOdl, datiEqCheck.IdxST, datiEqCheck.Oggetto, datiEqCheck.Num, BCodeVal, BCodeVal, true, user_std.UtSn.utente, false);
|
|
}
|
|
|
|
// se non trovato
|
|
if (!found)
|
|
{
|
|
// recupero record.. cercando in giacenza il LOTTO...
|
|
tabGiacenzeLotto = DataLayerObj.taArcaGiac.getBySearch(null, "", BCodeVal, "", false);
|
|
// controllo condizione tipo BATCH (speciale) - prima solo che CI SIA una richiesta di questo tipo
|
|
var trovatoBatch = tabRichieste.Where(x => x.CheckType == "BATCH");
|
|
if (trovatoBatch != null && trovatoBatch.Count() > 0)
|
|
{
|
|
datiBatchCheck = trovatoBatch.FirstOrDefault();
|
|
if (tabGiacenzeLotto != null && tabGiacenzeLotto.Count > 0)
|
|
{
|
|
datiLotto = tabGiacenzeLotto.FirstOrDefault();
|
|
|
|
// registro trovato
|
|
found = true;
|
|
// upsert controllo
|
|
DataLayerObj.taSTChk.upsertQuery(idxOdl, datiBatchCheck.IdxST, datiBatchCheck.Oggetto, datiBatchCheck.Num, BCodeVal, datiLotto.Cd_AR, true, user_std.UtSn.utente, false);
|
|
// conto quanti check ci sono dopo, se calati --> ok altrimenti errore
|
|
var tabRichiestePost = DataLayerObj.taSTAR.getPendingByOdl(idxOdl);
|
|
if (tabRichiestePost.Count < tabRichieste.Count)
|
|
{
|
|
lblMessage.Text = $"Lotto riconosciuto: {BCodeVal} --> {datiLotto.Cd_AR} | Articolo acquisito";
|
|
lblMessage.CssClass = "text-success";
|
|
batchOk = true;
|
|
}
|
|
else
|
|
{
|
|
lblMessage.Text = $"Lotto: {BCodeVal} --> {datiLotto.Cd_AR} | Articolo NON richiesto";
|
|
lblMessage.CssClass = "text-danger";
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!batchOk)
|
|
{
|
|
var currDeroga = DataLayerObj.getDerogaSt(tabRichieste[0].IdxST);
|
|
// ciclo tra TUTTE le richeiste attive
|
|
foreach (var item in tabRichieste)
|
|
{
|
|
// verifico EVENTUALI deroghe
|
|
// se è deroga x gruppo/tipo/num corretto...
|
|
if (currDeroga.CanForce && item.CodGruppo == currDeroga.CodGruppo && item.CodTipo == currDeroga.CodTipo && item.Num == currDeroga.Num && item.Oggetto == currDeroga.Oggetto)
|
|
{
|
|
// ... forzo accettazione deroga
|
|
DataLayerObj.taSTChk.upsertQuery(idxOdl, item.IdxST, item.Oggetto, item.Num, BCodeVal, item.Value, true, user_std.UtSn.utente, true);
|
|
lblMessage.Text = $"Lotto/articolo non valido: {BCodeVal} --> Forzato a valido per articolo {item.Value}";
|
|
lblMessage.CssClass = "text-warning";
|
|
DataLayerObj.setDerogaSt(new MapoSDK.StCheckOverride() { IdxST = item.IdxST, CanForce = false });
|
|
batchOk = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// se non trovato
|
|
if (!found)
|
|
{
|
|
if (tabGiacenzeLotto != null && tabGiacenzeLotto.Count > 0)
|
|
{
|
|
datiLotto = tabGiacenzeLotto.FirstOrDefault();
|
|
lblMessage.Text = $"Lotto: {BCodeVal} --> {datiLotto.Cd_AR} | Articolo NON richiesto";
|
|
lblMessage.CssClass = "text-danger";
|
|
}
|
|
else
|
|
{
|
|
lblMessage.Text = $"Parametro non riconosciuto: {BCodeVal}";
|
|
lblMessage.CssClass = "text-secondary";
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lblMessage.Text = $"Parametro non valido: {BCodeVal}";
|
|
lblMessage.CssClass = "text-secondary";
|
|
}
|
|
|
|
// sistemo visualizzaizone componente
|
|
BCodeVal = "";
|
|
checkInputData();
|
|
// sollevo evento
|
|
reportUpdate();
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
#region Protected Methods
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
lblMessage.Text = "prego confermare parametri";
|
|
lblMessage.CssClass = "text-dark";
|
|
}
|
|
txtInput.Focus();
|
|
}
|
|
|
|
/// <summary>
|
|
/// barcode completato con invio...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void txtInput_TextChanged(object sender, EventArgs e)
|
|
{
|
|
processInput();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Public Methods
|
|
|
|
public void checkInputData()
|
|
{
|
|
bool showInput = false;
|
|
try
|
|
{
|
|
showInput = DataLayerObj.taSTAR.getPendingByOdl(idxOdl).Count > 0;
|
|
}
|
|
catch
|
|
{ }
|
|
divCheckData.Visible = showInput;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |