Example #1
0
        // metodo principal ejecutar consulta
        public static List <string> executeQuery(string query)
        {
            query = query.ToLower();
            Dictionary <string, object> filters = new Dictionary <string, object>();

            filters = Utilities.selectQueryReader(query);
            string        table_name = (string)filters["table_name"];
            List <string> result     = new List <string>();

            if (table_name == "municipio")
            {
                result = Municipio.filterMunicipio(filters);
            }

            if (table_name == "provincia")
            {
                result = Provincia.filterProvincia(filters);
            }

            if (table_name == "barrio")
            {
                result = result = Barrio.filterBarrio(filters);
            }

            if (table_name == "urbanizacion")
            {
                result = result = Urbanizacion.filterUrbanizacion(filters);
            }

            if (table_name == "distrito_municipal")
            {
                result = result = DistritoMunicipal.filterDistritoMunicipal(filters);
            }

            if (table_name == "seccion_dm")
            {
                result = result = SeccionDM.filterSeccionDM(filters);
            }

            if (table_name == "barrio_dm")
            {
                result = result = BarrioDM.filterBarrioDM(filters);
            }

            if (table_name == "urbanizacion_dm")
            {
                result = result = UrbanizacionDM.filterUrbanizacionDM(filters);
            }

            if (table_name == "persona")
            {
                result = result = Persona.filterPersona(filters);
            }

            return(result);
        }
        public void insertarBarrioDM(BarrioDM ba_dm, bool is_editar = false)
        {
            char   sep  = Utils.Utilities.sep;
            string dir  = Utilities.barrio_dm_dir;
            string data = (ba_dm.Idbarrio_dm.ToString() + sep + ba_dm.iddistrito.ToString() + sep + ba_dm.nombre + sep + ba_dm.poblacion + sep + ba_dm.area + sep + ba_dm.punto_cardinal);

            if (is_editar)
            {
                Utilities.updateFromFileById(dir, ba_dm.idbarrio_dm, data);
            }
            else
            {
                Utilities.writeSingleLineToFile(dir, data);
            }
        }
        public static string executeQueryReturnString(string query)
        {
            query = query.ToLower();
            Dictionary <string, object> filters = new Dictionary <string, object>();

            filters = Utilities.selectQueryReader(query);
            string        table_name    = (string)filters["table_name"];
            List <string> result        = new List <string>();
            string        result_string = "";

            if (table_name == "municipio")
            {
                result = Municipio.filterMunicipio(filters);
            }

            if (table_name == "provincia")
            {
                result = Provincia.filterProvincia(filters);
            }

            if (table_name == "barrio")
            {
                result = result = Barrio.filterBarrio(filters);
            }

            if (table_name == "urbanizacion")
            {
                result = result = Urbanizacion.filterUrbanizacion(filters);
            }

            if (table_name == "distrito_municipal")
            {
                result = result = DistritoMunicipal.filterDistritoMunicipal(filters);
            }

            if (table_name == "seccion_dm")
            {
                result = result = SeccionDM.filterSeccionDM(filters);
            }

            if (table_name == "barrio_dm")
            {
                result = result = BarrioDM.filterBarrioDM(filters);
            }

            if (table_name == "urbanizacion_dm")
            {
                result = result = UrbanizacionDM.filterUrbanizacionDM(filters);
            }

            if (table_name == "persona")
            {
                result = result = Persona.filterPersona(filters);
            }

            for (int i = 0; i < result.Count; i++)
            {
                if (i != result.Count - 1)
                {
                    result_string += result[i] + "[";
                }
                else
                {
                    result_string += result[i];
                }
            }

            return(result_string);
        }