Exemplo n.º 1
0
        private async void cargarCategorias()
        {
            loadState(true);
            try
            {
                // Cargando las categorias desde el webservice
                List <Categoria> categoriaList = await categoriaModel.categoriasTodo();

                Categoria lastCategori = categoriaList.Last();//raiz
                categoriaList.Remove(lastCategori);

                // Cargando
                treeViewCategoria.Nodes.Clear();                                                                // limpiando
                treeViewCategoria.Nodes.Add(lastCategori.idCategoria.ToString(), lastCategori.nombreCategoria); // Cargando categoria raiz

                treeViewCategoria.Nodes[0].Checked = true;
                List <TreeNode> listNode = new List <TreeNode>();
                itemNumber = 0;
                foreach (Categoria categoria in categoriaList)
                {
                    TreeNode aux = new TreeNode(categoria.nombreCategoria);
                    aux.Name = categoria.idCategoria.ToString();
                    listNode.Add(aux);
                }
                treeviewVista(categoriaList, treeViewCategoria.Nodes[0], listNode);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "Listar", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            loadState(false);
        }
 private async void cargarCategorias()
 {
     loadState(true);
     try
     {
         // Cargando las categorias desde el webservice
         categoriaBindingSource.DataSource = await categoriaModel.categoriasTodo();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error: " + ex.Message, "Listar Categorias", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     loadState(false);
 }
Exemplo n.º 3
0
        private async void cargarCategorias()
        {
            loadState(true);
            try
            {
                // Cargando las categorias desde el webservice
                List <Categoria> categoriaList = await categoriaModel.categoriasTodo();

                Categoria lastCategori = categoriaList.Last();//raiz
                categoriaList.Remove(lastCategori);

                // Cargando
                treeViewCategoria.Nodes.Clear();                                                                // limpiando
                treeViewCategoria.Nodes.Add(lastCategori.idCategoria.ToString(), lastCategori.nombreCategoria); // Cargando categoria raiz


                List <TreeNode> listNode = new List <TreeNode>();

                foreach (Categoria categoria in categoriaList)
                {
                    TreeNode aux = new TreeNode(categoria.nombreCategoria);
                    aux.Name = categoria.idCategoria.ToString();
                    listNode.Add(aux);
                }
                treeviewVista(categoriaList, treeViewCategoria.Nodes[0], listNode);


                // Estableciendo valores por defecto

                /* if (ConfigModel.currentProductoCategory.Count > 0)
                 * {
                 *   recuperarCatSeleccionado();
                 * }
                 * else
                 * {
                 *   treeViewCategoria.Nodes[0].ExpandAll();
                 * }
                 * treeViewCategoria.Nodes[0].Checked = true;*/
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "Listar", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            loadState(false);
        }