-- 作者:明丰
-- 发布时间:2011/9/3 20:53:00
-- 代码修改
当同时删除多行时,出错:
错误代码位置:表,货品资料,BeforeDeleteDataRow
System.NullReferenceException: 未将对象引用设置到对象的实例。 在 UserCode.BeforeDeleteDataRow(DataRowEventArgs e)
请问下面代码如何修改?
Dim d1 As String = CurrentTable.Current("一级类别") \'
Dim d2 As String = CurrentTable.Current("二级类别") Dim d3 As String = CurrentTable.Current("三级类别") Dim d4 As String = CurrentTable.Current("四级类别") Dim d5 As String = CurrentTable.Current("五级类别") Dim d6 As String = CurrentTable.Current("六级类别") Dim dr1 As List(of DataRow) = e.DataTable.Select("一级类别 Like \'" & d1 & "\'") \'
Dim dr2 As List(of DataRow) = e.DataTable.Select("一级类别 Like \'" & d1 & "\'And 二级类别 Like \'" & d2 & "\'") Dim dr3 As List(of DataRow) = e.DataTable.Select("一级类别 Like \'" & d1 & "\'And 二级类别 Like \'" & d2 & "\'And 三级类别 Like \'" & d3 & "\'") Dim dr4 As List(of DataRow) = e.DataTable.Select("一级类别 Like \'" & d1 & "\'And 二级类别 Like \'" & d2 & "\'And 三级类别 Like \'" & d3 & "\'And 四级类别 Like \'" & d4 & "\'") Dim dr5 As List(of DataRow) = e.DataTable.Select("一级类别 Like \'" & d1 & "\'And 二级类别 Like \'" & d2 & "\'And 三级类别 Like \'" & d3 & "\'And 四级类别 Like \'" & d4 & "\'And 五级类别 Like \'" & d5 & "\'") Dim dr6 As List(of DataRow) = e.DataTable.Select("一级类别 Like \'" & d1 & "\'And 二级类别 Like \'" & d2 & "\'And 三级类别 Like \'" & d3 & "\'And 四级类别 Like \'" & d4 & "\'And 五级类别 Like \'" & d5 & "\'And 六级类别 Like \'" & d6 & "\'") Dim d7 As String = "该行包含类别, 是否删除?" If (dr6 IsNot Nothing And dr6.count = 1) OrElse (dr5 IsNot Nothing And dr5.count = 1) OrElse (dr4 IsNot Nothing And dr4.count = 1) OrElse (dr3 IsNot Nothing And dr3.count = 1) OrElse (dr2 IsNot Nothing And dr2.count = 1) OrElse (dr1 IsNot Nothing And dr1.count = 1) Then If MessageBox.Show(d7,"提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question) = DialogResult.No Then e.Cancel= True Else
End If End If
|