以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  删除表格中的数据,提示运行错误  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=88557)

--  作者:jason_pitt
--  发布时间:2016/8/4 20:53:00
--  删除表格中的数据,提示运行错误
您好,我在表中写入了一些DATACOLCHANGED之后,每次删除表格中的数据的时候,老是提示运行错误,请问是什么原因?谢谢
--  作者:jason_pitt
--  发布时间:2016/8/4 20:58:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看

--  作者:cbt
--  发布时间:2016/8/4 21:50:00
--  
 贴出 事件代码 来看看

--  作者:客人
--  发布时间:2016/8/4 21:52:00
--  

If e.DataCol.Name ="高锰酸盐指数L" Then

    If e.NewValue.Contains("L") Then

        e.DataRow("高锰酸盐指数") = val(e.NewValue) / 2

    Else

        e.DataRow("高锰酸盐指数") = e.NewValue

    End If

End If

If e.DataCol.Name ="五日生化需氧量L" Then

    If e.NewValue.Contains("L") Then

        e.DataRow("五日生化需氧量") = val(e.NewValue) / 2

    Else

        e.DataRow("五日生化需氧量") = e.NewValue

    End If

End If

If e.DataCol.Name ="氨氮L" Then

    If e.NewValue.Contains("L") Then

        e.DataRow("氨氮") = val(e.NewValue) / 2

    Else

        e.DataRow("氨氮") = e.NewValue

    End If

End If

If e.DataCol.Name ="石油类L" Then

    If e.NewValue.Contains("L") Then

        e.DataRow("石油类") = val(e.NewValue) / 2

    Else

        e.DataRow("石油类") = e.NewValue

    End If

End If

If e.DataCol.Name ="挥发酚L" Then

    If e.NewValue.Contains("L") Then

        e.DataRow("挥发酚") = val(e.NewValue) / 2

    Else

        e.DataRow("挥发酚") = e.NewValue

    End If

End If

Select Case e.DataCol.Name

        Case "溶解氧","高锰酸盐指数","五日生化需氧量","氨氮","石油类","挥发酚"        

        If e.DataRow.IsNull("溶解氧") = False AndAlso e.DataRow.IsNull("高锰酸盐指数") = False AndAlso e.DataRow.IsNull("五日生化需氧量") = False AndAlso e.DataRow.IsNull("氨氮") = False AndAlso e.DataRow.IsNull("石油类") = False AndAlso e.DataRow.IsNull("挥发酚") = False Then

            Dim lb1, lb2, lb3, lb4, lb5, lb6 As Integer

           If e.DataRow("溶解氧") < 2 Then

                lb1 = 6

            ElseIf e.DataRow("溶解氧") <3 Then

                lb1 = 5

            Else If e.DataRow("溶解氧") <5 Then

                lb1 = 4

            Else If e.DataRow("溶解氧") <6 Then

                lb1 = 3

            Else

                lb1 = 2

            End If


If e.DataRow("高锰酸盐指数") <= 4 Then

                lb2 = 2

            ElseIf e.DataRow("高锰酸盐指数") <= 6 Then

                lb2 =3

            Else If e.DataRow("高锰酸盐指数") <= 10 Then

                lb2= 4

            Else If e.DataRow("高锰酸盐指数") <= 15 Then

                lb2 = 5

            Else

                lb2 = 6

            End If

            

            If e.DataRow("五日生化需氧量") <= 3 Then

                lb3 = 2

            ElseIf e.DataRow("五日生化需氧量") <= 4 Then

                lb3 =3

            ElseIf e.DataRow("五日生化需氧量") <= 6 Then

                lb3 = 4

            ElseIf e.DataRow("五日生化需氧量") <= 10 Then

                lb3 = 5

            Else

                lb3 = 6

            End If

            

            If e.DataRow("氨氮") <=0.5 Then

                lb4 =2

            ElseIf e.DataRow("氨氮") <=1 Then

                lb4 = 3

            ElseIf e.DataRow("氨氮") <=1.5 Then

                lb4 =4

            ElseIf e.DataRow("氨氮") <=2 Then

                lb4 = 5

            Else

                lb4 =6

            End If

            

If e.DataRow("石油类") <= 0.05 Then

                lb5 = 2

            Else If e.DataRow("石油类") <= 0.5 Then

                lb5 = 4

            Else If e.DataRow("石油类") <= 1.0 Then

                lb5 =5

            Else

                lb5 =6

            End If

            

            If e.DataRow("挥发酚") <= 0.002 Then

                lb6 = 2

            ElseIf e.DataRow("挥发酚") <= 0.005 Then

                lb6 =3

            ElseIf e.DataRow("挥发酚") <= 0.01 Then

                lb6 = 4

            ElseIf e.DataRow("挥发酚") <= 0.1 Then

                lb6 = 5

            Else

                lb6 =6

            End If

            If lb1 > lb2 Then lb2 = lb1

            If lb2 > lb3 Then lb3 = lb2

            If lb3 > lb4 Then lb4 = lb3

            If lb4 > lb5 Then lb5 = lb4

            If lb5 > lb6 Then lb6 = lb5

     Dim ary() As String = {"", "", "Ⅱ类", "Ⅲ类", "Ⅳ类", "Ⅴ类", "劣Ⅴ类"}

            e.DataRow("断面类别") = ary(lb6)

             End If

End Select


--  作者:cbt
--  发布时间:2016/8/4 22:00:00
--  
 删除的时候  e.NewValue 为空,你要判断一下!

--  作者:jason_pitt
--  发布时间:2016/8/4 22:18:00
--  
我重新制作了一个表,就是上面的代码,出现的结果跟上面一样,删除表格中的数据的时候,就出现错误


--  作者:jason_pitt
--  发布时间:2016/8/4 22:18:00
--  
如何修改了,请专家指正,谢谢


--  作者:cbt
--  发布时间:2016/8/4 22:35:00
--  
 ‘参考

Dim dic As new Dictionary(of String,String)
dic.Add("高锰酸盐指数L","高锰酸盐指数")
dic.Add("五日生化需氧量L","五日生化需氧量")
dic.Add("氨氮L","氨氮")
dic.Add("石油类L","石油类")
dic.Add("挥发酚L","挥发酚")
Dim cln As String = e.DataCol.Name
If dic.ContainsKey(cln) AndAlso E.NewValue > "" Then
    If e.NewValue.contains("L") Then
        e.DataRow(dic(cln)) = val(e.NewValue) / 2
    Else
        e.DataRow(dic(cln)) = e.NewValue
    End If
End If

--  作者:jason_pitt
--  发布时间:2016/8/5 8:31:00
--  
我加上去了,还是一样的错误,是什么原因了,谢谢专家指正
--  作者:Hyphen
--  发布时间:2016/8/5 9:01:00
--  
Select Case e.DataCol.Name
    Case "溶解氧L","高锰酸盐指数L","五日生化需氧量L","氨氮L","石油类L","挥发酚L"
        If e.DataRow.IsNull(e.DataCol.Name) = False Then
            If  e.NewValue.Contains("L") Then
                e.DataRow(e.DataCol.Name.Replace("L","")) = e.NewValue
            Else
                e.DataRow(e.DataCol.Name.Replace("L","")) = val(e.NewValue) / 2
            End If
        End If
End Select