1f7b3ff79f
git-svn-id: https://keyhammer.ath.cx/svn/GMW/trunk@483 365432ac-a1b5-4ffd-bb28-6d3099d32164
602 lines
22 KiB
C#
602 lines
22 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using SteamWare;
|
|
using GMW_data;
|
|
|
|
namespace GMW.WebUserControls
|
|
{
|
|
public partial class mod_odette : SteamWare.ApplicationUserControl
|
|
{
|
|
#region area da NON modificare
|
|
|
|
#region area protected
|
|
|
|
protected string _idxGridView;
|
|
protected string _idxGridViewExt;
|
|
protected string _tabCache;
|
|
protected bool _showNewBtn = false;
|
|
|
|
/// <summary>
|
|
/// imposta errore non cancellabilità per record correlati
|
|
/// </summary>
|
|
protected void setNoDeletableErrorMessage()
|
|
{
|
|
// mostro avviso di non cancellabilità...
|
|
lblWarning.Text = traduci("notDeletable_hasChild");
|
|
lblWarning.Visible = true;
|
|
grView.DataBind();
|
|
}
|
|
/// <summary>
|
|
/// esegue cancellazioen record
|
|
/// </summary>
|
|
protected void doDelete()
|
|
{
|
|
// posso cancellare...
|
|
lblWarning.Visible = false;
|
|
ods.Delete();
|
|
}
|
|
/// <summary>
|
|
/// Valida la cancellazione per i dati mostrati dal gridView
|
|
/// richiede sia preventivamentedichiarato _idxGridView
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected virtual void validaDelete(object sender, ObjectDataSourceMethodEventArgs e)
|
|
{
|
|
int idx = Convert.ToInt32(e.InputParameters[string.Format("Original_{0}", _idxGridView)]);
|
|
if (objIsNotRelated(idx))
|
|
{
|
|
// annullo cancellazione...
|
|
e.Cancel = true;
|
|
// seleziono record... metto in session valore idx e poi ridisegno...
|
|
SteamWare.memLayer.ML.setSessionVal(_idxGridView, idx);
|
|
setNoDeletableErrorMessage();
|
|
}
|
|
else
|
|
{
|
|
doDelete();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// recupera i dati di un nuovo record contenuti nel footer di un gridView;
|
|
/// questi devono esses opportunamente nominati (es: txt{0}, dl{0}, ...)
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void recuperaFooter(object sender, ObjectDataSourceMethodEventArgs e)
|
|
{
|
|
//recupero la riga footer...
|
|
DataColumnCollection colonne = colonneObj();
|
|
string nomeCol;
|
|
string tipoColonna = "";
|
|
foreach (DataColumn colonna in colonne)
|
|
{
|
|
nomeCol = colonna.ColumnName;
|
|
// cerco un textbox o quello che sia...
|
|
if (grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol)) != null)
|
|
{
|
|
tipoColonna = "textBox";
|
|
}
|
|
else if (grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol)) != null)
|
|
{
|
|
tipoColonna = "dropDownList";
|
|
}
|
|
else if (grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol)) != null)
|
|
{
|
|
tipoColonna = "checkBox";
|
|
}
|
|
else if (grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol)) != null)
|
|
{
|
|
tipoColonna = "selAjax";
|
|
}
|
|
// in base al tipo salvo negli inputparameters dell'ODS
|
|
switch (tipoColonna)
|
|
{
|
|
case "textBox":
|
|
e.InputParameters[nomeCol] = ((TextBox)grView.FooterRow.FindControl(string.Format("txt{0}", nomeCol))).Text;
|
|
break;
|
|
case "dropDownList":
|
|
e.InputParameters[nomeCol] = ((DropDownList)grView.FooterRow.FindControl(string.Format("dl{0}", nomeCol))).SelectedValue;
|
|
break;
|
|
case "checkBox":
|
|
e.InputParameters[nomeCol] = ((CheckBox)grView.FooterRow.FindControl(string.Format("chk{0}", nomeCol))).Checked;
|
|
break;
|
|
case "selAjax":
|
|
e.InputParameters[nomeCol] = ((mod_selettore_ajax)grView.FooterRow.FindControl(string.Format("selAjax_{0}", nomeCol))).valore;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
tipoColonna = "";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// inserisce nuovo valore da footer
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lblIns_click(object sender, EventArgs e)
|
|
{
|
|
// click su inserimento, chiamo il metodo insert dell'ObjectDataSource
|
|
ods.Insert();
|
|
SteamWare.memLayer.ML.emptyCacheVal(_tabCache);
|
|
}
|
|
/// <summary>
|
|
/// annulla inserimento nuovo valore da footer
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lblCanc_click(object sender, EventArgs e)
|
|
{
|
|
// annullo inserimento: nascondo footer, bind controlli...
|
|
grView.FooterRow.Visible = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// aggiorna controlli datagrid e numero righe in pagina
|
|
/// </summary>
|
|
protected override void aggiornaControlliDataGL()
|
|
{
|
|
base.aggiornaControlliDataGL();
|
|
grView.PageSize = _righeDataGridMed;
|
|
}
|
|
/// <summary>
|
|
/// traduce gli header delle colonne
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grView_DataBound(object sender, EventArgs e)
|
|
{
|
|
if (grView.Rows.Count > 0)
|
|
{
|
|
LinkButton lb;
|
|
// aggiorno gli headers
|
|
foreach (TableCell cella in grView.HeaderRow.Cells)
|
|
{
|
|
try
|
|
{
|
|
lb = (LinkButton)cella.Controls[0];
|
|
lb.Text = traduci(lb.Text);
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
int totRecord = grView.Rows.Count + grView.PageSize * (grView.PageCount - 1);
|
|
lblNumRec.Text = string.Format("{0} records of ~ {1}", grView.Rows.Count, totRecord);
|
|
}
|
|
else
|
|
{
|
|
lblNumRec.Text = "";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// gestione evento richeista nuovo valore (mostra footer, ...)
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnNew_Click(object sender, EventArgs e)
|
|
{
|
|
// reset selezione...
|
|
resetSelezione();
|
|
// mostro il footer oppure la riga dei dettagli x nuovo...
|
|
if (grView.FooterRow != null)
|
|
{
|
|
grView.FooterRow.Visible = true;
|
|
}
|
|
// sollevo evento nuovo valore...
|
|
if (eh_nuovoValore != null)
|
|
{
|
|
eh_nuovoValore(this, new EventArgs());
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// reset della selezione
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnReset_Click(object sender, EventArgs e)
|
|
{
|
|
resetSelezione();
|
|
}
|
|
|
|
/// <summary>
|
|
/// collega i controlli
|
|
/// </summary>
|
|
protected override void bindControlli()
|
|
{
|
|
base.bindControlli();
|
|
caricaTabelle();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region gestione eventi
|
|
|
|
//public event EventHandler eh_resetSelezione;
|
|
public event EventHandler eh_nuovoValore;
|
|
//public event EventHandler eh_selValore;
|
|
|
|
#endregion
|
|
|
|
#region public
|
|
|
|
/// <summary>
|
|
/// definisce visibilità btnNew
|
|
/// </summary>
|
|
public bool showNewBtn
|
|
{
|
|
get
|
|
{
|
|
return _showNewBtn;
|
|
}
|
|
set
|
|
{
|
|
_showNewBtn = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// effettua update del modulo
|
|
/// </summary>
|
|
public void doUpdate()
|
|
{
|
|
resetSelezione();
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region area codice variabile
|
|
|
|
|
|
/// <summary>
|
|
/// carico le tabelle
|
|
/// </summary>
|
|
private void caricaTabelle()
|
|
{
|
|
}
|
|
/// <summary>
|
|
/// verifica complessiva non esistenza record child
|
|
/// </summary>
|
|
/// <param name="idxObj"></param>
|
|
/// <returns></returns>
|
|
protected bool objIsNotRelated(object idxObj)
|
|
{
|
|
bool answ = true;
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// elenco colonne del datagrid
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected DataColumnCollection colonneObj()
|
|
{
|
|
DS_magazzino.ElencoListePrelievoDataTable tabella = new DS_magazzino.ElencoListePrelievoDataTable();
|
|
DataColumnCollection colonne = tabella.Columns;
|
|
return colonne;
|
|
}
|
|
/// <summary>
|
|
/// inizializzazione valori di default
|
|
/// </summary>
|
|
/// <param name="e"></param>
|
|
protected override void OnInit(EventArgs e)
|
|
{
|
|
base.OnInit(e);
|
|
_idxGridView = "CodListaOd";
|
|
if (!Page.IsPostBack)
|
|
{
|
|
mod_viewOdette1.Visible = false;
|
|
mod_periodoAnalisi1.setPeriodoFree();
|
|
mod_bolle4odette1.Visible = false;
|
|
}
|
|
// registro evento update
|
|
mod_viewOdette1.eh_nuovoValore += new EventHandler(mod_viewOdette1_eh_nuovoValore);
|
|
mod_periodoAnalisi1.eh_doUpdate += new EventHandler(mod_periodoAnalisi1_eh_doUpdate);
|
|
mod_bolle4odette1.eh_nuovoValore += new EventHandler(mod_bolle4odette1_eh_nuovoValore);
|
|
}
|
|
|
|
/// <summary>
|
|
/// mostra oggetti x creare una nuova lista di prelievo
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
void mod_bolle4odette1_eh_nuovoValore(object sender, EventArgs e)
|
|
{
|
|
mod_bolle4odette1.Visible = false;
|
|
// aggiorno controllo corrente!
|
|
updateOds();
|
|
// ridisegno controllo child!
|
|
aggiornaElencoRighe();
|
|
}
|
|
/// <summary>
|
|
/// aggiorno x update selettore date
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
void mod_periodoAnalisi1_eh_doUpdate(object sender, EventArgs e)
|
|
{
|
|
// aggiorno controllo corrente!
|
|
updateOds();
|
|
// ridisegno controllo child!
|
|
aggiornaElencoRighe();
|
|
}
|
|
/// <summary>
|
|
/// aggiorno x update valori righe prelievo
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
void mod_viewOdette1_eh_nuovoValore(object sender, EventArgs e)
|
|
{
|
|
// aggiorno controllo corrente!
|
|
updateOds();
|
|
// ridisegno controllo child!
|
|
aggiornaElencoRighe();
|
|
}
|
|
/// <summary>
|
|
/// svuoto da cache post update
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ods_Updated(object sender, ObjectDataSourceStatusEventArgs e)
|
|
{
|
|
resetSelezione();
|
|
}
|
|
/// <summary>
|
|
/// aggiorno visualizzazione
|
|
/// </summary>
|
|
private void updateOds()
|
|
{
|
|
grView.DataBind();
|
|
}
|
|
|
|
/// <summary>
|
|
/// determina se sia abilitato il pulsante x creare le etichette odette
|
|
/// </summary>
|
|
/// <param name="codLista"></param>
|
|
/// <returns></returns>
|
|
public bool CreaOdetteEnabled(string codLista)
|
|
{
|
|
bool answ = false;
|
|
try
|
|
{
|
|
DS_magazzino.ElencoListePrelievoRow riga = MagClass.magazzino.taElencoListePrelievo.getByCodLista(codLista)[0];
|
|
DS_Odette.stp_OdetteStatoCreateRow rigaCreate = Odette.mgr.taOdCreate.GetData(codLista)[0];
|
|
answ = ((riga.CodStatoLista == (int)statoLista.scaricata) && (riga.CodTipoLista == "04-OdetSP") && (rigaCreate.OdetteCreate < rigaCreate.OdetteDaCreare));
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// gestione cambio selezione valore
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
// mostro modulo per associazione etichette odette / bolla
|
|
string codLista = grView.SelectedValue.ToString();
|
|
mod_bolle4odette1.Visible = CreaOdetteEnabled(codLista);
|
|
// salvo in session il valore selezionato...
|
|
memLayer.ML.setSessionVal(string.Format("{0}_sel", _idxGridView), grView.SelectedValue, true);
|
|
aggiornaElencoRighe();
|
|
}
|
|
/// <summary>
|
|
/// aggiorna visualizzazione
|
|
/// </summary>
|
|
private void aggiornaElencoRighe()
|
|
{
|
|
// setto se sia possibile prelevare le righe (SOLO se iniziata)
|
|
bool prelievoOk = false;
|
|
bool cambioUdcOk = false;
|
|
int codStato = 0;
|
|
string codTipoLista = "";
|
|
DS_magazzino.ElencoListePrelievoDataTable tabElencoListe = new DS_magazzino.ElencoListePrelievoDataTable();
|
|
try
|
|
{
|
|
tabElencoListe = GMW_data.MagClass.magazzino.taElencoListePrelievo.getByCodLista(grView.SelectedValue.ToString());
|
|
codStato = tabElencoListe[0].CodStatoLista;
|
|
codTipoLista = tabElencoListe[0].CodTipoLista;
|
|
cambioUdcOk = (codStato == (int)statoLista.bozza);
|
|
prelievoOk = (codStato == (int)statoLista.iniziata);
|
|
}
|
|
catch
|
|
{ }
|
|
mod_viewOdette1.intStatoLista = codStato; // salvo il cod (INT) stato della lista
|
|
mod_viewOdette1.codTipoLista = codTipoLista; // salvo il tipo lista
|
|
// mostra con dettagli
|
|
mod_viewOdette1.Visible = true;
|
|
mod_viewOdette1.resetSelezione();
|
|
}
|
|
/// <summary>
|
|
/// resetta la selezione dei valori in caso di modifiche su altri controlli
|
|
/// </summary>
|
|
public void resetSelezione()
|
|
{
|
|
// nascondo creazione odette se visualizzata
|
|
mod_bolle4odette1.Visible = false;
|
|
// sistemo il resto
|
|
SteamWare.memLayer.ML.emptySessionVal(string.Format("{0}_sel", _idxGridView));
|
|
grView.SelectedIndex = -1;
|
|
grView.DataBind();
|
|
lblWarning.Visible = false;
|
|
// nasconde dettagli
|
|
mod_viewOdette1.Visible = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// salvo in session il prox comando
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void img_Click(object sender, ImageClickEventArgs e)
|
|
{
|
|
SteamWare.memLayer.ML.setSessionVal("nextObjCommand", ((ImageButton)sender).CommandArgument);
|
|
}
|
|
/// <summary>
|
|
/// in caso di aggiornamento verifico se sia salvato un comando inizia o completa lista prelievo...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grView_RowUpdating(object sender, GridViewUpdateEventArgs e)
|
|
{
|
|
// carico l'idx dell'oggetto
|
|
string codLista = e.Keys["CodLista"].ToString();
|
|
// recupero il tipo lista
|
|
string codTipoLista = "";
|
|
DS_magazzino.ElencoListePrelievoDataTable tabElencoListe = new DS_magazzino.ElencoListePrelievoDataTable();
|
|
try
|
|
{
|
|
codTipoLista = tabElencoListe[0].CodTipoLista;
|
|
}
|
|
catch
|
|
{
|
|
httpLog(string.Format("Non ho trovato tipo lista per la lista di prelievo seguente: {0}", codLista), tipoLog.ERROR);
|
|
}
|
|
// quale comando?
|
|
string _comando = "";
|
|
if (SteamWare.memLayer.ML.isInSessionObject("nextObjCommand"))
|
|
{
|
|
_comando = SteamWare.memLayer.ML.StringSessionObj("nextObjCommand");
|
|
SteamWare.memLayer.ML.emptySessionVal("nextObjCommand");
|
|
}
|
|
string CodSoggetto = MagClass.magazzino.CodSoggCurrUser;
|
|
switch (_comando)
|
|
{
|
|
|
|
case "CreaEtichetteOdette":
|
|
// mostro modulo per associazione etichette odette / bolla
|
|
mod_bolle4odette1.Visible = true;
|
|
// blocco update!
|
|
e.Cancel = true;
|
|
break;
|
|
default:
|
|
// faccio update!
|
|
break;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// chiamato post modifica valore check/selezione nel selettore filtro stato
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
public void eh_selectedStato(object sender, EventArgs e)
|
|
{
|
|
checkFixOds();
|
|
}
|
|
/// <summary>
|
|
/// ssitema visualizzazione dal filtraggi
|
|
/// </summary>
|
|
private void checkFixOds()
|
|
{
|
|
ods.FilterParameters.Clear();
|
|
ods.FilterExpression = "(CodLista LIKE '%{0}%' OR Particolare LIKE '%{0}%' OR DescParticolare LIKE '%{0}%') AND CodTipoLista = '04-OdetSP' AND CodStatoLista = 4 ";
|
|
// parametro ricerca attuale
|
|
SessionParameter parametroFiltro = new SessionParameter();
|
|
parametroFiltro.SessionField = "valoreCercato";
|
|
parametroFiltro.Name = "ricerca";
|
|
parametroFiltro.DefaultValue = "*";
|
|
ods.FilterParameters.Add(parametroFiltro);
|
|
|
|
// chiamo procedura che aggiorna ods principale
|
|
grView.SelectedIndex = -1;
|
|
updateOds();
|
|
// ridisegno controllo child!
|
|
aggiornaElencoRighe();
|
|
}
|
|
/// <summary>
|
|
/// chiamato post modifica valore check/selezione nel selettore filtro tipo
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
public void eh_selectedTipo(object sender, EventArgs e)
|
|
{
|
|
checkFixOds();
|
|
}
|
|
/// <summary>
|
|
/// restituisce URL immagine del codice da mostrare x TIPO lista
|
|
/// </summary>
|
|
/// <param name="codStato"></param>
|
|
/// <returns></returns>
|
|
public string pathImgTipo(object codice)
|
|
{
|
|
return string.Format("~/images/lista_{0}_m.png", codice);
|
|
}
|
|
/// <summary>
|
|
/// restituisce tooltip da mostrare x TIPO lista
|
|
/// </summary>
|
|
/// <param name="codStato"></param>
|
|
/// <returns></returns>
|
|
public string tooltipTipo(object codice)
|
|
{
|
|
return traduci(codice.ToString());
|
|
}
|
|
/// <summary>
|
|
/// traduce il cod soggetto in cognome-nome operatore
|
|
/// </summary>
|
|
/// <param name="CodSogg"></param>
|
|
/// <returns></returns>
|
|
public string traduciCodSogg(object CodSogg)
|
|
{
|
|
string answ = "-";
|
|
try
|
|
{
|
|
DS_Applicazione.AnagOperatoriRow oper = DataProxy.obj.taAnagOperatore.getByCodSoggetto(CodSogg.ToString())[0];
|
|
answ = string.Format("In carico a: {0} {1} ({2})", oper.Cognome, oper.Nome, oper.CodDipendente); // Ermanno: traduzione testo!
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// restituisce l'url formattato del il report della stampa come da web.config
|
|
/// </summary>
|
|
/// <param name="codLista"></param>
|
|
/// <returns></returns>
|
|
public string formattaUrlReport(object codLista)
|
|
{
|
|
string url, urlFormat, opzPdf, nomeRep, urlWebServer;
|
|
try
|
|
{
|
|
urlFormat = SteamWare.memLayer.ML.confReadString("urlReporting");
|
|
urlWebServer = SteamWare.memLayer.ML.confReadString("urlWebServer");
|
|
opzPdf = "";
|
|
nomeRep = SteamWare.memLayer.ML.confReadString("reportName");
|
|
// versione con reporting services
|
|
url = string.Format(urlFormat, SteamWare.memLayer.ML.confReadString("reportingServerAddress"), SteamWare.memLayer.ML.confReadString("reportDir"), nomeRep, codLista, opzPdf);
|
|
|
|
}
|
|
catch
|
|
{
|
|
url = "";
|
|
}
|
|
return url;
|
|
}
|
|
|
|
/// <summary>
|
|
/// formatta una stringa x lo stato dell'odette (create/totale
|
|
/// </summary>
|
|
/// <param name="CodLista"></param>
|
|
/// <returns></returns>
|
|
public string StatoOdette(object CodLista)
|
|
{
|
|
string answ = "";
|
|
try
|
|
{
|
|
DS_Odette.stp_OdetteStatoCreateRow riga = Odette.mgr.taOdCreate.GetData(CodLista.ToString())[0];
|
|
answ = string.Format("{0}/{1}", riga.OdetteCreate, riga.OdetteDaCreare);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
} |