コード例 #1
0
    public void CargarCombo(String opcion)
    {
        EmpresaBL oEmpresaBL = new EmpresaBL();

        EmpresaBEList lista = new EmpresaBEList();

        lista = oEmpresaBL.GetListaEmpresa();

        cboEmpresa.DataSource     = lista;
        cboEmpresa.DataValueField = "nid_empresa";
        cboEmpresa.DataTextField  = "no_empresa";
        cboEmpresa.DataBind();

        if (!opcion.Equals(String.Empty))
        {
            if (opcion.Equals(ConstanteBE.OBJECTO_TIPO_TODOS))
            {
                this.cboEmpresa.Items.Insert(0, new ListItem(ConstanteBE.OBJECTO_TODOS, String.Empty));
            }
            else
            if (opcion.Equals(ConstanteBE.OBJECTO_TIPO_SELECCIONE))
            {
                this.cboEmpresa.Items.Insert(0, new ListItem(ConstanteBE.OBJECTO_SELECCIONE, String.Empty));
            }
        }
        this.cboEmpresa.SelectedValue = String.Empty;
    }
コード例 #2
0
        public EmpresaBEList GetListaEmpresa()
        {
            EmpresaBEList lista = new EmpresaBEList();

            IDataReader DReader = null;

            try
            {
                using (Database db = new Database())
                {
                    db.ProcedureName = "sgsnet_sps_listado_empresa";
                    DReader          = db.GetDataReader();
                }
                while (DReader.Read())
                {
                    lista.Add(CrearEntidadLista(DReader));
                }
                DReader.Close();
            }
            catch
            {
                if (DReader != null && !DReader.IsClosed)
                {
                    DReader.Close();
                }
                throw;
            }
            return(lista);
        }