Ejemplo n.º 1
0
 private static ActivityListing GenerateListing(StdBELista queryResult)
 {
     return(new ActivityListing
     {
         Tipo = TypeReference(queryResult),
         DataFim = TypeParser.Date(queryResult.Valor("DataFim")),
         Resumo = TypeParser.String(queryResult.Valor("Resumo")),
         Estado = TypeParser.Integer(queryResult.Valor("Estado")),
         Identificador = TypeParser.String(queryResult.Valor("Id")),
         DataInicio = TypeParser.Date(queryResult.Valor("DataInicio")),
         Prioridade = TypeParser.Integer(queryResult.Valor("Prioridade")),
         DataModificacao = TypeParser.Date(queryResult.Valor("DataUltAct"))
     });
 }
Ejemplo n.º 2
0
        public static List <CategoryListing> List()
        {
            if (PrimaveraEngine.InitializeCompany() == false)
            {
                throw new DatabaseConnectionException();
            }

            var categoryList = new List <CategoryListing>();
            var categoryInfo = PrimaveraEngine.Consulta(new SqlBuilder()
                                                        .FromTable("FAMILIAS")
                                                        .Columns(sqlColumnsFull)
                                                        .InnerJoin("ARTIGO", "Familia", Comparison.Equals, "FAMILIAS", "Familia")
                                                        .GroupBy(new string[] { "FAMILIAS.Familia", "FAMILIAS.Descricao" }));

            if (categoryInfo == null || categoryInfo.Vazia())
            {
                return(categoryList);
            }

            while (!categoryInfo.NoFim())
            {
                categoryList.Add(new CategoryListing()
                {
                    Identificador  = TypeParser.String(categoryInfo.Valor("Familia")),
                    Descricao      = TypeParser.String(categoryInfo.Valor("Descricao")),
                    NumeroProdutos = TypeParser.Integer(categoryInfo.Valor("Count"))
                });

                categoryInfo.Seguinte();
            }

            categoryList.Sort(delegate(CategoryListing lhs, CategoryListing rhs)
            {
                if (lhs.Identificador == null || rhs.Identificador == null)
                {
                    return(-1);
                }

                return(lhs.Descricao.CompareTo(rhs.Descricao));
            });

            return(categoryList);
        }
Ejemplo n.º 3
0
        public static List<QuoteListing> List()
        {
            if (PrimaveraEngine.InitializeCompany() == false)
            {
                throw new DatabaseConnectionException();
            }

            var query = new SqlBuilder()
                .FromTable("CabecDoc")
                .Columns(sqlQuoteListing)
                .Where("TipoDoc", Comparison.Equals, "ECL")
                .Where("Serie", Comparison.Equals, QuotesConstants.serie);
            query.AddOrderBy("NumDoc", Sorting.Descending);

            var queryObject = PrimaveraEngine.Consulta(query);

            if (queryObject == null || queryObject.Vazia())
            {
                return null;
            }

            var queryResult = new List<QuoteListing>();

            while (!queryObject.NoFim())
            {
                queryResult.Add(new QuoteListing
                {
                    NumEncomenda = TypeParser.Integer(queryObject.Valor("NumDoc")),
                    Cliente = TypeParser.String(queryObject.Valor("Entidade")),
                    NomeCliente = TypeParser.String(queryObject.Valor("Nome")),
                    TotalDocumento = TypeParser.Double(queryObject.Valor("TotalDocumento")),
                    Data = TypeParser.Date(queryObject.Valor("Data"))
                });

                queryObject.Seguinte();
            }

            return queryResult;
        }
Ejemplo n.º 4
0
        public static QuoteInfo View(string sessionId, string quoteId)
        {
            if (PrimaveraEngine.InitializeCompany() == false)
            {
                throw new DatabaseConnectionException();
            }

            var quoteInfo = PrimaveraEngine.Consulta(new SqlBuilder()
                .FromTable("CabecDoc")
                .Columns(sqlQuoteColumns)
                .Where("TipoDoc", Comparison.Equals, QuotesConstants.tipoDoc)
                .Where("NumDoc", Comparison.Equals, quoteId)
                .Where("Serie", Comparison.Equals, QuotesConstants.serie));

            if (quoteInfo == null || quoteInfo.Vazia())
            {
                throw new NotFoundException("encomenda", true);
            }

            if (TypeParser.String(quoteInfo.Valor("Responsavel")) != sessionId)
            {
                return null;
            }

            List<OrderInfo> quoteProducts = new List<OrderInfo>();

            var productsInfo = PrimaveraEngine.Consulta(new SqlBuilder()
                .FromTable("LinhasDoc")
                .Columns(sqlProductsColumns)
                .Where("IdCabecDoc", Comparison.Equals, quoteInfo.Valor("Id")));

            while (!productsInfo.NoFim())
            {
                quoteProducts.Add(new OrderInfo
                {
                    Quantidade = TypeParser.Integer(productsInfo.Valor("Quantidade")),
                    Preco = TypeParser.Double(productsInfo.Valor("PrecUnit")),
                    Desconto = TypeParser.Double(productsInfo.Valor("Desconto1")),
                    Iva = TypeParser.Double(productsInfo.Valor("TaxaIva")),
                    Unidade = TypeParser.String(productsInfo.Valor("Unidade")),
                    Produto = new Reference(TypeParser.String(productsInfo.Valor("Artigo")),
                    TypeParser.String(productsInfo.Valor("Descricao")))
                });

                productsInfo.Seguinte();
            }

            return new QuoteInfo
            {
                NumEncomenda = TypeParser.Integer(quoteInfo.Valor("NumDoc")),
                Cliente = TypeParser.String(quoteInfo.Valor("Entidade")),
                NomeCliente = TypeParser.String(quoteInfo.Valor("Nome")),
                EnderecoEntrega = new Address
                {
                    Morada = TypeParser.String(quoteInfo.Valor("Morada")),
                    CodigoPostal = TypeParser.String(quoteInfo.Valor("CodPostal")),
                    Localidade = TypeParser.String(quoteInfo.Valor("Localidade")),
                    Distrito = LocationIntegration.DistritoReference(TypeParser.String(quoteInfo.Valor("Distrito"))),
                    Pais = TypeParser.String(quoteInfo.Valor("Pais"))
                },
                Data = TypeParser.Date(quoteInfo.Valor("Data")),
                IdOportunidade = TypeParser.String(quoteInfo.Valor("IdOportunidade")),
                TotalDesc = TypeParser.Double(quoteInfo.Valor("TotalDesc")),
                TotalIva = TypeParser.Double(quoteInfo.Valor("TotalIva")),
                TotalMerc = TypeParser.Double(quoteInfo.Valor("TotalMerc")),
                TotalDocumento = TypeParser.Double(quoteInfo.Valor("TotalDocumento")),
                NumContribuinte = TypeParser.String(quoteInfo.Valor("NumContribuinte")),
                Produtos = quoteProducts
            };
        }