IMPORTAR ARQUIVO XML NF-E

MOREIRA 19/04/2017 13:34:20
#473399
pequei um exemplo aqui,
estou fuçando para entender o processo.
1 - pegar a chave da nota.
preciso pegar a chave de acesso da nota

  Public Function arqList() As String()
Dim I As Long
Dim File As String
Dim dr As DialogResult = Me.OpenFileDialog1.ShowDialog()
I = 0
If (dr = System.Windows.Forms.DialogResult.OK) Then
[ô] Read the files

For Each File In OpenFileDialog1.FileNames
[ô] Create a PictureBox for each file, and add that file to the FlowLayoutPanel.
Try
If Not File = [Ô][Ô] Then
ReDim Preserve a_arqListAs(I)
a_arqListAs(I) = File
I = I + 1
End If
Catch SecEx As SecurityException
[ô] The user lacks appropriate permissions to read files, discover paths, etc.
MessageBox.Show([Ô]Erro de segurança Contate o administrador de segurança da rede.

[Ô] &
[Ô]Mensagem : [Ô] & SecEx.Message & [Ô]

[Ô] &
[Ô]Detalhes (enviar ao suporte):

[Ô] & SecEx.StackTrace)
Catch ex As Exception
[ô] Could not load the image - probably permissions-related.
MessageBox.Show(([Ô]Não é possível exibir a imagem : [Ô] & File.Substring(File.LastIndexOf([Ô]\[Ô]c)) &
[Ô]. Você pode não ter permissão para ler o arquivo , ou [Ô] + [Ô]ele pode estar corrompido[Ô] _
& ControlChars.Lf & ControlChars.Lf & [Ô]Erro reportado: [Ô] & ex.Message))
End Try
Next File
End If
Return a_arqListAs
End Function


DS2T 19/04/2017 13:47:23
#473400
Tente usar o XmlDocument, fica facinho pegar as tags por ele.
MOREIRA 19/04/2017 14:55:42
#473401
Citação:

:
Tente usar o XmlDocument, fica facinho pegar as tags por ele.



  Dim docXML As New XmlDocument
OpenFileDialog1.InitialDirectory = Application.StartupPath & [Ô]\SCI[Ô]
OpenFileDialog1.ShowDialog()


primeiro passo.
KERPLUNK 19/04/2017 17:22:03
#473408
O que você quer é o processo de desserialização, tenho um vídeo mostrando isso.
JOHNSTEVE 19/04/2017 18:54:27
#473414
Resposta escolhida
Citação:

:
O que você quer é o processo de desserialização, tenho um vídeo mostrando isso.



MOREIRA, faça Desserialização. muito mais fácil e sem complicação. comece na video aula do amigo Kerplunk.
e o resto agente vai ajudando aqui nas tags.

vou te passar as funções.

  Private Sub Ler_XML_Deserializacao() [ô]metodo OOP - Kerplunk
If txtArquivo.Text = [Ô][Ô] Then
MsgBox([Ô]Localize o Arquivo XMl para Importação[Ô])
Else
[ô] btn_importar_ClickExtracted()

Dim ser As New XmlSerializer(GetType(Ler_XML_NFe.nfeProc))
Dim textReader As TextReader = DirectCast(New StreamReader(txtArquivo.Text), TextReader)
Dim reader As New XmlTextReader(textReader)
reader.Read()

Dim nota As Ler_XML_NFe.nfeProc = DirectCast(ser.Deserialize(reader), Ler_XML_NFe.nfeProc)

txt_Numero_NotaFiscal.Text = nota.NFe.infNFe.ide.nNF
txt_Serie.Text = nota.NFe.infNFe.ide.serie
txt_Modelo.Text = nota.NFe.infNFe.ide.mod
txt_NaturezaOperacao.Text = nota.NFe.infNFe.ide.natOp
mkb_DataEmissao.Text = CDate(nota.NFe.infNFe.ide.dhEmi)
txt_Logradouro_Emitente.Text = nota.NFe.infNFe.emit.enderEmit.xLgr
txt_Cidade_Emitente.Text = nota.NFe.infNFe.emit.enderEmit.xMun
txt_UF_Emitente.Text = nota.NFe.infNFe.emit.enderEmit.UF
txt_Cep_Emitente.Text = nota.NFe.infNFe.emit.enderEmit.CEP


