Esempio n. 1
0
        public Categoria ObtenerCategorias(Int32 IdCategoria)
        {
            Categoria obj = null;

            SqlConnection cnn = new SqlConnection(DalConexion.ObtenerConexion());

            cnn.Open();

            SqlCommand objComm = new SqlCommand("sp_ObtenerCategoriaPorId", cnn);

            objComm.CommandType = CommandType.StoredProcedure;

            SqlParameter pEstado = new SqlParameter("@IdCategoria", IdCategoria);

            objComm.Parameters.Add(pEstado);

            SqlDataReader dr = objComm.ExecuteReader();


            if (dr.Read())
            {
                obj             = new Categoria();
                obj.IdCategoria = Convert.ToInt32(dr["IdCategoria"]);
                obj.Codigo      = (dr["Codigo"]).ToString();
                obj.Descripcion = (dr["Descripcion"]).ToString();
                obj.Estado      = Convert.ToBoolean(dr["Estado"]);
            }
            cnn.Close();
            return(obj);
        }
Esempio n. 2
0
        public List <Categoria> LIstarCategorias(Boolean?Estado)
        {
            List <Categoria> lista = new List <Categoria>();

            SqlConnection cnn = new SqlConnection(DalConexion.ObtenerConexion());

            cnn.Open();

            SqlCommand objComm = new SqlCommand("sp_ObtenerListadoCategoriaPorEstado", cnn);

            objComm.CommandType = CommandType.StoredProcedure;

            SqlParameter pEstado = new SqlParameter("@Estado", Estado);

            objComm.Parameters.Add(pEstado);

            SqlDataReader dr = objComm.ExecuteReader();


            while (dr.Read())
            {
                Categoria obj = new Categoria();
                obj.IdCategoria = Convert.ToInt32(dr["IdCategoria"]);
                obj.Codigo      = (dr["Codigo"]).ToString();
                obj.Descripcion = (dr["Descripcion"]).ToString();
                obj.Estado      = Convert.ToBoolean(dr["Estado"]);


                lista.Add(obj);
            }
            cnn.Close();
            return(lista);
        }
Esempio n. 3
0
        public List <BeCurso> ObtenerListadoCursoPorEstado(Boolean?Estado)
        {
            List <BeCurso> listado = new List <BeCurso>();
            DatabaseHelper helper  = null;
            SqlDataReader  reader  = null;

            try
            {
                helper = new DatabaseHelper(DalConexion.getConexion());
                helper.AddParameter("@P_ESTADO", Estado);
                reader = (SqlDataReader)helper.ExecuteReader("spr_ObtenerListadoCursoPorEstado", System.Data.CommandType.StoredProcedure);
                while (reader.Read())
                {
                    BeCurso obj = new BeCurso();
                    obj.id          = Validacion.DBToInt32(ref reader, "id");
                    obj.descripcion = Validacion.DBToString(ref reader, "descripcion");
                    obj.image       = Validacion.DBToString(ref reader, "image");
                    obj.estado      = Validacion.DBToBoolean(ref reader, "estado");
                    listado.Add(obj);
                }
            }
            catch (Exception ex)
            {
                clsException localException = new clsException(ex, "DalCurso -> ObtenerListadoCursoPorEstado()");
            }
            finally
            {
                if (helper != null)
                {
                    helper.Dispose();
                }
            }
            return(listado);
        }
        public List <BePregunta> ObtenerListadoPreguntaPorCurMat(Int32 cursoid, Int32 materialid)
        {
            List <BePregunta> listado = new List <BePregunta>();
            DatabaseHelper    helper  = null;
            SqlDataReader     reader  = null;

            try
            {
                helper = new DatabaseHelper(DalConexion.getConexion());
                helper.AddParameter("@P_CURSOID", cursoid);
                helper.AddParameter("@P_MATERIALID", materialid);
                reader = (SqlDataReader)helper.ExecuteReader("spr_ObtenerListadoPreguntaPorCurMat", System.Data.CommandType.StoredProcedure);
                while (reader.Read())
                {
                    BePregunta obj = new BePregunta();
                    obj.id          = Validacion.DBToInt32(ref reader, "preguntaid");
                    obj.descripcion = Validacion.DBToString(ref reader, "desc_pregunta");
                    listado.Add(obj);
                }
            }
            catch (Exception ex)
            {
                clsException localException = new clsException(ex, "DalPregunta -> ObtenerListadoPreguntaPorCurMat()");
            }
            finally
            {
                if (helper != null)
                {
                    helper.Dispose();
                }
            }
            return(listado);
        }
