private void btnDownloadNFe_Click(object sender, EventArgs e) { var _cStat = string.Empty; var _xMotivo = string.Empty; try { var _xmlRetorno = _spdNFeX.ConsultarDistribuicaoDFeChave(GetCodigoUF(cbUF.SelectedIndex), txtCnpjCpf.Text, txtChaveDownload.Text); var _docXml = new XmlDocument(); _docXml.LoadXml(_xmlRetorno); if (_docXml.GetElementsByTagName("cStat")[1] != null) { _cStat = _docXml.GetElementsByTagName("cStat")[1].InnerText; } else if (_docXml.GetElementsByTagName("cStat")[0] != null) { _cStat = _docXml.GetElementsByTagName("cStat")[0].InnerText; } if (_docXml.GetElementsByTagName("xMotivo")[1] != null) { _xMotivo = _docXml.GetElementsByTagName("xMotivo")[1].InnerText; } else if (_docXml.GetElementsByTagName("xMotivo")[0] != null) { _xMotivo = _docXml.GetElementsByTagName("xMotivo")[0].InnerText; } if (_cStat == "138") //138 = Documento Localizado { txtStatusDownloadNFe.Text = "XML disponΓvel em: " + _spdNFeX.DiretorioDownloads + txtChaveDownload.Text + "-nfe.xml"; } else { txtStatusDownloadNFe.Text = _cStat + " - " + _xMotivo; } } catch (Exception ex) { MessageBox.Show("Erro ao realizar Download da NFe -> " + ex.Message); } }
private void BtnConsultaDFeChave_Click(object sender, EventArgs e) { txtXML.Text = spdNFe.ConsultarDistribuicaoDFeChave("51", spdNFe.CNPJ, txtIdNota.Text); }