Exemplo n.º 1
0
        public static void ActualizaOrden(int ModuloId, int Orden, string Panel)
        {
            string Sentencia = "SELECT PagID FROM modulos WHERE ModuloID = " + ModuloId;

            IDataReader Datos = AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

            int PagId = 0;

            if (Datos.Read())
            {
                PagId = (int)Datos["PagID"];
            }

            Datos.Close();

            Sentencia  = "SELECT MAX(ModuloOrden) AS ModuloOrden ";
            Sentencia += "FROM modulos WHERE  PagID = " + PagId;

            Datos = AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

            if (Datos.Read())
            {
                Orden = (Orden != -1) ? Orden : ((int)Datos["ModuloOrden"]) + 2;
            }

            Datos.Close();

            Sentencia  = "UPDATE modulos SET ModuloOrden = " + Orden;
            Sentencia += ", NombrePanel = '" + Regex.Replace(Panel, "'", "''") + "'";
            Sentencia += " WHERE PagID = " + PagId;
            Sentencia += " AND ModuloID = " + ModuloId;

            AyudanteMySQL.Ejecutar(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);
        }
Exemplo n.º 2
0
        public static int Crear()
        {
            string Sentencia = "SELECT MAX(PagOrden) AS Orden FROM paginas";

            IDataReader Datos = AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

            int Orden = 1000;

            if (Datos.Read())
            {
                Orden = (int)Datos["Orden"];
            }

            Orden = Orden + 2;

            Datos.Close();

            Sentencia  = "INSERT INTO paginas (PagPadre, PagOrden, PagNombre, GruposAutorizados) ";
            Sentencia += "VALUES (-1, " + Orden + ", 'Nueva Pagina', 'Todos')";

            AyudanteMySQL.Ejecutar(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

            Sentencia = "SELECT LAST_INSERT_ID() AS ID";
            Datos     = AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

            int resultado = (Datos.Read()) ? Int32.Parse(Datos["ID"].ToString()) : -1;

            Datos.Close();
            return(resultado);
        }
Exemplo n.º 3
0
        public static void ActualizaConfig(int ModuloId, string Configuracion, string Valor)
        {
            string Sentencia = "SELECT * FROM modulosconfig WHERE ModuloID = " + ModuloId;

            Sentencia += " AND Configuracion = '" + Regex.Replace(Configuracion, "'", "''") + "'";

            IDataReader Datos = AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

            if (Datos.Read())
            {
                Sentencia  = "UPDATE modulosconfig SET Valor = '" + Valor + "'";
                Sentencia += " WHERE ModuloID = " + ModuloId + " AND Configuracion = '" + Regex.Replace(Configuracion, "'", "''") + "'";

                AyudanteMySQL.Ejecutar(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);
            }
            else
            {
                Sentencia  = "INSERT INTO modulosconfig (ModuloID, Configuracion, Valor) VALUES (";
                Sentencia += ModuloId + ", '" + Regex.Replace(Configuracion, "'", "''") + "', '" + Regex.Replace(Valor, "'", "''") + "')";

                AyudanteMySQL.Ejecutar(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);
            }

            Datos.Close();
        }
Exemplo n.º 4
0
        public static int Crear(int PagId, int definicionId, string Nombre, int TiempoCache)
        {
            string Sentencia = "SELECT MAX(ModuloOrden) AS Orden FROM modulos WHERE ";

            Sentencia += "PagID = " + PagId + " AND NombrePanel = 'Centro'";

            IDataReader Datos = AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

            int Orden = 1;

            if (Datos.Read())
            {
                Orden = (Datos["Orden"] == DBNull.Value) ? 1 : ((int)Datos["Orden"]) + 2;
            }

            Datos.Close();

            Sentencia  = "INSERT INTO modulos (PagID, ModuloDefID, ModuloOrden, NombrePanel, ModuloTitulo, GruposAutorizados, GruposAutorizadosEdicion, TiempoCache) ";
            Sentencia += "VALUES (" + PagId + ", " + definicionId + ", " + Orden + ", 'Centro', ";
            Sentencia += "'" + Regex.Replace(Nombre, "'", "''") + "', 'Todos', 'Administradores', " + TiempoCache + ")";

            AyudanteMySQL.Ejecutar(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

            Sentencia = "SELECT LAST_INSERT_ID() AS ID";
            Datos     = AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

            int resultado = (Datos.Read()) ? Int32.Parse(Datos["ID"].ToString()) : -1;

            Datos.Close();
            return(resultado);
        }
Exemplo n.º 5
0
        public static IDataReader ObtenerHijas(int PagId)
        {
            string Sentencia = "SELECT * FROM paginas WHERE PagPadre = " + PagId;

            Sentencia += " ORDER BY PagOrden";

            return(AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia));
        }
Exemplo n.º 6
0
        public static IDataReader Obtener(string Usuario)
        {
            string Sentencia = "SELECT * FROM usuarios WHERE Usuario = '";

            Sentencia += Regex.Replace(Usuario, "'", "''") + "'";

            return(AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia));
        }
