Exemplo n.º 1
0
        public static Model.Categoria GetSubCategoria(string idCategoria, string idSubCategoria)
        {
            StdBELista objList;

            if (PriEngine.InitializeCompany(SINF.Properties.Settings.Default.Company.Trim(), SINF.Properties.Settings.Default.User.Trim(), SINF.Properties.Settings.Default.Password.Trim()) == true)
            {

                //objList = PriEngine.Engine.Comercial.Clientes.LstClientes();

                objList = PriEngine.Engine.Consulta("SELECT SubFamilia, Descricao FROM SubFamilias WHERE SubFamilia = '" + idSubCategoria + "' AND Familia = '" + idCategoria + "'");

                if (objList.NoFim())
                {
                    return null;
                }
                else
                {
                    Model.Categoria categoria = new Model.Categoria
                    {
                        CodCategoria = objList.Valor("SubFamilia"),
                        DescCategoria = objList.Valor("Descricao")
                    };

                    return categoria;
                }

            }
            else
                return null;
        }
Exemplo n.º 2
0
        public static List<Model.Categoria> ListaCategorias()
        {
            StdBELista objList;

            List<Model.Categoria> listCategorias = new List<Model.Categoria>();

            if (PriEngine.InitializeCompany(SINF.Properties.Settings.Default.Company.Trim(), SINF.Properties.Settings.Default.User.Trim(), SINF.Properties.Settings.Default.Password.Trim()) == true)
            {

                //objList = PriEngine.Engine.Comercial.Clientes.LstClientes();

                objList = PriEngine.Engine.Consulta("SELECT Familia, Descricao FROM Familias");

                while (!objList.NoFim())
                {

                    StdBELista objList2 = PriEngine.Engine.Consulta("SELECT SubFamilia, Descricao FROM SubFamilias WHERE Familia = '" + objList.Valor("Familia") + "'");

                    if (objList2.NoFim())
                    {
                        listCategorias.Add(new Model.Categoria
                        {
                            CodCategoria = objList.Valor("Familia"),
                            DescCategoria = objList.Valor("Descricao")
                        });
                    }
                    else
                    {
                        List<Model.Categoria> subs = new List<Model.Categoria>();

                        while (!objList2.NoFim())
                        {
                            Model.Categoria categoria = new Model.Categoria
                            {
                                CodCategoria = objList2.Valor("SubFamilia"),
                                DescCategoria = objList2.Valor("Descricao")
                            };
                            subs.Add(categoria);
                            objList2.Seguinte();
                        }

                        listCategorias.Add(new Model.Categoria
                        {
                            CodCategoria = objList.Valor("Familia"),
                            DescCategoria = objList.Valor("Descricao"),
                            SubCategorias = subs
                        });

                    }

                    objList.Seguinte();

                }

                return listCategorias;
            }
            else
                return null;
        }
Exemplo n.º 3
0
        public static Model.Categoria GetCategoria(string cod)
        {
            StdBELista objList;

            if (PriEngine.InitializeCompany(SINF.Properties.Settings.Default.Company.Trim(), SINF.Properties.Settings.Default.User.Trim(), SINF.Properties.Settings.Default.Password.Trim()) == true)
            {

                //objList = PriEngine.Engine.Comercial.Clientes.LstClientes();

                objList = PriEngine.Engine.Consulta("SELECT Familia, Descricao FROM Familias WHERE Familia = '" + cod + "'");
                if (!objList.NoFim())
                {
                    Model.Categoria categoria = new Model.Categoria
                    {
                        CodCategoria = objList.Valor("Familia"),
                        DescCategoria = objList.Valor("Descricao")
                    };
                    objList.Seguinte();

                    return categoria;
                }
                return null;

            }
            else
                return null;
        }