Example #1
0
        private void lerXML(String caminho)
        {
            xml1 = new LeituraXML(caminho);
            SIME.Class.NFe.nota_entrada nota;
            Boolean chaveCadastrada = false;

            //Processo de identificação e gravação da NFe
            try
            {
                nota            = new Class.NFe.nota_entrada(xml1.getChave());
                chaveCadastrada = true;
            }
            catch (Exception)
            {
                nota = new Class.NFe.nota_entrada(xml1.getProdutosNfe().Count());
                nota.setChave(xml1.getChave());
                nota.setLocal(caminho);
                nota.setDataEmissao(Convert.ToDateTime(xml1.getNota().getData()));
                nota.salvar();
            }

            LabChave.Text    = nota.getChave();//Armazena a chave da NF-e
            listaProdutosNFE = xml1.getProdutosNfe();
            ListNfe.Items.Clear();

            String CNPJ = xml1.getFornecedor().getCNPJ();

            ataulizaLista(nota, chaveCadastrada, listaProdutosNFE);//Verifica se já há registros de vinculo com a Tabela de Notas de entrada

            ListBuscaR1.Items.Clear();
            LabForncedor.Text = xml1.getFornecedor().getFantasia() + " - " + xml1.getFornecedor().getNome();

            if (chaveCadastrada)
            {
                imgOk.ImageUrl             = "~/imagens/ok_16x16.gif";
                upbuscaFornecedor1.Visible = false;
                LabForncedor.Text         += "</br> <font Color='RED'> NOTA JÁ CADASTRADA OU INICIADO O CADASTRO. </font>";
            }
            else
            {
                imgOk.ImageUrl             = "~/imagens/delete_16x16.gif";
                upbuscaFornecedor1.Visible = true;
                new Fornecedores().MontaListaFornecedores(CombForncedores1);
            }

            FormaPagamento formas = xml1.getFormasPagamento();


            List <String[]> lista = new List <String[]>();

            for (int i = 0; i < formas.getNumeroParcelas(); i++)
            {
                lista.Add(new String[] { (i + 1) + "ª", formas.getDtVencimento(i).ToString(), " Valor: " + formas.getValorParcela(i).ToString("N") });
            }

            UteisWeb util = new UteisWeb();

            LabForncedor0.Text = util.montaTab(lista, "N° de parcelas: " + formas.getNumeroParcelas(), System.Drawing.Color.LightBlue);
            LabForncedor1.Text = "N° da NF: " + xml1.getNota().getNumeroNF().ToString() + " Data da NF: " + xml1.getNota().getData().ToString();
        }
Example #2
0
        /// <summary>
        /// Busca XML da NFe passada para imprimir o DANFE
        /// </summary>
        /// <param name="idNFe"></param>
        /// <returns></returns>
        internal ProdutosNFe[] GetForDanfe(HttpContext context, string chaveAcesso)
        {
            List <ProdutosNFe> lstProdNFe = new List <ProdutosNFe>();

            // Verifica se NFe existe
            if (!File.Exists(Utils.GetNfeXmlPathInternal(context) + chaveAcesso + "-nfe.xml"))
            {
                throw new Exception("Arquivo da NF-e não encontrado.");
            }

            // Busca arquivo XML da NFe
            XmlDocument xmlNFe = new XmlDocument();

            xmlNFe.Load(Utils.GetNfeXmlPathInternal(context) + chaveAcesso + "-nfe.xml");

            #region Busca produtos da NF-e contidos no XML

            // Busca tags com produtos
            XmlNodeList xmlListProdsNFe = NFeDAO.Instance.GetXmlInfNFe(context, xmlNFe).GetElementsByTagName("det");

            foreach (XmlElement xmlProd in xmlListProdsNFe)
            {
                ProdutosNFe prod = new ProdutosNFe();
                prod.Codigo    = GetNodeValue(xmlProd, "prod", "cProd");
                prod.Descricao = Formatacoes.RestauraStringDocFiscal(GetNodeValue(xmlProd, "prod", "xProd"));
                prod.NcmSh     = GetNodeValue(xmlProd, "prod", "NCM");
                prod.Cfop      = GetNodeValue(xmlProd, "prod", "CFOP");
                prod.Unidade   = Formatacoes.RestauraStringDocFiscal(GetNodeValue(xmlProd, "prod", "uCom"));
                prod.Qtd       = Formatacoes.FormataValorDecimal(GetNodeValue(xmlProd, "prod", "qCom"), 4);
                prod.VlrUnit   = Formatacoes.FormataValorDecimal(GetNodeValue(xmlProd, "prod", "vUnCom"), 2);
                prod.VlrTotal  = Formatacoes.FormataValorDecimal(GetNodeValue(xmlProd, "prod", "vProd"), 2);
                prod.Cst       = GetICMSNodeValue(xmlProd, "imposto/ICMS", "orig") + GetICMSNodeValue(xmlProd, "imposto/ICMS", "CST");
                prod.Csosn     = GetICMSNodeValue(xmlProd, "imposto/ICMS", "orig") + GetICMSNodeValue(xmlProd, "imposto/ICMS", "CSOSN");
                prod.BcIcms    = Formatacoes.FormataValorDecimal(GetICMSNodeValue(xmlProd, "imposto/ICMS", "vBC"), 2);
                prod.AliqIcms  = Formatacoes.FormataValorDecimal(GetICMSNodeValue(xmlProd, "imposto/ICMS", "pICMS"), 2);
                prod.VlrIcms   = Formatacoes.FormataValorDecimal(GetICMSNodeValue(xmlProd, "imposto/ICMS", "vICMS"), 2);
                prod.BcIcmsSt  = Formatacoes.FormataValorDecimal(GetICMSNodeValue(xmlProd, "imposto/ICMS", "vBCST"), 2);
                prod.VlrIcmsSt = Formatacoes.FormataValorDecimal(GetICMSNodeValue(xmlProd, "imposto/ICMS", "vICMSST"), 2);
                prod.AliqIpi   = Formatacoes.FormataValorDecimal(GetNodeValue(xmlProd, "imposto/IPI/IPITrib", "pIPI"), 2);
                prod.VlrIpi    = Formatacoes.FormataValorDecimal(GetNodeValue(xmlProd, "imposto/IPI/IPITrib", "vIPI"), 2);

                lstProdNFe.Add(prod);

                if (xmlProd["infAdProd"] != null)
                {
                    ProdutosNFe pNf = new ProdutosNFe();
                    pNf.InfAdic   = true;
                    pNf.Descricao = Formatacoes.RestauraStringDocFiscal(xmlProd["infAdProd"].InnerText);
                    lstProdNFe.Add(pNf);
                }
            }

            #endregion

            return(lstProdNFe.ToArray());
        }
Example #3
0
        private void ataulizaLista(SIME.Class.NFe.nota_entrada nota, Boolean chaveCadastrada, ProdutosNFe listaProdutosNFE)
        {
            for (int i = 0; i < listaProdutosNFE.Count(); i++)
            {
                ListNfe.Visible = true;
                ListItem novoItem = new ListItem(listaProdutosNFE.getDescricaoProduto(i), i.ToString());

                if (chaveCadastrada && (nota.getItem(i) != 0))
                {
                    novoItem.Attributes.CssStyle.Add("Color", "Blue");
                }

                ListNfe.Items.Add(novoItem);
            }
        }