Beispiel #1
0
        /// <summary>
        /// Transmite a nota e salva o arquivo xml na pasta enviado
        /// </summary>
        public void TransmiteRPS()
        {
            try
            {
                if (File.Exists(this.GetsFilePathServico(false)))
                {
                    File.Delete(this.GetsFilePathServico(false));
                }
                belSerializeToXml.SerializeClasse <belNFesSusesu>(this, this.GetsFilePathServico(false));

                XmlDocument xml = new XmlDocument();
                xml.Load(this.GetsFilePathServico(false));

                string sRetorno = "";
                if (Acesso.SENHA_WEB_NFES == "" || Acesso.COD_PREFEITURA == "")
                {
                    throw new Exception("Verifique os parametros abaixo na configuração do GeraXml." + Environment.NewLine + "'Codigo da Prefeitura' e 'Senha acesso sistema NFe-Serviço'");
                }

                string sCNPJ          = Util.TiraSimbolo(Acesso.CNPJ_EMPRESA);
                string sSenha         = Acesso.SENHA_WEB_NFES;
                int    iCodPrefeitura = Convert.ToInt32(Acesso.COD_PREFEITURA);
                string sXmlEnvio      = xml.InnerXml;

                if (Acesso.TP_AMB_SERV == 1)
                {
                    HLP.GeraXml.WebService.Susessu_Producao_Servico.ServicoNfd rps = new WebService.Susessu_Producao_Servico.ServicoNfd();
                    sRetorno = rps.EnviarNota(iCodPrefeitura, sXmlEnvio, sCNPJ, sSenha);
                }
                else
                {
                    HLP.GeraXml.WebService.Susesu_Homologacao_Servico.ServicoNfd rps = new WebService.Susesu_Homologacao_Servico.ServicoNfd();
                    sRetorno = rps.EnviarNota(iCodPrefeitura, sXmlEnvio, sCNPJ, sSenha);
                }

                if (sRetorno[0] == '1')
                {
                    base.AlteraStatusNota(this.CD_NFSEQ, sRetorno);

                    FileInfo f = new FileInfo(this.GetsFilePathServico(true));

                    File.Copy(this.GetsFilePathServico(false), this.GetsFilePathServico(true));

                    KryptonMessageBox.Show(null, string.Format("Nota de serviço enviada com sucesso!{0}Chave de Retorno: {1}", Environment.NewLine, sRetorno), Mensagens.CHeader, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    throw new Exception("Nota recusada pelo servidor da prefeitura, verifique a informação abaixo:" + Environment.NewLine + sRetorno);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Transmite a nota e salva o arquivo xml na pasta enviado
        /// </summary>
        public void TransmiteRPS()
        {
            try
            {

                if (File.Exists(this.GetsFilePathServico(false)))
                {
                    File.Delete(this.GetsFilePathServico(false));
                }
                belSerializeToXml.SerializeClasse<belNFesSusesu>(this, this.GetsFilePathServico(false));

                XmlDocument xml = new XmlDocument();
                xml.Load(this.GetsFilePathServico(false));

                string sRetorno = "";
                if (Acesso.SENHA_WEB_NFES == "" || Acesso.COD_PREFEITURA == "")
                {
                    throw new Exception("Verifique os parametros abaixo na configuração do GeraXml." + Environment.NewLine + "'Codigo da Prefeitura' e 'Senha acesso sistema NFe-Serviço'");
                }

                string sCNPJ = Util.TiraSimbolo(Acesso.CNPJ_EMPRESA);
                string sSenha = Acesso.SENHA_WEB_NFES;
                int iCodPrefeitura = Convert.ToInt32(Acesso.COD_PREFEITURA);
                string sXmlEnvio = xml.InnerXml;

                if (Acesso.TP_AMB_SERV == 1)
                {
                    HLP.GeraXml.WebService.Susessu_Producao_Servico.ServicoNfd rps = new WebService.Susessu_Producao_Servico.ServicoNfd();
                    sRetorno = rps.EnviarNota(iCodPrefeitura, sXmlEnvio, sCNPJ, sSenha);
                }
                else
                {
                    HLP.GeraXml.WebService.Susesu_Homologacao_Servico.ServicoNfd rps = new WebService.Susesu_Homologacao_Servico.ServicoNfd();
                    sRetorno = rps.EnviarNota(iCodPrefeitura, sXmlEnvio, sCNPJ, sSenha);
                }

                if (sRetorno[0] == '1')
                {
                    base.AlteraStatusNota(this.CD_NFSEQ, sRetorno);

                    FileInfo f = new FileInfo(this.GetsFilePathServico(true));

                    File.Copy(this.GetsFilePathServico(false), this.GetsFilePathServico(true));

                    KryptonMessageBox.Show(null, string.Format("Nota de serviço enviada com sucesso!{0}Chave de Retorno: {1}", Environment.NewLine, sRetorno), Mensagens.CHeader, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    throw new Exception("Nota recusada pelo servidor da prefeitura, verifique a informação abaixo:" + Environment.NewLine + sRetorno);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }