Foxtable(狐表)用户栏目专家坐堂 → 如何将子表里面的内容自动随着父表里面内容的变更而自动更新?


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

主题:如何将子表里面的内容自动随着父表里面内容的变更而自动更新?

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


加好友 发短信
等级:幼狐 帖子:126 积分:898 威望:0 精华:0 注册:2016/8/2 9:17:00
  发帖心情 Post By:2016/8/10 20:56:00 [只看该作者]

If e.DataCol.Name.Contains("L") Then
    If e.newvalue > "" AndAlso e.NewValue.Contains("L") Then
        e.DataRow(e.DataCol.name.Replace("L", "")) = val(e.NewValue) / 2
    Else
        e.DataRow(e.DataCol.name.Replace("L", "")) = e.NewValue
    End If
End If
If e.DataCol.Name = "ABC" AndAlso e.DataRow("ABC") = True Then
    Dim nma() As String = {"断面名称","监测月份","规划类别","断面类别","超标项目","超标倍数"} 
    Dim nmb() As String = {"断面名称","监测月份","规划类别","断面类别","超标项目","超标倍数"} 
    Dim dr As DataRow = DataTables("地表水监测结果统计表").AddNew
    For i As Integer = 0 To nma.Length - 1
        dr(nmb(i)) = e.DataRow(nma(i))
    Next
End If
Select Case e.DataCol.Name
    
    Case "高锰酸盐指数","五日生化需氧量","氨氮","石油类","挥发酚","汞","铅","化学需氧量","总磷","铜","锌","氟化物","硒","砷","镉","六价铬","氰化物","阴离子表面活性剂","硫化物","规划类别数值","溶解氧"
        If e.DataRow.IsNull("高锰酸盐指数")  OrElse e.DataRow.IsNull("五日生化需氧量")  OrElse e.DataRow.IsNull("氨氮") OrElse e.DataRow.IsNull("石油类")  OrElse e.DataRow.IsNull("挥发酚")  OrElse e.DataRow.IsNull("汞")  OrElse e.DataRow.IsNull("铅") OrElse e.DataRow.IsNull("化学需氧量")  OrElse e.DataRow.IsNull("总磷")  OrElse e.DataRow.IsNull("铜")  OrElse e.DataRow.IsNull("锌") OrElse e.DataRow.IsNull("氟化物")  OrElse e.DataRow.IsNull("硒")  OrElse e.DataRow.IsNull("砷")  OrElse e.DataRow.IsNull("镉") OrElse e.DataRow.IsNull("六价铬")  OrElse e.DataRow.IsNull("氰化物") OrElse e.DataRow.IsNull("阴离子表面活性剂")  OrElse e.DataRow.IsNull("硫化物") OrElse e.DataRow.IsNull("溶解氧") OrElse e.DataRow.IsNull("溶解氧") Then Return 
        Dim dic As new Dictionary(of String, Double())
        dic.Add("高锰酸盐指数", new Double() {4,6,10,15,999})
        dic.Add("五日生化需氧量", new Double() {3,4,6,10,999})
        dic.Add("氨氮", new Double() {0.5,1,1.5,2,999})
        dic.Add("石油类", new Double() {0.05,0.05,0.5,1,999})
        dic.Add("挥发酚", new Double() {0.002,0.005,0.01,0.1,999})
        dic.Add("汞", new Double() {0.00005,0.0001,0.001,0.001,999})
        dic.Add("铅", new Double() {0.01,0.05,0.05,0.1,999})
        dic.Add("化学需氧量", new Double() {15,20,30,40,999})
        dic.Add("总磷", new Double() {0.1,0.2,0.3,0.4,999})
        dic.Add("铜", new Double() {1.0,1.0,1.0,1.0,999})
        dic.Add("锌", new Double() {1,1,2,2,999})
        dic.Add("氟化物", new Double() {1,1,1.5,1.5,999})
        dic.Add("硒", new Double() {0.01,0.01,0.02,0.02,999})
        dic.Add("砷", new Double() {0.05,0.05,0.1,0.1,999})
        dic.Add("镉", new Double() {0.005,0.005,0.005,0.01,999})
        dic.Add("六价铬", new Double() {0.05,0.05,0.05,0.1,999})
        dic.Add("氰化物", new Double() {0.05,0.2,0.2,0.2,999})
        dic.Add("阴离子表面活性剂", new Double() {0.2,0.2,0.3,0.3,999})
        dic.Add("硫化物", new Double() {0.1,0.2,0.5,1.0,999})
        Dim s As String = ""
        Dim n As String = ""
        Dim max As Double = 0
        Dim bz As Integer = e.DataRow("规划类别数值")
        If bz >= 2 Then
            For Each key As String In dic.Keys
                Dim ary() As Double = dic(key)
                For i As Integer = 0 To ary.length - 1
                    If e.DataRow(key) <= ary(i) Then
                        If i+2 > max Then
                            max = i+2
                        End If
                        If i+2 > bz Then
                            s = s & "," & key
n = n & "," & format((e.DataRow(key)-ary(bz-2)) / ary(bz-2), "0.##")
                        End If
                        Exit For
                    End If
                Next
            Next
            Dim rjy() As Double = new Double() {2,3,5,6,999}
            For i As Integer = 0 To rjy.length - 1
                If e.DataRow("溶解氧") < rjy(i) Then
                    If 6-i > max Then
                        max = 6-i
                    End If
                    If 6-i > bz Then
                        s = s & ",溶解氧"
                        n = n & "," & format(rjy(6-bz) / e.DataRow("溶解氧"), "0.##")
                    End If
                    Exit For
                End If
            Next
            
        End If
        
        e.DataRow("超标项目") = s.trim(",")
        e.DataRow("超标倍数") = n.trim(",")
        Dim ary1() As String = {"", "", "Ⅱ类", "Ⅲ类", "Ⅳ类", "Ⅴ类", "劣Ⅴ类"}
        e.DataRow("断面类别数值") = max
        e.DataRow("断面类别") = ary1(max)
    Case "断面名称"
        Dim fdr As DataRow = DataTables("名称类别").find("名称 = '" & e.DataRow("断面名称") & "'")
        If fdr IsNot Nothing Then
            Dim ary() As String = {"", "", "Ⅱ类", "Ⅲ类", "Ⅳ类", "Ⅴ类", "劣Ⅴ类"}
            e.DataRow("规划类别数值") = fdr("类别")
            e.DataRow("规划类别") = ary(fdr("类别"))
        End If

If e.DataCol.Name = "断面名称" AndAlso e.DataRow("断面名称") = True Then
    Dim nma() As String = {"断面名称","监测月份"}
    Dim nmb() As String = {"断面名称","监测月份"}
    Dim dr As DataRow = DataTables("地表水监测结果统计表").AddNew
    For i As Integer = 0 To nma.Length - 1
        dr(nmb(i)) = e.DataRow(nma(i))
    For Each dc As DataCol In DataTables("地表水监测结果统计表").DataCols
        dr(dc.Name) = e.DataRow(dc.Name)
    Next
    Next
End If

End Select

 回到顶部
总数 31 1 2 3 4 下一页