Example #1
0
        public ArrayList ObtenerFiltrosReporte(string idReporte)
        {
                                    
            ArrayList filtrosConsulta = new ArrayList();
            
            String sql = String.Format(
                 "SELECT SFIL_ID, \n" +
                 "       SFIL_CONTASOC, \n" +
                 "       SFIL_TABLA, \n" +
                 "       SFIL_CAMPO, \n" +
                 "       SFIL_DATOCOMP1, \n" +
                 "       SFIL_ETIQUETA, \n" +
                 "       SFIL_LUPA, \n" +
                 "       SFIL_TIPCOMPA, \n" +
                 "       SFIL_DATOCOMP2 \n" +
                 "FROM SFILTRO \n" +
                 "WHERE SREP_ID = {0} ORDER BY SFIL_ID"
                 , idReporte);

            ArrayList filtrosData;

            if (usaGlobal)
                filtrosData = DBFunctions.RequestGlobalAsCollection(sql);
            else
                filtrosData = DBFunctions.RequestAsCollection(sql);
            
            foreach (Hashtable hash in filtrosData)
            {
                FiltroDescriptor newFiltro = new FiltroDescriptor()
                {
                    Id = Convert.ToInt32(hash["SFIL_ID"]),
                    Label = hash["SFIL_ETIQUETA"].ToString(),
                    Nombre = hash["SFIL_CAMPO"].ToString(),
                    Filtro = hash["SFIL_DATOCOMP1"].ToString(),
                    TipoCampo = ObtenerTipoCampo(hash["SFIL_CONTASOC"].ToString()),
                    TablaLupa = hash["SFIL_LUPA"].ToString(),
                    TipoComparacion = hash["SFIL_TIPCOMPA"].ToString(),
                    DatoComparar = hash["SFIL_DATOCOMP2"].ToString()
                };

                //bool isNum;
                //double retNum;
                //    isNum = Double.TryParse(Convert.ToString(newFiltro.DatoComparar), 
                //    System.Globalization.NumberStyles.Any, 
                //    System.Globalization.NumberFormatInfo.InvariantInfo, 
                //    out retNum);

                if (newFiltro.TipoCampo == TipoCampo.RelacionForanea)
                {
                    string[] camposRelacion = newFiltro.Nombre.Split(',');

                    string fieldId = camposRelacion[0].Trim();
                    string table = hash["SFIL_TABLA"].ToString();
                    string fieldLabel = null;
                    string filtroDDL = newFiltro.Filtro;
                    string orderID = "1";
                    if (camposRelacion.Length == 3)
                        orderID = camposRelacion[2].Trim();
                    

                    if (newFiltro.Filtro != "" && newFiltro.TipoComparacion != "" && newFiltro.DatoComparar != "")
                        filtroDDL = "WHERE " + newFiltro.Filtro + " " + newFiltro.TipoComparacion + " " + newFiltro.DatoComparar;

                    if (camposRelacion.Length > 1)
                    {  
                        fieldLabel = camposRelacion[1].Trim();
                    }

                    newFiltro.Relacion = CrearRelacionFiltro(table, fieldId, fieldLabel, filtroDDL, orderID);
                }

                filtrosConsulta.Add(newFiltro);
            }

            return filtrosConsulta;
        }
Example #2
0
 public ConsultaFiltroUI(FiltroDescriptor descriptor)
 {
     PlaceHolder = new PlaceHolder();
     Descriptor  = descriptor;
 }