From e60ac60c7ec985e0d5f19c388cc9da2c726f384b Mon Sep 17 00:00:00 2001 From: samuele Date: Wed, 17 Sep 2008 11:10:56 +0000 Subject: [PATCH] Va con bozza anagrafica eventi, scelto di usare direttamente componente DS dentro applicativo customizzato... git-svn-id: https://keyhammer.ath.cx/svn/XPS/trunk@5 43c8e981-f90d-406c-a89a-24a2c4268d51 --- XPS/AnagraficaEventi.aspx | 6 + XPS/AnagraficaEventi.aspx.cs | 18 ++ XPS/Web.config | 10 +- XPS/mod_anagraficaEventi.ascx | 68 +++++ XPS/mod_anagraficaEventi.ascx.cs | 410 +++++++++++++++++++++++++++++++ 5 files changed, 505 insertions(+), 7 deletions(-) create mode 100644 XPS/AnagraficaEventi.aspx create mode 100644 XPS/AnagraficaEventi.aspx.cs create mode 100644 XPS/mod_anagraficaEventi.ascx create mode 100644 XPS/mod_anagraficaEventi.ascx.cs diff --git a/XPS/AnagraficaEventi.aspx b/XPS/AnagraficaEventi.aspx new file mode 100644 index 0000000..5790b1e --- /dev/null +++ b/XPS/AnagraficaEventi.aspx @@ -0,0 +1,6 @@ +<%@ Page Language="C#" MasterPageFile="~/AjaxSearch.master" AutoEventWireup="true" CodeFile="AnagraficaEventi.aspx.cs" Inherits="AnagraficaEventi" Title="Untitled Page" %> + +<%@ Register Src="mod_anagraficaEventi.ascx" TagName="mod_anagraficaEventi" TagPrefix="uc1" %> + + + \ No newline at end of file diff --git a/XPS/AnagraficaEventi.aspx.cs b/XPS/AnagraficaEventi.aspx.cs new file mode 100644 index 0000000..eb63d3c --- /dev/null +++ b/XPS/AnagraficaEventi.aspx.cs @@ -0,0 +1,18 @@ +using System; +using System.Data; +using System.Configuration; +using System.Collections; +using System.Web; +using System.Web.Security; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Web.UI.WebControls.WebParts; +using System.Web.UI.HtmlControls; + +public partial class AnagraficaEventi : System.Web.UI.Page +{ + protected void Page_Load(object sender, EventArgs e) + { + + } +} diff --git a/XPS/Web.config b/XPS/Web.config index 4f40f77..8a3f622 100644 --- a/XPS/Web.config +++ b/XPS/Web.config @@ -104,13 +104,9 @@ - - + + diff --git a/XPS/mod_anagraficaEventi.ascx b/XPS/mod_anagraficaEventi.ascx new file mode 100644 index 0000000..fbe0baf --- /dev/null +++ b/XPS/mod_anagraficaEventi.ascx @@ -0,0 +1,68 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeFile="mod_anagraficaEventi.ascx.cs" Inherits="mod_anagraficaEventi" %> +<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> + + + + + + + + + + + + + + + + + + + + +   + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ diff --git a/XPS/mod_anagraficaEventi.ascx.cs b/XPS/mod_anagraficaEventi.ascx.cs new file mode 100644 index 0000000..dee947a --- /dev/null +++ b/XPS/mod_anagraficaEventi.ascx.cs @@ -0,0 +1,410 @@ +using System; +using System.Data; +using System.Configuration; +using System.Collections; +using System.Web; +using System.Web.Security; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Web.UI.WebControls.WebParts; +using System.Web.UI.HtmlControls; +using SteamWare; +using SteamWare.XPS; + + +public partial class mod_anagraficaEventi : SteamWare.ApplicationUserControl +{ + #region area da NON modificare + + #region area protected + + protected string _idxGridView; + //protected string _idxGridViewExt; + protected string _tabCache; + protected bool _showNewBtn = true; + + /// + /// imposta errore non cancellabilità per record correlati + /// + protected void setNoDeletableErrorMessage() + { + // mostro avviso di non cancellabilità... + lblWarning.Text = traduci("notDeletable_hasChild"); + lblWarning.Visible = true; + grView.DataBind(); + } + /// + /// esegue cancellazione record + /// + protected void doDelete() + { + // posso cancellare... + lblWarning.Visible = false; + ods.Delete(); + } + /// + /// Valida la cancellazione per i dati mostrati dal gridView + /// richiede sia preventivamentedichiarato _idxGridView + /// + /// + /// + 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(); + } + } + /// + /// inserisce nuovo valore da footer + /// + /// + /// + protected void lblIns_click(object sender, EventArgs e) + { + // click su inserimento, chiamo il metodo insert dell'ObjectDataSource + ods.Insert(); + SteamWare.memLayer.ML.emptyCacheVal(_tabCache); + } + /// + /// annulla inserimento nuovo valore da footer + /// + /// + /// + protected void lblCanc_click(object sender, EventArgs e) + { + // annullo inserimento: nascondo footer, bind controlli... + grView.FooterRow.Visible = false; + } + /// + /// aggiorna controlli datagrid e numero righe in pagina + /// + protected override void aggiornaControlliDataGL() + { + base.aggiornaControlliDataGL(); + grView.PageSize = _righeDataGridMed; + } + /// + /// traduce gli header delle colonne + /// + /// + /// + 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 = ""; + } + } + /// + /// gestione evento richeista nuovo valore (mostra footer, ...) + /// + /// + /// + 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()); + } + } + /// + /// reset della selezione + /// + /// + /// + protected void btnReset_Click(object sender, EventArgs e) + { + resetSelezione(); + } + /// + /// collega i controlli + /// + protected override void bindControlli() + { + base.bindControlli(); + caricaTabelle(); + } + /// + /// gestione cambio selezione valore + /// + /// + /// + protected void grView_SelectedIndexChanged(object sender, EventArgs e) + { + // salvo in session il valore selezionato... + SteamWare.memLayer.ML.setSessionVal(string.Format("{0}_sel", _idxGridView), grView.SelectedValue); + // sollevo evento nuovo valore... + if (eh_selValore != null) + { + eh_selValore(this, new EventArgs()); + } + } + + #endregion + + #region gestione eventi + + public event EventHandler eh_resetSelezione; + public event EventHandler eh_nuovoValore; + public event EventHandler eh_selValore; + + #endregion + + #region public + + /// + /// definisce visibilità btnNew + /// + public bool showNewBtn + { + get + { + return _showNewBtn; + } + set + { + _showNewBtn = value; + } + } + /// + /// effettua update del modulo + /// + public void doUpdate() + { + resetSelezione(); + } + + + #endregion + + #endregion + + #region area codice variabile + + /// + /// carico le tabelle + /// + private void caricaTabelle() + { + // non serve qui... + } + + /// + /// verifica complessiva non esistenza record child + /// + /// + /// + protected bool objIsNotRelated(object idxObj) + { + // !!! FARE vero controllo cancellazione? + return false;// (taRouteVersion.getByOggetti(idxObj.ToString(), vers.ToString()).Rows.Count == 0); + } +#if false + /// + /// elenco colonne del datagrid + /// + /// + protected DataColumnCollection colonneObj() + { + DS_applicazione.OggettiDataTable tabella = new DS_applicazione.OggettiDataTable(); + DataColumnCollection colonne = tabella.Columns; + return colonne; + } +#endif + +#if false + /// + /// inizializzazione valori di default + /// + /// + protected override void OnInit(EventArgs e) + { + base.OnInit(e); + _idxGridView = "idxObj"; + _tabCache = "tabOggetti"; + Mod_filtro1.eh_selValore += new EventHandler(Mod_filtro1_eh_selValore); + if (!Page.IsPostBack) + { + Mod_filtro1.ods = odsFiltro; + } + + } +#endif + + void Mod_filtro1_eh_selValore(object sender, EventArgs e) + { + // ridisegno + } + + /// + /// setta selected alla riga il cui valore key è in session + /// + /// + /// + protected void grView_RowDataBound(object sender, GridViewRowEventArgs e) + { +#if false + // se riga di dati... + if (e.Row.RowType == DataControlRowType.DataRow) + { + // ottengo la riga tipizzata... + System.Data.DataRowView _drv = (System.Data.DataRowView)e.Row.DataItem; + DS_applicazione.OggettiRow riga = (DS_applicazione.OggettiRow)_drv.Row; + if (SteamWare.memLayer.ML.StringSessionObj(_idxGridView) == riga.idxObj.ToString()) + { + grView.SelectedIndex = e.Row.RowIndex; + } + } +#endif + } + /// + /// resetta la selezione dei valori in caso di modifiche su altri controlli + /// + public void resetSelezione() + { +#if false + SteamWare.memLayer.ML.emptySessionVal(string.Format("{0}_sel", _idxGridView)); + grView.SelectedIndex = -1; + grView.DataBind(); + lblWarning.Visible = false; + if (eh_resetSelezione != null) + { + eh_resetSelezione(this, new EventArgs()); + } +#endif + } + + /// + /// gestione evento inserimento nuovo record standard (se ZERO presenti) + /// + /// + /// + protected void btnNewFromEmpty_Click(object sender, EventArgs e) + { +#if false + // reset selezione... + resetSelezione(); + DS_applicazioneTableAdapters.OggettiTableAdapter taOggetti = new DS_applicazioneTableAdapters.OggettiTableAdapter(); + // creo 1 obj vuoto... + taOggetti.Insert("Descrizione oggetto", Convert.ToInt32(Mod_filtro1.valore), "Cod brembo originale"); + grView.DataBind(); + // sollevo evento nuovo valore... + if (eh_nuovoValore != null) + { + eh_nuovoValore(this, new EventArgs()); + } +#endif + } + + /// + /// recupera i dati di un nuovo record contenuti nel footer di un gridView; + /// questi devono esses opportunamente nominati (es: txt{0}, dl{0}, ...) + /// + /// + /// + protected void recuperaFooter(object sender, ObjectDataSourceMethodEventArgs e) + { +#if false + //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("dl{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 = ""; + } + e.InputParameters["idxTipoObj"] = Convert.ToInt32(Mod_filtro1.valore); + e.InputParameters["codBrembo"] = e.InputParameters["codBrembo"].ToString().ToUpper(); + // svuoto cache... + SteamWare.memLayer.ML.emptyCacheVal("_tabSelOggetti"); +#endif + } + protected void ods_Updating(object sender, ObjectDataSourceMethodEventArgs e) + { +#if false + e.InputParameters["idxTipoObj"] = Convert.ToInt32(Mod_filtro1.valore); + e.InputParameters["codBrembo"] = e.InputParameters["codBrembo"].ToString().ToUpper(); + // svuoto cache... + SteamWare.memLayer.ML.emptyCacheVal("_tabSelOggetti"); +#endif + } + + #endregion + + protected void ods_Init(object sender, EventArgs e) + { + //SteamWare.XPS.DS_XPSTableAdapters.EventiTableAdapter ta = new SteamWare.XPS.DS_XPSTableAdapters.EventiTableAdapter(); + //ta.Connection.ConnectionString = "Data Source=localhost;Initial Catalog=LVF_JPS;Integrated Security=True"; + } +} \ No newline at end of file