Ejemplo n.º 1
0
        public IActionResult Pesquisar(string produto, string tipo)
        {
            CamadaNegocio.ProdIndustCamadaNegocio pcn = new CamadaNegocio.ProdIndustCamadaNegocio();
            var id_indust = Convert.ToInt32(HttpContext.User.Claims.ToList()[3].Value);

            List <Models.ProdutoIndust> prodindust = pcn.Pesquisar(produto, id_indust, tipo);

            //objeto anônimo
            var produtosLimpos = new List <object>();

            if (prodindust != null)
            {
                foreach (var p in prodindust)
                {
                    var produtoLimpo = new
                    {
                        id        = p.Id,
                        cod_ref   = p.Cod_ref,
                        descricao = p.Descricao,
                    };

                    produtosLimpos.Add(produtoLimpo);
                }
            }

            return(Json(new {
                operacao = prodindust != null,
                produtosLimpos
            }));
        }
Ejemplo n.º 2
0
 public IActionResult ObterEditar(int id)
 {
     CamadaNegocio.ProdIndustCamadaNegocio pcn = new CamadaNegocio.ProdIndustCamadaNegocio();
     Models.ProdutoIndust prodindust           = pcn.Obter(id);
     return(Json(new
     {
         prodindust
     }));
 }
Ejemplo n.º 3
0
        public IActionResult Excluir(int id)
        {
            CamadaNegocio.ProdIndustCamadaNegocio pcn = new CamadaNegocio.ProdIndustCamadaNegocio();
            bool operacao = pcn.Excluir(id);

            return(Json(new
            {
                operacao
            }));
        }
        public IActionResult ObterProd([FromBody] Dictionary <string, string> dados)
        {
            CamadaNegocio.ProdIndustCamadaNegocio pcn = new CamadaNegocio.ProdIndustCamadaNegocio();
            string cod_ref = dados["cod_ref"];

            Models.ProdutoIndust prodemp = pcn.ObterProd(cod_ref);
            return(Json(new
            {
                prodemp
            }));
        }
        public IActionResult ObterProdDist([FromBody] Dictionary <string, string> dados)
        {
            CamadaNegocio.ProdIndustCamadaNegocio pcn = new CamadaNegocio.ProdIndustCamadaNegocio();
            string codigo = dados["codigo"];
            bool   operacao;
            string cod_ref, descricao;

            (operacao, cod_ref, descricao) = pcn.ObterProdDist(codigo);
            return(Json(new
            {
                operacao,
                cod_ref,
                descricao
            }));
        }
Ejemplo n.º 6
0
        public IActionResult Criar([FromBody] Dictionary <string, string> dados, int id)
        {
            bool operacao;

            Models.ProdutoIndust prodindust = new Models.ProdutoIndust();
            prodindust.Id        = id;
            prodindust.Cod_ref   = dados["cod_ref"];
            prodindust.Descricao = dados["descricao"];
            prodindust.Id_indust = Convert.ToInt32(HttpContext.User.Claims.ToList()[3].Value);

            CamadaNegocio.ProdIndustCamadaNegocio pcn = new CamadaNegocio.ProdIndustCamadaNegocio();
            operacao = pcn.Criar(prodindust);

            return(Json(new
            {
                operacao
            }));
        }
Ejemplo n.º 7
0
        private (bool, string, int, string) ProcessImport(XmlDocument xmlDoc)
        {
            CamadaNegocio.ProdIndustCamadaNegocio picn = new CamadaNegocio.ProdIndustCamadaNegocio();
            List <Models.ProdutoIndust>           pi   = new List <Models.ProdutoIndust>();

            CamadaNegocio.NotaCamadaNegocio ncn = new CamadaNegocio.NotaCamadaNegocio();
            Models.NotaFiscal notamodelo        = new Models.NotaFiscal();

            CamadaNegocio.ItemNotaCamadaNegocio incn = new CamadaNegocio.ItemNotaCamadaNegocio();
            Models.ItemNota itemnota;

            //dados para rastreamento
            List <int>    rastroCod  = new List <int>();
            List <string> rastroLote = new List <string>();

            XmlNodeList xnList, xnList2;

            bool operacao, entrou;

            entrou = operacao = false;
            string msg      = "Produtos sem Cadastro - Códigos: ";
            string cnpjdist = "";

            xnList          = xmlDoc.GetElementsByTagName("prod");
            notamodelo.Tipo = HttpContext.User.Claims.ToList()[1].Value;
            for (int i = 0; i < xnList.Count; i++)
            {
                string id_prod = xnList[i]["cProd"].InnerText;

                pi.Add(picn.ObterProd(id_prod));
                if (pi[i] == null)
                {
                    entrou = true;
                    msg   += id_prod + ", ";
                }
            }
            msg  = msg.Remove(msg.Length - 2);
            msg += ".";

            //todos produtos cadastrados
            if (!entrou)
            {
                //dados nota fiscal
                notamodelo.Cod_indust = Convert.ToInt32(HttpContext.User.Claims.ToList()[3].Value);

                xnList           = xmlDoc.GetElementsByTagName("infProt");
                notamodelo.Chave = xnList[0]["chNFe"].InnerText;

                xnList            = xmlDoc.GetElementsByTagName("ide");
                notamodelo.Serie  = Convert.ToInt32(xnList[0]["serie"].InnerText);
                notamodelo.Numero = Convert.ToInt32(xnList[0]["nNF"].InnerText);
                notamodelo.Data   = Convert.ToDateTime(xnList[0]["dhEmi"].InnerText);

                xnList = xmlDoc.GetElementsByTagName("fat");
                notamodelo.Valor_nf = GetDouble(xnList[0]["vLiq"].InnerText, 0d);

                operacao = ncn.Criar(notamodelo);

                if (operacao)
                {
                    xnList  = xmlDoc.GetElementsByTagName("prod");
                    xnList2 = xmlDoc.GetElementsByTagName("rastro");

                    for (int i = 0; i < xnList.Count; i++)
                    {
                        itemnota         = new Models.ItemNota();
                        itemnota.Id_nota = notamodelo.Id;
                        itemnota.Id_prod = pi[i].Id;
                        itemnota.Lote    = xnList2[i]["nLote"].InnerText;
                        string qtdeaux = xnList[i]["qTrib"].InnerText;
                        string qtde    = "";
                        for (int j = 0; qtdeaux[j] != '.'; j++)
                        {
                            qtde += qtdeaux[j];
                        }

                        itemnota.Qtde = Convert.ToInt32(qtde);

                        itemnota.Valor_unit = GetDouble(xnList[i]["vUnTrib"].InnerText, 0d);

                        rastroCod.Add(itemnota.Id_prod);
                        rastroLote.Add(itemnota.Lote);
                        operacao = incn.Criar(itemnota);
                    }
                }
                else
                {
                    return(operacao, "Problemas com os dados da Nota Fiscal!", notamodelo.Id, cnpjdist);
                }
            }
            if (!entrou)
            {
                xnList   = xmlDoc.GetElementsByTagName("dest");
                cnpjdist = xnList[0]["CNPJ"].InnerText;

                //salvar o rastreio
                CamadaNegocio.RastroCamadaNegocio rcn = new CamadaNegocio.RastroCamadaNegocio();
                rcn.Criar(rastroCod, rastroLote, cnpjdist, notamodelo.Cod_indust);

                return(operacao, "Dados Importados!", notamodelo.Id, cnpjdist);
            }
            else
            {
                return(false, msg, 0, cnpjdist);
            }
        }