Foxtable(狐表)用户栏目专家坐堂 → 关于XML的问题,初学,请发代码学习


  共有7618人关注过本帖树形打印复制链接

主题:关于XML的问题,初学,请发代码学习

帅哥哟,离线,有人找我吗?
hongyefor
  41楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/3/13 17:06:00 [只看该作者]

Dim db1 As WinForm.DropDownBox = e.Form.Controls("DropBox1")
Dim db2 As WinForm.DropDownBox = e.Form.Controls("DropBox2")
Dim dzml1 As String = db1.text
Dim dzml2 As String = db2.text
If dzml2 IsNot Nothing Then
    For Each f As String In FileSys.GetFiles(dzml2)
        If f.EndsWith(".xml") Then
            Dim txt As String = FileSys.ReadAllText(f, Encoding.utf8)
            Dim xmlDoc As New System.XML.XmlDocument
            xmlDoc.Loadxml(txt.Trim)
            Dim ndList  = xmlDoc.GetElementsByTagName("mxxx")
            For Each dr As object In ndlist
                Dim ndr As DataRow = DataTables("表b").find("fa piao代码 = '" & dr("fpdm").innertext  & "'And fa piao号码 = '" & dr("fphm").innertext  & "'")
                If ndr Is Nothing Then ndr = DataTables("表b").addnew
                For Each n As System.XML.XmlNode In dr.childNodes
                    output.show(n.Name & " = " & n.InnerText)
                    If n.name = "fpdm" Then
                        ndr("fa piao代码") = n.innertext
                    End If
                    If n.name = "fphm" Then
                        ndr("fa piao号码") = n.innertext
                    End If
                    If n.name = "gmfnsrsbh" Then
                        ndr("纳税人识别号") = n.innertext
                    End If
                    If n.name = "kprq" Then
                        Dim str = n.innertext
                        ndr("开piao日期") = str.SubString(0,4) + "-" + str.SubString(4,2) + "-" + str.SubString(6,2)
                    End If
                    If n.name = "je" Then
                        ndr("合计金额")  = n.innertext
                    End If
                    If n.name = "se" Then
                        ndr("合计税额") = n.innertext
                    End If
                    If n.name = "zfbz" Then
                        ndr("fa piao状态") = n.innertext
                    End If
                    ndr("价税合计") =val(ndr("合计税额"))+ val(ndr("合计金额"))
                    Dim ndrb1 As DataRow = DataTables("表c").find("税号 = '" &  ndr("纳税人识别号") & "'")
                    If ndrb1 IsNot Nothing Then
                        ndr("客户名称") = ndrb1("名称")
                        ndr("地址电话") = ndrb1("地址电话")
                        ndr("开户银行及账号") = ndrb1("银行账号")
                    End If
                Next
            Next
        End If
    Next
End If
If dzml1 IsNot Nothing Then
    For Each f As String In FileSys.GetFiles(dzml1)
        If DataTables("表A").Find("文件名 = '" & f.SubString(f.Length - 25) & "'" ) Is Nothing Then
            Dim txt As String = FileSys.ReadAllText(f, Encoding.utf8)
            Dim xmlDoc As New System.XML.XmlDocument
            xmlDoc.Loadxml(txt.Trim)
            Dim ndList  = xmlDoc.GetElementsByTagName("Sph")
            For Each dr As object In ndlist
                Dim ndr As Row = Tables("表A").addnew
                For Each n As System.XML.XmlNode In dr.childNodes
                    output.show(n.Name & " = " & n.InnerText)
                    If n.name = "Spmc" Then
                        ndr("货物或服务名称") = n.innertext
                    End If
                    If n.name = "Ggxh" Then
                        ndr("规格") = n.innertext
                    End If
                    If n.name = "Jldw" Then
                        ndr("单位") = n.innertext
                    End If
                    If n.name = "Dj" Then
                        ndr("单价") = n.innertext
                    End If
                    If n.name = "sl" Then
                        ndr("数量") = val(n.innertext)
                    End If
                    If n.name = "Je" Then
                        ndr("金额") = n.innertext
                    End If
                    If n.name = "Slv" Then
                        ndr("税率") = n.innertext
                    End If
                    If n.name = "Kce" Then
                        ndr("税额") = n.innertext
                    End If
                    Dim str = f.SubString(f.Length - 25)
                    Dim ary = str.split("_")
                    ndr("文件名") = str
                    ndr("fa piao代码") = ary(0)
                    ndr("fa piao号码") = ary(1)
                    Dim ndrb2 As DataRow = DataTables("表b").find("fa piao代码 = '" &  ndr("fa piao代码")  & "'And fa piao号码 = '" & ndr("fa piao号码") & "'")
                    ndrb2("文件名") = ndr("文件名")
                    ndr("fa piao状态") = ndrb2("fa piao状态")
                    ndr("客户名称") = ndrb2("客户名称")
                Next
            Next
        End If
    Next
