352 lines
14 KiB
C#
352 lines
14 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using GMW_data;
|
|
using SteamWare;
|
|
|
|
namespace GMW.WebUserControls
|
|
{
|
|
public partial class mod_spostaDataMatrix : System.Web.UI.UserControl
|
|
{
|
|
/// <summary>
|
|
/// controlli al caricamento pagina
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
// se primo caricamento resetto gitterbox...)
|
|
if (!Page.IsPostBack)
|
|
{
|
|
currGitterBox = "";
|
|
pnlAll.CssClass = "stileAttesa";
|
|
}
|
|
checkBarcode();
|
|
lblPezziGitterbox.Text = string.Format("{0} pz.", pezziGitterbox);
|
|
lblCurrentPage.Text = traduci(PagCorrente);
|
|
if (currGitterBox != "")
|
|
{
|
|
lblGitterBoxAttivo.Text = string.Format("Gitterbox selezionato <b>{0}</b>", currGitterBox);
|
|
}
|
|
else
|
|
{
|
|
lblGitterBoxAttivo.Text = "...";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// restituisce il nome della pagina corrente
|
|
/// </summary>
|
|
protected string PagCorrente
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
Uri MyUrl = Request.Url;
|
|
string delimStr = "/";
|
|
char[] delimiter = delimStr.ToCharArray();
|
|
string[] finalUrl = MyUrl.LocalPath.ToString().Split(delimiter);
|
|
int n = finalUrl.Length;
|
|
answ = finalUrl[n - 1].ToString();
|
|
DataLayer_AnagGen.PermessiRow riga = (DataLayer_AnagGen.PermessiRow)user_std.UtSn.permessi.Select(string.Format("URL = '{0}'", answ))[0];
|
|
answ = riga.NOME;
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// wrapper traduzione
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
public string traduci(object lemma)
|
|
{
|
|
return user_std.UtSn.Traduci(lemma.ToString());
|
|
}
|
|
/// <summary>
|
|
/// num pezzi del gitterbox
|
|
/// </summary>
|
|
public int pezziGitterbox
|
|
{
|
|
get
|
|
{
|
|
int answ = 0;
|
|
try
|
|
{
|
|
answ = (int)MagClass.magazzino.taCartellini.getByUdc(currGitterBox)[0].Qta;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// indica il gitterbox correntemente selezionato
|
|
/// </summary>
|
|
protected string currGitterBox
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.StringSessionObj("currGitterBox");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("currGitterBox", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// controllo booleano sul gitterbox se sia ok x caricamento altri pezzi (ovvero en contiene meno del max consentito
|
|
/// </summary>
|
|
protected bool gitterboxOk
|
|
{
|
|
get
|
|
{
|
|
bool answ = false;
|
|
int maxPezzi = memLayer.ML.confReadInt("qtaOdette");
|
|
int numPezzi = maxPezzi;
|
|
try
|
|
{
|
|
numPezzi = (int)MagClass.magazzino.taCartellini.getByUdc(currGitterBox)[0].Qta;
|
|
}
|
|
catch
|
|
{
|
|
httpLog(string.Format("Non sono riuscito a trovare dati per il gitterbox {0}", currGitterBox), tipoLog.ERROR);
|
|
}
|
|
// controllo se il codice sia "Pieno", ovvero max pezzi
|
|
if (numPezzi < maxPezzi)
|
|
{
|
|
answ = true;
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// wrapper per log con salvataggio dell'IP del chiamante
|
|
/// </summary>
|
|
/// <param name="_testoPre"></param>
|
|
/// <returns></returns>
|
|
public bool httpLog(string _testoPre)
|
|
{
|
|
bool answ = false;
|
|
string postazione_IP = "";
|
|
try
|
|
{
|
|
postazione_IP = string.Format(" | {0} | ", Request.UserHostName);
|
|
}
|
|
catch
|
|
{ }
|
|
logger.lg.scriviLog(postazione_IP + _testoPre);
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// wrapper per log con salvataggio dell'IP del chiamante
|
|
/// </summary>
|
|
/// <param name="_testoPre"></param>
|
|
/// <returns></returns>
|
|
public bool httpLog(string testoLog, tipoLog tipo)
|
|
{
|
|
bool answ = false;
|
|
string postazione_IP = "";
|
|
try
|
|
{
|
|
postazione_IP = string.Format(" | {0} | ", Request.UserHostName);
|
|
}
|
|
catch
|
|
{ }
|
|
logger.lg.scriviLog(postazione_IP + testoLog, tipo);
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// controlla se ci sia un barcode
|
|
/// </summary>
|
|
private void checkBarcode()
|
|
{
|
|
if (barcodeIn != "")
|
|
{
|
|
lblMessaggi.Text = string.Format("Barcode digitato: {0}", barcodeIn);
|
|
switch (tipoBCode)
|
|
{
|
|
case tipoCodiceBarcode.Gitterbox:
|
|
// imposto il gitterbox corrente
|
|
currGitterBox = barcodeIn;
|
|
if (gitterboxOk)
|
|
{
|
|
// controllo se il gitterbox non sia stato già associato ad una etichetta odette - non si può spostare
|
|
if (Odette.mgr.gitterboxInOdette(currGitterBox))
|
|
{
|
|
currGitterBox = "";
|
|
lblMessaggi.Text += " - gitterbox <b>associato</b>ad odette!!! non impostabile.";
|
|
pnlAll.CssClass = "stileComandoKo";
|
|
}
|
|
else
|
|
{
|
|
lblMessaggi.Text += " - impostato nuovo gitterbox di destinazione!";
|
|
pnlAll.CssClass = "stileComandoOk";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lblMessaggi.Text += " - gitterbox <b>pieno</b>!!! impostato, ma non si possono versare altri pezzi.";
|
|
pnlAll.CssClass = "stileComandoKo";
|
|
}
|
|
break;
|
|
case tipoCodiceBarcode.DataMatrixTrovato:
|
|
// se c'è un gitterbox attivo sposto il datamatrix
|
|
if (currGitterBox != "")
|
|
{
|
|
if (gitterboxOk)
|
|
{
|
|
decimal dataMatrix = Convert.ToDecimal(barcodeIn);
|
|
// controllo che esissta il datamatrix...
|
|
if (Odette.mgr.datamatrixEsiste(dataMatrix))
|
|
{
|
|
// effettuo spostamento del datamatrix nel nuovo gitterbox
|
|
if (!Odette.mgr.datamatrixInOdette(dataMatrix))
|
|
{
|
|
// controllo che il gitterbox sia coerente col datamatrix per prodotto...
|
|
if (Odette.mgr.dtMtxGtboxCompatibili(dataMatrix, currGitterBox))
|
|
{
|
|
DataMatrix.mgr.taElencoDM.spostaInGitterbox(dataMatrix, currGitterBox, MagClass.magazzino.CodSoggCurrUser);
|
|
lblMessaggi.Text += " - spostato nel gitterbox attivo!";
|
|
pnlAll.CssClass = "stileComandoAdd";
|
|
}
|
|
else
|
|
{
|
|
lblMessaggi.Text += " - datamatrix non spostabile, il gitterbox contiene prodotti diversi!";
|
|
pnlAll.CssClass = "stileErr01";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lblMessaggi.Text += " - datamatrix non spostabile, in gitterbox già associato ad odette!";
|
|
pnlAll.CssClass = "stileErr03";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lblMessaggi.Text += " - datamatrix non trovato!";
|
|
pnlAll.CssClass = "stileErr02";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lblMessaggi.Text += " - il gitterbox è <b>pieno</b>!!!";
|
|
pnlAll.CssClass = "stileComandoKo";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// altrimenti segnalo che manca il gitterbox di destinazione
|
|
lblMessaggi.Text += " - <b>errore</b>, manca un gitterbox di destinazione!";
|
|
pnlAll.CssClass = "stileComandoKo";
|
|
}
|
|
break;
|
|
case tipoCodiceBarcode.Comando:
|
|
// controllo se è svuota gitterbox, nel caso lo svuoto
|
|
string cmdSvuotaGbox = memLayer.ML.confReadString("cmdSvuotaGitterBox");
|
|
string cmdEsci = memLayer.ML.confReadString("cmdEsci");
|
|
if (barcodeIn == cmdSvuotaGbox)
|
|
{
|
|
if (gitterboxOk)
|
|
{
|
|
DataMatrix.mgr.taElencoDM.svuotaGitterbox(currGitterBox, MagClass.magazzino.CodSoggCurrUser);
|
|
lblMessaggi.Text += " - <b>Gitterbox svuotato</b>!";
|
|
pnlAll.CssClass = "stileAttesa";
|
|
}
|
|
}
|
|
else if (barcodeIn == cmdEsci)
|
|
{
|
|
currGitterBox = "";
|
|
Response.Redirect("~/menu.aspx");
|
|
}
|
|
else
|
|
{
|
|
lblMessaggi.Text += " - codice comando <b>non riconosciuto</b>!";
|
|
}
|
|
break;
|
|
default:
|
|
lblMessaggi.Text += " - codice <b>non riconosciuto</b>!";
|
|
pnlAll.CssClass = "stileComandoND";
|
|
break;
|
|
}
|
|
barcodeIn = "";
|
|
}
|
|
else
|
|
{
|
|
lblMessaggi.Text = traduci("AttesaBCode");
|
|
pnlAll.CssClass = "stileAttesa";
|
|
}
|
|
grView.DataBind();
|
|
txtBarcode.Focus();
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public tipoCodiceBarcode tipoBCode
|
|
{
|
|
get
|
|
{
|
|
tipoCodiceBarcode answ = tipoCodiceBarcode.ND;
|
|
int trovati = 0;
|
|
// controllo non si tratti di un comando...
|
|
string preCmd = memLayer.ML.cdv("prefComandi");
|
|
if (barcodeIn.StartsWith(preCmd))
|
|
{
|
|
answ = tipoCodiceBarcode.Comando;
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
// cerco tra gitterbox (UDC)...
|
|
trovati = MagClass.magazzino.taCartellini.getByUdc(barcodeIn).Rows.Count;
|
|
// cerco tra datamatrix
|
|
if (trovati > 0)
|
|
{
|
|
answ = tipoCodiceBarcode.Gitterbox;
|
|
}
|
|
else
|
|
{
|
|
trovati = DataMatrix.mgr.taElencoDM.getByCode(Convert.ToDecimal(barcodeIn)).Rows.Count;
|
|
if (trovati > 0)
|
|
{
|
|
answ = tipoCodiceBarcode.DataMatrixTrovato;
|
|
}
|
|
}
|
|
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// valore barcode
|
|
/// </summary>
|
|
public string barcodeIn
|
|
{
|
|
get
|
|
{
|
|
return txtBarcode.Text.Trim();
|
|
}
|
|
set
|
|
{
|
|
txtBarcode.Text = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// indica se i caratteri vadano forzati a maiuscoli
|
|
/// </summary>
|
|
public bool forceUppercase
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.confReadBool("forceUppercase");
|
|
}
|
|
}
|
|
}
|
|
} |