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


  共有7639人关注过本帖平板打印复制链接

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

帅哥哟,离线,有人找我吗?
hongyefor
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | 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

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