/// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public List <Institucion> obtenerInstitucion()
        {
            List <Institucion> list = new List <Institucion>();

            Institucion cat;

            try
            {
                var command = new SqlCommand("dbo.usp_ConsultaInst", ConexionSingleton.abrirConexion());
                command.CommandType = CommandType.StoredProcedure;
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    cat = new Institucion();
                    cat.idInstitucion     = (int)reader["IdInstitucion"];
                    cat.NombreInstitucion = (string)reader["nombreInstitucion"];
                    cat.Direccion         = (string)reader["Direccion"];
                    cat.fechaCreacion     = (DateTime)reader["FechaCreacion"];
                    list.Add(cat);
                }
            }
            catch (SqlException ex)
            {
                throw new Exception("SQl Error en obtener los datos de institución" + ex.Message);
            }
            catch (Exception ex)
            {
                throw new Exception("Code Error en obtener los datos de institución" + ex.Message);
            }

            ConexionSingleton.cerrarConexion();

            return(list);
        }
Exemplo n.º 2
0
        public Carrera buscaCarrera(int iCarrera, int iInstituc)
        {
            Carrera regCarrera = new Carrera();

            try
            {
                var command = new SqlCommand("dbo.usp_BuscaCarrera", ConexionSingleton.abrirConexion());
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@iCarrera", iCarrera);
                command.Parameters.AddWithValue("@idInst", iInstituc);
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    regCarrera.idCarrera         = (int)reader["idCarrera"];
                    regCarrera.Nombre            = (string)reader["Nombre"];
                    regCarrera.idInstit          = (int)reader["idInstitucion"];
                    regCarrera.fechaCreacion     = (DateTime)reader["FechaCreacion"];
                    regCarrera.fechaModificacion = (DateTime)reader["FechaModificacion"];
                    regCarrera.lValid            = (bool)reader["lValido"];
                    regCarrera.cancelado         = (bool)reader["Cancelado"];
                }
            }
            catch (SqlException ex)
            {
                throw new Exception("[buscaCarrera]SQl Error en obtener los datos de modelos" + ex.Message);
            }
            catch (Exception ex)
            {
                throw new Exception("[buscaCarrera]Code Error en obtener los datos de modelos" + ex.Message);
            }

            ConexionSingleton.cerrarConexion();
            return(regCarrera);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="_institucion"></param>
        /// <returns></returns>
        public int InsertaInstitucion(Institucion _institucion)
        {
            // alta de usuario

            var command = new SqlCommand("dbo.usp_AltaInst", ConexionSingleton.abrirConexion());

            command.CommandType = System.Data.CommandType.StoredProcedure;

            command.Parameters.AddWithValue("@cNombreInstitucion", _institucion.NombreInstitucion);
            command.Parameters.AddWithValue("@cDireccion", _institucion.Direccion);


            int folio = 0;

            try
            {
                folio = (int)command.ExecuteScalar();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            ConexionSingleton.cerrarConexion();
            return(folio);
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public List <Estado> obtenerEstado()
        {
            List <Estado> list = new List <Estado>();

            Estado cat;

            try
            {
                var command = new SqlCommand("dbo.usp_ConsultaEstado", ConexionSingleton.abrirConexion());
                command.CommandType = CommandType.StoredProcedure;
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    cat                   = new Estado();
                    cat.idEstado          = (int)reader["idEstado"];
                    cat.Nombre            = (string)reader["Nombre"];
                    cat.FechaCreacion     = (DateTime)reader["FechaCreacion"];
                    cat.FechaModificacion = (DateTime)reader["FechaModificacion"];
                    list.Add(cat);
                }
            }
            catch (SqlException ex)
            {
                throw new Exception("SQl Error en obtener los datos de Estado" + ex.Message);
            }
            catch (Exception ex)
            {
                throw new Exception("Code Error en obtener los datos de Estado" + ex.Message);
            }

            ConexionSingleton.cerrarConexion();

            return(list);
        }
Exemplo n.º 5
0
        public void eliminaParametro(Parametro _parametro)
        {
            var command = new SqlCommand("SP_bajaParametro", ConexionSingleton.abrirConexion());

            command.CommandType = System.Data.CommandType.StoredProcedure;

            command.Parameters.AddWithValue("@idParametro", _parametro.idParametro);


            try
            {
                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception("Error al ejecutar el store procedure" + ex.Message);
            }

            ConexionSingleton.cerrarConexion();
        }
Exemplo n.º 6
0
        public void modificaEstado(Estado _estado)
        {
            var command = new SqlCommand("SP_modificaEstado", ConexionSingleton.abrirConexion());

            command.CommandType = System.Data.CommandType.StoredProcedure;

            command.Parameters.AddWithValue("@idEstado", _estado.idEstado);
            command.Parameters.AddWithValue("@cNombre", _estado.Nombre);

            try
            {
                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception("Error al ejecutar el store procedure" + ex.Message);
            }

            ConexionSingleton.cerrarConexion();
        }
Exemplo n.º 7
0
        public void eliminaCarrera(Carrera _carrera)
        {
            var command = new SqlCommand("uspEliminaCarrera", ConexionSingleton.abrirConexion());

            command.CommandType = System.Data.CommandType.StoredProcedure;

            command.Parameters.AddWithValue("@idInstitucion", _carrera.idInstit);
            command.Parameters.AddWithValue("@idCarrera", _carrera.idCarrera);


            try
            {
                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception("Error al ejecutar el store procedure" + ex.Message);
            }

            ConexionSingleton.cerrarConexion();
        }
        public void modificaTipoDocumento(TipoDocumento _tipoDocumento)
        {
            var command = new SqlCommand("SP_ModTipoDoc", ConexionSingleton.abrirConexion());

            command.CommandType = System.Data.CommandType.StoredProcedure;

            command.Parameters.AddWithValue("@idTipoDocumento", _tipoDocumento.idTipoDocumento);
            command.Parameters.AddWithValue("@cNombre", _tipoDocumento.Nombre);
            command.Parameters.AddWithValue("@cDescripcion", _tipoDocumento.cRutaImagen);

            try
            {
                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception("Error al ejecutar el store procedure" + ex.Message);
            }

            ConexionSingleton.cerrarConexion();
        }
        public void modificaInstitucion(Institucion _institucion)
        {
            var command = new SqlCommand("SP_modificaInstitucion", ConexionSingleton.abrirConexion());

            command.CommandType = System.Data.CommandType.StoredProcedure;

            command.Parameters.AddWithValue("@idInstitucion", _institucion.idInstitucion);
            command.Parameters.AddWithValue("@cNombreInstitucion", _institucion.NombreInstitucion);
            command.Parameters.AddWithValue("@cDireccion", _institucion.Direccion);
            command.Parameters.AddWithValue("@lValido", _institucion.lValido);

            try
            {
                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception("Error al ejecutar el store procedure" + ex.Message);
            }

            ConexionSingleton.cerrarConexion();
        }
Exemplo n.º 10
0
        public int InsertaEstado(Estado _estado)
        {
            var command = new SqlCommand("dbo.usp_CreaEstado", ConexionSingleton.abrirConexion());

            command.CommandType = System.Data.CommandType.StoredProcedure;

            command.Parameters.AddWithValue("@cNombre", _estado.Nombre);

            int folio = 0;

            try
            {
                folio = (int)command.ExecuteScalar();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            ConexionSingleton.cerrarConexion();
            return(folio);
        }
Exemplo n.º 11
0
        public int InsertaParametro(Parametro _parametro)
        {
            var command = new SqlCommand("dbo.usp_AltaParametro", ConexionSingleton.abrirConexion());

            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.Parameters.AddWithValue("@cNombre", _parametro.cNombre);
            command.Parameters.AddWithValue("@cDescripcion", _parametro.cDescripcion);
            command.Parameters.AddWithValue("@cValor", _parametro.cValor);

            int folio = 0;

            try
            {
                folio = (int)command.ExecuteScalar();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            ConexionSingleton.cerrarConexion();
            return(folio);
        }
Exemplo n.º 12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="_carrera"></param>
        /// <returns></returns>
        public int InsertaCarrera(Carrera _carrera)
        {
            var command = new SqlCommand("dbo.usp_AltaCarrera", ConexionSingleton.abrirConexion());

            command.CommandType = System.Data.CommandType.StoredProcedure;

            command.Parameters.AddWithValue("@cNombre", _carrera.Nombre);
            command.Parameters.AddWithValue("@iidInstitucion", _carrera.idInstit);

            int folio = 0;

            try
            {
                folio = (int)command.ExecuteScalar();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            ConexionSingleton.cerrarConexion();
            return(folio);
        }
Exemplo n.º 13
0
        public void modificaCarrera(Carrera _carrera)
        {
            var command = new SqlCommand("dbo.usp_ModificaCarrera", ConexionSingleton.abrirConexion());

            command.CommandType = System.Data.CommandType.StoredProcedure;

            command.Parameters.AddWithValue("@idCarrera", _carrera.idCarrera);
            command.Parameters.AddWithValue("@cNombre", _carrera.Nombre);
            command.Parameters.AddWithValue("@iidInstitucion", _carrera.idInstit);
            command.Parameters.AddWithValue("@bValid", _carrera.lValid);
            command.Parameters.AddWithValue("@cCan", _carrera.cancelado);

            try
            {
                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception("Error al ejecutar el store procedure" + ex.Message);
            }

            ConexionSingleton.cerrarConexion();
        }
        public int InsertaTipoDocumento(TipoDocumento _tipoDocumento)
        {
            var command = new SqlCommand("dbo.usp_AltaTipoDoc", ConexionSingleton.abrirConexion());

            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.Parameters.AddWithValue("@cNombre", _tipoDocumento.Nombre);
            command.Parameters.AddWithValue("@cRutaImagen", _tipoDocumento.cRutaImagen);


            int folio = 0;

            try
            {
                folio = (int)command.ExecuteScalar();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            ConexionSingleton.cerrarConexion();
            return(folio);
        }
Exemplo n.º 15
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public List <Carrera> obtenerCarrera()
        {
            List <Carrera> list = new List <Carrera>();

            Carrera catCarrera;

            try
            {
                var command = new SqlCommand("dbo.usp_ConsultaCarrera", ConexionSingleton.abrirConexion());
                command.CommandType = CommandType.StoredProcedure;
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    catCarrera                   = new Carrera();
                    catCarrera.idCarrera         = (int)reader["idCarrera"];
                    catCarrera.Nombre            = (string)reader["Nombre"];
                    catCarrera.idInstit          = (int)reader["idInstitucion"];
                    catCarrera.fechaCreacion     = (DateTime)reader["FechaCreacion"];
                    catCarrera.fechaModificacion = (DateTime)reader["FechaModificacion"];
                    catCarrera.lValid            = (bool)reader["lValido"];
                    catCarrera.cancelado         = (bool)reader["Cancelado"];
                    list.Add(catCarrera);
                }
            }
            catch (SqlException ex)
            {
                throw new Exception("SQl Error en obtener los datos de modelos" + ex.Message);
            }
            catch (Exception ex)
            {
                throw new Exception("Code Error en obtener los datos de modelos" + ex.Message);
            }

            ConexionSingleton.cerrarConexion();

            return(list);
        }
        public int InsertaUsuario(Prestador _Prestador)
        {
            int folio   = 0;
            var command = new SqlCommand("dbo.AltaUsuario", ConexionSingleton.abrirConexion());

            command.CommandType = System.Data.CommandType.StoredProcedure;

            command.Parameters.AddWithValue("@cNombre", _Prestador.Nombre);
            command.Parameters.AddWithValue("@cApellidoPaterno", _Prestador.ApellidoPat);
            command.Parameters.AddWithValue("@cApellidoMaterno", _Prestador.ApellidoMat);
            command.Parameters.AddWithValue("@cCelular", _Prestador.celular);
            command.Parameters.AddWithValue("@cEmail", _Prestador.eMail);
            command.Parameters.AddWithValue("@cDomicilio", _Prestador.domicilio);
            command.Parameters.AddWithValue("@cPassword", _Prestador.password);
            command.Parameters.AddWithValue("@iMatricula", _Prestador.Matricula);
            command.Parameters.AddWithValue("@nidInstitucion", 1);
            command.Parameters.AddWithValue("@nidCarrera", 1);
            command.Parameters.AddWithValue("@nidEstado", _Prestador.idEstado);
            command.Parameters.AddWithValue("@nidMunicipio", _Prestador.idMunicipio);

            try
            {
                folio = (int)command.ExecuteScalar();
            }
            catch (SqlException ex)
            {
                throw new Exception("SQl Error en obtener los datos de modelos" + ex.Message);
            }
            catch (Exception ex)
            {
                throw new Exception("Code Error AltaUsuario en obtener los datos de modelos   " + ex.Message);
            }

            ConexionSingleton.cerrarConexion();
            return(folio);
        }