Usuário com melhor resposta
Enviando Vetores via Parametros

Pergunta
-
Boa tarde pessoal.
Estou definindo um vetor dentro do meu form da seguinte maneira, Depois de carregá-lo, preciso enviá-lo via parâmetro para utilizá-lo em uma classe. Não estou conseguindo montar essa rotina, vocês poderiam me ajudar?
//--------- Cubagem -------------------- int nIndiceCubagem = 0; string[] aNumeroNotaMedida = new string[100]; string[] aCodigoMedida = new string[100]; decimal[] aAltura = new decimal[100]; decimal[] aLargura = new decimal[100]; decimal[] aTamanho = new decimal[100]; decimal[] aMetragem = new decimal[100]; string[] aVolumes = new string[100]; decimal[] aTotalMetragem = new decimal[100]; decimal[] aFator = new decimal[100]; decimal[] aTotalPeso = new decimal[100]; DateTime[] aDataNotaMedida = new DateTime[100];
Respostas
-
Boa tarde Garibaldo!
Você pode fazer exatamente como o Bruno indicou, passando os vetores por parâmetro modificando o método construtor da classe. Segue alguns links qie poderão lhe auxiliar:
Abraços e espero ter ajudado.
Pablo Batista Cardoso
- Marcado como Resposta Cristopher C I_ quinta-feira, 25 de junho de 2015 19:43
-
Todas as Respostas
-
Olá Garibaldo, segue abaixo um exemplo.
public Form1() { InitializeComponent(); string[] aNumeroNotaMedida = new string[100]; aNumeroNotaMedida[0] = "Elemento1"; aNumeroNotaMedida[1] = "Elemento2"; aNumeroNotaMedida[2] = "Elemento3"; aNumeroNotaMedida[3] = "Elemento4"; aNumeroNotaMedida[4] = "Elemento5"; aNumeroNotaMedida[5] = "Elemento6"; MinhaClasse classe = new MinhaClasse(aNumeroNotaMedida); } public class MinhaClasse { public MinhaClasse(string[] meuVetor) { foreach (var elemento in meuVetor) Console.WriteLine(elemento); } }
- Editado Bruno Maschio Joaquim domingo, 21 de junho de 2015 17:32
-
Bruno boa noite. Desculpe a minha falta de conhecimento. Estou aprendendo C# à pouco tempo e ainda não tenho muito domínio da linguagem. Vim direto do clipper para o C# e estou aprendendo através dos livros e de dúvidas postadas aqui no Fórum.
Na sua resposta acima eu entendi a criação do Vetor, porém, a classe à qual eu preciso utilizar o vetor chama-se GerandoXMLCTe. Nessa classe eu estou gerando um arquivo XML e para finalizar esse arquivo eu preciso ler as informações que estou carregando dentro do vetor. Eu carrego o vetor, porém, não estou conseguindo enviar para a classe GerandoXMLCTe como parâmetro. estou postando aqui a Classe GerandoXMLCTe.
Não estou conseguindo postar o código.using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; using Transportes.Rotinas; using System.Xml.Linq; using System.Xml; namespace Transportes.Rotinas { public class GerandoXMLCTe { public int nUFEmitente { get; set; } public string cCodIBGEEmitente { get; set; } public string cCnpjEmitente { get; set; } public DateTime dDataEmissao { get; set; } public string cModeloDocumento { get; set; } public string cSerieConhec { get; set; } public int nNumeroCTe { get; set; } public string cFormaEmissaoCTe { get; set; } public int nCodigoNumerico { get; set; } public string cAAEmissao { get; set; } public string cMMEmissao { get; set; } public string cDVChave { get; set; } public string cChaveAcesso { get; set; } public string cUFEmitente { get; set; } public string cNumeroCte { get; set; } public string cCfop { get; set; } public string cNaturezaCarga { get; set; } public string cCondicaoFrete { get; set; } public int nNumero_Conhec { get; set; } public DateTime dtpDataConhec { get; set; } public string cFormatoImpressaoDact { get; set; } public string cTipoAmbiente { get; set; } public string cCodSitConhec { get; set; } public string cIdentificadorCTe { get; set; } public string cVersaoAplicativo { get; set; } public string cNomeMunicipio { get; set; } public string cUFEnvioCTe { get; set; } public string cTipoModal { get; set; } public string cTipoServico { get; set; } public string cNumeroIbgeInicial { get; set; } public string cMunicipioInicial { get; set; } public string cUFInicial { get; set; } public string cNumeroIbgeFinal { get; set; } public string cMunicipioFinal { get; set; } public string cUFFinal { get; set; } public string cClienteRetira { get; set; } public string ArquivoXMLGerado { get; set; } public string cCodServTomador { get; set; } public string cCnpjTomador { get; set; } public string cFlagTomador { get; set; } public string cContribuinteIcms { get; set; } public string cInscricaoEstTomador { get; set; } public string cNomeTomador { get; set; } public string cNomeFantTomador { get; set; } public string cNroTelefone { get; set; } public string cEnderecoTomador { get; set; } public string cNroEnderecoTomador { get; set; } public string cComplEndTomador { get; set; } public string cBairroEndTomador { get; set; } public string cCodIbgeTomador { get; set; } public string cNomeMuniTomador { get; set; } public string cCepTomador { get; set; } public string cUFTomador { get; set; } public string cCodPaisTomador { get; set; } public string cNomePaisTomador { get; set; } public string dDataCadastroTomador { get; set; } public string cEmailTomador { get; set; } public string cCaractTransporte { get; set; } public string cCaractServico { get; set; } public string cNomeDigitador { get; set; } public string cSiglaOrigem { get; set; } public string cSiglaPassagem { get; set; } public string cSiglaDestino { get; set; } public string cCodigoRota { get; set; } public string cProgramacaoEntrega { get; set; } public DateTime dtpDataInicial { get; set; } public DateTime dtpDataFinal { get; set; } public string cTipoHorarioEntrega { get; set; } public string dHoraEntregaInicial { get; set; } public string dHoraEntregaFinal { get; set; } public string cObservacoes { get; set; } public string cInscricaoEstEmitente { get; set; } public string cNomeEmitente { get; set; } public string cNomeFantEmitente { get; set; } public string cEnderecoEmitente { get; set; } public string cNroEnderecoEmitente { get; set; } public string cComplEndEmitente { get; set; } public string cBairroEndEmitente { get; set; } public string cCodIbgeEmitente { get; set; } public string cNomeMuniEmitente { get; set; } public string cCepEmitente { get; set; } public string cUFEmitente1 { get; set; } public string cNroTelefoneEmitente { get; set; } public string cTipoDocRemetente { get; set; } public string cCnpjRemetente { get; set; } public string cFlagRemetente { get; set; } public string cContribIcmsRemetente { get; set; } public string cInscricaoEstRemetente { get; set; } public string cNomeRemetente { get; set; } public string cNomeFantRemetente { get; set; } public string cNroTelefoneRemetente { get; set; } public string cEnderecoRemetente { get; set; } public string cNroEnderecoRemetente { get; set; } public string cComplEndRemetente { get; set; } public string cBairroEndRemetente { get; set; } public string cCodIbgeRemetente { get; set; } public string cNomeMuniRemetente { get; set; } public string cCepRemetente { get; set; } public string cUFRemetente { get; set; } public string cCodPaisRemetente { get; set; } public string cNomePaisRemetente { get; set; } public string cEmailRemetente { get; set; } public string cFlagEndColeta { get; set; } public string cTipoDocEndColeta { get; set; } public string cCnpjEndColeta { get; set; } public string cNomeEndColeta { get; set; } public string cEnderecoEndColeta { get; set; } public string cNroEnderecoEndColeta { get; set; } public string cComplEndColeta { get; set; } public string cBairroEndColeta { get; set; } public string cCodIbgeEndColeta { get; set; } public string cNomeMuniEndColeta { get; set; } public string cUFEndColeta { get; set; } public string cCodPaisEndColeta { get; set; } public string cNomePaisEndColeta { get; set; } public string cFlagExpedidor { get; set; } public string cTipoDocExpedidor { get; set; } public string cCnpjExpedidor { get; set; } public string cContribIcmsExpedidor { get; set; } public string cInscricaoEstExpedidor { get; set; } public string cNomeExpedidor { get; set; } public string cNomeFantExpedidor { get; set; } public string cNroTelefoneExpedidor { get; set; } public string cEnderecoExpedidor { get; set; } public string cNroEnderecoExpedidor { get; set; } public string cComplEndExpedidor { get; set; } public string cBairroEndExpedidor { get; set; } public string cCodIbgeExpedidor { get; set; } public string cNomeMuniExpedidor { get; set; } public string cCepExpedidor { get; set; } public string cUFExpedidor { get; set; } public string cCodPaisExpedidor { get; set; } public string cNomePaisExpedidor { get; set; } public string cEmailExpedidor { get; set; } public string cFlagRecebedor { get; set; } public string cTipoDocRecebedor { get; set; } public string cCnpjRecebedor { get; set; } public string cContribIcmsRecebedor { get; set; } public string cInscricaoEstRecebedor { get; set; } public string cNomeRecebedor { get; set; } public string cNomeFantRecebedor { get; set; } public string cNroTelefoneRecebedor { get; set; } public string cEnderecoRecebedor { get; set; } public string cNroEnderecoRecebedor { get; set; } public string cComplEndRecebedor { get; set; } public string cBairroEndRecebedor { get; set; } public string cCodIbgeRecebedor { get; set; } public string cNomeMuniRecebedor { get; set; } public string cCepRecebedor { get; set; } public string cUFRecebedor { get; set; } public string cCodPaisRecebedor { get; set; } public string cNomePaisRecebedor { get; set; } public string cEmailRecebedor { get; set; } public string cFlagDestinatario { get; set; } public string cTipoDocDestinatario { get; set; } public string cCnpjDestinatario { get; set; } public string cContribIcmsDestinatario { get; set; } public string cInscricaoEstDestinatario { get; set; } public string cNomeDestinatario { get; set; } public string cNomeFantDestinatario { get; set; } public string cNroTelefoneDestinatario { get; set; } public string cInscSuframaDestinatario { get; set; } public string cEnderecoDestinatario { get; set; } public string cNroEnderecoDestinatario { get; set; } public string cComplEndDestinatario { get; set; } public string cBairroEndDestinatario { get; set; } public string cCodIbgeDestinatario { get; set; } public string cNomeMuniDestinatario { get; set; } public string cCepDestinatario { get; set; } public string cUFDestinatario { get; set; } public string cCodPaisDestinatario { get; set; } public string cNomePaisDestinatario { get; set; } public string cEmailDestinatario { get; set; } public string cFlagEndEntrega { get; set; } public string cTipoDocEndEntrega { get; set; } public string cCnpjEndEntrega { get; set; } public string cCpfEndEntrega { get; set; } public string cNomeEndEntrega { get; set; } public string cEnderecoEndEntrega { get; set; } public string cNroEnderecoEndEntrega { get; set; } public string cComplEndEntrega { get; set; } public string cBairroEndEntrega { get; set; } public string cCodIbgeEndEntrega { get; set; } public string cNomeMuniEndEntrega { get; set; } public string cUFEndEntrega { get; set; } public string dValorTotalPrestacao { get; set; } public string dValorFretePeso { get; set; } public string dValorFreteValor { get; set; } public string dValorExcFretePeso { get; set; } public string dValorSeguro { get; set; } public string dValorCate { get; set; } public string dValorDespacho { get; set; } public string dValorItr { get; set; } public string dValorPedagio { get; set; } public string dValorAdeme { get; set; } public string dValorGris { get; set; } public string dValorColeta { get; set; } public string dValorAdicColeta { get; set; } public string dValorEntrega { get; set; } public string dValorAdicEntrega { get; set; } public string dValorEmergencia { get; set; } public string dValorTarifa { get; set; } public string dValorAjudante { get; set; } public string dValorAdAjudante { get; set; } public string dValorArmazem { get; set; } public string dValorPericulosidade { get; set; } public string dValorPaletizacao { get; set; } public string dValorDevolucao { get; set; } public string dValorSuframa { get; set; } public string dValorContainer { get; set; } public string dValorOutros { get; set; } public string dValorMagazine { get; set; } public string cSimplesNacional { get; set; } public string cMensagemSimples { get; set; } public string cCodigoClasTribIcms { get; set; } public string dValorBaseIcms { get; set; } public string dAliquotaIcms { get; set; } public string dValorIcms { get; set; } public string dValorBCIcmsReduzida { get; set; } public string dAliquotaIcmsReduzida { get; set; } public string dValorBCIcmsSTRetido { get; set; } public string dValorIcmsSTRetido { get; set; } public string dAliquotaIcmsSTRetido { get; set; } public string dValorCreditoOrtPresumido { get; set; } public string dAliquotaIcmsReducao { get; set; } public string dValorBaseIcmsReducao { get; set; } public string dAliquotaIcms1 { get; set; } public string dValorIcms1 { get; set; } public string dValorCreditoOrtPresumido1 { get; set; } public string dValorMercadoria { get; set; } public string cOutrasCaracteristicas { get; set; } public string cRespSeg { get; set; } public string cNomeSeguradora { get; set; } public string cNumeroApolice { get; set; } public string cNumeroAverbacao { get; set; } public string cNumeroRNTRC { get; set; } public DateTime dDataPrevisao { get; set; } public string cLotacao { get; set; } public string cNumeroCIOT { get; set; } public EnvioDadosCTe(string _ArquivoXMLGerado, int _nUFEmitente, string _cCodIBGEEmitente, string _cCnpjEmitente, DateTime _dDataEmissao, string _cModeloDocumento, string _cSerieConhec, int _nNumeroCTe, string _cFormaEmissaoCTe, int _nCodigoNumerico, string _cAAEmissao, string _cMMEmissao, string _cDVChave, string _cChaveAcesso, string _cUFEmitente, string _cNumeroCte, string _cCfop, string _cNaturezaCarga, string _cCondicaoFrete, int _nNumero_Conhec, DateTime _dtpDataConhec, string _cFormatoImpressaoDact, string _cTipoAmbiente, string _cCodSitConhec, string _cIdentificadorCTe, string _cVersaoAplicativo, string _cNomeMunicipio, string _cUFEnvioCTe, string _cTipoModal, string _cTipoServico, string _cNumeroIbgeInicial, string _MunicipioInicial, string _cUFInicial, string _cNumeroIbgeFinal, string _cMunicipioFinal, string _cUFFinal, string _cClienteRetira, string _cCodServTomador, string _cCnpjTomador, string _cFlagTomador, string _cContribuinteIcms, string _cInscricaoEstTomador, string _cNomeTomador, string _cNomeFantTomador, string _cNroTelefone, string _cEnderecoTomador, string _cNroEnderecoTomador, string _cComplEndTomador, string _cBairroEndTomador, string _cCodIbgeTomador, string _cNomeMuniTomador, string _cCepTomador, string _cUFTomador, string _cCodPaisTomador, string _cNomePaisTomador, string _dDataCadastroTomador, string _cEmailTomador, string _cCaractTransporte, string _cCaractServico, string _cNomeDigitador, string _cSiglaOrigem, string _cSiglaPassagem, string _cSiglaDestino, string _cCodigoRota, string _cProgramacaoEntrega, DateTime _dtpDataInicial, DateTime _dtpDataFinal, string _cTipoHorarioEntrega, string _dHoraEntregaInicial, string _dHoraEntregaFinal, string _cObservacoes, string _cInscricaoEstEmitente, string _cNomeEmitente, string _cNomeFantEmitente, string _cEnderecoEmitente, string _cNroEnderecoEmitente, string _cComplEndEmitente, string _cBairroEndEmitente, string _cCodIbgeEmitente, string _cNomeMuniEmitente, string _cCepEmitente, string _cUFEmitente1, string _cNroTelefoneEmitente, string _cTipoDocRemetente, string _cCnpjRemetente, string _cFlagRemetente, string _cContribIcmsRemetente, string _cInscricaoEstRemetente, string _cNomeRemetente, string _cNomeFantRemetente, string _cNroTelefoneRemetente, string _cEnderecoRemetente, string _cNroEnderecoRemetente, string _cComplEndRemetente, string _cBairroEndRemetente, string _cCodIbgeRemetente, string _cNomeMuniRemetente, string _cCepRemetente, string _cUFRemetente, string _cCodPaisRemetente, string _cNomePaisRemetente, string _cEmailRemetente, string _cFlagEndColeta, string _cTipoDocEndColeta, string _cCnpjEndColeta, string _cNomeEndColeta, string _cEnderecoEndColeta, string _cNroEnderecoEndColeta, string _cComplEndColeta, string _cBairroEndColeta, string _cCodIbgeEndColeta, string _cNomeMuniEndColeta, string _cUFEndColeta, string _cCodPaisEndColeta, string _cNomePaisEndColeta, string _cFlagExpedidor, string _cTipoDocExpedidor, string _cCnpjExpedidor, string _cContribIcmsExpedidor, string _cInscricaoEstExpedidor, string _cNomeExpedidor, string _cNomeFantExpedidor, string _cNroTelefoneExpedidor, string _cEnderecoExpedidor, string _cNroEnderecoExpedidor, string _cComplEndExpedidor, string _cBairroEndExpedidor, string _cCodIbgeExpedidor, string _cNomeMuniExpedidor, string _cCepExpedidor, string _cUFExpedidor, string _cCodPaisExpedidor, string _cNomePaisExpedidor, string _cEmailExpedidor, string _cFlagRecebedor, string _cTipoDocRecebedor, string _cCnpjRecebedor, string _cContribIcmsRecebedor, string _cInscricaoEstRecebedor, string _cNomeRecebedor, string _cNomeFantRecebedor, string _cNroTelefoneRecebedor, string _cEnderecoRecebedor, string _cNroEnderecoRecebedor, string _cComplEndRecebedor, string _cBairroEndRecebedor, string _cCodIbgeRecebedor, string _cNomeMuniRecebedor, string _cCepRecebedor, string _cUFRecebedor, string _cCodPaisRecebedor, string _cNomePaisRecebedor, string _cEmailRecebedor, string _cFlagDestinatario, string _cTipoDocDestinatario, string _cCnpjDestinatario, string _cContribIcmsDestinatario, string _cInscricaoEstDestinatario, string _cNomeDestinatario, string _cNomeFantDestinatario, string _cInscSuframaDestinatario, string _cNroTelefoneDestinatario, string _cEnderecoDestinatario, string _cNroEnderecoDestinatario, string _cComplEndDestinatario, string _cBairroEndDestinatario, string _cCodIbgeDestinatario, string _cNomeMuniDestinatario, string _cCepDestinatario, string _cUFDestinatario, string _cCodPaisDestinatario, string _cNomePaisDestinatario, string _cEmailDestinatario, string _cFlagEndEntrega, string _cTipoDocEndEntrega, string _cCnpjEndEntrega, string _cCpfEndEntrega, string _cNomeEndEntrega, string _cEnderecoEndEntrega, string _cNroEnderecoEndEntrega, string _cComplEndEntrega, string _cBairroEndEntrega, string _cCodIbgeEndEntrega, string _cNomeMuniEndEntrega, string _cUFEndEntrega, string _dValorTotalPrestacao, string _dValorFretePeso, string _dValorFreteValor, string _dValorExcFretePeso, string _dValorSeguro, string _dValorCate, string _dValorDespacho, string _dValorItr, string _dValorPedagio, string _dValorAdeme, string _dValorGris, string _dValorColeta, string _dValorAdicColeta, string _dValorEntrega, string _dValorAdicEntrega, string _dValorEmergencia, string _dValorTarifa, string _dValorAjudante, string _dValorAdAjudante, string _dValorArmazem, string _dValorPericulosidade, string _dValorPaletizacao, string _dValorDevolucao, string _dValorSuframa, string _dValorContainer, string _dValorOutros, string _dValorMagazine, string _cSimplesNacional, string _cMensagemSimples, string _cCodigoClasTribIcms, string _dValorBaseIcms, string _dAliquotaIcms, string _dValorIcms, string _dValorBCIcmsReduzida, string _dAliquotaIcmsReduzida, string _dValorBCIcmsSTRetido, string _dValorIcmsSTRetido, string _dAliquotaIcmsSTRetido, string _dValorCreditoOrtPresumido, string _dAliquotaIcmsReducao, string _dValorBaseIcmsReducao, string _dAliquotaIcms1, string _dValorIcms1, string _dValorCreditoOrtPresumido1, string _dValorMercadoria, string _cOutrasCaracteristicas, string _cRespSeg, string _cNomeSeguradora, string _cNumeroApolice, string _cNumeroAverbacao, string _cNumeroRNTRC, DateTime _dDataPrevisao, string _cLotacao, string _cNumeroCIOT) { this.nUFEmitente = _nUFEmitente; this.cCodIBGEEmitente = _cCodIBGEEmitente; this.cCnpjEmitente = _cCnpjEmitente; this.dDataEmissao = _dDataEmissao; this.cModeloDocumento = _cModeloDocumento; this.cSerieConhec = _cSerieConhec; this.nNumeroCTe = _nNumeroCTe; this.cFormaEmissaoCTe = _cFormaEmissaoCTe; this.nCodigoNumerico = _nCodigoNumerico; this.cAAEmissao = _cAAEmissao; this.cMMEmissao = _cMMEmissao; this.cDVChave = _cDVChave; this.cChaveAcesso = _cChaveAcesso; this.cUFEmitente = _cUFEmitente; this.cNumeroCte = _cNumeroCte; this.cCfop = _cCfop; this.cNaturezaCarga = _cNaturezaCarga; this.cCondicaoFrete = _cCondicaoFrete; this.nNumero_Conhec = _nNumero_Conhec; this.dtpDataConhec = _dtpDataConhec; this.cFormatoImpressaoDact = _cFormatoImpressaoDact; this.cTipoAmbiente = _cTipoAmbiente; this.cCodSitConhec = _cCodSitConhec; this.cIdentificadorCTe = _cIdentificadorCTe; this.cVersaoAplicativo = _cVersaoAplicativo; this.cNomeMunicipio = _cNomeMunicipio; this.cUFEnvioCTe = _cUFEnvioCTe; this.cTipoModal = _cTipoModal; this.cTipoServico = _cTipoServico; this.cNumeroIbgeInicial = _cNumeroIbgeInicial; this.cMunicipioInicial = _MunicipioInicial; this.cUFInicial = _cUFInicial; this.cNumeroIbgeFinal = _cNumeroIbgeFinal; this.cMunicipioFinal = _cMunicipioFinal; this.cUFFinal = _cUFFinal; this.cClienteRetira = _cClienteRetira; this.ArquivoXMLGerado = _ArquivoXMLGerado; this.cCodServTomador = _cCodServTomador; this.cCnpjTomador = _cCnpjTomador; this.cFlagTomador = _cFlagTomador; this.cContribuinteIcms = _cContribuinteIcms; this.cInscricaoEstTomador = _cInscricaoEstTomador; this.cNomeTomador = _cNomeTomador; this.cNomeFantTomador = _cNomeFantTomador; this.cNroTelefone = _cNroTelefone; this.cEnderecoTomador = _cEnderecoTomador; this.cNroEnderecoTomador = _cNroEnderecoTomador; this.cComplEndTomador = _cComplEndTomador; this.cBairroEndTomador = _cBairroEndTomador; this.cCodIbgeTomador = _cCodIbgeTomador; this.cNomeMuniTomador = _cNomeMuniTomador; this.cCepTomador = _cCepTomador; this.cUFTomador = _cUFTomador; this.cCodPaisTomador = _cCodPaisTomador; this.cNomePaisTomador = _cNomePaisTomador; this.dDataCadastroTomador = _dDataCadastroTomador; this.cEmailTomador = _cEmailTomador; this.cCaractTransporte = _cCaractTransporte; this.cCaractServico = _cCaractServico; this.cNomeDigitador = _cNomeDigitador; this.cSiglaOrigem = _cSiglaOrigem; this.cSiglaPassagem = _cSiglaPassagem; this.cSiglaDestino = _cSiglaDestino; this.cCodigoRota = _cCodigoRota; this.cProgramacaoEntrega = _cProgramacaoEntrega; this.dtpDataInicial = _dtpDataInicial; this.dtpDataFinal = _dtpDataFinal; this.cTipoHorarioEntrega = _cTipoHorarioEntrega; this.dHoraEntregaInicial = _dHoraEntregaInicial; this.dHoraEntregaFinal = _dHoraEntregaFinal; this.cObservacoes = _cObservacoes; this.cInscricaoEstEmitente = _cInscricaoEstEmitente; this.cNomeEmitente = _cNomeEmitente; this.cNomeFantEmitente = _cNomeFantEmitente; this.cEnderecoEmitente = _cEnderecoEmitente; this.cNroEnderecoEmitente = _cNroEnderecoEmitente; this.cComplEndEmitente = _cComplEndEmitente; this.cBairroEndEmitente = _cBairroEndEmitente; this.cCodIbgeEmitente = _cCodIbgeEmitente; this.cNomeMuniEmitente = _cNomeMuniEmitente; this.cCepEmitente = _cCepEmitente; this.cUFEmitente = _cUFEmitente; this.cNroTelefoneEmitente = _cNroTelefoneEmitente; this.cCnpjRemetente = _cCnpjRemetente; this.cTipoDocRemetente = _cTipoDocRemetente; this.cFlagRemetente = _cFlagRemetente; this.cContribIcmsRemetente = _cContribIcmsRemetente; this.cInscricaoEstRemetente = _cInscricaoEstRemetente; this.cNomeRemetente = _cNomeRemetente; this.cNomeFantRemetente = _cNomeFantRemetente; this.cNroTelefoneRemetente = _cNroTelefoneRemetente; this.cEnderecoRemetente = _cEnderecoRemetente; this.cNroEnderecoRemetente = _cNroEnderecoRemetente; this.cComplEndRemetente = _cComplEndRemetente; this.cBairroEndRemetente = _cBairroEndRemetente; this.cCodIbgeRemetente = _cCodIbgeRemetente; this.cNomeMuniRemetente = _cNomeMuniRemetente; this.cCepRemetente = _cCepRemetente; this.cUFRemetente = _cUFRemetente; this.cCodPaisRemetente = _cCodPaisRemetente; this.cNomePaisRemetente = _cNomePaisRemetente; this.cEmailRemetente = _cEmailRemetente; this.cFlagEndColeta = _cFlagEndColeta; this.cTipoDocEndColeta = _cTipoDocEndColeta; this.cCnpjEndColeta = _cCnpjEndColeta; this.cNomeEndColeta = _cNomeEndColeta; this.cEnderecoEndColeta = _cEnderecoEndColeta; this.cNroEnderecoEndColeta = _cNroEnderecoEndColeta; this.cComplEndColeta = _cComplEndColeta; this.cBairroEndColeta = _cBairroEndColeta; this.cCodIbgeEndColeta = _cCodIbgeEndColeta; this.cNomeMuniEndColeta = _cNomeMuniEndColeta; this.cUFEndColeta = _cUFEndColeta; this.cCodPaisEndColeta = _cCodPaisEndColeta; this.cNomePaisEndColeta = _cNomePaisEndColeta; this.cFlagExpedidor = _cFlagExpedidor; this.cTipoDocExpedidor = _cTipoDocExpedidor; this.cCnpjExpedidor = _cCnpjExpedidor; this.cContribIcmsExpedidor = _cContribIcmsExpedidor; this.cInscricaoEstExpedidor = _cInscricaoEstExpedidor; this.cNomeExpedidor = _cNomeExpedidor; this.cNomeFantExpedidor = _cNomeFantExpedidor; this.cNroTelefoneExpedidor = _cNroTelefoneExpedidor; this.cEnderecoExpedidor = _cEnderecoExpedidor; this.cNroEnderecoExpedidor = _cNroEnderecoExpedidor; this.cComplEndExpedidor = _cComplEndExpedidor; this.cBairroEndExpedidor = _cBairroEndExpedidor; this.cCodIbgeExpedidor = _cCodIbgeExpedidor; this.cNomeMuniExpedidor = _cNomeMuniExpedidor; this.cCepExpedidor = _cCepExpedidor; this.cUFExpedidor = _cUFExpedidor; this.cCodPaisExpedidor = _cCodPaisExpedidor; this.cNomePaisExpedidor = _cNomePaisExpedidor; this.cEmailExpedidor = _cEmailExpedidor; this.cFlagRecebedor = _cFlagRecebedor; this.cTipoDocRecebedor = _cTipoDocRecebedor; this.cCnpjRecebedor = _cCnpjRecebedor; this.cContribIcmsRecebedor = _cContribIcmsRecebedor; this.cInscricaoEstRecebedor = _cInscricaoEstRecebedor; this.cNomeRecebedor = _cNomeRecebedor; this.cNomeFantRecebedor = _cNomeFantRecebedor; this.cNroTelefoneRecebedor = _cNroTelefoneRecebedor; this.cEnderecoRecebedor = _cEnderecoRecebedor; this.cNroEnderecoRecebedor = _cNroEnderecoRecebedor; this.cComplEndRecebedor = _cComplEndRecebedor; this.cBairroEndRecebedor = _cBairroEndRecebedor; this.cCodIbgeRecebedor = _cCodIbgeRecebedor; this.cNomeMuniRecebedor = _cNomeMuniRecebedor; this.cCepRecebedor = _cCepRecebedor; this.cUFRecebedor = _cUFRecebedor; this.cCodPaisRecebedor = _cCodPaisRecebedor; this.cNomePaisRecebedor = _cNomePaisRecebedor; this.cEmailRecebedor = _cEmailRecebedor; this.cFlagRecebedor = _cFlagRecebedor; this.cTipoDocRecebedor = _cTipoDocRecebedor; this.cCnpjRecebedor = _cCnpjRecebedor; this.cContribIcmsRecebedor = _cContribIcmsRecebedor; this.cInscricaoEstRecebedor = _cInscricaoEstRecebedor; this.cNomeRecebedor = _cNomeRecebedor; this.cNomeFantRecebedor = _cNomeFantRecebedor; this.cNroTelefoneRecebedor = _cNroTelefoneRecebedor; this.cInscSuframaDestinatario = _cInscSuframaDestinatario; this.cEnderecoRecebedor = _cEnderecoRecebedor; this.cNroEnderecoRecebedor = _cNroEnderecoRecebedor; this.cComplEndRecebedor = _cComplEndRecebedor; this.cBairroEndRecebedor = _cBairroEndRecebedor; this.cCodIbgeRecebedor = _cCodIbgeRecebedor; this.cNomeMuniRecebedor = _cNomeMuniRecebedor; this.cCepRecebedor = _cCepRecebedor; this.cUFRecebedor = _cUFRecebedor; this.cCodPaisRecebedor = _cCodPaisRecebedor; this.cNomePaisRecebedor = _cNomePaisRecebedor; this.cEmailRecebedor = _cEmailRecebedor; this.cFlagEndEntrega = _cFlagEndEntrega; this.cTipoDocEndEntrega = _cTipoDocEndEntrega; this.cCnpjEndEntrega = _cCnpjEndEntrega; this.cCpfEndEntrega = _cCpfEndEntrega; this.cNomeEndEntrega = _cNomeEndEntrega; this.cEnderecoEndEntrega = _cEnderecoEndEntrega; this.cNroEnderecoEndEntrega = _cNroEnderecoEndEntrega; this.cComplEndEntrega = _cComplEndEntrega; this.cBairroEndEntrega = _cBairroEndEntrega; this.cCodIbgeEndEntrega = _cCodIbgeEndEntrega; this.cNomeMuniEndEntrega = _cNomeMuniEndEntrega; this.cUFEndEntrega = _cUFEndEntrega; this.dValorTotalPrestacao = _dValorTotalPrestacao; this.dValorFretePeso = _dValorFretePeso; this.dValorFreteValor = _dValorFreteValor; this.dValorExcFretePeso = _dValorExcFretePeso; this.dValorSeguro = _dValorSeguro; this.dValorCate = _dValorCate; this.dValorDespacho = _dValorDespacho; this.dValorAdeme = _dValorAdeme; this.dValorGris = _dValorGris; this.dValorColeta = _dValorColeta; this.dValorAdicColeta = _dValorAdicColeta; this.dValorEntrega = _dValorEntrega; this.dValorAdicEntrega = _dValorAdicEntrega; this.dValorEmergencia = _dValorEmergencia; this.dValorTarifa = _dValorTarifa; this.dValorAjudante = _dValorAjudante; this.dValorAdAjudante = _dValorAdAjudante; this.dValorArmazem = _dValorArmazem; this.dValorPericulosidade = _dValorPericulosidade; this.dValorPaletizacao = _dValorPaletizacao; this.dValorDevolucao = _dValorDevolucao; this.dValorSuframa = _dValorSuframa; this.dValorContainer = _dValorContainer; this.dValorOutros = _dValorOutros; this.dValorMagazine = _dValorMagazine; this.cSimplesNacional = _cSimplesNacional; this.cMensagemSimples = _cMensagemSimples; this.cCodigoClasTribIcms = _cCodigoClasTribIcms; this.dValorBaseIcms = _dValorBaseIcms; this.dAliquotaIcms = _dAliquotaIcms; this.dValorIcms = _dValorIcms; this.dValorBCIcmsReduzida = _dValorBCIcmsReduzida; this.dAliquotaIcmsReduzida = _dAliquotaIcmsReduzida; this.dValorBCIcmsSTRetido = _dValorBCIcmsSTRetido; this.dValorIcmsSTRetido = _dValorIcmsSTRetido; this.dAliquotaIcmsSTRetido = _dAliquotaIcmsSTRetido; this.dValorCreditoOrtPresumido = _dValorCreditoOrtPresumido; this.dAliquotaIcmsReducao = _dAliquotaIcmsReducao; this.dValorBaseIcmsReducao = _dValorBaseIcmsReducao; this.dAliquotaIcms1 = _dAliquotaIcms1; this.dValorIcms1 = _dValorIcms1; this.dValorCreditoOrtPresumido1 = _dValorCreditoOrtPresumido1; this.dValorMercadoria = _dValorMercadoria; this.cOutrasCaracteristicas = _cOutrasCaracteristicas; this.cRespSeg = _cRespSeg; this.cNomeSeguradora = _cNomeSeguradora; this.cNumeroApolice = _cNumeroApolice; this.cNumeroAverbacao = _cNumeroAverbacao; this.cNumeroRNTRC = _cNumeroRNTRC; this.dDataPrevisao = _dDataPrevisao; this.cLotacao = _cLotacao; this.cNumeroCIOT = _cNumeroCIOT; GerandoXMLCte(); } public void GerandoXMLCte() { GeraXML(); } //********************************* Rotina Para Gerar o Arquivo XML ******************************************************************** private void GeraXML() {
} } }
-
-
-
Não sei se entendi bem qual é o seu problema, segue o código.
GerandoXMLCte(meuVetor); } public void GerandoXMLCte(string[] meuVetor) { GeraXML(meuVetor); } //********************************* Rotina Para Gerar o Arquivo XML ******************************************************************** private void GeraXML(string[] meuVetor) { //aqui voce usa o vetor. }
seria isso?
- Sugerido como Resposta Pablo Batista Cardoso segunda-feira, 22 de junho de 2015 18:20
-
Boa tarde Garibaldo!
Você pode fazer exatamente como o Bruno indicou, passando os vetores por parâmetro modificando o método construtor da classe. Segue alguns links qie poderão lhe auxiliar:
Abraços e espero ter ajudado.
Pablo Batista Cardoso
- Marcado como Resposta Cristopher C I_ quinta-feira, 25 de junho de 2015 19:43
-
Eu preciso utilizar o meu vetor nesse ponto:
dValorPaletizacao = Convert.ToString(dValor); cTotal1 = dValorPaletizacao.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("vComp", cTotal4); // 3 Campo-213 --> Valor da Paletização do Total da Prestação dos Serviços Realizados. xtw.WriteEndElement(); } if (dValorDevolucao != "0,00" && dValorDevolucao != "0" && dValorDevolucao != "") { xtw.WriteStartElement("Comp"); // 2 Campo-211 --> Componentes dos Valores da Prestação de Serviços xtw.WriteElementString("xNome", "Valor Devolucao"); // 3 Campo-212 --> Descrição do Componente Valor da Devolução. cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = Convert.ToDecimal(dValorDevolucao); dValorDevolucao = Convert.ToString(dValor); cTotal1 = dValorDevolucao.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("vComp", cTotal4); // 3 Campo-213 --> Valor da Devolução do Total da Prestação dos Serviços Realizados. xtw.WriteEndElement(); } if (dValorSuframa != "0,00" && dValorSuframa != "0" && dValorSuframa != "") { xtw.WriteStartElement("Comp"); // 2 Campo-211 --> Componentes dos Valores da Prestação de Serviços xtw.WriteElementString("xNome", "Valor Suframa"); // 3 Campo-212 --> Descrição do Componente Valor do Suframa. cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = Convert.ToDecimal(dValorSuframa); dValorSuframa = Convert.ToString(dValor); cTotal1 = dValorSuframa.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("vComp", cTotal4); // 3 Campo-213 --> Valor do Suframa do Total da Prestação dos Serviços Realizados. xtw.WriteEndElement(); } if (dValorContainer != "0,00" && dValorContainer != "0" && dValorContainer != "") { xtw.WriteStartElement("Comp"); // 2 Campo-211 --> Componentes dos Valores da Prestação de Serviços xtw.WriteElementString("xNome", "Valor Container"); // 3 Campo-212 --> Descrição do Componente Valor do Container. cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = Convert.ToDecimal(dValorContainer); dValorContainer = Convert.ToString(dValor); cTotal1 = dValorContainer.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("vComp", cTotal4); // 3 Campo-213 --> Valor do Container do Total da Prestação dos Serviços Realizados. xtw.WriteEndElement(); } if (dValorOutros != "0,00" && dValorOutros != "0" && dValorOutros != "") { xtw.WriteStartElement("Comp"); // 2 Campo-211 --> Componentes dos Valores da Prestação de Serviços xtw.WriteElementString("xNome", "Valor Outros"); // 3 Campo-212 --> Descrição do Componente Valor Outros. cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = Convert.ToDecimal(dValorOutros); dValorOutros = Convert.ToString(dValor); cTotal1 = dValorOutros.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("vComp", cTotal4); // 3 Campo-213 --> Valor Outros do Total da Prestação dos Serviços Realizados. xtw.WriteEndElement(); } if (dValorMagazine != "0,00" && dValorMagazine != "0" && dValorMagazine != "") { xtw.WriteStartElement("Comp"); // 2 Campo-211 --> Componentes dos Valores da Prestação de Serviços xtw.WriteElementString("xNome", "Valor Magazine"); // 3 Campo-212 --> Descrição do Componente Valor do Magazine. cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = Convert.ToDecimal(dValorMagazine); dValorMagazine = Convert.ToString(dValor); cTotal1 = dValorMagazine.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("vComp", cTotal4); // 3 Campo-213 --> Valor do Magazine do Total da Prestação dos Serviços Realizados. xtw.WriteEndElement(); } xtw.WriteEndElement(); // xtw.WriteEndElement(); //---------------------- Imposto de Icms ---------------------------- if (cSimplesNacional == "S") { xtw.WriteStartElement("imp"); // 1 Campo-214 --> Informações relativas a impostos xtw.WriteStartElement("ICMS"); // 2 Campo-215 --> Informações relativas a Icms xtw.WriteStartElement("ICMSSN"); // 3 Campo-248 --> Simples Nacional xtw.WriteElementString("indSN", "1"); // 4 Campo-249 --> Valor do Magazine do Total da Prestação dos Serviços Realizados. xtw.WriteEndElement(); // 3 xtw.WriteEndElement(); // 2 xtw.WriteElementString("indAdFisco", cMensagemSimples); // 2 Campo-251 --> Norma Referenciada, informações complementares. xtw.WriteEndElement(); } if (cCodigoClasTribIcms == "00") { xtw.WriteStartElement("imp"); // 1 Campo-214 --> Informações relativas a impostos xtw.WriteStartElement("ICMS"); // 2 Campo-215 --> Informações relativas a Icms xtw.WriteStartElement("ICMS00"); // 3 Campo-216 --> Prestação sujeito à tributação normal do ICMS xtw.WriteElementString("CST", cCodigoClasTribIcms); // 4 Campo-217 --> classificação Tributária do Serviço cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; dValor = Convert.ToDecimal(dValorBaseIcms); dValorBaseIcms = Convert.ToString(dValor); cTotal1 = dValorBaseIcms.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("vBC", cTotal4); // 4 Campo-218 --> Valor da BC do ICMS. cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; dValor = Convert.ToDecimal(dAliquotaIcms); dAliquotaIcms = Convert.ToString(dValor); cTotal1 = dAliquotaIcms.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("pICMS", cTotal4); // 4 Campo-219 --> Aliquota do ICMS. cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; dValor = Convert.ToDecimal(dValorIcms); dValorIcms = Convert.ToString(dValor); cTotal1 = dValorIcms.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("vICMS", cTotal4); // 4 Campo-220 --> Valor do ICMS. xtw.WriteEndElement(); xtw.WriteEndElement(); xtw.WriteElementString("vTotTrib", cTotal4); // 2 Campo-250 --> Valor de tributos federais, estaduais e municipais xtw.WriteEndElement(); } if (cCodigoClasTribIcms == "20") { xtw.WriteStartElement("imp"); // 1 Campo-214 --> Informações relativas a impostos xtw.WriteStartElement("ICMS"); // 2 Campo-215 --> Informações relativas a Icms xtw.WriteStartElement("ICMS20"); // 3 Campo-221 --> Prestação sujeito à tributação com redução de BC do ICMS xtw.WriteElementString("CST", cCodigoClasTribIcms); // 4 Campo-222 --> tributação com BC reduzida do ICMS cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; dValor = Convert.ToDecimal(dAliquotaIcmsReduzida); dAliquotaIcmsReduzida = Convert.ToString(dValor); cTotal1 = dAliquotaIcmsReduzida.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("pRedBC", cTotal4); // 4 Campo-223 --> Percentual de Redução BC. cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; dValor = Convert.ToDecimal(dValorBCIcmsReduzida); dValorBCIcmsReduzida = Convert.ToString(dValor); cTotal1 = dValorBCIcmsReduzida .PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("vBC", cTotal4); // 4 Campo-224 --> Valor da BC do ICMS. cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; dValor = Convert.ToDecimal(dAliquotaIcms); dAliquotaIcms = Convert.ToString(dValor); cTotal1 = dAliquotaIcms.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("pICMS", cTotal4); // 4 Campo-225 --> Aliquota do ICMS. cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; dValor = Convert.ToDecimal(dValorIcms); dValorIcms = Convert.ToString(dValor); cTotal1 = dValorIcms.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("vICMS", cTotal4); // 4 Campo-226 --> Valor do ICMS. xtw.WriteEndElement(); xtw.WriteEndElement(); xtw.WriteElementString("vTotTrib", cTotal4); // 2 Campo-250 --> Valor de tributos federais, estaduais e municipais xtw.WriteEndElement(); } if (cCodigoClasTribIcms == "40" || cCodigoClasTribIcms == "41" || cCodigoClasTribIcms == "51") { xtw.WriteStartElement("imp"); // 1 Campo-214 --> Informações relativas a impostos xtw.WriteStartElement("ICMS"); // 2 Campo-215 --> Informações relativas a Icms xtw.WriteStartElement("ICMS45"); // 3 Campo-227 --> ICMS Isento, não Tributado ou diferido xtw.WriteElementString("CST", cCodigoClasTribIcms); // 4 Campo-228 --> Classificação Tributária do Serviço } if (cCodigoClasTribIcms == "60") { xtw.WriteStartElement("imp"); // 1 Campo-214 --> Informações relativas a impostos xtw.WriteStartElement("ICMS"); // 2 Campo-215 --> Informações relativas a Icms xtw.WriteStartElement("ICMS60"); // 3 Campo-229 --> Tributação pelo ICMS60 - ICMS cobrado por substituição tributária.Responsabilidade do recolhimento do ICMS atribuído ao tomador ou 3º por ST xtw.WriteElementString("CST", cCodigoClasTribIcms); // 4 Campo-230 --> 60 - ICMS cobrado anteriormente por substituição tributária cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; dValor = Convert.ToDecimal(dValorBCIcmsSTRetido); dValorBCIcmsSTRetido = Convert.ToString(dValor); cTotal1 = dValorBCIcmsSTRetido.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("vBCSTRet", cTotal4); // 4 Campo-231 --> Valor da BC do ICMS ST retido. cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; dValor = Convert.ToDecimal(dValorIcmsSTRetido); dValorIcmsSTRetido = Convert.ToString(dValor); cTotal1 = dValorIcmsSTRetido.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("vICMSSTRet", cTotal4); // 4 Campo-232 --> Valor do ICMS ST retido. cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; dValor = Convert.ToDecimal(dAliquotaIcmsSTRetido); dAliquotaIcmsSTRetido = Convert.ToString(dValor); cTotal1 = dAliquotaIcmsSTRetido.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("pICMSSTRet", cTotal4); // 4 Campo-233 --> Aliquota do ICMS. cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; dValor = Convert.ToDecimal(dValorCreditoOrtPresumido); dValorCreditoOrtPresumido = Convert.ToString(dValor); cTotal1 = dValorCreditoOrtPresumido.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("vCred", cTotal4); // 4 Campo-234 --> Valor do Crédito outorgado/Presumido. xtw.WriteEndElement(); xtw.WriteEndElement(); xtw.WriteEndElement(); } if (cCodigoClasTribIcms == "90") { xtw.WriteStartElement("imp"); // 1 Campo-214 --> Informações relativas a impostos xtw.WriteStartElement("ICMS"); // 2 Campo-215 --> Informações relativas a Icms xtw.WriteStartElement("ICMS90"); // 3 Campo-235 --> Tributação pelo ICMS60 - ICMS cobrado por substituição tributária.Responsabilidade do recolhimento do ICMS atribuído ao tomador ou 3º por ST xtw.WriteElementString("CST", cCodigoClasTribIcms); // 4 Campo-236 --> ICMS Outros cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; dValor = Convert.ToDecimal(dAliquotaIcmsReducao); dAliquotaIcmsReducao = Convert.ToString(dValor); cTotal1 = dAliquotaIcmsReducao.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("pRedBC", cTotal4); // 4 Campo-237 --> Percentual de redução da BC. cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; dValor = Convert.ToDecimal(dValorBaseIcmsReducao); dValorBaseIcmsReducao = Convert.ToString(dValor); cTotal1 = dValorBaseIcmsReducao.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("vBC", cTotal4); // 4 Campo-238 --> Valor da BC do ICMS. cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; dValor = Convert.ToDecimal(dAliquotaIcms1); dAliquotaIcms1 = Convert.ToString(dValor); cTotal1 = dAliquotaIcms1.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("pICMS", cTotal4); // 4 Campo-239 --> Aliquota do ICMS. cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; dValor = Convert.ToDecimal(dValorIcms1); dValorIcms1 = Convert.ToString(dValor); cTotal1 = dValorIcms1.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("vICMS", cTotal4); // 4 Campo-240 --> Valor do ICMS. cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; dValor = Convert.ToDecimal(dValorCreditoOrtPresumido1); dValorCreditoOrtPresumido1 = Convert.ToString(dValor); cTotal1 = dValorCreditoOrtPresumido1.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("vCred", cTotal4); // 4 Campo-241 --> Valor do Crédito outorgado/Presumido. xtw.WriteEndElement(); xtw.WriteEndElement(); xtw.WriteEndElement(); } if (cCodigoClasTribIcms == "90") { xtw.WriteStartElement("imp"); // 1 Campo-214 --> Informações relativas a impostos xtw.WriteStartElement("ICMS"); // 2 Campo-215 --> Informações relativas a Icms xtw.WriteStartElement("ICMSOutraUF"); // 3 Campo-242 --> ICMS devido à UF de origem da prestação, quando diferente da UF do emitente xtw.WriteElementString("CST", cCodigoClasTribIcms); // 4 Campo-243 --> ICMS Outros cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; dValor = Convert.ToDecimal(dAliquotaIcmsReducao); dAliquotaIcmsReducao = Convert.ToString(dValor); cTotal1 = dAliquotaIcmsReducao.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("pRedBCOutraUF", cTotal4); // 4 Campo-244 --> Percentual de redução da BC. cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; dValor = Convert.ToDecimal(dValorBaseIcmsReducao); dValorBaseIcmsReducao = Convert.ToString(dValor); cTotal1 = dValorBaseIcmsReducao.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("vBCOutraUF", cTotal4); // 4 Campo-245 --> Valor da BC do ICMS. cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; dValor = Convert.ToDecimal(dAliquotaIcms1); dAliquotaIcms1 = Convert.ToString(dValor); cTotal1 = dAliquotaIcms1.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("pICMSOutraUF", cTotal4); // 4 Campo-246 --> Aliquota do ICMS. cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; dValor = Convert.ToDecimal(dValorIcms1); dValorIcms1 = Convert.ToString(dValor); cTotal1 = dValorIcms1.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("vICMSOutraUF", cTotal4); // 4 Campo-247 --> Valor do ICMS devido outra UF. xtw.WriteEndElement(); xtw.WriteEndElement(); xtw.WriteEndElement(); } xtw.WriteStartElement("infCTeNorm"); // 1 Campo-252 --> Grupo de informações do CT-e Normal e Substituto xtw.WriteStartElement("infCarga"); // 2 Campo-253 --> Informações da Carga do CT-e if (dValorMercadoria != "0,00" && dValorMercadoria != "0" && dValorMercadoria != "") { cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; dValor = Convert.ToDecimal(dValorMercadoria); dValorMercadoria = Convert.ToString(dValor); cTotal1 = dValorMercadoria.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 12); cTotal3 = cTotal1.Substring(14, 2); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("vCarga", cTotal4); // 3 Campo-254 --> Valor total da carga. } if (cNaturezaCarga != "" && cNaturezaCarga != " ") { xtw.WriteElementString("proPred", cNaturezaCarga); // 3 Campo-255 --> Informar a descrição do produto predominante. } if (cOutrasCaracteristicas != "" && cOutrasCaracteristicas != " ") { xtw.WriteElementString("xOutCat", cOutrasCaracteristicas); // 3 Campo-256 --> Outras características da carga. } // xtw.WriteEndElement(); for (int c = 1; c <= aNumeroNota.Length - 1; c++) { if (aNumeroNota[c] != null) { xtw.WriteStartElement("infQ"); // 3 Campo-257 --> Informações de quantidades da Carga do CT-e. xtw.WriteElementString("cUnid", aCodigoUnidadeMedida[c]); // 4 Campo-258 --> Código da Unidade de Medida. xtw.WriteElementString("tpMed", aTipoMedida[c]); // 4 Campo-259 --> Tipo da Medida. cTotal1 = ""; cTotal2 = ""; cTotal3 = ""; cTotal4 = ""; dValor = 0; string cPeso; cPeso = Convert.ToString(aPesoNota[c]); cTotal1 = cPeso.PadLeft(16, '0'); cTotal2 = cTotal1.Substring(1, 10); cTotal3 = cTotal1.Substring(12, 4); cTotal2 = cTotal2.TrimStart('0'); if (cTotal2 == "") { cTotal2 = "0"; } cTotal4 = (cTotal2 + "." + cTotal3); xtw.WriteElementString("qCarga", cTotal4); // 4 Campo-260 --> Tipo da Medida. xtw.WriteEndElement(); xtw.WriteEndElement(); } } xtw.WriteStartElement("infDoc"); // 2 Campo-261 --> Informações dos documentos transportados pelo CT-e Opcional para Redespacho Intermediario e Serviço vinculado a multimodal. for (int c = 1; c <= aNumeroNota.Length - 1; c++) { if (aNumeroNota[c] != null) { xtw.WriteStartElement("infNFe"); // 3 Campo-297 --> Informações das NFe. xtw.WriteElementString("chave", aChaveAcesso[c]); // 4 Campo-298 --> Chave de acesso da NF-e. if (aPinNota[c] != "") { xtw.WriteElementString("PIN", aPinNota[c]); // 4 Campo-299 --> PIN SUFRAMA. } xtw.WriteEndElement(); } } xtw.WriteEndElement();
-
-
Nesse último for.
Bruno você me ajudou em um post com o título percorrendo um DataGrid. Eu não havia testado ainda, pois, estava desenvolvendo o escopo da rotina. Fui testar e deu um erro. Coloquei o erro no dropbox
https://www.dropbox.com/s/kxmhq252lk4errg/Captura%20de%20tela%202015-06-22%2022.42.28.png?dl=0
-
-
Boa tarde,
Por falta de retorno do usuário, esta thread será encerrada.
Caso seja necessário, por gentileza, abra uma thread nova.
Atenciosamente
Marcos Roberto de Souza Junior
Esse conteúdo e fornecido sem garantias de qualquer tipo, seja expressa ou implícita
MSDN Community Support
Por favor, lembre-se de Marcar como Resposta as respostas que resolveram o seu problema. Essa e uma maneira comum de reconhecer aqueles que o ajudaram e fazer com que seja mais fácil para os outros visitantes encontrarem a resolução mais tarde.