End If
If DataTables("表A").HasChanges Then
    DataTables("表B").Save
    DataTables("表A").Save
    MessageBox.Show("fa piao数据导入完成")
Else
    MessageBox.Show("没有导入任何fa piao数据")
End If

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  42楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/3/13 17:07:00 [只看该作者]

报错是因为你路径没有写对导致的。我用下面代码测试没问题

 

'Dim db4 As WinForm.DropDownBox = e.Form.Controls("DropBox4")
'Dim db5 As WinForm.DropDownBox = e.Form.Controls("DropBox5")
Dim dzml4 As String = "C:\Users\dv rrxaI600 007\Downloads\signlog\SignLog\20170606" 'db4.text
'Dim dzml5 As String = db5.text
If dzml4 IsNot Nothing Then
    Tables("表A").StopRedraw
    For Each f As String In FileSys.GetFiles(dzml4)
        If f.EndsWith("_verifysign.log") Then
            If DataTables("表B").Find("文件名 = '" & f & "'" ) Is Nothing Then
                Dim txt As String = FileSys.ReadAllText(f, Encoding.Default)
                Dim idx As Integer = txt.IndexOf("</business>")
               
                Dim s1 As String = txt.SubString(0, idx+11)
                Dim s2 As String = txt.SubString(idx+12)
                Dim xmlDoc As New System.XML.XmlDocument
                xmlDoc.Loadxml(s1)
               
                Dim ndList  = xmlDoc.GetElementsByTagName("input")
                Dim kprq As String
                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 hjje As String
                Dim hjse As String
                Dim jshj As String
                Dim bz As String
                Dim fpzt As String
                For i As Integer = 0 To ndList.count - 1
                    If ndList(i).Item("kprq") IsNot Nothing Then kprq = ndList(i).Item("kprq").InnerText
                    If ndList(i).Item("fpdm") IsNot Nothing Then fpdm = ndList(i).Item("fpdm").InnerText
                    If ndList(i).Item("fphm") IsNot Nothing Then fphm = ndList(i).Item("fphm").InnerText
                    If ndList(i).Item("ghdwmc") IsNot Nothing Then ghdwmc = ndList(i).Item("ghdwmc").InnerText
                    If ndList(i).Item("ghdwdzdh") IsNot Nothing Then ghdwdzdh = ndList(i).Item("ghdwdzdh").InnerText
                    If ndList(i).Item("ghdwsbh") IsNot Nothing Then ghdwsbh = ndList(i).Item("ghdwsbh").InnerText
                    If ndList(i).Item("ghdwyhzh") IsNot Nothing Then ghdwyhzh = ndList(i).Item("ghdwyhzh").InnerText
                    If ndList(i).Item("hjje") IsNot Nothing Then hjje = ndList(i).Item("hjje").InnerText
                    If ndList(i).Item("hjse") IsNot Nothing Then hjse = ndList(i).Item("hjse").InnerText
                    If ndList(i).Item("jshj") IsNot Nothing Then jshj = ndList(i).Item("jshj").InnerText
                    If ndList(i).Item("bz") IsNot Nothing Then bz = ndList(i).Item("bz").InnerText
                    If ndList(i).Item("fpzt") IsNot Nothing Then fpzt = ndList(i).Item("fpzt").InnerText
                Next
                If fphm <> Nothing Then
                    Dim ndr As DataRow = DataTables("表b").addnew
                    ndr("开piao日期") = kprq.SubString(0,4) + "-" + kprq.SubString(4,2) + "-" + kprq.SubString(6,2)
                    ndr("fa piao代码") = fpdm
                    ndr("fa piao号码") = fphm
                    ndr("客户名称") =ghdwmc
                    ndr("地址电话") =ghdwdzdh
                    ndr("纳税人识别号") = ghdwsbh
                    ndr("开户银行及账号") = ghdwyhzh
                    ndr("合计金额") = hjje
                    ndr("合计税额") = hjse
                    ndr("价税合计") = jshj
                    ndr("备注") = bz
                    ndr("fa piao状态") = fpzt
                    ndr("文件名") = f
                    ndList = xmlDoc.GetElementsByTagName("fyxm")(0).ChildNodes
                    For i As Integer = 0 To ndList.count - 1
                        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 je As String = ndList(i).Item("je").InnerText
                        Dim r As Row = Tables("表A").AddNew
                        r("fa piao代码") = fpdm
                        r("fa piao号码") = fphm
                        r("客户名称") = ghdwmc
                        r("货物或服务名称") = spmc
                        r("规格") = ggxh
                        r("单位") = dw
                        r("数量") = val(spsl)
                        r("单价") = dj
                        r("税率") = sl
                        r("税额") = se
                        r("金额") = je
                        r("fa piao状态") = fpzt
                    Next
                End If
            End If
        End If
    Next
    Tables("表A").ResumeRedraw
    DataTables("表b").DeleteFor("fa piao状态 = '2'")
    For Each s As String In DataTables("表A").GetValues("fa piao号码", "fa piao状态 = '3'")
        DataTables("表A").DeleteFor("fa piao号码 = '" & s & "' and fa piao状态 = '0'")
    Next
    For Each s1 As String In DataTables("表b").GetValues("fa piao号码", "fa piao状态 = '3'")
        DataTables("表b").DeleteFor("fa piao号码 = '" & s1 & "' and fa piao状态 = '0'")
    Next