Exemplo n.º 7
0
        public static IDataReader Obtener(int moduloId)
        {
            string Sentencia = "SELECT * FROM modulos WHERE ModuloID = ";

            Sentencia += moduloId;

            return(AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia));
        }
Exemplo n.º 8
0
        public static IDataReader ObtenerDefiniciones(int definicionId)
        {
            string Sentencia = "SELECT * FROM modulosdefinicion WHERE ";

            Sentencia += "ModuloDefID = " + definicionId;

            return(AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia));
        }
Exemplo n.º 9
0
        public static IDataReader ObtenerUsuarios(int grupoId)
        {
            string Sentencia = "SELECT usuarios.* ";

            Sentencia += "FROM usuarios INNER JOIN usuariosgrupos ON usuarios.UsuarioID = usuariosgrupos.UsuarioID ";
            Sentencia += "WHERE usuariosgrupos.GrupoID = " + grupoId;

            return(AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia));
        }
Exemplo n.º 10
0
        public static IDataReader ObtienePermisos(int moduloId)
        {
            string Sentencia = "SELECT modulos.GruposAutorizados, modulos.GruposAutorizadosEdicion ";

            Sentencia += "FROM modulos INNER JOIN paginas ON modulos.PagID = paginas.PagID ";
            Sentencia += "WHERE ModuloID = " + moduloId;

            return(AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia));
        }
Exemplo n.º 11
0
        public static IDataReader ObtenerPagina(int PagId)
        {
            string Sentencia = "SELECT modulos.*, modulosdefinicion.Ubicacion, modulosdefinicion.UbicacionEdicion ";

            Sentencia += "FROM modulos INNER JOIN modulosdefinicion ON modulos.ModuloDefID = modulosdefinicion.ModuloDefID ";
            Sentencia += "WHERE PagID = " + PagId + " ORDER BY ModuloOrden";

            return(AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia));
        }
Exemplo n.º 12
0
        public static IDataReader ObtenerEventos(int moduloId)
        {
            string Sentencia = "SELECT * FROM eventos WHERE (ModuloID = " + moduloId + ")";

            Sentencia += " AND (Fecha_Vencimiento >= CURDATE())";
            Sentencia += " ORDER BY Fecha DESC, Titulo ASC";

            return(AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia));
        }
Exemplo n.º 13
0
        public static IDataReader ObtenerGruposReader(string Usuario)
        {
            string Sentencia = "SELECT grupos.GrupoID, grupos.Nombre FROM grupos ";

            Sentencia += "INNER JOIN (usuarios INNER JOIN usuariosgrupos ON usuarios.UsuarioID = usuariosgrupos.UsuarioID) ";
            Sentencia += "ON grupos.GrupoID = usuariosgrupos.GrupoID ";
            Sentencia += "WHERE Usuario = '" + Regex.Replace(Usuario, "'", "''") + "'";

            return(AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia));
        }
Exemplo n.º 14
0
        public static void ActualizaOrdenModulos(int PagId)
        {
            int    Contador;
            int    Orden;
            string Panel;

            string Sentencia = "SELECT DISTINCT NombrePanel FROM modulos ";

            Sentencia += "WHERE PagID = " + PagId + " ORDER BY NombrePanel";

            IDataReader Paneles = AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

            while (Paneles.Read())
            {
                Panel = Paneles["NombrePanel"].ToString();

                Contador = 0;

                Sentencia  = "SELECT DISTINCT ModuloOrden FROM modulos WHERE ";
                Sentencia += "PagID = " + PagId + " AND NombrePanel = '" + Regex.Replace(Panel, "'", "''") + "' ";
                Sentencia += "ORDER BY ModuloOrden";

                IDataReader Modulos = AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

                while (Modulos.Read())
                {
                    Contador++;

                    Orden = (int)Modulos["ModuloOrden"];

                    int NuevoOrden = ((Contador * 2) - 1) * -1;

                    Sentencia  = "UPDATE modulos SET ModuloOrden = " + NuevoOrden;
                    Sentencia += " WHERE PagID = " + PagId;
                    Sentencia += " AND ModuloOrden = " + Orden;
                    Sentencia += " AND NombrePanel = '" + Regex.Replace(Panel, "'", "''") + "'";

                    AyudanteMySQL.Ejecutar(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);
                }

                Modulos.Close();

                Sentencia  = "UPDATE modulos SET ModuloOrden = ModuloOrden * -1";
                Sentencia += " WHERE PagID = " + PagId;
                Sentencia += " AND NombrePanel = '" + Regex.Replace(Panel, "'", "''") + "'";

                AyudanteMySQL.Ejecutar(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);
            }
            Paneles.Close();
        }
