/*=========================================================================================================================== * Instituto Costarricense de Acueductos y Alcantarillados. - 2015 * Administración de la Seguridad * Nombre del control de usuario: cuwBusquedaList.ascx * * Explicación de los contenidos del archivo *=========================================================================================================================== * HISTORIAL * * PERSONA DIA – MES - AÑO DESCRIPCIÓN * Juan Pablo Monge Delgad 22 – 02 - 2016 Se inicia con el diseño del control * Juan Pablo Monge Delgad 22 – 02 - 2016 Se finaliza con el desarrollo del control * ………………………………………………………… *=========================================================================================================================== * Derechos Reservados (C) 2015 AyA. * ESTE CÓDIGO ES PROVEÍDO “TAL CUAL ES” SIN GARANTÍA ALGUNA * DE NINGÚN TIPO, SEA IMPLICITA O EXPLICITA. * NO SE PERMITE SU REPRODUCCIÓN PARCIAL O TOTAL, NI SU COMERCIALIZACIÓN *=========================================================================================================================== * Este control utiliza jquery por lo que se debera ir al archivo ../../Scripts/WebForms/General/cuwBusquedaList.js, si se desea agregar algun cambio en el comportamiento * Para utilizarlo debera agregar el siguiente tag a la ventana en el archivo .aspx: * <%@ Register Src="~/ControlUsuario/cuwBusquedaList.ascx" TagPrefix="uc1" TagName="cuwBusquedaList" %> Se deben agregar los siguientes metodos al archivo .cs En inicializarFormulario(): cuwBusquedaList.Buscar += new _controlesusuario_Estandar_cuwBusquedaList.SearchEvent(Buscar); construirGridView: cuwBusquedaList.LlenarCHKLBusqueda(grvListaDatosTemp); llenarGridView: condicionesBusqueda(p_parametros); y DataSet dsBitacora = objBitacoraBL.getDatosBitacora(arlCondicionesFiltroBusqueda); * Debe existir el metodo condicionesBusqueda() sino debe extraerlo de la pagina de bitacora * llenarGridView despues del isPostback: condicionesBusqueda(); */ using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using AyABL.RCS; public partial class _controlesusuario_Estandar_cuwBusquedaList : System.Web.UI.UserControl { #region Variables public delegate void SearchEvent(); public event SearchEvent Buscar; #endregion #region Eventos Controles Web protected void btnBusqueda_Click(object sender, ImageClickEventArgs e) { try { Buscar(); } catch (Exception ex) { throw ex; } } #endregion #region Métodos Personalizados /// /// Metodo que carga el listado desplegable del buscador /// public void LlenarCHKLBusqueda(GridView gridView) { try { TableRow row = new TableRow(); foreach (DataControlField dgcDGTempColumn in gridView.Columns)//por cada coloumna del gridview { if (dgcDGTempColumn.GetType().ToString() == "GridViewBoundField") { GridViewBoundField ndbTempDGBoundField = (GridViewBoundField)dgcDGTempColumn; if (ndbTempDGBoundField.Visible && ndbTempDGBoundField.IsSearch)//si se habilito la busqueda durante la inicializacion { ListItem litTempItem = new ListItem(ndbTempDGBoundField.HeaderText, ndbTempDGBoundField.DataField); //chkFiltro.Items.Add(litTempItem); Label lblTitulo = new Label(); lblTitulo.ID = "lbl" + ndbTempDGBoundField.DataField; lblTitulo.Text = ndbTempDGBoundField.HeaderText; CheckBox chkTitulo = new CheckBox(); chkTitulo.ID = "chk" + ndbTempDGBoundField.DataField; TableCell cell = new TableCell(); cell.Controls.Add(chkTitulo); cell.Controls.Add(lblTitulo); row.Cells.Add(cell); } } } tblParametrosConsulta.Rows.Add(row); //se crea una subtabla para poder acomodar los controles de fecha TableRow rowControles = new TableRow(); foreach (DataControlField dgcDGTempColumn in gridView.Columns) { if (dgcDGTempColumn.GetType().ToString() == "GridViewBoundField") { GridViewBoundField ndbTempDGBoundField = (GridViewBoundField)dgcDGTempColumn; if (ndbTempDGBoundField.Visible && ndbTempDGBoundField.IsSearch) { TextBox txtParametro = new TextBox(); txtParametro.Attributes["placeholder"] = ndbTempDGBoundField.HeaderText; DropDownList ddlParametro = new DropDownList(); ddlParametro.Items.Add(new ListItem("No", "0")); ddlParametro.Items.Add(new ListItem("Si", "1")); ddlParametro.Items.Add(new ListItem("Ambos", "2")); ddlParametro.SelectedValue = "2"; TextBox txtCalendarioInicio = new TextBox(); txtCalendarioInicio.CssClass = "date"; txtCalendarioInicio.Attributes["placeholder"] = ndbTempDGBoundField.HeaderText + " INICIO"; TextBox txtCalendarioFin = new TextBox(); txtCalendarioFin.CssClass = "date"; txtCalendarioFin.Attributes["placeholder"] = ndbTempDGBoundField.HeaderText + " FIN"; TableCell cell = new TableCell(); if (ndbTempDGBoundField.DataField.Contains("FECHA") == true) { Table tbFecha = new Table(); tbFecha.ID = "tablaFecha" + ndbTempDGBoundField.DataField; TableRow rowfFecha = new TableRow(); TableCell cellFechaInicio = new TableCell(); TableCell cellFechaFin = new TableCell(); txtCalendarioInicio.ID = ndbTempDGBoundField.DataField + "INICIO"; cellFechaInicio.Controls.Add(txtCalendarioInicio); rowfFecha.Cells.Add(cellFechaInicio); tbFecha.Rows.Add(rowfFecha); txtCalendarioFin.ID = ndbTempDGBoundField.DataField + "FIN"; cellFechaFin.Controls.Add(txtCalendarioFin); rowfFecha.Cells.Add(cellFechaFin); tbFecha.Rows.Add(rowfFecha); cell.Controls.Add(tbFecha); } else { if (ndbTempDGBoundField.ValorFalse != "False" && ndbTempDGBoundField.ValorTrue != "True") { ddlParametro.ID = ndbTempDGBoundField.DataField; cell.Controls.Add(ddlParametro); } else { txtParametro.ID = ndbTempDGBoundField.DataField; cell.Controls.Add(txtParametro); } } rowControles.Cells.Add(cell); } } } tblParametrosConsulta.Rows.Add(rowControles); } catch (Exception ex) { throw ex; } } // //Metodo que devuelve el filtro seleccionado (Nombre del campo en la base de datos) y el valor de busqueda // // public string getValorBusqueda() { try { string allTextBoxValues = ""; foreach (Control c in tblParametrosConsulta.Rows[1].Controls) { foreach (Control childc in c.Controls) { if (childc is TextBox) { allTextBoxValues += childc.ID + ":"; allTextBoxValues += ((TextBox)childc).Text + ","; } if (childc is DropDownList) { allTextBoxValues += "booleano|" + childc.ID + ":"; allTextBoxValues += ((DropDownList)childc).SelectedValue.ToString() + ","; } if (childc is Table) { Table tbFecha = (Table)childc; foreach (Control c2 in tbFecha.Rows[0].Controls) { foreach (Control childc2 in c2.Controls) { if (childc2 is TextBox) { allTextBoxValues += childc2.ID + ":"; allTextBoxValues += ((TextBox)childc2).Text + ","; } } } } } } return allTextBoxValues; } catch (Exception ex) { throw ex; } } #endregion }