// EXERCICIO: Faça as devidas adaptações na CC-e de acordo com sua necessidade public void CCe() { var idlote = Funcoes.InpuBox(null, "Carta de correção", "Identificador de controle do Lote de envio:"); if (string.IsNullOrEmpty(idlote)) { throw new Exception("A Id do Lote deve ser informada!"); } var sequenciaEvento = Funcoes.InpuBox(null, "Carta de correção", "Número sequencial do evento:"); if (string.IsNullOrEmpty(sequenciaEvento)) { throw new Exception("O número sequencial deve ser informado!"); } var chave = Funcoes.InpuBox(null, "Carta de correção", "Chave da NFe:"); if (string.IsNullOrEmpty(chave)) { throw new Exception("A Chave deve ser informada!"); } if (chave.Length != 44) { throw new Exception("Chave deve conter 44 caracteres!"); } var correcao = Funcoes.InpuBox(null, "Carta de correção", "Correção"); if (string.IsNullOrEmpty(correcao)) { throw new Exception("A Correção deve ser informada!"); } var servicoNFe = new ServicosNFe(_configuracoes.CfgServico); var cpfcnpj = string.IsNullOrEmpty(_configuracoes.Emitente.CNPJ) ? _configuracoes.Emitente.CPF : _configuracoes.Emitente.CNPJ; var retornoCartaCorrecao = servicoNFe.RecepcaoEventoCartaCorrecao(Convert.ToInt16(idlote), Convert.ToInt16(sequenciaEvento), chave, correcao, cpfcnpj); string mensagem = ""; foreach (var atributos in Funcoes.LerPropriedades(retornoCartaCorrecao.Retorno)) { mensagem += atributos.Key + " = " + atributos.Value + "\r"; } MessageBox.Show(mensagem, "Informação do Sistema", MessageBoxButton.OK, MessageBoxImage.Information); }
private void BtnCartaCorrecao_Click(object sender, RoutedEventArgs e) { try { #region Carta de correção var idlote = Funcoes.InpuBox(this, "Carta de correção", "Identificador de controle do Lote de envio:"); if (String.IsNullOrEmpty(idlote)) { throw new Exception("A Id do Lote deve ser informada!"); } var sequenciaEvento = Funcoes.InpuBox(this, "Carta de correção", "Número sequencial do evento:"); if (String.IsNullOrEmpty(sequenciaEvento)) { throw new Exception("O número sequencial deve ser informado!"); } var chave = Funcoes.InpuBox(this, "Carta de correção", "Chave da NFe:"); if (String.IsNullOrEmpty(chave)) { throw new Exception("A Chave deve ser informada!"); } if (chave.Length != 44) { throw new Exception("Chave deve conter 44 caracteres!"); } var correcao = Funcoes.InpuBox(this, "Carta de correção", "Correção"); if (String.IsNullOrEmpty(correcao)) { throw new Exception("A Correção deve ser informada!"); } var servicoNFe = new ServicosNFe(_configuracoes.CfgServico); var cpfcnpj = String.IsNullOrEmpty(_configuracoes.Emitente.CNPJ) ? _configuracoes.Emitente.CPF : _configuracoes.Emitente.CNPJ; var retornoCartaCorrecao = servicoNFe.RecepcaoEventoCartaCorrecao(Convert.ToInt16(idlote), Convert.ToInt16(sequenciaEvento), chave, correcao, cpfcnpj); TrataRetorno(retornoCartaCorrecao); #endregion } catch (Exception ex) { if (!String.IsNullOrEmpty(ex.Message)) { Funcoes.Mensagem(ex.Message, "Erro", MessageBoxButton.OK); } } }
/// <summary> /// Responsavel por enviar Carta de Correção para Sefaz /// </summary> /// <param name="idLote"></param> /// <param name="sequenciaEvento"></param> /// <param name="chave"></param> /// <param name="correcao"></param> /// <param name="cpfcnpj"></param> /// <param name="cFgServico"></param> /// <returns></returns> public RetornoRecepcaoEvento CartaCorrecao(int idLote, int sequenciaEvento, string chave, string correcao, string cpfcnpj, ConfiguracaoServico cFgServico) { var servicoNFe = new ServicosNFe(cFgServico); var retornoEnvio = servicoNFe.RecepcaoEventoCartaCorrecao(idLote, sequenciaEvento, chave, correcao, cpfcnpj); foreach (var evento in retornoEnvio.ProcEventosNFe) { var proceventoXmlString = evento.ObterXmlString(); if (evento.retEvento.infEvento.cStat == 135) { //Salva procEventoNFe this.SalvarXmlArquivo(evento.retEvento.infEvento.chNFe + "-procEventoNFe", proceventoXmlString, cFgServico.tpAmb); } } return(retornoEnvio); }