For Each f As String In FileSys.GetFiles(dzml2)
If f.EndsWith(".log") Then
Dim txt As String = FileSys.ReadAllText(f, Encoding.Default)
Dim idx As Integer = txt.IndexOf("<?xml version")
Dim idx2 As Integer = txt.IndexOf("</business>",idx)
Do While idx > -1 And idx2 > -1
Dim s2 As String = txt.SubString(idx,idx2-idx+11)
idx = txt.IndexOf("<?xml version",idx2)
If idx > -1
idx2 = txt.IndexOf("</business>",idx)
Else
idx2=-1
End If
Dim xmlDoc As New System.XML.XmlDocument
xmlDoc.Loadxml(s2)
Dim ndList1 = xmlDoc.GetElementsByTagName("kpxx")
If ndList1.count > 0
Dim ndList3 = ndList1(0).ChildNodes
Dim fpdm As String
Dim fphm As String
Dim ghdwmc As String
Dim ghdwdzdh As String
Dim ghdwsbh As String
Dim ghdwyhzh As String
Dim xhdwmc As String
Dim bz As String
For s As Integer = 0 To ndList3.count - 1
If ndList3(s).Item("fpdm") IsNot Nothing Then fpdm = ndList3(s).Item("fpdm").InnerText
If ndList3(s).Item("fphm") IsNot Nothing Then fphm = ndList3(s).Item("fphm").InnerText
If ndList3(s).Item("ghdwmc") IsNot Nothing Then ghdwmc = ndList3(s).Item("ghdwmc").InnerText
If ndList3(s).Item("ghdwdzdh") IsNot Nothing Then ghdwdzdh = ndList3(s).Item("ghdwdzdh").InnerText
If ndList3(s).Item("ghdwsbh") IsNot Nothing Then ghdwsbh = ndList3(s).Item("ghdwsbh").InnerText
If ndList3(s).Item("ghdwyhzh") IsNot Nothing Then ghdwyhzh = ndList3(s).Item("ghdwyhzh").InnerText
If ndList3(s).Item("xhdwmc") IsNot Nothing Then xhdwmc = ndList3(s).Item("xhdwmc").InnerText
If ndList3(s).Item("bz") IsNot Nothing Then bz = ndList3(s).Item("bz").InnerText
Dim ndList2 = xmlDoc.GetElementsByTagName("fyxm")
Dim ndList = ndList2(0).ChildNodes
For i As Integer = 0 To ndList.count - 1
Dim sr As DataRow = DataTables("开piao导入查询窗口_开piao主表").find("fa piao代码 = '" & fpdm & "'And fa piao号码= '" & fphm & "'")
If DataTables("开piao导入查询窗口_fa piao明细").find("fa piao代码 = '" & fpdm & "'And fa piao号码 = '" & fphm & "'And 行号 = '" & ndList(i).Attributes("xh").value & "'") Is Nothing Then
Dim r As DataRow = DataTables("开piao导入查询窗口_fa piao明细").addnew
Dim spmc As String = ndList(i).Item("spmc").InnerText
Dim ggxh As String = ndList(i).Item("ggxh").InnerText
Dim sl As String = ndList(i).Item("sl").InnerText
Dim se As String = ndList(i).Item("se").InnerText
Dim dw As String = ndList(i).Item("dw").InnerText
Dim spsl As String = ndList(i).Item("spsl").InnerText
Dim dj As String = ndList(i).Item("dj").InnerText
Dim zsl As String = ndList(i).Item("zsl").InnerText
Dim je As String = ndList(i).Item("je").InnerText
Dim fpxhh As String = ndList(i).Attributes("xh").value
r("fa piao代码") = fpdm
r("fa piao号码") = fphm
r("客户名称") = ghdwmc
r("货物或服务名称") = spmc
r("规格") = ggxh
r("单位") = dw
r("数量") = spsl
r("单价") = dj
r("税率") = Format(zsl,"Percent")
r("税额") = se
r("金额") = je
r("行号") = fpxhh
If sr Is Nothing Then
r("fa piao状态") = "无fa piao信息"
Else
r("fa piao状态") = sr("fa piao状态")
sr("地址电话") = ghdwdzdh
sr("开户银行及账号") = ghdwyhzh
sr("备注") = bz
sr("fa piao标识") = xhdwmc
If drt.SQLFind("客户名称 = '" & ghdwmc & "'and 税号 = '" & ghdwsbh & "'") Is Nothing Then
Dim ksr As DataRow = drt.Addnew
ksr("客户名称") = ghdwmc
ksr("税号") = ghdwsbh
ksr("地址电话") = ghdwdzdh
ksr("银行账号") = ghdwyhzh
drt.Save
drt.Load
End If
End If
r("文件名") = FileSys.GetName(f)
End If
Next
Next
End If
Loop
End If
Next
在导入文件时,第一次导入代码没问题,如果再次按导入按钮时好的,但是关闭窗口后再次打开不知道为什么就会可以再次导入,求解
附上导入的文件