assim ja da para vc começar a entender.
qualquer duvida vai postando q agente vai ajudando
JOHNSTEVE 19/04/2017 19:00:14
#473415
Citação:

:
O que você quer é o processo de desserialização, tenho um vídeo mostrando isso.



MOREIRA, faça Desserialização. muito mais fácil e sem complicação. comece na video aula do amigo Kerplunk.
e o resto agente vai ajudando aqui nas tags.

vou te passar as funções.

  Private Sub Ler_XML_Deserializacao() [ô]metodo OOP - Kerplunk
If txtArquivo.Text = [Ô][Ô] Then
MsgBox([Ô]Localize o Arquivo XMl para Importação[Ô])
Else
[ô] btn_importar_ClickExtracted()

Dim ser As New XmlSerializer(GetType(Ler_XML_NFe.nfeProc))
Dim textReader As TextReader = DirectCast(New StreamReader(txtArquivo.Text), TextReader)
Dim reader As New XmlTextReader(textReader)
reader.Read()

Dim nota As Ler_XML_NFe.nfeProc = DirectCast(ser.Deserialize(reader), Ler_XML_NFe.nfeProc)

txt_Numero_NotaFiscal.Text = nota.NFe.infNFe.ide.nNF
txt_Serie.Text = nota.NFe.infNFe.ide.serie
txt_Modelo.Text = nota.NFe.infNFe.ide.mod
txt_NaturezaOperacao.Text = nota.NFe.infNFe.ide.natOp
mkb_DataEmissao.Text = CDate(nota.NFe.infNFe.ide.dhEmi)
txt_Logradouro_Emitente.Text = nota.NFe.infNFe.emit.enderEmit.xLgr
txt_Cidade_Emitente.Text = nota.NFe.infNFe.emit.enderEmit.xMun
txt_UF_Emitente.Text = nota.NFe.infNFe.emit.enderEmit.UF
txt_Cep_Emitente.Text = nota.NFe.infNFe.emit.enderEmit.CEP


assim ja da para vc começar a entender.
qualquer duvida vai postando q agente vai ajudando
FUTURA 19/04/2017 22:32:45
#473418
John, neste exemplo que vc postou fica bem simples, pegando os campos específicos, mas como ficaria para pegar os produtos e seus respectivos impostos?. acho que essa é a duvida da maioria....
MOREIRA 19/04/2017 22:41:08
#473419
Citação:

:
John, neste exemplo que vc postou fica bem simples, pegando os campos específicos, mas como ficaria para pegar os produtos e seus respectivos impostos?. acho que essa é a duvida da maioria....



Boa pergunta. Futura !!!
KERPLUNK 19/04/2017 22:50:17
#473420
Citação:

:
John, neste exemplo que vc postou fica bem simples, pegando os campos específicos, mas como ficaria para pegar os produtos e seus respectivos impostos?. acho que essa é a duvida da maioria....


Os produtos, são nada mais nada menos que ítens da nota. Navegue pelo objeto(usando o Object Browser) e vai ver os produtos lá.
MOREIRA 19/04/2017 23:19:02
#473421
erro ao usar paste especial - pasta xml as classe

o exemplo do vídeo é em C#, mas estou usando vb.net.


