private List <CatalogosBE> GetDdlCatalogos(string sIdCatalogo, bool bEsCatalogo, string sValorFiltro) { CatalogosBR oCommonServiceClient = new CatalogosBR(); RespuestaComunBE Respuesta = new RespuestaComunBE(); List <CatalogosBE> lstCatalogos = new List <CatalogosBE>(); if (sIdCatalogo != "0") { Respuesta = oCommonServiceClient.GetCatEspecifico(sIdCatalogo, sValorFiltro); } else { return(lstCatalogos); } List <CatalogosBE> lstDdl = new List <CatalogosBE>(); CatalogosBE item = new CatalogosBE(); if (bEsCatalogo) { item.ID = "0"; item.DESCRIPCION = "Seleccione Opción.."; lstDdl.Add(item); } lstDdl.AddRange(Respuesta.lstCatalogo); lstCatalogos = lstDdl; return(lstCatalogos); }
private void SetDdlCatalogos(DropDownList ddl, string sIdCatalogo, string sValorFiltro = "") { CatalogosBR oBus = new CatalogosBR(); RespuestaComunBE Respuesta = new RespuestaComunBE(); if (sIdCatalogo != "0") { Respuesta = oBus.GetCatEspecifico(sIdCatalogo, sValorFiltro); } else { return; } List <CatalogosBE> lstDdl = new List <CatalogosBE>(); CatalogosBE item = new CatalogosBE(); item.ID = "0"; item.DESCRIPCION = "Seleccione Opción.."; lstDdl.Add(item); lstDdl.AddRange(Respuesta.lstCatalogo); ddl.DataSource = lstDdl; ddl.DataValueField = "ID"; ddl.DataTextField = "DESCRIPCION"; ddl.DataBind(); }
/// <summary> /// Consulta de catalogo espeficico. Definición de todos los catalogos de la aplicación /// </summary> /// <param name="item">Se usa CatGeneralesBE para la consulta, Se requiere el idCatGenerales</param> /// <param name="sConexionString">cadena de conexión que se obtiene de la clase ConfiguracionDA</param> /// <returns>RespuestaComun.lstCatGenerales</returns> public RespuestaComunBE GetCatEspecifico(CatGeneralesBE item, string sConexionString) { RespuestaComunBE RespuestaComun = new RespuestaComunBE(); OleDbCommand Comando = new OleDbCommand(); OleDbConnection Conexion = new OleDbConnection(); OleDbDataReader Lector = null; string sComando = string.Empty; StringBuilder sMensajeError = new StringBuilder(); string sResultado = string.Empty; RespuestaComun.lstCatalogo = new List <CatalogosBE>(); RespuestaComun.itemError = new ErrorBE(); RespuestaComun.itemError.psMensaje = new StringBuilder(string.Empty); try { Conexion.ConnectionString = sConexionString; Conexion.Open(); Comando.Connection = Conexion; sComando = "spGetCatEspecifico"; Comando.CommandText = sComando; Comando.CommandType = CommandType.StoredProcedure; Comando.CommandTimeout = 0; Comando.Parameters.Clear(); Comando.Parameters.Add(new OleDbParameter("IDCATGENERALES", item.psIDCATGENERALES)).Direction = ParameterDirection.Input; Comando.Parameters.Add(new OleDbParameter("NOMBRECATALOGO", item.psNOMBRECATALOGO)).Direction = ParameterDirection.Input; Comando.Parameters.Add(new OleDbParameter("IDCATALOGO", item.psIDCATALOGO)).Direction = ParameterDirection.Input; Comando.Parameters.Add(new OleDbParameter("DESCRIPCION", item.psDESCRIPCION)).Direction = ParameterDirection.Input; Comando.Parameters.Add(new OleDbParameter("FILTRO", item.psFILTRO)).Direction = ParameterDirection.Input; Comando.Parameters.Add(new OleDbParameter("ACTIVO", item.psACTIVO)).Direction = ParameterDirection.Input; Comando.Parameters.Add(new OleDbParameter("VALORFILTRO", item.psVALORFILTRO)).Direction = ParameterDirection.Input; //[15102015][falta agregar la instruccion que obtiene el nombre del metodo]RespuestaComun.itemError.psMensaje.Append("[spGetConfigApp]"); RespuestaComun.itemError.psMensaje.Append("[spGetCatEspecifico]"); Lector = Comando.ExecuteReader(); if (Lector.HasRows) { while (Lector.Read()) { CatalogosBE itemLector = new CatalogosBE(); itemLector.ID = Lector["ID"].ToString(); itemLector.DESCRIPCION = Lector["DESCRIPCION"].ToString(); RespuestaComun.lstCatalogo.Add(itemLector); } } RespuestaComun.itemError.pbFlag = true; } catch (Exception Ex) { //Generar una deccion para crear Log de errores RespuestaComun.itemError.psMensaje.Append("["); RespuestaComun.itemError.psMensaje.Append(Ex.Message); RespuestaComun.itemError.psMensaje.Append("]"); RespuestaComun.itemError.pbFlag = false; } finally { Lector.Close(); Lector.Dispose(); Lector = null; Comando.Dispose(); Comando = null; Conexion.Close(); Conexion = null; } return(RespuestaComun); }
public List <CatalogosBE> getCatSelection(int IdCatGeneral, int IdSubCatalogo, Int64 App) { try { linqIELDataBaseDataContext dboSegLatino = new linqIELDataBaseDataContext(); List <CatalogosBE> ListaCatalogo = new List <CatalogosBE>(); CatalogosBE items = new CatalogosBE(); ////Obtenemos el catalogo especifico por id var lnqgetCat = (from c in dboSegLatino.CAT_GRALs where c.IDCATGRAL == IdCatGeneral select new { IDCATGRAL = c.IDCATGRAL, NOMBRETABLA = c.NOMBRETABLA, IDTABLA = c.IDTABLA, DESCRIPCIONTABLA = c.DESCRIPCIONTABLA, IDFILTRO = c.IDFILTRO, }).ToList(); Cat_GralsBE CatGrasl = new Cat_GralsBE(); foreach (var a in lnqgetCat) { CatGrasl.IDCATGRAL = a.IDCATGRAL; CatGrasl.NOMBRETABLA = a.NOMBRETABLA; CatGrasl.IDTABLA = a.IDTABLA; CatGrasl.DESCRIPCIONTABLA = a.DESCRIPCIONTABLA; CatGrasl.IDFILTRO = a.IDFILTRO; } ////Obtenemos finalmente el catalogo StringBuilder sComando = new StringBuilder(string.Empty); sComando.Append("SELECT CONVERT(VARCHAR(250),"); sComando.Append(CatGrasl.IDTABLA); sComando.Append(") AS ID,"); sComando.Append("CONVERT(VARCHAR(250),"); sComando.Append(CatGrasl.DESCRIPCIONTABLA); sComando.Append(")"); sComando.Append(" AS DESCRIPCION"); sComando.Append(" FROM "); sComando.Append(CatGrasl.NOMBRETABLA); if (!string.IsNullOrEmpty(CatGrasl.IDFILTRO) && IdSubCatalogo != 0) { sComando.Append(" WHERE "); sComando.Append(CatGrasl.IDFILTRO); sComando.Append("='"); sComando.Append(IdSubCatalogo); sComando.Append("' AND ACTIVO = 1 "); } else { sComando.Append(" WHERE ACTIVO = 1 "); } var lnqConsulta = dboSegLatino.ExecuteQuery <CatalogosBE>(sComando.ToString()); List <CatalogosBE> ListCatalogo = new List <CatalogosBE>(); foreach (var a in lnqConsulta) { CatalogosBE item = new CatalogosBE(); item.ID = a.ID.ToString(); item.DESCRIPCION = a.DESCRIPCION.ToUpper(); ListaCatalogo.Add(item); } lnqConsulta = null; List <CatalogosBE> ListaGrlSort = ListaCatalogo.OrderBy(x => x.DESCRIPCION).ThenBy(x => x.DESCRIPCION).ToList(); CatalogosBE lista = new CatalogosBE(); lista.ID = "0"; lista.DESCRIPCION = "[SELECCIONE UNA OPCIÓN]"; ListaGrlSort.Insert(0, lista); return(ListaGrlSort); } catch (Exception ex) { StackTrace st = new StackTrace(true); CommonDA ComunDA = new CommonDA(); ComunDA.insErrorDB("Error: " + ex.Message + " En El Metodo: " + MethodBase.GetCurrentMethod().Name, st, "", App.ToString()); throw new Exception(ex.Message); } }
/// <summary> /// Ejecuta el sl_help de la tabla que se envia /// </summary> /// <param name="sNombreTabla"> Nombre de la tabla a consultar</param> /// <param name="sConexionString"> cadena de conexión que se obtiene de la clase ConfiguracionDA</param> /// <returns>En lstCatalogos[].DESCRIPCION se regresa el nombre de las columnas de la tabla. En psIdentityTabla Se regresa el Identity de la tabla ///</returns> public RespuestaComunBE GetDefinicionTabla(string sNombreTabla, string sConexionString) { RespuestaComunBE RespuestaComun = new RespuestaComunBE(); OleDbCommand Comando = new OleDbCommand(); OleDbConnection Conexion = new OleDbConnection(); OleDbDataReader Lector = null; string sComando = string.Empty; StringBuilder sMensajeError = new StringBuilder(); string sResultado = string.Empty; RespuestaComun.lstCatalogo = new List <CatalogosBE>(); RespuestaComun.itemError = new ErrorBE(); RespuestaComun.itemError.psMensaje = new StringBuilder(string.Empty); try { Conexion.ConnectionString = sConexionString; Conexion.Open(); Comando.Connection = Conexion; sComando = "spGetDefinicionTabla"; Comando.CommandText = sComando; Comando.CommandType = CommandType.StoredProcedure; Comando.CommandTimeout = 0; Comando.Parameters.Clear(); Comando.Parameters.Add(new OleDbParameter("NombreTabla", sNombreTabla)).Direction = ParameterDirection.Input; //[15102015][falta agregar la instruccion que obtiene el nombre del metodo]RespuestaComun.itemError.psMensaje.Append("[spGetConfigApp]"); RespuestaComun.itemError.psMensaje.Append("[spGetDefinicionTabla]"); Lector = Comando.ExecuteReader(); if (Lector.HasRows) { Lector.NextResult(); while (Lector.Read()) { CatalogosBE itemLector = new CatalogosBE(); itemLector.DESCRIPCION = Lector["Column_name"].ToString(); RespuestaComun.lstCatalogo.Add(itemLector); } Lector.NextResult(); while (Lector.Read()) { //Se encuentra el nombre de la columna IDentity RespuestaComun.psIdentityTabla = Lector["Identity"].ToString(); RespuestaComun.psDescripcionTabla = "Descripcion"; } } RespuestaComun.itemError.pbFlag = true; } catch (Exception Ex) { //Generar una deccion para crear Log de errores RespuestaComun.itemError.psMensaje.Append("["); RespuestaComun.itemError.psMensaje.Append(Ex.Message); RespuestaComun.itemError.psMensaje.Append("]"); RespuestaComun.itemError.pbFlag = false; } finally { Lector.Close(); Lector.Dispose(); Lector = null; Comando.Dispose(); Comando = null; Conexion.Close(); Conexion = null; } return(RespuestaComun); }