private void frmImportaEscritorNfe_Load(object sender, EventArgs e) { try { belInfNFe objInfNFe = new belInfNFe(); belEscrituracao objEscrituracao = new belEscrituracao(objInfNFe); cbxEmpresas.DisplayMember = "Descricao"; cbxEmpresas.ValueMember = "Codigo"; cbxEmpresas.DataSource = objEscrituracao.RetornaEmpresa(); } catch (Exception ex) { new HLPexception(ex); } }
private List <strucArquivo> MontaStrucArquivos(string[] Arquivos) { List <strucArquivo> objArquivos = new List <strucArquivo>(); List <strucXmlValidacao> objLisXmlNaoValidado = new List <strucXmlValidacao>(); string sNomearq = string.Empty; try { foreach (string sArquivo in Arquivos) { strucArquivo objArquivo = new strucArquivo(); objArquivo.Arquivo = sArquivo.ToString(); sNomearq = sArquivo; belImportaXmlNFe xmlEscritor = new belImportaXmlNFe(sNomearq); try { belInfNFe objInfNFe = xmlEscritor.MontaInfNFe(); if (objInfNFe != null) { objArquivo.Nota = objInfNFe.ide.Nnf; objArquivo.Emitente = objInfNFe.emit.Xnome; objArquivo.Destinatario = objInfNFe.dest.Xnome; objArquivo.Emissao = objInfNFe.ide.Demi; objArquivo.NFE = objInfNFe.id; objArquivos.Add(objArquivo); } else { strucXmlValidacao obj = new strucXmlValidacao(); obj.Xml = sNomearq; obj.Motivo = "Não foi encontrado a Tag 'protNFe'. Xml não é válid0"; objLisXmlNaoValidado.Add(obj); } } catch (Exception ex) { strucXmlValidacao obj = new strucXmlValidacao(); obj.Xml = sNomearq; obj.Motivo = ex.Message; objLisXmlNaoValidado.Add(obj); } } } catch (Exception ex) { //throw new Exception(string.Format("Não foi possivel ler o arquivo {0}, devido ao Erro.: {1}", // sNomearq, // ex.Message)); strucXmlValidacao obj = new strucXmlValidacao(); obj.Xml = sNomearq; obj.Motivo = ex.Message; objLisXmlNaoValidado.Add(obj); } dgvXmlNaoValidado.DataSource = objLisXmlNaoValidado; if (objLisXmlNaoValidado.Count > 0) { lblXmlNaoValidado.Text = objLisXmlNaoValidado.Count.ToString() + " arquivo(s) não válido(s)"; } else { lblXmlNaoValidado.Text = ""; } return(objArquivos); }
private void btnImporta_Click(object sender, EventArgs e) { string sArquivoXML = string.Empty; try { if (txtXml.Text == "") { throw new Exception("Pasta dos Arquivos Xml não foi selecionada"); } if (cbxEmpresas.SelectedValue.ToString() == "") { throw new Exception("Empresa para Importação não foi selecionada"); } List <string> lsXmls = new List <string>(); for (int i = 0; i < dgvXmls.RowCount; i++) { if (((dgvXmls["Selecionar", i].Value != null) && (dgvXmls["Selecionar", i].Value.ToString().Equals("True")))) { lsXmls.Add((string)dgvXmls["Arquivo", i].Value); } } if (lsXmls.Count > 0) { pgbNF.Step = 1; pgbNF.Minimum = 0; pgbNF.Maximum = lsXmls.Count; pgbNF.MarqueeAnimationSpeed = lsXmls.Count; pgbNF.Value = 0; for (int i = 0; i < lsXmls.Count; i++) { try { lblStatusScrituracao.Text = "Escriturando " + (i + 1).ToString() + " de " + lsXmls.Count.ToString(); pgbNF.PerformStep(); statusStrip1.Refresh(); this.Refresh(); sArquivoXML = lsXmls[i]; belImportaXmlNFe xmlEscritor = new belImportaXmlNFe(lsXmls[i]); belInfNFe objInfNFe = xmlEscritor.MontaInfNFe(); objInfNFe.Empresa = cbxEmpresas.SelectedValue.ToString(); belEscrituracao objEscrituracao = new belEscrituracao(objInfNFe); } catch (Exception ex) { new HLPexception(ex); } } KryptonMessageBox.Show(null, string.Format("Importação efetuada com Sucesso!"), "Importação de XML", MessageBoxButtons.OK, MessageBoxIcon.Information); pgbNF.Value = 0; //toolStripButton2_Click(sender, e); lblarquivosEscriturados.Text = "Escriturado " + lsXmls.Count.ToString() + " registro(s) de " + lsXmls.Count.ToString(); } else { KryptonMessageBox.Show(null, string.Format("Nenhum Xml Foi selecionado!"), "Importação de XML", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { if (!String.IsNullOrEmpty(sArquivoXML)) { KryptonMessageBox.Show(null, string.Format("Não foi possível importar o Xml. Erro {0}, Lendo o Arquivo {1}", ex.Message, sArquivoXML), Mensagens.MSG_Aviso, MessageBoxButtons.OK, MessageBoxIcon.Information); } else { new HLPexception(ex); } } }
public void CarregaDados() { try { lNotas = new List <belInfNFe>(); foreach (belPesquisaNotas nota in lPesquisa) { belInfNFe objInfNFe = new belInfNFe(); nota.sCHAVENFE = daoUtil.GeraChaveNFe(nota.sCD_NFSEQ); objInfNFe.chaveNFe = "NFe" + nota.sCHAVENFE; objInfNFe.ide.Carrega(nota.sCD_NFSEQ, objInfNFe.sDigVerif); objInfNFe.emit.Carrega(nota.sCD_NFSEQ); objInfNFe.dest.Carrega(nota.sCD_NFSEQ); bool bEX = (objInfNFe.dest.Uf.Equals("EX") ? true : false); objInfNFe.endent.Carrega(nota.sCD_NFSEQ); belDet objbelDet = new belDet(); objInfNFe.det = objbelDet.Carrega(nota.sCD_NFSEQ, bEX, objInfNFe.dest.Uf); #region RetiraValorBCICMSret dos Totais; decimal dVbcIcmsRt = objInfNFe.det.Where(p => p.imposto.belIcms.belICMSSN500 != null).Select(p => p.imposto.belIcms.belICMSSN500.vBCSTRet).Sum(); decimal dVIcmsRt = objInfNFe.det.Where(p => p.imposto.belIcms.belICMSSN500 != null).Select(p => p.imposto.belIcms.belICMSSN500.vICMSSTRet).Sum(); #endregion objInfNFe.total.Carrega(nota.sCD_NFSEQ, objbelDet.pbIndustri, bEX); objInfNFe.total.belIcmstot.Vbcst = objInfNFe.total.belIcmstot.Vbcst - dVbcIcmsRt; objInfNFe.total.belIcmstot.Vst = objInfNFe.total.belIcmstot.Vst - dVIcmsRt; objInfNFe.total.belIcmstot.vTotTrib = objInfNFe.det.Sum(c => c.prod.vTotTrib); objInfNFe.transp.Carrega(nota.sCD_NFSEQ); objInfNFe.cobr.Carrega(nota.sCD_NFSEQ); objInfNFe.infAdic.Carrega(nota.sCD_NFSEQ, objInfNFe.det, objInfNFe.dest.Cnpj, dVbcIcmsRt, dVIcmsRt); if (Acesso.TRANSPARENCIA == 0 || Acesso.TRANSPARENCIA == 2) { string sMsg = objInfNFe.infAdic.Infcpl; objInfNFe.infAdic.Infcpl = null; objInfNFe.infAdic.Infcpl = daoUtil.CarregaObsTransparenciaNF(nota.sCD_NFSEQ) + sMsg; } if (Acesso.NM_EMPRESA.Equals("GIWA")) { if (objInfNFe.cobr != null) { if (objInfNFe.cobr.Fat != null) { if (objInfNFe.cobr.Fat.belDup != null) { string sparecelas = string.Empty; foreach (var item in objInfNFe.cobr.Fat.belDup) { sparecelas += string.Format("{0}{1} VALOR R$ {2} | ", item.Dvenc.ToShortDateString(), (sparecelas == "" ? "" : " -") , item.Vdup.ToString("#0.00")); } if (objInfNFe.cobr.Fat.belDup.Count() > 0) { objInfNFe.infAdic.Infcpl = "PARCELA(S): " + sparecelas; } } } } } lNotas.Add(objInfNFe); } objbelCriaXml = new belCriaXmlNFe(lNotas); } catch (Exception ex) { throw ex; } }