Exemplo n.º 15
0
        public static int Crear()
        {
            string Sentencia = "INSERT INTO grupos (Nombre) VALUES ('(Nuevo Grupo)')";

            AyudanteMySQL.Ejecutar(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

            Sentencia = "SELECT LAST_INSERT_ID() AS ID";
            IDataReader Datos = AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

            int resultado = (Datos.Read()) ? Int32.Parse(Datos["ID"].ToString()) : -1;

            Datos.Close();
            return(resultado);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Verifica si el usuario y la clave son validos para ingresar
        /// al Portal.
        /// </summary>
        /// <param name="Usuario">
        /// Usuario que desea ingresar al Portal.
        /// </param>
        /// <param name="Clave">
        /// Clave del usuario
        /// </param>
        /// <returns>
        /// Una cadena vacia si el Usuario no se corresponde con la
        /// clave o no existe; en caso contrario devuelve el login
        /// del Usuario.
        /// </returns>
        public static string Ingresar(string Usuario, string Clave)
        {
            string Sentencia = "SELECT * FROM usuarios WHERE Usuario = '";

            Sentencia += Regex.Replace(Usuario, "'", "''") + "' and Clave = '";
            Sentencia += Regex.Replace(Clave, "'", "''") + "'";

            IDataReader Datos = AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

            string resultado = (Datos.Read()) ? (string)Datos["Usuario"] : string.Empty;

            Datos.Close();
            return(resultado);
        }
Exemplo n.º 17
0
        public static int Crear(string Usuario, string Nombre)
        {
            string Sentencia = "INSERT INTO usuarios (Usuario, Nombre) VALUES ('";

            Sentencia += Regex.Replace(Usuario, "'", "''") + "', '" + Regex.Replace(Nombre, "'", "''") + "')";

            AyudanteMySQL.Ejecutar(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

            Sentencia = "SELECT LAST_INSERT_ID() AS ID";
            IDataReader Datos = AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

            int resultado = (Datos.Read()) ? Int32.Parse(Datos["ID"].ToString()) : -1;

            Datos.Close();

            return(resultado);
        }
Exemplo n.º 18
0
        public static Hashtable ObtenerConfig(int ModuloId)
        {
            Hashtable config = new Hashtable();

            string Sentencia = "SELECT * FROM modulosconfig WHERE ModuloID = " + ModuloId;

            IDataReader Datos = AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

            while (Datos.Read())
            {
                config[(string)Datos["Configuracion"]] = (string)Datos["Valor"];
            }

            Datos.Close();

            return(config);
        }
Exemplo n.º 19
0
        public static void ActualizaOrden()
        {
            int Contador;
            int Padre;
            int Orden;

            string Sentencia = "SELECT DISTINCT PagPadre FROM paginas ORDER BY PagPadre";

            IDataReader Padres = AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

            while (Padres.Read())
            {
                Padre = (int)Padres["PagPadre"];

                Contador = 0;

                Sentencia  = "SELECT DISTINCT PagOrden FROM paginas WHERE PagPadre = " + Padre;
                Sentencia += " ORDER BY PagOrden";

                IDataReader Paginas = AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

                while (Paginas.Read())
                {
                    Contador++;

                    Orden = (int)Paginas["PagOrden"];

                    int NuevoOrden = ((Contador * 2) - 1) * -1;

                    Sentencia  = "UPDATE paginas SET PagOrden = " + NuevoOrden;
                    Sentencia += " WHERE PagPadre = " + Padre;
                    Sentencia += " AND PagOrden = " + Orden;

                    AyudanteMySQL.Ejecutar(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);
                }
                Paginas.Close();
            }
            Padres.Close();

            Sentencia = "UPDATE paginas SET PagOrden = PagOrden * -1";
            AyudanteMySQL.Ejecutar(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

            Sentencia = "UPDATE paginas SET PagOrden = 1000 WHERE PagNombre = 'Administración' ";
            AyudanteMySQL.Ejecutar(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);
        }
Exemplo n.º 20
0
        public static int CrearDefinicion(string Nombre, string Ubicacion, string UbicacionEdicion)
        {
            string Sentencia = "INSERT INTO modulosdefinicion (Nombre, Ubicacion, UbicacionEdicion) VALUES (";

            Sentencia += "'" + Regex.Replace(Nombre, "'", "''") + "', ";
            Sentencia += "'" + Regex.Replace(Ubicacion, "'", "''") + "', ";
            Sentencia += "'" + Regex.Replace(UbicacionEdicion, "'", "''") + "')";

            AyudanteMySQL.Ejecutar(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

            Sentencia = "SELECT LAST_INSERT_ID() AS ID";
            IDataReader Datos = AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia);

            int resultado = (Datos.Read()) ? Int32.Parse(Datos["ID"].ToString()) : -1;

            Datos.Close();
            return(resultado);
        }
        public static int CrearBanco(string NumeroDep, string Fecha, string NumeroCta, string Monto)
        {
            string Sentencia = "INSERT INTO DepositoBanco (NumeroDep, Fecha, NumeroCta, Monto ) VALUES ('";

            Sentencia += Regex.Replace(NumeroDep, "'", "''") + "', '" + Regex.Replace(Fecha, "'", "''") + "', '";
            Sentencia += Regex.Replace(NumeroCta, "'", "''") + "', '" + Regex.Replace(Monto, "'", "''") + "')";

            AyudanteMySQL.Ejecutar(ConfigurationSettings.AppSettings["PortalGene"], Sentencia);

            Sentencia = "SELECT LAST_INSERT_ID() AS ID";
            IDataReader Datos = AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["PortalGene"], Sentencia);

            int resultado = (Datos.Read()) ? Int32.Parse(Datos["ID"].ToString()) : -1;

            Datos.Close();

            return(resultado);
        }
Exemplo n.º 22
0
        public static int Crear(string Codigo, string Descripcion, string NumeroId)
        {
            string Sentencia = "INSERT INTO analisisdeprecios (Codigo, Descripcion, Numero) VALUES ('";

            Sentencia += Regex.Replace(Codigo, "'", "''") + "', '" + Regex.Replace(Descripcion, "'", "''") + "', '";
            Sentencia += Regex.Replace(NumeroId, "'", "''") + "')";

            AyudanteMySQL.Ejecutar(ConfigurationSettings.AppSettings["PortalGene"], Sentencia);

            Sentencia = "SELECT LAST_INSERT_ID() AS ID";
            IDataReader Datos = AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["PortalGene"], Sentencia);

            int resultado = (Datos.Read()) ? Int32.Parse(Datos["ID"].ToString()) : -1;

            Datos.Close();

            return(resultado);
        }
Exemplo n.º 23
0
        public static IDataReader ObtenerUnContacto(int Cid)         //Para obtener el contacto a editar (si se hace click sobre el nombre)
        {
            string Sentencia = "SELECT ContactoID, Nombre, Cargo, Email, Contacto1, Contacto2 FROM Contactos Where ContactoID = " + Cid;

            return(AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia));
        }
        public static IDataReader ObtenerUnDocumento(int DocId)         //Para obtener el Documento a editar (si se hace click sobre el nombre)
        {
            string Sentencia = "SELECT Fecha,Descripcion, Formato,DocumentoId,Link, Titulo FROM Documentos Where DocumentoId = " + DocId;

            return(AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia));
        }
        public static IDataReader BorrarDocumento(int DocId)         //Para Borrar un documento dado su DocId
        {
            string Sentencia = "DELETE FROM Documentos WHERE DocumentoId = " + DocId;

            return(AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia));
        }
        public static IDataReader ObtenerDocumentos(int moduloid)         //Para llenar la lista
        {
            string Sentencia = "SELECT Fecha,Descripcion, Formato,DocumentoId,Link,Titulo FROM Documentos WHERE ModuloID = " + moduloid + " ORDER BY DocumentoId";

            return(AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia));
        }
Exemplo n.º 27
0
        public static IDataReader BorrarContacto(int Cid)         //Para Borrar un contacto dado su ContactId
        {
            string Sentencia = "DELETE FROM Contactos WHERE ContactoID = " + Cid;

            return(AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia));
        }
Exemplo n.º 28
0
        public static IDataReader Obtener()
        {
            string Sentencia = "SELECT * FROM grupos ORDER BY Nombre";

            return(AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia));
        }
Exemplo n.º 29
0
        //----------------------------------------------------------------------
        // Usuario

        //---------------------------------------------------------------------
        // Grupos
        public static IDataReader ObtenerGrupos()
        {
            string Sentencia = "select * from grupos";

            return(AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia));
        }
Exemplo n.º 30
0
        public static IDataReader ObtenerDefiniciones()
        {
            string Sentencia = "SELECT * FROM modulosdefinicion WHERE Sistema = 0 ORDER BY Nombre";

            return(AyudanteMySQL.EjecutarReader(ConfigurationSettings.AppSettings["CadenaConexion"], Sentencia));
        }