コード例 #1
0
        public void cargarCategoria()
        {
            try
            {
                var dt   = new DataTable();
                var rows = objCat.Consultar();

                ddlCategoria.DataTextField  = "Nombre";
                ddlCategoria.DataValueField = "idCategoria";
                dt.Columns.Add("idCategoria", typeof(System.String));
                dt.Columns.Add("Nombre", typeof(System.String));

                foreach (CAT_CATEGORIA r in rows)
                {
                    DataRow fila = dt.NewRow();

                    fila["idCategoria"] = r.idCategoria;
                    fila["Nombre"]      = r.Nombre;
                    dt.Rows.Add(fila);
                }
                ddlCategoria.DataSource = dt;
                ddlCategoria.DataBind();
            }
            catch (Exception ex)
            {
                var err = ex.Message;
            }
        }
コード例 #2
0
        public void CargarTablaCategoria()
        {
            try
            {
                var dt   = new DataTable();
                var rows = objCat.Consultar();

                dt.Columns.Add("idCategoria", typeof(System.String));
                dt.Columns.Add("Nombre", typeof(System.String));
                //dt.Columns.Add("Codigo", typeof(System.String));

                foreach (CAT_CATEGORIA r in rows)
                {
                    DataRow fila = dt.NewRow();

                    fila["idCategoria"] = r.idCategoria;
                    fila["Nombre"]      = r.Nombre;
                    //fila["Codigo"] = r.Codigo;
                    dt.Rows.Add(fila);
                }
                gvwCategoria.DataSource = dt;
                gvwCategoria.DataBind();
            }
            catch (Exception ex)
            {
                var err = ex.Message;
            }
        }
コード例 #3
0
        public IHttpActionResult Get(int id)
        {
            CategoriaResponse cResponse = new CategoriaResponse();

            cResponse.Categorias = new List <CategoriaTO>();
            try
            {
                Categoria categoria = Categoria.Consultar(id);

                CategoriaTO cTO = new CategoriaTO();
                cTO.Id   = categoria.Id;
                cTO.Nome = categoria.Nome;
                cResponse.Categorias.Add(cTO);
            }
            catch (Exception ex)
            {
                cResponse.Status    = -1;
                cResponse.Descricao = ex.Message;
            }
            return(Ok(cResponse));
        }
コード例 #4
0
        // GET: api/Categoria/5
        public IHttpActionResult Get(int id)
        {
            CategoriaResponse cResponse = new CategoriaResponse();

            try
            {
                Categoria c = Categoria.Consultar(id);
                cResponse.Categoria      = new CategoriaTO();
                cResponse.Categoria.Id   = c.Id;
                cResponse.Categoria.Nome = c.Nome;
            }
            catch (NegociosExceptions nex)
            {
                cResponse.Status   = (int)nex.Codigo;
                cResponse.Detalhes = nex.Message;
            }
            catch (Exception ex)
            {
                cResponse.Status   = -1;
                cResponse.Detalhes = ex.Message;
            }
            return(Ok(cResponse));
        }