End If


 回到顶部
帅哥哟,离线,有人找我吗?
hongyefor
  43楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/3/13 17:08:00 [只看该作者]

.NET Framework 版本:2.0.50727.8800
Foxtable 版本:2018.10.9.1
错误所在事件:窗口,窗口1,Button1,Click
详细错误信息:
路径的形式不合法。

 

可以导入一半的数据,接下来错误


 回到顶部
帅哥哟,离线,有人找我吗?
hongyefor
  44楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/3/13 17:16:00 [只看该作者]

 For Each dir As String In FileSys.GetDirectories(dzml4)

现在加了这个代码,前期不报错,但中期又报错了


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  45楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/3/13 17:33:00 [只看该作者]

Dim dzml4 As String = "C:\Users\dv rrxaI600 007\Downloads\signlog\SignLog\"
If dzml4 IsNot Nothing Then
    Tables("表A").StopRedraw
    For Each dir As String In FileSys.GetDirectories(dzml4)
        For Each f As String In FileSys.GetFiles(dir)
            If f.EndsWith("_verifysign.log") Then
                Dim str = f.SubString(f.Length - 38)
                If DataTables("表B").Find("文件名 = '" & str & "'" ) Is Nothing Then
                    Dim txt As String = FileSys.ReadAllText(f, Encoding.Default)
                    Dim idx As Integer = txt.IndexOf("</business>")
                   
                    Dim s1 As String = txt.SubString(0, idx+11)
                    Dim s2 As String = txt.SubString(idx+12)
                    Dim xmlDoc As New System.XML.XmlDocument
                    xmlDoc.Loadxml(s1)
                   
                    Dim ndList  = xmlDoc.GetElementsByTagName("input")
                    Dim kprq As String
                    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 hjje As String
                    Dim hjse As String
                    Dim jshj As String
                    Dim bz As String
                    Dim fpzt As String
                    For i As Integer = 0 To ndList.count - 1
                        If ndList(i).Item("kprq") IsNot Nothing Then kprq = ndList(i).Item("kprq").InnerText
                        If ndList(i).Item("fpdm") IsNot Nothing Then fpdm = ndList(i).Item("fpdm").InnerText
                        If ndList(i).Item("fphm") IsNot Nothing Then fphm = ndList(i).Item("fphm").InnerText
                        If ndList(i).Item("ghdwmc") IsNot Nothing Then ghdwmc = ndList(i).Item("ghdwmc").InnerText
                        If ndList(i).Item("ghdwdzdh") IsNot Nothing Then ghdwdzdh = ndList(i).Item("ghdwdzdh").InnerText
                        If ndList(i).Item("ghdwsbh") IsNot Nothing Then ghdwsbh = ndList(i).Item("ghdwsbh").InnerText
                        If ndList(i).Item("ghdwyhzh") IsNot Nothing Then ghdwyhzh = ndList(i).Item("ghdwyhzh").InnerText
                        If ndList(i).Item("hjje") IsNot Nothing Then hjje = ndList(i).Item("hjje").InnerText
                        If ndList(i).Item("hjse") IsNot Nothing Then hjse = ndList(i).Item("hjse").InnerText
                        If ndList(i).Item("jshj") IsNot Nothing Then jshj = ndList(i).Item("jshj").InnerText
                        If ndList(i).Item("bz") IsNot Nothing Then bz = ndList(i).Item("bz").InnerText
                        If ndList(i).Item("fpzt") IsNot Nothing Then fpzt = ndList(i).Item("fpzt").InnerText
                    Next
                    If fphm <> Nothing Then
                        Dim ndr As DataRow = DataTables("表b").addnew
                        ndr("开piao日期") = kprq.SubString(0,4) + "-" + kprq.SubString(4,2) + "-" + kprq.SubString(6,2)
                        ndr("fa piao代码") = fpdm
                        ndr("fa piao号码") = fphm
                        ndr("客户名称") =ghdwmc
                        ndr("地址电话") =ghdwdzdh
                        ndr("纳税人识别号") = ghdwsbh
                        ndr("开户银行及账号") = ghdwyhzh
                        ndr("合计金额") = hjje
                        ndr("合计税额") = hjse
                        ndr("价税合计") = jshj
                        ndr("备注") = bz
                        ndr("fa piao状态") = fpzt
                       
                        ndr("文件名") = str
                        ndList = xmlDoc.GetElementsByTagName("fyxm")(0).ChildNodes
                        For i As Integer = 0 To ndList.count - 1
                            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 je As String = ndList(i).Item("je").InnerText
                            Dim r As Row = Tables("表A").AddNew
                            r("fa piao代码") = fpdm
                            r("fa piao号码") = fphm
                            r("客户名称") = ghdwmc
                            r("货物或服务名称") = spmc
                            r("规格") = ggxh
                            r("单位") = dw
                            r("数量") = val(spsl)
                            r("单价") = dj
                            r("税率") = sl
                            r("税额") = se
                            r("金额") = je
                            r("fa piao状态") = fpzt
                            ndr("文件名") = str
                        Next
                    End If
                End If
            End If
        Next
    Next
    Tables("表A").ResumeRedraw
    DataTables("表b").DeleteFor("fa piao状态 = '2'")
    For Each s As String In DataTables("表A").GetValues("fa piao号码", "fa piao状态 = '3'")
        DataTables("表A").DeleteFor("fa piao号码 = '" & s & "' and fa piao状态 = '0'")
    Next
    For Each s1 As String In DataTables("表b").GetValues("fa piao号码", "fa piao状态 = '3'")
        DataTables("表b").DeleteFor("fa piao号码 = '" & s1 & "' and fa piao状态 = '0'")
    Next