Esempio n. 5
0
        public List <BeRespuesta> ObtenerRespuestasByPregunta(Int32 preguntaid)
        {
            List <BeRespuesta> listado = new List <BeRespuesta>();
            DatabaseHelper     helper  = null;
            SqlDataReader      reader  = null;

            try
            {
                helper = new DatabaseHelper(DalConexion.getConexion());
                helper.AddParameter("@P_PREGUNTAID", preguntaid);
                reader = (SqlDataReader)helper.ExecuteReader("spr_ObtenerRespuestasByPregunta", System.Data.CommandType.StoredProcedure);
                while (reader.Read())
                {
                    BeRespuesta obj = new BeRespuesta();
                    obj.id          = Validacion.DBToInt32(ref reader, "id_respuesta");
                    obj.descripcion = Validacion.DBToString(ref reader, "desc_respuesta");
                    listado.Add(obj);
                }
            }
            catch (Exception ex)
            {
                clsException localException = new clsException(ex, "DalRespuesta -> ObtenerRespuestasByPregunta()");
            }
            finally
            {
                if (helper != null)
                {
                    helper.Dispose();
                }
            }
            return(listado);
        }
        public BeCursoMaterial ObtenerListadoMaterialPorCurso(Int32 cursoid)
        {
            BeCursoMaterial obj = new BeCursoMaterial();

            obj.lstMaterial = new List <BeMaterial>();
            DatabaseHelper helper = null;
            SqlDataReader  reader = null;

            try
            {
                helper = new DatabaseHelper(DalConexion.getConexion());
                helper.AddParameter("@P_CURSOID", cursoid);
                reader = (SqlDataReader)helper.ExecuteReader("spr_ObtenerListadoMaterialPorCurso", System.Data.CommandType.StoredProcedure);
                while (reader.Read())
                {
                    BeCurso objCurso = new BeCurso();
                    objCurso.id          = Validacion.DBToInt32(ref reader, "cursoid");
                    objCurso.descripcion = Validacion.DBToString(ref reader, "desc_curso");

                    BeMaterial objMaterial = new BeMaterial();
                    objMaterial.id          = Validacion.DBToInt32(ref reader, "materialid");
                    objMaterial.descripcion = Validacion.DBToString(ref reader, "desc_material");
                    objMaterial.curso       = new BeCurso()
                    {
                        id = Validacion.DBToInt32(ref reader, "cursoid")
                    };

                    obj.curso = objCurso;
                    obj.lstMaterial.Add(objMaterial);
                }
            }
            catch (Exception ex)
            {
                clsException localException = new clsException(ex, "DalCursoMaterial -> ObtenerListadoMaterialPorCurso()");
            }
            finally
            {
                if (helper != null)
                {
                    helper.Dispose();
                }
            }
            return(obj);
        }
Esempio n. 7
0
        public Boolean InsertarCategoria(Categoria obj)
        {
            Boolean       exito = false;
            SqlConnection cnn   = new SqlConnection(DalConexion.ObtenerConexion());

            cnn.Open();


            SqlCommand objComm = new SqlCommand("sp_insertarCategoria", cnn);

            objComm.CommandType = CommandType.StoredProcedure;

            SqlParameter pCodigo      = new SqlParameter("@Codigo", obj.Codigo);
            SqlParameter pDescripcion = new SqlParameter("@Descripcion", obj.Descripcion);

            objComm.Parameters.Add(pCodigo);
            objComm.Parameters.Add(pDescripcion);

            exito = Convert.ToBoolean(objComm.ExecuteNonQuery());


            return(exito);
        }