Esempio n. 1
0
 public belEventoMDFe(XmlElement AnyXml, PesquisaManifestosModel objPesquisa, string tpEvento, string nSeq = "1")
 {
     this.objPesquisa = objPesquisa;
     evento = new TEvento();
     evento.versao = Acesso.versaoMDFe;
     evento.infEvento = new TEventoInfEvento();
     evento.infEvento.Id = "ID" + tpEvento + objPesquisa.chaveMDFe + nSeq.PadLeft(2,'0');
     evento.infEvento.cOrgao = Convert.ToByte(Acesso.cUF).ToString();
     evento.infEvento.tpAmb = Acesso.TP_AMB == 1 ? TAmb.Item1 : TAmb.Item2;
     evento.infEvento.CNPJ = Util.RetiraCaracterCNPJ(Acesso.CNPJ_EMPRESA);
     evento.infEvento.chMDFe = objPesquisa.chaveMDFe;
     evento.infEvento.dhEvento = daoUtil.GetDateServidor().ToString("yyyy-MM-ddTHH:mm:ss");
     evento.infEvento.tpEvento = tpEvento;
     evento.infEvento.nSeqEvento = nSeq;
     evento.infEvento.detEvento = new TEventoInfEventoDetEvento();
     evento.infEvento.detEvento.versaoEvento = Acesso.versaoMDFe;
     evento.infEvento.detEvento.Any = AnyXml;
 }
Esempio n. 2
0
 public belEventoMDFe(XmlElement AnyXml, PesquisaManifestosModel objPesquisa, string tpEvento, string nSeq = "1")
 {
     this.objPesquisa                        = objPesquisa;
     evento                                  = new TEvento();
     evento.versao                           = Acesso.versaoMDFe;
     evento.infEvento                        = new TEventoInfEvento();
     evento.infEvento.Id                     = "ID" + tpEvento + objPesquisa.chaveMDFe + nSeq.PadLeft(2, '0');
     evento.infEvento.cOrgao                 = Convert.ToByte(Acesso.cUF).ToString();
     evento.infEvento.tpAmb                  = Acesso.TP_AMB == 1 ? TAmb.Item1 : TAmb.Item2;
     evento.infEvento.CNPJ                   = Util.RetiraCaracterCNPJ(Acesso.CNPJ_EMPRESA);
     evento.infEvento.chMDFe                 = objPesquisa.chaveMDFe;
     evento.infEvento.dhEvento               = daoUtil.GetDateServidor().ToString("yyyy-MM-ddTHH:mm:ss");
     evento.infEvento.tpEvento               = tpEvento;
     evento.infEvento.nSeqEvento             = nSeq;
     evento.infEvento.detEvento              = new TEventoInfEventoDetEvento();
     evento.infEvento.detEvento.versaoEvento = Acesso.versaoMDFe;
     evento.infEvento.detEvento.Any          = AnyXml;
 }
