308 lines
9.7 KiB
C#
308 lines
9.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using SteamWare;
|
|
using GMW_data;
|
|
|
|
namespace GMW.WebUserControls
|
|
{
|
|
public partial class mod_consumoFusi : System.Web.UI.UserControl
|
|
{
|
|
/// <summary>
|
|
/// caricamento pagina
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
calcolaPostazione();
|
|
traduciObj();
|
|
}
|
|
doChecks();
|
|
lblGitterBoxAttivo.Text = "";
|
|
if (currUdcFrom != "")
|
|
{
|
|
lblGitterBoxAttivo.Text += string.Format("UDC FROM: <b>{0}</b>", currUdcFrom);
|
|
}
|
|
if (lblGitterBoxAttivo.Text == "")
|
|
{
|
|
lblGitterBoxAttivo.Text = "...";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// effettua controlli visibilità
|
|
/// </summary>
|
|
private void doChecks()
|
|
{
|
|
checkBarcode();
|
|
checkConsuma();
|
|
}
|
|
/// <summary>
|
|
/// sistemo labels oggetti
|
|
/// </summary>
|
|
private void traduciObj()
|
|
{
|
|
// labels
|
|
lblPostazione.Text = string.Format("{2}: {0} ({1})", postazione_name, postazione_IP, traduci("postazione"));
|
|
lblPrinter.Text = string.Format("{1}: {0}", postazione_printer, traduci("stampante"));
|
|
lblCurrentPage.Text = traduci(PagCorrente);
|
|
// buttons
|
|
btnConsuma.Text = traduci("btnConsumaUdcF10");
|
|
}
|
|
/// <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>
|
|
/// calcola postazione corrente (ip, name, printer)
|
|
/// </summary>
|
|
private void calcolaPostazione()
|
|
{
|
|
postazione_IP = Request.UserHostName;
|
|
postazione_name = dnsUtils.DetermineCompName(postazione_IP);
|
|
// cerco stampante x postazione
|
|
postazione_printer = "n.d.";
|
|
try
|
|
{
|
|
DS_Applicazione.ElencoPostazioniDataTable tabPost = DataProxy.obj.taElPost.getByCod(postazione_name);
|
|
if (tabPost.Rows.Count > 0)
|
|
{
|
|
postazione_printer = tabPost[0].stampante;
|
|
}
|
|
else
|
|
{
|
|
tabPost = DataProxy.obj.taElPost.getByCod("default");
|
|
postazione_printer = tabPost[0].stampante;
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
/// <summary>
|
|
/// indica name della postazione corrente
|
|
/// </summary>
|
|
protected string postazione_name
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.StringSessionObj("postazione_name");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("postazione_name", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// indica ip della postazione corrente
|
|
/// </summary>
|
|
protected string postazione_IP
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.StringSessionObj("postazione_IP");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("postazione_IP", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// indica stampante associata alla postazione corrente
|
|
/// </summary>
|
|
protected string postazione_printer
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.StringSessionObj("postazione_printer");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("postazione_printer", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// indica UDC FROM (F10) selezionato
|
|
/// </summary>
|
|
protected string currUdcFrom
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.StringSessionObj("currUdcFrom");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("currUdcFrom", value, false);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// indica se i caratteri vadano forzati a maiuscoli
|
|
/// </summary>
|
|
public bool forceUppercase
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.confReadBool("forceUppercase");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// decodifica il tipo barcode acquisito
|
|
/// </summary>
|
|
public tipoCodiceBarcode tipoBCode
|
|
{
|
|
get
|
|
{
|
|
tipoCodiceBarcode answ = tipoCodiceBarcode.ND;
|
|
int trovati = 0;
|
|
// controllo non si tratti di un comando...
|
|
string preCmd = memLayer.ML.confReadString("prefComandi");
|
|
if (barcodeIn.StartsWith(preCmd))
|
|
{
|
|
answ = tipoCodiceBarcode.Comando;
|
|
}
|
|
// controllo se sia un particolare "P"
|
|
else if (barcodeIn.StartsWith("P"))
|
|
{
|
|
answ = tipoCodiceBarcode.Particolare;
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
// cerco tra gitterbox (UDC)...
|
|
trovati = MagClass.magazzino.taCartellini.getByUdc(barcodeIn).Rows.Count;
|
|
if (trovati > 0)
|
|
{
|
|
answ = tipoCodiceBarcode.UDC;
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// valore barcode
|
|
/// </summary>
|
|
public string barcodeIn
|
|
{
|
|
get
|
|
{
|
|
return txtBarcode.Text.Trim();
|
|
}
|
|
set
|
|
{
|
|
txtBarcode.Text = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// controlla se ci sia un barcode
|
|
/// </summary>
|
|
private void checkBarcode()
|
|
{
|
|
if (barcodeIn != "")
|
|
{
|
|
DS_Applicazione.ElencoCartelliniRow rigaCart;
|
|
string tipoImballo = "";
|
|
lblMessaggi.Text = string.Format("Barcode digitato: {0}", barcodeIn);
|
|
switch (tipoBCode)
|
|
{
|
|
|
|
case tipoCodiceBarcode.UDC:
|
|
// procedo solo se UDC esistente
|
|
if (MagClass.magazzino.checkUDC(barcodeIn))
|
|
{
|
|
// cerco di recuperare riga UDC
|
|
try
|
|
{
|
|
rigaCart = DataProxy.obj.taCartellini.stp_getByUdc(barcodeIn)[0];
|
|
tipoImballo = rigaCart.CodImballo;
|
|
}
|
|
catch
|
|
{ }
|
|
// salvo UDC from
|
|
currUdcFrom = barcodeIn;
|
|
}
|
|
break;
|
|
default:
|
|
lblMessaggi.Text += " - codice <b>non riconosciuto</b>!";
|
|
pnlAll.CssClass = "stileComandoND";
|
|
break;
|
|
}
|
|
barcodeIn = "";
|
|
}
|
|
else
|
|
{
|
|
lblMessaggi.Text = "...attesa barcode...";
|
|
}
|
|
//grView.DataBind();
|
|
txtBarcode.Focus();
|
|
}
|
|
/// <summary>
|
|
/// controllo abilitazione consumo
|
|
/// </summary>
|
|
private void checkConsuma()
|
|
{
|
|
bool consumaOk = false;
|
|
if (currUdcFrom != "")
|
|
{
|
|
consumaOk = true;
|
|
}
|
|
btnConsuma.Enabled = consumaOk;
|
|
}
|
|
/// <summary>
|
|
/// genera i barcode di
|
|
/// - trattamenti
|
|
/// - nuovo x pezzi liquidi
|
|
/// e lancia la relativa stampa
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnConsuma_Click(object sender, EventArgs e)
|
|
{
|
|
if (currUdcFrom != "")
|
|
{
|
|
// controllo se UDC non sia già consumato...
|
|
if (MagClass.magazzino.udcMpIsConsumabile(currUdcFrom))
|
|
{
|
|
// consumo UDC
|
|
MagClass.magazzino.scaricaUdcMpWip(currUdcFrom, Request.UserHostName);
|
|
}
|
|
// indico UDC consumato!
|
|
lblMessaggi.Text = string.Format("{0} {1}", traduci("effettuatoConsumoUDC"), currUdcFrom);
|
|
currUdcFrom = "";
|
|
lblGitterBoxAttivo.Text = "";
|
|
}
|
|
}
|
|
}
|
|
} |