以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 筛选问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=161845) |
-- 作者:hongye -- 发布时间:2021/3/31 15:43:00 -- 筛选问题 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("开票导入查询窗口_开票主表").find("发票代码 = \'" & fpdm & "\'And 发票号码= \'" & fphm & "\'") If DataTables("开票导入查询窗口_发票明细").find("发票代码 = \'" & fpdm & "\'And 发票号码 = \'" & fphm & "\'And 行号 = \'" & ndList(i).Attributes("xh").value & "\'") Is Nothing Then Dim r As DataRow = DataTables("开票导入查询窗口_发票明细").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("发票代码") = fpdm r("发票号码") = 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("发票状态") = "无发票信息" Else r("发票状态") = sr("发票状态") sr("地址电话") = ghdwdzdh sr("开户银行及账号") = ghdwyhzh sr("备注") = bz sr("发票标识") = 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 在导入文件时,第一次导入代码没问题,如果再次按导入按钮时好的,但是关闭窗口后再次打开不知道为什么就会可以再次导入,求解 附上导入的文件
|
-- 作者:有点蓝 -- 发布时间:2021/3/31 15:45:00 -- 窗口表是不是没有加载数据,find改为sqlfind从后台查询 |
-- 作者:hongye -- 发布时间:2021/3/31 16:10:00 -- 是的,谢谢 |
-- 作者:hongye -- 发布时间:2021/3/31 16:26:00 -- 为什么还有部分的会重复,我本来就按照发票代码、发票号码和行号来筛选的? |
-- 作者:有点蓝 -- 发布时间:2021/3/31 16:40:00 -- sqlfind只能查询已经保存的数据,每一行添加后马上保存 |