void GeraXMLtoPDF(HLP.GeraXml.bel.NFe.ClassesSerializadas.NFe_HLP nf) { try { NFe_Report objnfReport; string sFilePath = Pastas.Temp + "NFeToReportPDF_{0}.xml"; sFilePath = string.Format(sFilePath, nf.ide_nNF); this.Invoke(new MethodInvoker(delegate() { try { if (File.Exists(sFilePath)) { File.Delete(sFilePath); } objnfReport = new NFe_Report(); objnfReport.Notas.Add(nf); SerializeClassToXml.SerializeClasse<List<NFe_HLP>>(objnfReport.Notas, sFilePath); } catch (Exception ex) { throw; } })); } catch (Exception ex) { throw ex; } }
private void ConsultaLote(HLP.GeraXml.WebService.NFSE_Campinas.LoteRpsService _lt, string sXmlConsulta, string num_lote, out RetornoConsultaLote objretorno) { string sRetornoLote = ""; for (int i = 5; ((i != 0) && (sRetornoLote == "")); i--) { try { tempo.Start(); sRetornoLote = _lt.consultarLote(sXmlConsulta); tempo.Stop(); } catch (Exception ex) { if (i == 0) { throw ex; } } } sRetornoLote = _lt.consultarLote(sXmlConsulta); string sPathRetConsultaLote = Pastas.PROTOCOLOS + "\\Ret_Consulta_Lote_" + num_lote + ".xml"; try { XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(sRetornoLote); xDoc.Save(sPathRetConsultaLote); } catch (Exception ex) { throw new Exception("Falha ao converter o retorno do webservice do método consultarLote" + Environment.NewLine + "MSG:" + sRetornoLote.ToString() + Environment.NewLine + ex.Message); } objretorno = SerializeClassToXml.DeserializeClasse<RetornoConsultaLote>(sPathRetConsultaLote); }
private static string BuscaSituacaoTribDoItem(HLP.bel.belIcms objIcms) { string sSitTrib = ""; if (objIcms.belIcms00 != null) sSitTrib = objIcms.belIcms00.Orig + objIcms.belIcms00.Cst; else if (objIcms.belIcms10 != null) sSitTrib = objIcms.belIcms10.Orig + objIcms.belIcms10.Cst; else if (objIcms.belIcms20 != null) sSitTrib = objIcms.belIcms20.Orig + objIcms.belIcms20.Cst; else if (objIcms.belIcms30 != null) sSitTrib = objIcms.belIcms30.Orig + objIcms.belIcms30.Cst; else if (objIcms.belIcms40 != null) sSitTrib = objIcms.belIcms40.Orig + objIcms.belIcms40.Cst; else if (objIcms.belIcms41 != null) sSitTrib = objIcms.belIcms41.Orig + objIcms.belIcms41.Cst; else if (objIcms.belIcms50 != null) sSitTrib = objIcms.belIcms50.Orig + objIcms.belIcms50.Cst; else if (objIcms.belIcms51 != null) sSitTrib = objIcms.belIcms51.Orig + objIcms.belIcms51.Cst; else if (objIcms.belIcms60 != null) sSitTrib = objIcms.belIcms60.Orig + objIcms.belIcms60.Cst; else if (objIcms.belIcms70 != null) sSitTrib = objIcms.belIcms70.Orig + objIcms.belIcms70.Cst; else if (objIcms.belIcms90 != null) sSitTrib = objIcms.belIcms90.Orig + objIcms.belIcms90.Cst; else if (objIcms.belICMSSN101 != null) sSitTrib = objIcms.belICMSSN101.CSOSN; else if (objIcms.belICMSSN102 != null) sSitTrib = objIcms.belICMSSN102.CSOSN; else if (objIcms.belICMSSN201 != null) sSitTrib = objIcms.belICMSSN201.CSOSN; else if (objIcms.belICMSSN500 != null) sSitTrib = objIcms.belICMSSN500.CSOSN; else if (objIcms.belICMSSN900 != null) sSitTrib = objIcms.belICMSSN900.CSOSN; return sSitTrib; }
void CarregaDadosNFe(ref NFe_HLP objNFe, ref nfeProc objNfeProc, ref infNFe nfe, HLP.GeraXml.UI.NFe.frmGeraArquivoNFe.DadosImpressao dados) { //"C:\\GeraXml\\Arquivos\\VIVABEM\\Contingencia\\\\35130947853981000183550010000001872000000665-nfe.xml" if (dados.tipo == frmGeraArquivoNFe.TipoPDF.CONTINGENCIA) { objNfeProc = new nfeProc(); objNfeProc.lNfe = new List<bel.NFe.ClassesSerializadas.NFe>(); objNfeProc.lNfe.Add(SerializeClassToXml.DeserializeClasse<HLP.GeraXml.bel.NFe.ClassesSerializadas.NFe>(dados.sCaminhoXml)); } else { objNfeProc = SerializeClassToXml.DeserializeClasse<nfeProc>(dados.sCaminhoXml); } if (objNfeProc != null) { nfe = objNfeProc.lNfe.FirstOrDefault().lInfNfe.FirstOrDefault(); objNFe = new NFe_HLP(); objNFe.Id = nfe.Id.ToUpper().Replace("NFE", "").Trim(); objNFe.tpEmis = nfe.ideField.tpEmis.ToString().Replace("Item", "").Trim(); objNFe.tipoPDF = dados.tipo.ToString(); rowImg = dsImg.Imagens.NewImagensRow(); if (objNfeProc.protNFeField != null) objNFe.infprot_nprot = objNfeProc.protNFeField.FirstOrDefault().infProtField.FirstOrDefault().nProt; objNFe.ide_nNF = nfe.ideField.nNF; objNFe.natOP = nfe.ideField.natOp; objNFe.ide_serie = nfe.ideField.serie; objNFe.ide_tpNF = nfe.ideField.tpNF; if (nfe.ideField.dEmi != "") objNFe.ide_dEmi = nfe.ideField.dEmi.ToDateTime().ToShortDateString(); if (Convert.ToBoolean(Acesso.VISUALIZA_DATA_DANFE)) if (nfe.ideField.dSaiEnt != "") objNFe.ide_dSaiEnt = nfe.ideField.dSaiEnt.ToDateTime().ToShortDateString(); objNFe.emit_xNome = nfe.emitField.xNome; objNFe.emit_xFant = nfe.emitField.xFant; objNFe.emit_CPF_CNPJ = nfe.emitField.Item; objNFe.emit_IE = nfe.emitField.IE; objNFe.emit_IEST = nfe.emitField.IEST; objNFe.enderEmit_xLgr = nfe.emitField.enderEmit.xLgr; objNFe.enderEmit_nro = nfe.emitField.enderEmit.nro; objNFe.enderEmit_xCpl = nfe.emitField.enderEmit.xCpl; objNFe.enderEmit_xBairro = nfe.emitField.enderEmit.xBairro; objNFe.enderEmit_cMun = nfe.emitField.enderEmit.cMun; objNFe.enderEmit_xMun = nfe.emitField.enderEmit.xMun; objNFe.enderEmit_UF = nfe.emitField.enderEmit.UF; objNFe.enderEmit_CEP = nfe.emitField.enderEmit.CEP; objNFe.enderEmit_fone = nfe.emitField.enderEmit.fone; objNFe.dest_xNome = nfe.destField.xNome; objNFe.dest_CPF_CNPJ = nfe.destField.Item; // Verificar objNFe.dest_IE = nfe.destField.IE; objNFe.enderDest_xLgr = nfe.destField.enderDest.xLgr; objNFe.enderDest_nro = nfe.destField.enderDest.nro; objNFe.enderDest_xCpl = nfe.destField.enderDest.xCpl; objNFe.enderDest_xBairro = nfe.destField.enderDest.xBairro; objNFe.enderDest_cMun = nfe.destField.enderDest.cMun; objNFe.enderDest_xMun = nfe.destField.enderDest.xMun; objNFe.enderDest_UF = nfe.destField.enderDest.UF; objNFe.enderDest_CEP = nfe.destField.enderDest.CEP; objNFe.enderDest_fone = nfe.destField.enderDest.fone; if (nfe.transpField != null) { if (nfe.transpField.transporta != null) { objNFe.transp_xNome = nfe.transpField.transporta.xNome; objNFe.transp_modFrete = nfe.transpField.modFrete; objNFe.transp_CFP_CNPJ = nfe.transpField.transporta.Item; objNFe.transp_xEnder = nfe.transpField.transporta.xEnder; objNFe.transp_xMun = nfe.transpField.transporta.xMun; objNFe.transp_UF = nfe.transpField.transporta.UF; objNFe.transp_IE = nfe.transpField.transporta.IE; if (nfe.transpField.Items != null) { TVeiculo veic = nfe.transpField.Items.FirstOrDefault(c => c.GetType() == typeof(TVeiculo)) as TVeiculo; if (veic != null) { objNFe.transp_RNTCVeic = veic.RNTC; objNFe.transp_placaVeic = veic.placa; objNFe.transp_UFVeic = veic.UF.ToString(); } } if (nfe.transpField.vol != null) { objNFe.transp_qVol = nfe.transpField.vol.FirstOrDefault().qVol; objNFe.transp_esp = nfe.transpField.vol.FirstOrDefault().esp; objNFe.transp_marca = nfe.transpField.vol.FirstOrDefault().marca; objNFe.transp_nVol = nfe.transpField.vol.FirstOrDefault().nVol; objNFe.transp_PesoB = nfe.transpField.vol.FirstOrDefault().pesoB; objNFe.transp_PesoL = nfe.transpField.vol.FirstOrDefault().pesoL; } } } objNFe.ICMSTot_vBC = nfe.totalField.ICMSTot.vBC.Replace('.', ','); objNFe.ICMSTot_vICMS = nfe.totalField.ICMSTot.vICMS.Replace('.', ','); objNFe.ICMSTot_vBCST = nfe.totalField.ICMSTot.vBCST.Replace('.', ','); objNFe.ICMSTot_vST = nfe.totalField.ICMSTot.vST.Replace('.', ','); objNFe.ICMSTot_vProd = nfe.totalField.ICMSTot.vProd.Replace('.', ','); objNFe.ICMSTot_vFrete = nfe.totalField.ICMSTot.vFrete.Replace('.', ','); objNFe.ICMSTot_vSeg = nfe.totalField.ICMSTot.vSeg.Replace('.', ','); objNFe.ICMSTot_vDesc = nfe.totalField.ICMSTot.vDesc.Replace('.', ','); objNFe.ICMSTot_vII = nfe.totalField.ICMSTot.vII.Replace('.', ','); objNFe.ICMSTot_vIPI = nfe.totalField.ICMSTot.vIPI.Replace('.', ','); objNFe.ICMSTot_vPIS = nfe.totalField.ICMSTot.vPIS.Replace('.', ','); objNFe.ICMSTot_vCOFINS = nfe.totalField.ICMSTot.vCOFINS.Replace('.', ','); objNFe.ICMSTot_vOutro = nfe.totalField.ICMSTot.vOutro.Replace('.', ','); objNFe.ICMSTot_vNF = nfe.totalField.ICMSTot.vNF.Replace('.', ','); objNFe.ICMSTot_vTotTrib = nfe.totalField.ICMSTot.vTotTrib.Replace('.', ','); if (nfe.infAdicField.infCpl != null) { objNFe.xObs = nfe.infAdicField.infCpl.Replace(";", "." + Environment.NewLine); } if (nfe.totalField.ISSQNtot != null) { objNFe.ISSQNtot_vBC = nfe.totalField.ISSQNtot.vBC.Replace('.', ','); objNFe.ISSQNtot_vServ = nfe.totalField.ISSQNtot.vServ.Replace('.', ','); objNFe.ISSQNtot_vISS = nfe.totalField.ISSQNtot.vISS.Replace('.', ','); } int iCount = 1; // if (Acesso.IMPRIMI_FATURA) { if (nfe.cobrField != null) { string sDupl = "Nº:{0}-{1}-R${2}"; objNFe.xDuplicatas = ""; string sDup = ""; foreach (TNFeInfNFeCobrDup dupli in nfe.cobrField.dup) { if (Acesso.NM_EMPRESA.Equals("GIWA")) sDup = dupli.nDup.ToString().Insert(dupli.nDup.Count() - 1, "-"); else sDup = dupli.nDup.ToString(); objNFe.xDuplicatas += string.Format(sDupl, sDup, Convert.ToDateTime(dupli.dVenc).ToString("dd/MM/yy"), Convert.ToDecimal(dupli.vDup.Replace(".", ",")).ToString("#0.00").Replace(".", ",")).PadRight(33, ' ') + "|"; if (iCount == 3) objNFe.xDuplicatas += Environment.NewLine; iCount++; if (iCount > 3) iCount = 1; } } } objNFe.xDupli = objNFe.xDuplicatas; objNFe.Produtos = new List<Produto>(); Produto prod = null; iCount = 1; foreach (det item in nfe.lDet) { prod = new Produto(); prod.count = iCount; iCount++; prod.ide_nNF = objNFe.ide_nNF; prod.cProd = item.prodField.cProd.ToString().Trim(); prod.xProd = item.prodField.xProd; prod.ncm = item.prodField.NCM; prod.cfop = item.prodField.CFOP; prod.uCom = item.prodField.uCom; prod.qCom = PopulaDs.FormataQtdeComercial(item.prodField.qCom.ToString().Replace('.', ',')); prod.vProd = item.prodField.vProd.Replace('.', ','); prod.vUnCom = item.prodField.vUnCom.Replace('.', ','); prod.cEAN = item.prodField.cEAN; prod.xObs = item.infAdProd == null ? "" : item.infAdProd; object icms = item.impostoField.Items.FirstOrDefault(c => c.GetType() == typeof(TNFeInfNFeDetImpostoICMS)); if (icms != null) { try { prod.vBC = (icms as TNFeInfNFeDetImpostoICMS).Item.GetPropertyValue("vBC").ToString().Replace('.', ','); ; } catch (Exception) { } try { prod.vICMS = (icms as TNFeInfNFeDetImpostoICMS).Item.GetPropertyValue("vICMS").ToString().Replace('.', ','); ; } catch (Exception) { } try { prod.pICMS = (icms as TNFeInfNFeDetImpostoICMS).Item.GetPropertyValue("pICMS").ToString().Replace('.', ','); } catch (Exception) { } string cst = ""; try { cst = (icms as TNFeInfNFeDetImpostoICMS).Item.GetPropertyValue("CST").ToString(); } catch (Exception) { cst = (icms as TNFeInfNFeDetImpostoICMS).Item.GetPropertyValue("CSOSN").ToString(); } cst = (icms as TNFeInfNFeDetImpostoICMS).Item.GetPropertyValue("orig").ToString() + cst; prod.cst = cst; } object ipi = item.impostoField.Items.FirstOrDefault(c => c.GetType() == typeof(TNFeInfNFeDetImpostoIPI)); if (ipi != null) { try { prod.vIPI = (ipi as TNFeInfNFeDetImpostoIPI).Item.GetPropertyValue("vIPI").ToString().Replace('.', ','); } catch (Exception) { } try { prod.pIPI = (ipi as TNFeInfNFeDetImpostoIPI).Item.GetPropertyValue("pIPI").ToString().Replace('.', ','); } catch (Exception) { } } objNFe.Produtos.Add(prod); } Byte[] bimagem = SalvaCodBarras(objNFe.Id); rowImg.cod_barras = bimagem; rowImg.LogoTipo = Util.CarregaLogoEmpresa(); rowImg.id = objNFe.Id; if (Convert.ToBoolean(Acesso.VISUALIZA_HORA_DANFE)) { rowImg.hora_impressao = DateTime.Now.ToString("HH:mm"); } if (objNFe.tpEmis == "2") { objNFe.dadosNFe = this.GeraChaveDadosNFe(objNFe); Byte[] bImagemDadosNfe = SalvaCodBarras(objNFe.dadosNFe); rowImg.cod_barras_contingencia = bImagemDadosNfe; } dsImg.Imagens.Rows.Add(rowImg); objNFeToReport.Add(objNFe); } }
public string AnalisaRetornoEnvioCCeCTe(HLP.GeraXml.bel.CTe.Evento.TRetEvento ret, string sNotaFis) { try { //string sNota = ""; if (ret.infEvento.cStat == "135") { //sNota = objlItensPesquisa.FirstOrDefault(c => c.CHNFE == ret.infEvento.chCTe).CD_NOTAFIS; int iQT_ENVIO = objlItensPesquisa.FirstOrDefault(c => c.CHNFE == ret.infEvento.chCTe).QT_ENVIO; string sNR_LANC = objlItensPesquisa.FirstOrDefault(c => c.CHNFE == ret.infEvento.chCTe).CD_NRLANC; AtualizaContadorCCe(sNR_LANC, iQT_ENVIO); string sPath = Pastas.CCe + "\\" + ret.infEvento.chCTe.Substring(2, 4); DirectoryInfo dPastaData = new DirectoryInfo(sPath); if (!dPastaData.Exists) { dPastaData.Create(); } sPath = sPath + "\\35140614920065000160570010000011721000029623" + "_ret-cce.xml"; SerializeClassToXml.SerializeClasse<HLP.GeraXml.bel.CTe.Evento.TRetEvento>(ret, sPath); } return string.Format("CCe do CTe: {0} - '{1}'{2}", sNotaFis, ret.infEvento.xMotivo, Environment.NewLine); } catch (Exception) { throw; } }