Files
GMW/GMW/WebUserControls/mod_SearchProvUDC.ascx.cs
T
2014-02-27 07:41:49 +01:00

292 lines
10 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_SearchProvUDC : System.Web.UI.UserControl
{
/// <summary>
/// evento selezione valore
/// </summary>
public event EventHandler eh_selValore;
/// <summary>
/// evento generale di reset
/// </summary>
public event EventHandler eh_reset;
/// <summary>
/// gestisce controllo se l'UDC sia già consumato
/// </summary>
public bool udcConsumato
{
get
{
return memLayer.ML.BoolSessionObj("UdcConsumato");
}
set
{
memLayer.ML.setSessionVal("UdcConsumato", value, false);
}
}
/// <summary>
/// caricamento pagina
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
doTraduci();
mod_detailUDC1.Visible = false;
mod_execUDC1.Visible = false;
memLayer.ML.setSessionVal("RicercaUdcAttiva", false, false);
memLayer.ML.setSessionVal("_inizio", DateTime.Now.AddYears(-memLayer.ML.confReadInt("defaultYearSAO")));
memLayer.ML.setSessionVal("_fine", DateTime.Now.AddDays(1));
}
mod_listUDC1.eh_selValore += new EventHandler(mod_listUDC1_eh_selValore);
mod_listUDC1.eh_resetSelezione += new EventHandler(mod_listUDC1_eh_resetSelezione);
mod_execUDC1.eh_btnGoToMagPressed += new EventHandler(mod_execUDC1_eh_btnGoToMagPressed);
mod_execUDC1.eh_btnListaPrelievoPressed += new EventHandler(mod_execUDC1_eh_btnListaPrelievoPressed);
mod_execUDC1.eh_nuovoValore += new EventHandler(mod_execUDC1_eh_nuovoValore);
if (memLayer.ML.BoolSessionObj("RicercaUdcAttiva"))
{
mod_execUDC1.Visible = !udcConsumato;
mod_detailUDC1.Visible = true;
}
else
{
mod_execUDC1.Visible = false;
mod_detailUDC1.Visible = false;
}
fixDetailVisibility();
}
/// <summary>
/// sistema visibilità dettagli UDC
/// </summary>
private void fixDetailVisibility()
{
// fix visibilità dettagli UDC
bool showCurUdc = false;
bool showHistUdc = false;
string udcSel = memLayer.ML.StringSessionObj("UDC_sel");
string udcHist = memLayer.ML.StringSessionObj("FullSearchValue");
if (udcHist != "")
{
if (!MagClass.magazzino.checkUDC(udcHist) && udcHist.Length >= 12)
{
showHistUdc = true;
}
}
if (udcSel != "")
{
if (MagClass.magazzino.checkUDC(udcSel))
{
showCurUdc = true;
showHistUdc = false;
}
else
{
showHistUdc = true;
}
}
else
{
showHistUdc = false;
}
mod_detailUDC1.Visible = showCurUdc;
mod_detailUDC_storico1.Visible = showHistUdc;
mod_detLDP1.Visible = showCurUdc;
mod_detAttr1.Visible = showCurUdc;
}
void mod_execUDC1_eh_nuovoValore(object sender, EventArgs e)
{
aggiornaDettaglio();
}
/// <summary>
/// evento crea lista di prelievo chiamato
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void mod_execUDC1_eh_btnListaPrelievoPressed(object sender, EventArgs e)
{
memLayer.ML.setSessionVal("PrecompilaListaPrelievo", true, false);
Response.Redirect("~/ElencoListePrelievo.aspx");
}
/// <summary>
/// evento vai a magazzino chiamato
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void mod_execUDC1_eh_btnGoToMagPressed(object sender, EventArgs e)
{
Response.Redirect("~/DettaglioBlocco.aspx");
}
void mod_listUDC1_eh_resetSelezione(object sender, EventArgs e)
{
doReset();
if (eh_reset != null)
{
eh_reset(this, new EventArgs());
}
}
void mod_listUDC1_eh_selValore(object sender, EventArgs e)
{
// controllo se l'UDC sia o meno già consumato...
string UDC = memLayer.ML.StringSessionObj("UDC_sel");
GMW_data.DS_magazzino.v_UdcDetailRow rigaUdc = (GMW_data.DS_magazzino.v_UdcDetailRow)GMW_data.MagClass.magazzino.taDettUDC.getByFullUdc(UDC, memLayer.ML.confReadString("CodCS"))[0];
if (rigaUdc.IdxPosizione < 0)
{
udcConsumato = true;
}
else
{
udcConsumato = false;
}
memLayer.ML.setSessionVal("RicercaUdcAttiva", true, false);
aggiornaDettaglio();
}
private void aggiornaDettaglio()
{
if (memLayer.ML.BoolSessionObj("RicercaUdcAttiva"))
{
mod_detailUDC1.Visible = true;
mod_detailUDC1.doUpdate();
mod_detLDP1.doUpdate();
mod_detAttr1.doUpdate();
mod_execUDC1.Visible = !udcConsumato;
mod_execUDC1.doUpdate();
// salvo dati UDC selezionato... UDC_sel c'è già...
string UDC = memLayer.ML.StringSessionObj("UDC_sel");
GMW_data.DS_magazzino.v_UdcDetailRow rigaUdc = (GMW_data.DS_magazzino.v_UdcDetailRow)GMW_data.MagClass.magazzino.taDettUDC.getByFullUdc(UDC, memLayer.ML.confReadString("CodCS"))[0];
// inizializzo a vuoti
string particolare = "";
string esponente = "";
string codMag = "";
string codBlocco = "";
string codCellaMag = "";
int idxCellaMag = 0;
int idxBlocco = 0;
// provoa caricare sennò segno errore..
try
{
particolare = rigaUdc.Particolare;
esponente = rigaUdc.Esponente;
codMag = rigaUdc.CodMag;
codBlocco = rigaUdc.CodBlocco;
codCellaMag = rigaUdc.CodCella;
idxCellaMag = rigaUdc.IdxCella;
idxBlocco = GMW_data.MagClass.magazzino.taBlocchi.getByCodBlocco(codBlocco)[0].IdxBlocco;
}
catch (Exception exc)
{
httpLog(string.Format("Eccezione: {0}", exc), tipoLog.EXCEPTION);
}
// salvo in session
memLayer.ML.setSessionVal("Particolare_sel", particolare, false);
memLayer.ML.setSessionVal("Esponente_sel", esponente, false);
memLayer.ML.setSessionVal("CodMag_sel", codMag, false);
memLayer.ML.setSessionVal("CodCellaMag", codCellaMag, false);
memLayer.ML.setSessionVal("IdxCellaMag", idxCellaMag, false);
memLayer.ML.setSessionVal("IdxBlocco_sel", idxBlocco, false);
// sollevo evento nuovo valore...
if (eh_selValore != null)
{
eh_selValore(this, new EventArgs());
}
}
fixDetailVisibility();
}
/// <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;
}
private void doTraduci()
{
lblSearchProvider.Text = traduci("UDC");
}
/// <summary>
/// Effettua la ricerca indicata
/// </summary>
public void doSearch()
{
mod_listUDC1.doUpdate();
mod_detailUDC1.Visible = false;
mod_execUDC1.Visible = false;
fixDetailVisibility();
}
/// <summary>
/// wrapper metodo traduzione
/// </summary>
/// <param name="lemma"></param>
/// <returns></returns>
public string traduci(string lemma)
{
return user_std.UtSn.Traduci(lemma);
}
/// <summary>
/// effettua refresh della visualizzazione
/// </summary>
public void doRefresh()
{
mod_listUDC1.doRefresh();
}
/// <summary>
/// effettua reset del controllo
/// </summary>
public void doReset()
{
memLayer.ML.setSessionVal("RicercaUdcAttiva", false, false);
mod_listUDC1.doRefresh();
mod_detailUDC1.Visible = false;
mod_execUDC1.Visible = false;
mod_detLDP1.Visible = false;
mod_detAttr1.Visible = false;
}
}
}