End If

 回到顶部
帅哥哟,离线,有人找我吗?
hongyefor
  46楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/3/13 17:41:00 [只看该作者]

我把项目发上来你看看

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:foxtable项目.rar


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  47楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/3/13 18:27:00 [只看该作者]

请自己单独执行45楼代码。认认真真测试。

 回到顶部
帅哥哟,离线,有人找我吗?
hongyefor
  48楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/3/13 19:10:00 [只看该作者]

Dim db4 As WinForm.DropDownBox = e.Form.Controls("DropBox4")
Dim db5 As WinForm.DropDownBox = e.Form.Controls("DropBox5")
Dim dzml4 As String = db4.text
Dim dzml5 As String = db5.text
If dzml4 IsNot Nothing Then
    Tables("表A").StopRedraw
    For Each dir As String In FileSys.GetDirectories(dzml4)
        For Each f As String In FileSys.GetFiles(dir)
            If f.EndsWith("_verifysign.log") Then
                If DataTables("表B").Find("文件名 = '" & f.SubString(f.Length - 38) & "'"  ) Is Nothing Then
                    Dim txt As String = FileSys.ReadAllText(f, Encoding.Default)
                    Dim idx As Integer = txt.IndexOf("</business>")
                   
                    Dim s1 As String = txt.SubString(0, idx+11)
                    Dim s2 As String = txt.SubString(idx+12)
                    Dim xmlDoc As New System.XML.XmlDocument
                    xmlDoc.Loadxml(s1)
                   
                    Dim ndList  = xmlDoc.GetElementsByTagName("input")
                    Dim kprq As String
                    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 hjje As String
                    Dim hjse As String
                    Dim jshj As String
                    Dim bz As String
                    Dim fpzt As String
                    For i As Integer = 0 To ndList.count - 1
                        If ndList(i).Item("kprq") IsNot Nothing Then kprq = ndList(i).Item("kprq").InnerText
                        If ndList(i).Item("fpdm") IsNot Nothing Then fpdm = ndList(i).Item("fpdm").InnerText
                        If ndList(i).Item("fphm") IsNot Nothing Then fphm = ndList(i).Item("fphm").InnerText
                        If ndList(i).Item("ghdwmc") IsNot Nothing Then ghdwmc = ndList(i).Item("ghdwmc").InnerText
                        If ndList(i).Item("ghdwdzdh") IsNot Nothing Then ghdwdzdh = ndList(i).Item("ghdwdzdh").InnerText
                        If ndList(i).Item("ghdwsbh") IsNot Nothing Then ghdwsbh = ndList(i).Item("ghdwsbh").InnerText
                        If ndList(i).Item("ghdwyhzh") IsNot Nothing Then ghdwyhzh = ndList(i).Item("ghdwyhzh").InnerText
                        If ndList(i).Item("hjje") IsNot Nothing Then hjje = ndList(i).Item("hjje").InnerText
                        If ndList(i).Item("hjse") IsNot Nothing Then hjse = ndList(i).Item("hjse").InnerText
                        If ndList(i).Item("jshj") IsNot Nothing Then jshj = ndList(i).Item("jshj").InnerText
                        If ndList(i).Item("bz") IsNot Nothing Then bz = ndList(i).Item("bz").InnerText
                        If ndList(i).Item("fpzt") IsNot Nothing Then fpzt = ndList(i).Item("fpzt").InnerText
                    Next
                    If fphm <> Nothing Then
                        Dim ndr As DataRow = DataTables("表b").addnew
                        ndr("开piao日期") = kprq.SubString(0,4) + "-" + kprq.SubString(4,2) + "-" + kprq.SubString(6,2)
                        ndr("fa piao代码") = fpdm
                        ndr("fa piao号码") = fphm
                        ndr("客户名称") =ghdwmc
                        ndr("地址电话") =ghdwdzdh
                        ndr("纳税人识别号") = ghdwsbh
                        ndr("开户银行及账号") = ghdwyhzh
                        ndr("合计金额") = hjje
                        ndr("合计税额") = hjse
                        ndr("价税合计") = jshj
                        ndr("备注") = bz
                        ndr("fa piao状态") = fpzt
                        Dim str = f.SubString(f.Length - 38)
                        ndr("文件名") = str
                        ndList = xmlDoc.GetElementsByTagName("fyxm")(0).ChildNodes
                        For i As Integer = 0 To ndList.count - 1
                            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 je As String = ndList(i).Item("je").InnerText
                            Dim r As Row = Tables("表A").AddNew
                            r("fa piao代码") = fpdm
                            r("fa piao号码") = fphm
                            r("客户名称") = ghdwmc
                            r("货物或服务名称") = spmc
                            r("规格") = ggxh
                            r("单位") = dw
                            r("数量") = spsl
                            r("单价") = dj
                            r("税率") = sl
                            r("税额") = se
                            r("金额") = je
                            r("fa piao状态") = fpzt
                            r("文件名") = str
                        Next
                    End If
                End If
            End If
        Next
    Next
    Tables("表A").ResumeRedraw
    DataTables("表b").DeleteFor("fa piao状态 = '2'")
    For Each s As String In DataTables("表A").GetValues("fa piao号码", "fa piao状态 = '3'")
        DataTables("表A").DeleteFor("fa piao号码 = '" & s & "' and fa piao状态 = '0'")
    Next
    For Each s1 As String In DataTables("表b").GetValues("fa piao号码", "fa piao状态 = '3'")
        DataTables("表b").DeleteFor("fa piao号码 = '" & s1 & "' and fa piao状态 = '0'")
    Next
