Files
2017-03-13 17:31:01 +01:00

760 lines
24 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_Term.WebUserControls
{
public partial class mod_btnUdc : System.Web.UI.UserControl
{
#region variabili globali controllo
/// <summary>
/// codice company/sito in sessione
/// </summary>
protected string _CodCS
{
get
{
return memLayer.ML.StringSessionObj("CodCS");
}
}
/// <summary>
/// UDC correntemente selezionato
/// </summary>
protected string _UDC
{
get
{
return memLayer.ML.StringSessionObj("UDC_sel");
}
set
{
memLayer.ML.setSessionVal("UDC_sel", value);
}
}
/// <summary>
/// CodLista della lsita di prelievo correntemente attiva
/// </summary>
protected string _CodLista
{
get
{
return memLayer.ML.StringSessionObj("CodListaAttiva");
}
set
{
memLayer.ML.setSessionVal("CodListaAttiva", value);
}
}
/// <summary>
/// Particolare dell'UDC correntemente selezionato
/// </summary>
protected string _PartUdc
{
get
{
string answ = "";
try
{
answ = MagClass.magazzino.taDettUDC.getByFullUdc(_UDC, _CodCS)[0].Particolare;
}
catch
{ }
return answ;
}
}
/// <summary>
/// Indica se l'UDC correntemente selezionato sia disponibile x prelievo
/// </summary>
protected bool _UdcDisp
{
get
{
bool answ = false;
try
{
answ = (MagClass.magazzino.taRigheListePrelievo.getPrelevateByUdc(_UDC).Rows.Count == 0);
}
catch
{ }
return answ;
}
}
/// <summary>
/// Indica se la cella DI DESTINAZIONE dell'azione sia da indicare come piena
/// </summary>
protected bool _cellaPiena
{
get
{
return memLayer.ML.BoolSessionObj("cellaPiena");
}
set
{
memLayer.ML.setSessionVal("cellaPiena", value);
}
}
/// <summary>
/// Particolare della Lista di Prelievo correntemente attiva
/// </summary>
protected string _PartLdP
{
get
{
string answ = "";
if (_CodLista != "")
{
try
{
answ = MagClass.magazzino.taElencoListePrelievo.getByCodLista(_CodLista)[0].Particolare;
}
catch
{ }
}
return answ;
}
}
/// <summary>
/// testo contenuto nella textbox
/// </summary>
public string txtScansione
{
get
{
return txtInput.Text.Trim().ToUpper();
}
set
{
txtInput.Text = value.ToUpper();
}
}
/// <summary>
/// valore della scansione barcode SALVANDOLO ToUpper
/// </summary>
public string valoreScanUdc
{
get
{
return memLayer.ML.StringSessionObj("scannedValueUdc");
}
set
{
memLayer.ML.setSessionVal("scannedValueUdc", value, false);
}
}
/// <summary>
/// tipologia di edit attivo (in session...)
/// </summary>
protected tipoEditUdc editAttivo
{
get
{
tipoEditUdc answ = tipoEditUdc.nd;
try
{
answ = (tipoEditUdc)memLayer.ML.objSessionObj("EditAttivo");
}
catch
{ }
return answ;
}
set
{
memLayer.ML.setSessionVal("EditAttivo", value, false);
}
}
#endregion
#region area eventi
public event EventHandler eh_btnPressed;
//public event EventHandler eh_reqSposta;
//public event EventHandler eh_reqDeposita;
#endregion
#region setup modulo
/// <summary>
/// caricamento pagina
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
setupIniziale();
}
txtInput.Focus();
}
private void setupIniziale()
{
pnlButtons.Visible = true;
pnlInput.Visible = false;
traduciObj();
setupBtn();
}
/// <summary>
/// resetta panel input
/// </summary>
private void resetInputPanel()
{
pnlButtons.Visible = false;
pnlInput.Visible = true;
lblData.Text = "";
}
/// <summary>
/// sistemo abilitazione buttons (a seconda dello stato dell'UDC)
/// </summary>
private void setupBtn()
{
bool consumato = false;
bool posizAssegn = false;
bool udcPieno = false;
DS_magazzino.v_UdcDetailRow rigaUdc;
try
{
rigaUdc = MagClass.magazzino.taDettUDC.getByFullUdc(_UDC, _CodCS)[0];
consumato = (rigaUdc.IdxPosizione < 0);
}
catch
{ }
try
{
rigaUdc = MagClass.magazzino.taDettUDC.getByFullUdc(_UDC, _CodCS)[0];
posizAssegn = (rigaUdc.CodCella.Length > 4);
}
catch
{ }
try
{
rigaUdc = MagClass.magazzino.taDettUDC.getByFullUdc(_UDC, _CodCS)[0];
udcPieno = (rigaUdc.Particolare != "");
}
catch
{ }
// abilito rettifica, deposita e sposta SOLO SE contiene dei particolari E NON E' STATO CONSUMATO...
if (udcPieno && !consumato)
{
// in base a che sia in una posizione magazzino o meno scelgo che buttons abilitare
if (posizAssegn)
{
btnDeposita.Visible = false;
btnSposta.Visible = true;
}
else
{
btnDeposita.Visible = true;
btnSposta.Visible = false;
}
btnRettifica.Visible = true;
}
else
{
btnDeposita.Visible = false;
btnSposta.Visible = false;
btnRettifica.Visible = false;
}
// button preleva abilitato SOLO SE NON CONSUMATO E SE c'è una lista di prelievo attiva per l'utente e per il particolare corrente...
// e se l'UDC non è stato prelevato...
if (_CodLista != "" && (_PartLdP == _PartUdc) && _UdcDisp && !consumato)
{
btnPreleva.Visible = true;
}
else
{
btnPreleva.Visible = false;
}
// controllo se il riattiva sia possibile, ovvero se è in un mag con riattiva enabled...
if (MagClass.magazzino.udcIsRiattivabile(_UDC))
{
btnRiattiva.Visible = true;
}
else
{
btnRiattiva.Visible = false;
}
// setup ulteriori pulsanti
setupBtnDelibere();
setupBtnChiudi();
}
/// <summary>
/// sistemo btn x delibere
/// </summary>
private void setupBtnDelibere()
{
bool consumato = false;
DS_magazzino.v_UdcDetailRow rigaUdc;
try
{
rigaUdc = MagClass.magazzino.taDettUDC.getByFullUdc(_UDC, _CodCS)[0];
consumato = (rigaUdc.IdxPosizione < 0);
}
catch
{ }
string codTipoDelibera = "";
try
{
rigaUdc = MagClass.magazzino.taDettUDC.getByFullUdc(_UDC, _CodCS)[0];
codTipoDelibera = MagClass.magazzino.taPosizDelib.getByIdxPosizione(rigaUdc.IdxPosizione)[0].CodTipoDelibera;
}
catch
{ }
// controllo NON sia in OVAS
bool isInOvas = false;
try
{
isInOvas = (MagClass.magazzino.taPosUdcCorr.getByUdcCodMag(_UDC, "OVAS").Rows.Count > 0);
}
catch
{ }
// se NON CONSUMATO, la posizione prevede una delibera e NON E' in OVAS mostro il relativo pulsante...
if (!consumato && codTipoDelibera != "" && !isInOvas)
{
switch (codTipoDelibera) //!!!OCCHIO HARD CODED!!!
{
case "DelibFusi":
btnDeliberaFusi.Visible = true;
btnDeliberaWipPre.Visible = false;
btnDeliberaWipPost.Visible = false;
break;
case "DelibWipPost":
btnDeliberaFusi.Visible = false;
btnDeliberaWipPre.Visible = false;
btnDeliberaWipPost.Visible = true;
break;
case "DelibWipPre":
btnDeliberaFusi.Visible = false;
btnDeliberaWipPre.Visible = true;
btnDeliberaWipPost.Visible = false;
break;
default:
btnDeliberaFusi.Visible = false;
btnDeliberaWipPre.Visible = false;
btnDeliberaWipPost.Visible = false;
break;
}
}
else
{
btnDeliberaFusi.Visible = false;
btnDeliberaWipPre.Visible = false;
btnDeliberaWipPost.Visible = false;
}
}
/// <summary>
/// sistemo btn x chiusura
/// </summary>
private void setupBtnChiudi()
{
// mostro chiudi generale o chiudi del modulo a seconda dello stato
switch (editAttivo)
{
case tipoEditUdc.deposito:
btnBarcode.Visible = true;
btnChiudiInput.Visible = true;
btnChiudi.Visible = false;
btnConferma.Visible = true;
btnCellaPiena.Visible = false;
break;
case tipoEditUdc.prelievo:
btnBarcode.Visible = true;
btnChiudiInput.Visible = true;
btnChiudi.Visible = false;
btnConferma.Visible = false;
btnCellaPiena.Visible = false;
break;
case tipoEditUdc.rettifica:
btnBarcode.Visible = true;
btnChiudiInput.Visible = true;
btnChiudi.Visible = false;
btnConferma.Visible = false;
btnCellaPiena.Visible = false;
break;
case tipoEditUdc.spostamento:
btnBarcode.Visible = true;
btnChiudiInput.Visible = true;
btnChiudi.Visible = false;
btnConferma.Visible = true;
btnCellaPiena.Visible = false;
break;
default:
btnBarcode.Visible = true;
btnChiudiInput.Visible = false;
btnChiudi.Visible = true;
btnConferma.Visible = false;
btnCellaPiena.Visible = false;
break;
}
}
/// <summary>
/// sistemazione buttons
/// </summary>
private void traduciObj()
{
// buttons primari
btnDeposita.Text = traduci("Store") + "\n[Alt+4]";
btnDeposita.AccessKey = "4";
btnSposta.Text = traduci("Move") + "\n[Alt+5]";
btnSposta.AccessKey = "5";
btnRettifica.Text = traduci("Correct") + "\n[Alt+6]";
btnRettifica.AccessKey = "6";
btnPreleva.Text = traduci("Take") + "\n[Alt+7]";
btnPreleva.AccessKey = "7";
btnChiudi.Text = "Home" + "\n[Alt+9]";
btnChiudi.AccessKey = "9";
btnChiudiInput.Text = traduci("Close") + "\n[Alt+0]";
btnChiudiInput.AccessKey = "0";
btnBarcode.Text = "Barcode" + "\n[Alt+1]";
btnBarcode.AccessKey = "1";
// buttons delibera
btnDeliberaFusi.Text = traduci("deliberaFusi") + "\n[Alt+3]";
btnDeliberaFusi.AccessKey = "3";
btnDeliberaWipPre.Text = traduci("deliberaTerzPre") + "\n[Alt+3]";
btnDeliberaWipPre.AccessKey = "3";
btnDeliberaWipPost.Text = traduci("deliberaTerzPost") + "\n[Alt+3]";
btnDeliberaWipPost.AccessKey = "3";
// buttons secondari
btnConferma.Text = "OK" + "\n[Alt+2]";
btnConferma.AccessKey = "2";
btnCellaPiena.Text = traduci("OkFull") + "\n[Alt+4]";
btnCellaPiena.AccessKey = "4";
// gestione riattivazione
btnRiattiva.Text = traduci("RiattivaUdc") + "\n[Alt+8]";
btnRiattiva.AccessKey = "8";
}
/// <summary>
/// wrapper traduzione termini
/// </summary>
/// <param name="lemma"></param>
/// <returns></returns>
public string traduci(string lemma)
{
return user_std.UtSn.Traduci(lemma);
}
/// <summary>
/// effettua reset del controllo
/// </summary>
/// <returns></returns>
public void doReset()
{
// svuoto dati temporanei
valoreScanUdc = "";
txtScansione = "";
editAttivo = tipoEditUdc.nd;
// sistema visibilità
pnlButtons.Visible = true;
pnlInput.Visible = false;
// sistemo buttons
setupBtn();
}
/// <summary>
/// nasconde buttons standard e mostra area "chiudi"
/// </summary>
public void doHideBtn()
{
// nascondo i bottoni...
pnlButtons.Visible = false;
setupBtnChiudi();
}
/// <summary>
/// resetta panel buttons
/// </summary>
public void doResetPnl()
{
// nasconde/mostra panels
resetInputPanel();
setupBtnChiudi();
}
#endregion
#region gestione input barcode
/// <summary>
/// inserito testo nella TextBox
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void txtInput_TextChanged(object sender, EventArgs e)
{
// salvo in sessione la scansione attuale...
valoreScanUdc = txtScansione;
// verifica l'input immesso
tipoCodiceBarcode answ = TermClass.Ter.riconosciBarcode(txtScansione);
switch (editAttivo)
{
case tipoEditUdc.nd:
break;
case tipoEditUdc.deposito:
verificaInputFaseDepositaSposta(answ);
break;
case tipoEditUdc.prelievo:
break;
case tipoEditUdc.rettifica:
break;
case tipoEditUdc.spostamento:
verificaInputFaseDepositaSposta(answ);
break;
default:
break;
}
}
/// <summary>
/// effettua le verifiche dell'input e di conseguenza esegue task quando si è in fase di deposito in cella
/// </summary>
/// <param name="answ"></param>
private void verificaInputFaseDepositaSposta(tipoCodiceBarcode answ)
{
switch (answ)
{
case tipoCodiceBarcode.Cella:
lblData.Text = txtScansione;
txtScansione = "";
setupConferma_confPiena();
break;
default:
lblData.Text = traduci("CodeNotRecognized") + ": " + valoreScanUdc;
txtInput.Text = "";
txtInput.Focus();
break;
}
}
/// <summary>
/// sistema visibilità buttons conferma e conferma piena...
/// </summary>
private void setupConferma_confPiena()
{
// mostro btnConferma
btnConferma.Visible = true;
// metto focus
btnConferma.Focus();
// controllo se la cella sia "papabile" per indicazione "piena"
bool alertCapa = false;
bool cellaPiena = false;
try
{
DS_magazzino.V_statoCelleCapienzaAssegnatiRow rigaStato = MagClass.magazzino.taStatoCelle.getByCodCella(valoreScanUdc)[0];
alertCapa = ((rigaStato.Capienza - rigaStato.UdcAssegnati) <= 1);
cellaPiena = MagClass.magazzino.cellaPiena(_CodCS, MagClass.magazzino.IdxCellaByCodCella(_CodCS, valoreScanUdc));
}
catch
{ }
if (alertCapa && !(cellaPiena))
{
btnCellaPiena.Visible = true;
btnCellaPiena.Focus();
}
else
{
btnCellaPiena.Visible = false;
}
}
#endregion
#region area buttons
/// <summary>
/// ritorna alla home
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnChiudi_Click(object sender, EventArgs e)
{
// svuoto da session l'UDC corrente... e pure il barcode corrente...
memLayer.ML.emptySessionVal("scannedValue");
_UDC = "";
memLayer.ML.emptySessionVal("activeTask");
Response.Redirect("Home.aspx");
}
/// <summary>
/// ritorna alla home
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnChiudiInput_Click(object sender, EventArgs e)
{
// svuoto da session l'UDC corrente... e pure il barcode corrente...
memLayer.ML.emptySessionVal("scannedValue");
editAttivo = tipoEditUdc.nd;
Response.Redirect("UDC.aspx");
}
/// <summary>
/// richiesta rettifica dati UDC: qta
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnRettifica_Click(object sender, EventArgs e)
{
editAttivo = tipoEditUdc.rettifica;
doHideBtn();
if (eh_btnPressed != null)
{
eh_btnPressed(this, new EventArgs());
}
}
/// <summary>
/// click button deposito
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnDeposita_Click(object sender, EventArgs e)
{
editAttivo = tipoEditUdc.deposito;
doResetPnl();
//if (eh_btnPressed != null)
//{
// eh_btnPressed(this, new EventArgs());
//}
}
/// <summary>
/// click button DELIBERA FUSI
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnDeliberaFusi_Click(object sender, EventArgs e)
{
editAttivo = tipoEditUdc.deliberaFusi;
doResetPnl();
if (eh_btnPressed != null)
{
eh_btnPressed(this, new EventArgs());
}
}
/// <summary>
/// click button DELIBERA WIP pre spedizione
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnDeliberaWipPre_Click(object sender, EventArgs e)
{
editAttivo = tipoEditUdc.deliberaWipPre;
doResetPnl();
if (eh_btnPressed != null)
{
eh_btnPressed(this, new EventArgs());
}
}
/// <summary>
/// click button DELIBERA WIP post spedizione
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnDeliberaWipPost_Click(object sender, EventArgs e)
{
editAttivo = tipoEditUdc.deliberaWipPost;
doResetPnl();
if (eh_btnPressed != null)
{
eh_btnPressed(this, new EventArgs());
}
}
/// <summary>
/// richiesta di spostamento di un UDC: mostro input x nuova posizione!
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSposta_Click(object sender, EventArgs e)
{
editAttivo = tipoEditUdc.spostamento;
doResetPnl();
//if (eh_btnPressed != null)
//{
// eh_btnPressed(this, new EventArgs());
//}
}
/// <summary>
/// richiesto caricamento UDC
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnConferma_Click(object sender, EventArgs e)
{
_cellaPiena = false;
callAzioneCella();
}
/// <summary>
/// richiesto caricamento UDC e set a piena della cella
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnCellaPiena_Click(object sender, EventArgs e)
{
_cellaPiena = true;
callAzioneCella();
}
/// <summary>
/// fa una chiamata sulla celal a seconda del tipo di edit attivo
/// </summary>
private void callAzioneCella()
{
switch (editAttivo)
{
case tipoEditUdc.deposito:
if (eh_btnPressed != null)
{
eh_btnPressed(this, new EventArgs());
}
break;
case tipoEditUdc.spostamento:
if (eh_btnPressed != null)
{
eh_btnPressed(this, new EventArgs());
}
break;
default:
break;
}
}
/// <summary>
/// associa l'UDC corrente alla lsita di prelievo attualmente in essere...
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnPreleva_Click(object sender, EventArgs e)
{
MagClass.magazzino.confermaUdcPrelevatoPerLista(_CodLista, _UDC);
editAttivo = tipoEditUdc.nd;
// fix visualizzazione
setupIniziale();
}
/// <summary>
/// riattiva l'UDC corrente (-84 --> 84)...
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnRiattiva_Click(object sender, EventArgs e)
{
// chiamo la procedura di riattivazione x l'UDC
MagClass.magazzino.riattivaUdc(_UDC, MagClass.magazzino.CodSoggCurrUser, Request.UserHostName);
}
/// <summary>
/// passa al barcode!
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnBarcode_Click(object sender, EventArgs e)
{
Response.Redirect("~/Barcode.aspx");
}
#endregion
}
}