'修改日期列时,年度月度可根据日期列自动修改
If e.DataCol.name = "日期" Then
If e.DataRow.IsNull("日期") Then '是否为空
e.DataRow("月度") = Nothing '如果为空,则月度为空
e.DataRow("年度") = Nothing
Else
e.DataRow("月度") = month(e.DataRow("日期"))
e.DataRow("年度") = year(e.DataRow("日期"))
End If
End If
'上月余额
Select Case e.DataCol.name
Case "企业名称"
If e.DataRow.IsNull("企业名称") Then
e.DataRow("上月余额") = Nothing
Else
Dim fdr As DataRow = e.DataTable.find("年度 = '" & e.DataRow("年度") - 1 & "' and 月度 = '12' and 企业名称 = '" & e.DataRow("企业名称") & "'","本月余额",0)
Dim fdr1 As DataRow = e.DataTable.find("月度 = '" & e.DataRow("月度") - 1 & "' And 年度 = '" & e.DataRow("年度") & "' and 企业名称 = '" & e.DataRow("企业名称") & "'","本月余额",0)
If e.DataRow("月度") = "1" Then
If fdr IsNot Nothing Then
e.DataRow("上月余额") = fdr("本月余额")
Else
e.DataRow("上月余额") = "0"
End If
ElseIf e.DataRow("月度") > "1" Then
If fdr1 IsNot Nothing Then
e.DataRow("上月余额") =fdr1("本月余额")
Else
e.DataRow("上月余额") = "0"
End If
End If
End If
Case "日期"
If e.DataRow.IsNull("日期") Then
e.DataRow("上月余额") = Nothing
Else
Dim fdr As DataRow = e.DataTable.find("年度 = '" & e.DataRow("年度") - 1 & "' and 月度 = '12' and 企业名称 = '" & e.DataRow("企业名称") & "'","本月余额",0)
Dim fdr1 As DataRow = e.DataTable.find("月度 = '" & e.DataRow("月度") - 1 & "' And 年度 = '" & e.DataRow("年度") & "' and 企业名称 = '" & e.DataRow("企业名称") & "'","本月余额",0)
If e.DataRow("月度") = "1" Then
If fdr IsNot Nothing Then
e.DataRow("上月余额") = fdr("本月余额")
Else
e.DataRow("上月余额") = "0"
End If
ElseIf e.DataRow("月度") > "1" Then
If fdr1 IsNot Nothing Then
e.DataRow("上月余额") =fdr1("本月余额")
Else
e.DataRow("上月余额") = "0"
End If
End If
End If
End Select
'本月应提额
Select Case e.DataCol.name
Case "企业名称"
If e.DataRow.IsNull("企业名称") Then
e.DataRow("本月应提额") = Nothing
Else
Dim r1 As DataRow = DataTables("安全费用提取").find("企业名称 = '" & Tables("安全费用使用").current ("企业名称") & "' And 年度 = '"& Tables("安全费用使用").current ("年度") &"'")
If r1 IsNot Nothing Then
e.DataRow("本月应提额") = r1("每月提取额")
Else
e.DataRow("本月应提额") = "0"
End If
End If
Case "日期"
If e.DataRow.IsNull("日期") Then
e.DataRow("本月应提额") = Nothing
Else
Dim r1 As DataRow = DataTables("安全费用提取").find("企业名称 = '" & Tables("安全费用使用").current ("企业名称") & "' And 年度 = '"& Tables("安全费用使用").current ("年度") &"'")
If r1 IsNot Nothing Then
e.DataRow("本月应提额") = r1("每月提取额")
Else
e.DataRow("本月应提额") = "0"
End If
End If
End Select
'本月支出额
If e.DataCol.name = "数量" Then
If e.DataRow.IsNull("数量") Then '是否为空
e.DataRow("本月支出额") = Nothing '如果为空,则为空
Else
e.DataRow("本月支出额") = DataTables("安全费用使用").Compute("Sum(金额)","月度 = '" & e.DataRow("月度") & "' And 年度 = '" & e.DataRow("年度") & "' and 企业名称 = '" & e.DataRow("企业名称") & "'")
End If
End If
'按照企业名称和日期列排序
If e.DataCol.name = "数量" Then
If e.DataRow IsNot Nothing Then '不为空
Tables("安全费用使用").Sort = "企业名称,日期" '按企业名称和日期排序
Else
End If
End If
请老师帮忙看一下,代码哪里有问题。谢谢!