End If
If DataTables("表A").HasChanges Then
    DataTables("表B").Save
    DataTables("表A").Save
    MessageBox.Show("fa piao数据导入完成")
Else
    MessageBox.Show("没有导入任何fa piao数据")
End If

 回到顶部
帅哥哟,离线,有人找我吗?
hongyefor
  49楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/3/13 19:10:00 [只看该作者]

Dim db1 As WinForm.DropDownBox = e.Form.Controls("DropBox1")
Dim db2 As WinForm.DropDownBox = e.Form.Controls("DropBox2")
Dim dzml1 As String = db1.text
Dim dzml2 As String = db2.text
If dzml2 IsNot Nothing Then
    For Each f As String In FileSys.GetFiles(dzml2)
        If f.EndsWith(".xml") Then
            Dim txt As String = FileSys.ReadAllText(f, Encoding.utf8)
            Dim xmlDoc As New System.XML.XmlDocument
            xmlDoc.Loadxml(txt.Trim)
            Dim ndList  = xmlDoc.GetElementsByTagName("mxxx")
            For Each dr As object In ndlist
                Dim ndr As DataRow = DataTables("表b").find("fa piao代码 = '" & dr("fpdm").innertext  & "'And fa piao号码 = '" & dr("fphm").innertext  & "'")
                If ndr Is Nothing Then ndr = DataTables("表b").addnew
                For Each n As System.XML.XmlNode In dr.childNodes
                    output.show(n.Name & " = " & n.InnerText)
                    If n.name = "fpdm" Then
                        ndr("fa piao代码") = n.innertext
                    End If
                    If n.name = "fphm" Then
                        ndr("fa piao号码") = n.innertext
                    End If
                    If n.name = "gmfnsrsbh" Then
                        ndr("纳税人识别号") = n.innertext
                    End If
                    If n.name = "kprq" Then
                        Dim str = n.innertext
                        ndr("开piao日期") = str.SubString(0,4) + "-" + str.SubString(4,2) + "-" + str.SubString(6,2)
                    End If
                    If n.name = "je" Then
                        ndr("合计金额")  = n.innertext
                    End If
                    If n.name = "se" Then
                        ndr("合计税额") = n.innertext
                    End If
                    If n.name = "zfbz" Then
                        ndr("fa piao状态") = n.innertext
                    End If
                    ndr("价税合计") =val(ndr("合计税额"))+ val(ndr("合计金额"))
                    Dim ndrb1 As DataRow = DataTables("表c").find("税号 = '" &  ndr("纳税人识别号") & "'")
                    If ndrb1 IsNot Nothing Then
                        ndr("客户名称") = ndrb1("名称")
                        ndr("地址电话") = ndrb1("地址电话")
                        ndr("开户银行及账号") = ndrb1("银行账号")
                    End If
                Next
            Next
        End If
    Next
