BLL.Asignaturas.Buscar C# (CSharp) Method

Buscar() public method

public Buscar ( int prmIdAsignatura ) : bool
prmIdAsignatura int
return bool
        public bool Buscar(int prmIdAsignatura)
        {
            DataTable Datos = new DataTable();
            bool Retorno = false;

            Datos = Conexion.BuscarDb("Select * from Asignaturas where IdAsignatura= " + prmIdAsignatura);

            if (Datos.Rows.Count > 0)
            {
                Retorno = true;

                this.Codigo = (string)Datos.Rows[0]["Codigo"];
                this.Nombre = (string)Datos.Rows[0]["Nombre"];
                this.Creditos = (int)Datos.Rows[0]["Creditos"];
                this.Activo = (bool)Datos.Rows[0]["Activo"];
            }
            return Retorno;
        }

Usage Example

        protected void Page_Load(object sender, EventArgs e)
        {
            asignaturas = new Asignaturas();//todo: oojo
            if (!IsPostBack)
            {
                int id = 0;
                int.TryParse(Request.QueryString["Codigo"], out id);

                if (asignaturas.Buscar(id))
                {
                    Buscar();

                }

                if (CodigoTextBox.Text == string.Empty)
                {
                    EliminarButton.Enabled = false;

                }
                else
                {
                    EliminarButton.Enabled = true;

                }

                ProfesoresDropDownList.DataSource = BLL.Profesores.Listar("IdProfesor, Nombres+' '+Apellidos as NombreCompleto", "1=1");
                ProfesoresDropDownList.DataValueField = "IdProfesor";
                ProfesoresDropDownList.DataTextField = "NombreCompleto";
                ProfesoresDropDownList.DataBind();
            }

        }