示例#1
0
        public string TrataRetornoManifestacao(string sTipoRegistro)
        {
            try
            {
                if (this.sXMLretorno != "")
                {
                    objRet = SerializeClassToXml.DeserializeClasseString <belRetEventoCancelamento>(this.sXMLretorno);

                    if (objRet.cStat == "128")
                    {
                        if (objRet.retEvento.infEvento.cStat == "135")
                        {
                            daoUtil.SetStatusManifestacao(this.xChaveNFe, sTipoRegistro);
                            this.stManifesto = sTipoRegistro;
                        }
                    }
                    return(string.Format("NFe: {0} - Status: {1} - Motivo: {2}{3}", this.xNumero, objRet.cStat, objRet.retEvento != null?
                                         objRet.retEvento.infEvento.xMotivo: objRet.xMotivo, Environment.NewLine));
                }
                else
                {
                    return("Nenhum evento registrado.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#2
0
        private void btnImpressao_Click(object sender, EventArgs e)
        {
            try
            {
                List <PesquisaManifestosModel> objSelect = this.objPesquisa.resultado.Where(c =>
                                                                                            c.bEnviado == true &&
                                                                                            c.recibo != "" && c.bSeleciona && c.protocolo != ""
                                                                                            ).ToList();

                dsMdfe = new dsMDFe();
                foreach (PesquisaManifestosModel item in objSelect)
                {
                    rowMdfe = dsMdfe.MDFe.NewMDFeRow();
                    Byte[] bimagem = SalvaCodBarras(item.chaveMDFe);
                    rowMdfe.barras   = bimagem;
                    rowMdfe.logotipo = Util.CarregaLogoEmpresa();

                    string sPath = "";

                    if (item.bCancelado)
                    {
                        sPath = Util.BuscaCaminhoArquivoXml(item.chaveMDFe, 2, true);
                    }
                    else
                    {
                        sPath = Util.BuscaCaminhoArquivoXml(item.chaveMDFe, 2);
                    }
                    XmlDocument xml = new XmlDocument();
                    xml.Load(sPath);
                    XmlNodeList node = xml.GetElementsByTagName("infModal");

                    mdfeProc objEnvi = SerializeClassToXml.DeserializeClasse <mdfeProc>(sPath);
                    rodo     objRodo = SerializeClassToXml.DeserializeClasseString <rodo>(node[0].InnerXml.ToString());
                    rowMdfe.xEmpresa = string.Format("{0}{10}CNPJ:{1} - IE:{2}, RNTRC:{3} - Logradouro:{4}, nº{5} - Bairro:{6}, {7}/{8} Cep:{9}",
                                                     objEnvi.enviMDFe.MDFe.infMDFe.emit.xNome,
                                                     objEnvi.enviMDFe.MDFe.infMDFe.emit.CNPJ,
                                                     objEnvi.enviMDFe.MDFe.infMDFe.emit.IE,
                                                     objRodo.RNTRC,
                                                     objEnvi.enviMDFe.MDFe.infMDFe.emit.enderEmit.xLgr,
                                                     objEnvi.enviMDFe.MDFe.infMDFe.emit.enderEmit.nro,
                                                     objEnvi.enviMDFe.MDFe.infMDFe.emit.enderEmit.xBairro,
                                                     objEnvi.enviMDFe.MDFe.infMDFe.emit.enderEmit.UF,
                                                     objEnvi.enviMDFe.MDFe.infMDFe.emit.enderEmit.xMun,
                                                     objEnvi.enviMDFe.MDFe.infMDFe.emit.enderEmit.CEP, Environment.NewLine);

                    rowMdfe.ufCarreg    = objEnvi.enviMDFe.MDFe.infMDFe.ide.UFIni;
                    rowMdfe.numero      = item.numero;
                    rowMdfe.chave       = item.chaveMDFe;
                    rowMdfe.protocolo   = item.protocolo;
                    rowMdfe.serie       = objEnvi.enviMDFe.MDFe.infMDFe.ide.serie;
                    rowMdfe.dataEmissao = Convert.ToDateTime(objEnvi.enviMDFe.MDFe.infMDFe.ide.dhEmi).ToShortDateString();
                    rowMdfe.CIOT        = objRodo.CIOT;
                    rowMdfe.qtdeCT      = objEnvi.enviMDFe.MDFe.infMDFe.tot.qCT == null ? "0" : objEnvi.enviMDFe.MDFe.infMDFe.tot.qCT.ToString();
                    rowMdfe.qtdeCTE     = objEnvi.enviMDFe.MDFe.infMDFe.tot.qCTe == null ? "0" : objEnvi.enviMDFe.MDFe.infMDFe.tot.qCTe;
                    rowMdfe.qtdeNF      = objEnvi.enviMDFe.MDFe.infMDFe.tot.qNF == null ? "0" : objEnvi.enviMDFe.MDFe.infMDFe.tot.qNF;
                    rowMdfe.qtdeNFe     = objEnvi.enviMDFe.MDFe.infMDFe.tot.qNFe == null ? "0" : objEnvi.enviMDFe.MDFe.infMDFe.tot.qNFe;
                    rowMdfe.pesoTotal   = objEnvi.enviMDFe.MDFe.infMDFe.tot.qCarga;

                    rowMdfe.veicPlaca = objRodo.veicTracao.placa + Environment.NewLine;
                    foreach (var v in objRodo.veicReboque)
                    {
                        rowMdfe.veicPlaca += v.placa + Environment.NewLine;
                    }

                    if (objRodo.veicTracao.prop != null)
                    {
                        rowMdfe.veicRNTRC = objRodo.veicTracao.prop.RNTRC + Environment.NewLine;
                    }

                    foreach (var v in objRodo.veicReboque)
                    {
                        if (v.prop != null)
                        {
                            rowMdfe.veicRNTRC += v.prop.RNTRC + Environment.NewLine;
                        }
                    }
                    if (objRodo.veicTracao.condutor != null)
                    {
                        foreach (var cond in objRodo.veicTracao.condutor)
                        {
                            rowMdfe.Condutor_cpf  += cond.CPF + Environment.NewLine;
                            rowMdfe.Condutor_Nome += cond.xNome + Environment.NewLine;
                        }
                    }

                    if (objRodo.valePed != null)
                    {
                        foreach (var vale in objRodo.valePed)
                        {
                            rowMdfe.Pedagio_Resp_cnp    += vale.CNPJPg + Environment.NewLine;
                            rowMdfe.Pedagio_Forn_cnpj   += vale.CNPJForn + Environment.NewLine;
                            rowMdfe.Pedagio_comprovante += vale.nCompra + Environment.NewLine;
                        }
                    }

                    string sDocEletronico = "{0} - Chave: {1}{2}";
                    rowMdfe.documentos_Fiscais = "";
                    foreach (var doc in objEnvi.enviMDFe.MDFe.infMDFe.infDoc)
                    {
                        if (doc.infCTe != null)
                        {
                            foreach (var cte in doc.infCTe)
                            {
                                rowMdfe.documentos_Fiscais += string.Format(sDocEletronico, "CTe", cte.chCTe, Environment.NewLine);
                            }
                        }
                        if (doc.infNFe != null)
                        {
                            foreach (var nfe in doc.infNFe)
                            {
                                rowMdfe.documentos_Fiscais += string.Format(sDocEletronico, "NFe", nfe.chNFe, Environment.NewLine);
                            }
                        }
                        if (doc.infNF != null)
                        {
                            foreach (var nf in doc.infNF)
                            {
                                rowMdfe.documentos_Fiscais += string.Format("{0} - CNPJ{1} - Serie:{2} - Nº {3}{4}", "NF", nf.CNPJ, nf.serie, nf.nNF, Environment.NewLine);
                            }
                        }
                        if (doc.infCT != null)
                        {
                            foreach (var ct in doc.infCT)
                            {
                                rowMdfe.documentos_Fiscais += string.Format("{0} - Serie:{1} - Nº {2}{3}", "CT", ct.serie, ct.nCT, Environment.NewLine);
                            }
                        }
                    }
                    if (objEnvi.enviMDFe.MDFe.infMDFe.infAdic != null)
                    {
                        rowMdfe.observacao = objEnvi.enviMDFe.MDFe.infMDFe.infAdic.infCpl;
                    }

                    if (item.bCancelado)
                    {
                        rowMdfe.observacao = "***** CONHECIMENTO CANCELADO *****" + Environment.NewLine + rowMdfe.observacao;
                    }

                    // objPrint.ldados.Add(obj);
                    dsMdfe.MDFe.Rows.Add(rowMdfe);
                }
                Print();
            }
            catch (Exception ex)
            {
                throw new HLPexception(ex);
            }
        }