End If
If dzml1 IsNot Nothing Then
    For Each f As String In FileSys.GetFiles(dzml1)
        If DataTables("表A").Find("文件名 = '" & f.SubString(f.Length - 25) & "'" ) Is Nothing Then
            Dim txt As String = FileSys.ReadAllText(f, Encoding.utf8)
            Dim xmlDoc As New System.XML.XmlDocument
            xmlDoc.Loadxml(txt.Trim)
            Dim ndList  = xmlDoc.GetElementsByTagName("Sph")
            For Each dr As object In ndlist
                Dim ndr As Row = Tables("表A").addnew
                For Each n As System.XML.XmlNode In dr.childNodes
                    output.show(n.Name & " = " & n.InnerText)
                    If n.name = "Spmc" Then
                        ndr("货物或服务名称") = n.innertext
                    End If
                    If n.name = "Ggxh" Then
                        ndr("规格") = n.innertext
                    End If
                    If n.name = "Jldw" Then
                        ndr("单位") = n.innertext
                    End If
                    If n.name = "Dj" Then
                        ndr("单价") = n.innertext
                    End If
                    If n.name = "sl" Then
                        ndr("数量") = val(n.innertext)
                    End If
                    If n.name = "Je" Then
                        ndr("金额") = n.innertext
                    End If
                    If n.name = "Slv" Then
                        ndr("税率") = n.innertext
                    End If
                    If n.name = "Kce" Then
                        ndr("税额") = n.innertext
                    End If
                    Dim str = f.SubString(f.Length - 25)
                    Dim ary = str.split("_")
                    ndr("文件名") = str
                    ndr("fa piao代码") = ary(0)
                    ndr("fa piao号码") = ary(1)
                    Dim ndrb2 As DataRow = DataTables("表b").find("fa piao代码 = '" &  ndr("fa piao代码")  & "'And fa piao号码 = '" & ndr("fa piao号码") & "'")
                    ndrb2("文件名") = ndr("文件名")
                    ndr("fa piao状态") = ndrb2("fa piao状态")
                    ndr("客户名称") = ndrb2("客户名称")
                Next
            Next
        End If
    Next
End If
If DataTables("表A").HasChanges Then
    DataTables("表B").Save
    DataTables("表A").Save
    MessageBox.Show("fa piao数据导入完成")
Else
    MessageBox.Show("没有导入任何fa piao数据")
End If

 回到顶部
帅哥哟,离线,有人找我吗?
hongyefor
  50楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:524 积分:3676 威望:0 精华:0 注册:2012/7/27 10:28:00
  发帖心情 Post By:2019/3/13 19:11:00 [只看该作者]

以上两个代码单独运行没问题,但是合并起来就不行了

 回到顶部
总数 51 上一页 1 2 3 4 5 6 下一页