NILSONTRES 20/04/2017 08:50:54
#473423
For I = 0 To Nota.NFe.infNFe.det.Count - 1
Dim V_vProd As Double = Format(CType(Replace(Nota.NFe.infNFe.det(I).prod.vProd, [Ô].[Ô], [Ô],[Ô]), Double))
[ô]**GRID2
GRID_ITENS2.Rows.Add()
GRID_ITENS2.Rows(I).Cells(ICODCORRES2.Name).Value = [Ô]COD.CORRES[Ô]
GRID_ITENS2.Rows(I).Cells(IITEM2.Name).Value = I + 1
GRID_ITENS2.Rows(I).Cells(ICODPROD2.Name).Value = Nota.NFe.infNFe.det(I).prod.cProd
GRID_ITENS2.Rows(I).Cells(ICODBARRAS2.Name).Value = Nota.NFe.infNFe.det(I).prod.cEAN
GRID_ITENS2.Rows(I).Cells(IDESCRICAO2.Name).Value = Nota.NFe.infNFe.det(I).prod.xProd.ToUpper

[ô]**GRIDITENS
GRID_ITENS.Rows.Add()
GRID_ITENS.Rows(I).Cells(IDESC.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(ITOT.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvBC_ICMS.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpICMS.Name).Value = [Ô]0[Ô]
GRID_ITENS.Rows(I).Cells(IpRedBC.Name).Value = [Ô]0[Ô]
GRID_ITENS.Rows(I).Cells(IpMVAST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvBCST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvICMSST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpICMSST.Name).Value = [Ô]0[Ô]
GRID_ITENS.Rows(I).Cells(IvCredICMSSN.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpCredSN.Name).Value = [Ô]0[Ô]
GRID_ITENS.Rows(I).Cells(IvBC_COFINS.Name).Value = [Ô]0[Ô]
GRID_ITENS.Rows(I).Cells(IvCOFINS.Name).Value = [Ô]0[Ô]
GRID_ITENS.Rows(I).Cells(IpCOFINS.Name).Value = [Ô]0[Ô]
GRID_ITENS.Rows(I).Cells(IvBC_PIS.Name).Value = [Ô]0[Ô]
GRID_ITENS.Rows(I).Cells(IvPIS.Name).Value = [Ô]0[Ô]
GRID_ITENS.Rows(I).Cells(IpPIS.Name).Value = [Ô]0[Ô]
GRID_ITENS.Rows(I).Cells(IpIPI.Name).Value = [Ô]0[Ô]
GRID_ITENS.Rows(I).Cells(IvBC_IPI.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvIPI.Name).Value = [Ô]0[Ô]


GRID_ITENS.Rows(I).Cells(ICODCORRES.Name).Value = [Ô]COD.CORRES[Ô]
GRID_ITENS.Rows(I).Cells(IITEM.Name).Value = I + 1
GRID_ITENS.Rows(I).Cells(ICODPROD.Name).Value = Nota.NFe.infNFe.det(I).prod.cProd
GRID_ITENS.Rows(I).Cells(ICODBARRAS.Name).Value = Nota.NFe.infNFe.det(I).prod.cEAN
GRID_ITENS.Rows(I).Cells(IDESCRICAO.Name).Value = Nota.NFe.infNFe.det(I).prod.xProd.ToUpper
GRID_ITENS.Rows(I).Cells(INCM.Name).Value = Nota.NFe.infNFe.det(I).prod.NCM

[ô]***********ICMS
[ô]**ICMS00
If Not Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS00 Is Nothing Then
GRID_ITENS.Rows(I).Cells(ICST.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS00.CST
GRID_ITENS.Rows(I).Cells(IvBC_ICMS.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS00.vBC
GRID_ITENS.Rows(I).Cells(IpICMS.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS00.pICMS
GRID_ITENS.Rows(I).Cells(IvICMS.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS00.vICMS
GRID_ITENS.Rows(I).Cells(IpRedBC.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpMVAST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvBCST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvICMSST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpICMSST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvCredICMSSN.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpCredSN.Name).Value = [Ô]0,00[Ô]
End If
[ô]**ICMS10
If Not Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS10 Is Nothing Then
GRID_ITENS.Rows(I).Cells(ICST.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS10.CST
GRID_ITENS.Rows(I).Cells(IvBC_ICMS.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS10.vBC
GRID_ITENS.Rows(I).Cells(IpICMS.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS10.pICMS
GRID_ITENS.Rows(I).Cells(IvICMS.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS10.vICMS
GRID_ITENS.Rows(I).Cells(IpRedBC.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpMVAST.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS10.pMVAST
GRID_ITENS.Rows(I).Cells(IvBCST.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS10.vBCST
GRID_ITENS.Rows(I).Cells(IpICMSST.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS10.pICMSST [ô]pICMSST
GRID_ITENS.Rows(I).Cells(IvICMSST.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS10.vICMSST
GRID_ITENS.Rows(I).Cells(IvCredICMSSN.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpCredSN.Name).Value = [Ô]0,00[Ô]
End If
[ô]**ICMS20
If Not Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS20 Is Nothing Then
GRID_ITENS.Rows(I).Cells(ICST.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS20.CST
GRID_ITENS.Rows(I).Cells(IvBC_ICMS.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS20.vBC
GRID_ITENS.Rows(I).Cells(IpICMS.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS20.pICMS
GRID_ITENS.Rows(I).Cells(IvICMS.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS20.vICMS
GRID_ITENS.Rows(I).Cells(IpRedBC.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS20.pRedBC
GRID_ITENS.Rows(I).Cells(IpMVAST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvBCST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpICMSST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvICMSST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvCredICMSSN.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpCredSN.Name).Value = [Ô]0,00[Ô]
End If
[ô]**ICMS30
If Not Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS30 Is Nothing Then
GRID_ITENS.Rows(I).Cells(ICST.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS30.CST
GRID_ITENS.Rows(I).Cells(IpMVAST.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS30.pMVAST
GRID_ITENS.Rows(I).Cells(IvBCST.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS30.vBCST
GRID_ITENS.Rows(I).Cells(IpICMSST.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS30.pICMSST
GRID_ITENS.Rows(I).Cells(IvICMSST.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS30.vICMSST
GRID_ITENS.Rows(I).Cells(IvICMS.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvBC_ICMS.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpRedBC.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpICMS.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvCredICMSSN.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpCredSN.Name).Value = [Ô]0,00[Ô]
End If
[ô]**ICMS40
If Not Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS40 Is Nothing Then
GRID_ITENS.Rows(I).Cells(ICST.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS40.CST
GRID_ITENS.Rows(I).Cells(IpMVAST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvBCST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpICMSST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvICMSST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvICMS.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvBC_ICMS.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpRedBC.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpICMS.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvCredICMSSN.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpCredSN.Name).Value = [Ô]0,00[Ô]
End If
[ô]**ICMS51
If Not Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS51 Is Nothing Then
GRID_ITENS.Rows(I).Cells(ICST.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS51.CST
GRID_ITENS.Rows(I).Cells(IpRedBC.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS51.pRedBC
GRID_ITENS.Rows(I).Cells(IvBC_ICMS.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS51.vBC
GRID_ITENS.Rows(I).Cells(IpICMS.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS51.pICMS
GRID_ITENS.Rows(I).Cells(IvICMS.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS51.vICMS
GRID_ITENS.Rows(I).Cells(IpMVAST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvBCST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpICMSST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvICMSST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvCredICMSSN.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpCredSN.Name).Value = [Ô]0,00[Ô]
End If
[ô]**ICMS60
If Not Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS60 Is Nothing Then
GRID_ITENS.Rows(I).Cells(ICST.Name).Value = Nota.NFe.infNFe.det(I).imposto.ICMS.ICMS60.CST
GRID_ITENS.Rows(I).Cells(IpMVAST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvBCST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpICMSST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvICMSST.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvICMS.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvBC_ICMS.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpRedBC.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpICMS.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IvCredICMSSN.Name).Value = [Ô]0,00[Ô]
GRID_ITENS.Rows(I).Cells(IpCredSN.Name).Value = [Ô]0,00
Página 1 de 2 [12 registro(s)]
Tópico encerrado , respostas não são mais permitidas