Esempio n. 3
0
        private void PopulaTabVisualizacao(object obj)
        {
            try
            {
                if (Acesso.NM_RAMO != Acesso.BancoDados.TRANSPORTE)
                {
                    belEvento objEvento = obj as belEvento;
                    txtNotaFis.Text     = (bsGrid.DataSource as List <belPesquisaCCe>).FirstOrDefault(c => c.CHNFE == objEvento.infEvento.chNFe).CD_NOTAFIS;
                    txtChaveNFe.Text    = objEvento.infEvento.chNFe;
                    txtRazaoSocial.Text = (bsGrid.DataSource as List <belPesquisaCCe>).FirstOrDefault(c => c.CHNFE == objEvento.infEvento.chNFe).NM_CLIFOR;
                    txtCondUso.Text     = objEvento.infEvento.detEvento.xCondUso;
                    txtAjustes.Text     = objEvento.infEvento.detEvento.xCorrecao.Replace("|", Environment.NewLine);
                }
                else
                {
                    TEvento objEvCCeCTe = obj as TEvento;
                    txtNotaFis.Text     = (bsGrid.DataSource as List <belPesquisaCCe>).FirstOrDefault(c => c.CHNFE == objEvCCeCTe.infEvento.chCTe).CD_NOTAFIS;
                    txtChaveNFe.Text    = objEvCCeCTe.infEvento.chCTe;
                    txtRazaoSocial.Text = (bsGrid.DataSource as List <belPesquisaCCe>).FirstOrDefault(c => c.CHNFE == objEvCCeCTe.infEvento.chCTe).NM_CLIFOR;

                    string   xFile     = Pastas.CCe + "\\" + (bsGrid.DataSource as List <belPesquisaCCe>).FirstOrDefault(c => c.CHNFE == objEvCCeCTe.infEvento.chCTe).CD_NRLANC + "_prevalida.xml";
                    evCCeCTe objEvCanc = SerializeClassToXml.DeserializeClasse <evCCeCTe>(xFile);
                    txtCondUso.Text = objEvCanc.xCondUso.ToString();
                    txtAjustes.Text = "";

                    foreach (var item in objEvCanc.infCorrecao)
                    {
                        txtAjustes.Text += string.Format("GRUPO: {0} - CAMPO: {1} - CORREÇÃO:{2} - {3}{4}" + Environment.NewLine,
                                                         item.grupoAlterado.ToString().ToUpper().Trim(),
                                                         item.campoAlterado.ToString().ToUpper().Trim(),
                                                         item.valorAlterado.ToString().ToUpper().Trim(),
                                                         (item.nroItemAlterado != null ? "INDEX:" : ""),
                                                         (item.nroItemAlterado != null ? item.nroItemAlterado.ToString() : ""));
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 4
0
        private void CarregaItensEventoCartaCorrecao(belPesquisaCCe objbelPesquisa)
        {
            try
            {
                if (Acesso.NM_RAMO != Acesso.BancoDados.TRANSPORTE)
                {
                    objEnvEvento        = new belEnvEvento();
                    objEnvEvento.versao = this._VERSAO;
                    objEnvEvento.id     = objbelPesquisa.CD_NRLANC;
                    belEvento objEvento = new belEvento();
                    objEvento.versao              = _VERSAO;
                    objEvento.infEvento           = new _infEvento();
                    objEvento.infEvento.CNPJ      = objbelPesquisa.CNPJ;
                    objEvento.infEvento.CPF       = objbelPesquisa.CPF;
                    objEvento.infEvento.dhEvento  = daoUtil.GetDateServidor().ToString("yyyy-MM-ddTHH:mm:ss" + Acesso.FUSO);
                    objEvento.infEvento.verEvento = _VERSAO;
                    objEvento.infEvento.tpAmb     = Acesso.TP_AMB;
                    objEvento.infEvento.chNFe     = objbelPesquisa.CHNFE;
                    objEvento.infEvento.cOrgao    = Acesso.cUF.ToString();
                    objEvento.infEvento.detEvento = new _detEvento
                    {
                        versao = _VERSAO
                    };
                    objEvento.infEvento.detEvento.xCorrecao = BuscaCorrecoes(objbelPesquisa.CD_NRLANC);
                    objEvento.infEvento.nSeqEvento          = objbelPesquisa.QT_ENVIO + 1;
                    objEvento.idLote = "ID" + objEvento.infEvento.tpEvento + objEvento.infEvento.chNFe + objEvento.infEvento.nSeqEvento.ToString().PadLeft(2, '0');
                    objEnvEvento.evento.Add(objEvento);
                }
                else
                {
                    objEvCCeCTe = new TEvento();

                    objEvCCeCTe.versao               = Acesso.versaoCTe;
                    objEvCCeCTe.infEvento            = new  TEventoInfEvento();
                    objEvCCeCTe.infEvento.tpEvento   = "110110";
                    objEvCCeCTe.infEvento.nSeqEvento = (objbelPesquisa.QT_ENVIO + 1).ToString();// numero de evento
                    objEvCCeCTe.infEvento.Id         = "ID" + objEvCCeCTe.infEvento.tpEvento + objlItensPesquisa.FirstOrDefault().CHNFE + objEvCCeCTe.infEvento.nSeqEvento.ToString().PadLeft(2, '0');
                    //objEvCCeCTe.infEvento.Id = "ID" + objlItensPesquisa.FirstOrDefault().CHNFE;
                    objEvCCeCTe.infEvento.cOrgao    = Convert.ToByte(Acesso.cUF);
                    objEvCCeCTe.infEvento.tpAmb     = Acesso.TP_AMB == 1 ? TAmb.Item1 : TAmb.Item2;
                    objEvCCeCTe.infEvento.CNPJ      = Util.RetiraCaracterCNPJ(Acesso.CNPJ_EMPRESA);
                    objEvCCeCTe.infEvento.chCTe     = objbelPesquisa.CHNFE;
                    objEvCCeCTe.infEvento.dhEvento  = daoUtil.GetDateServidor().ToString("yyyy-MM-ddTHH:mm:ss");
                    objEvCCeCTe.infEvento.detEvento = new TEventoInfEventoDetEvento();
                    objEvCCeCTe.infEvento.detEvento.versaoEvento = Acesso.versaoCTe;

                    evCCeCTe objEvCanc = new evCCeCTe();
                    objEvCanc.descEvento  = evCCeCTeDescEvento.CartadeCorrecao;
                    objEvCanc.infCorrecao = new List <evCCeCTeInfCorrecao>();
                    objEvCanc.CD_NRLANC   = objbelPesquisa.CD_NRLANC;
                    foreach (DataRow item in BuscaCorrecoesCTe(objbelPesquisa.CD_NRLANC).Rows)
                    {
                        objEvCanc.infCorrecao.Add(new evCCeCTeInfCorrecao
                        {
                            grupoAlterado   = item["grupoAlterado"].ToString(),
                            campoAlterado   = item["campoAlterado"].ToString(),
                            valorAlterado   = item["valorAlterado"].ToString(),
                            nroItemAlterado = item["nroItemAlterado"].ToString(),
                        });
                    }
                    objEvCanc.xCondUso = evCCeCTeXCondUso.ACartadeCorreçãoédisciplinadapeloArt58BdoCONVÊNIOSINIEF0689FicapermitidaautilizaçãodecartadecorreçãopararegularizaçãodeerroocorridonaemissãodedocumentosfiscaisrelativosàprestaçãodeserviçodetransportedesdequeoerronãoestejarelacionadocomIasvariáveisquedeterminamovalordoimpostotaiscomobasedecálculoalíquotadiferençadepreçoquantidadevalordaprestaçãoIIacorreçãodedadoscadastraisqueimpliquemudançadoemitentetomadorremetenteoudodestinatárioIIIadatadeemissãooudesaída;
                    string xFile = Pastas.CCe + "\\" + objEvCanc.CD_NRLANC + "_prevalida.xml";
                    SerializeClassToXml.SerializeClasse <evCCeCTe>(objEvCanc, xFile);
                    XmlDocument xml = new XmlDocument();
                    xml.Load(xFile);
                    objEvCCeCTe.infEvento.detEvento.Any = (System.Xml.XmlElement)xml.DocumentElement;


                    XmlSerializer xs      = new XmlSerializer(typeof(TEvento));
                    MemoryStream  memory  = new MemoryStream();
                    XmlTextWriter xmltext = new XmlTextWriter(memory, Encoding.UTF8);
                    xs.Serialize(xmltext, objEvCCeCTe);
                    UTF8Encoding encoding = new UTF8Encoding();
                    this.sXMLfinal = encoding.GetString(memory.ToArray());
                    this.sXMLfinal = this.sXMLfinal.Substring(1);

                    belAssinaXml Assinatura = new belAssinaXml();
                    this.sXMLfinal = Assinatura.ConfigurarArquivo(this.sXMLfinal, "infEvento", Acesso.cert_CTe);

                    xml = new XmlDocument();
                    xml.LoadXml(this.sXMLfinal);
                    string sPath = Pastas.PROTOCOLOS + "\\" + objbelPesquisa.CHNFE + "_ped-cce.xml";
                    if (File.Exists(sPath))
                    {
                        File.Delete(sPath);
                    }
                    xml.Save(sPath);
                    try
                    {
                        belValidaXml.ValidarXml("http://www.portalfiscal.inf.br/cte", Pastas.SCHEMA_CTE + "\\eventoCTe_v2.00.xsd", sPath);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }