'本年内企业名称禁止重复
If e.DataCol.Name = "企业名称" Then
Dim filter As String = "年度 = '" & Date.Today.year & "'"
If e.DataRow("企业名称") = Nothing Then
filter &= " and 企业名称 is null"
Else
filter &= " and 企业名称 = '" & e.DataRow("企业名称") & "'"
End If
Dim nr As DataRow = DataTables("安全费用提取").Find(filter,"年度 DESC",1)
If nr IsNot Nothing Then
e.Cancel = True '那么取消输入并提示用户
'Dim Result As DialogResult
'Result =
MessageBox.Show("本年度本公司已添加了安全费用提取记录,禁止重复添加! 请删除当前行或添加其他企业!", "提示", MessageBoxButtons.OK, MessageBoxIcon.warning)
'If Result = DialogResult.Yes Then
'e.DataRow.Delete
'Else
'End If
e.DataRow("企业名称") = Nothing
Else
End If
End If
Select Case e.DataCol.Name
'自动填入上年度结余的值
Case "企业名称"
If e.DataRow.Isnull("企业名称") Then
e.DataRow("上年度结余") = Nothing
Else
Dim fdr As DataRow = DataTables("安全费用使用").find("年度 = '" & e.DataRow("年度") - 1 & "' and 月度 = '12' and 企业名称 = '" & e.DataRow("企业名称") & "'","本月余额",0) '填写上年度结余
If fdr IsNot Nothing Then
If fdr("本月余额") > "0" Then '年底结余为负数时,清零
e.DataRow("上年度结余") = fdr("本月余额")
Else
e.DataRow("上年度结余") = "0"
End If
End If
End If
Case "上年度营业收入" '如果更改的是列
If e.DataRow.Isnull("行业类型") = False Then
If e.DataRow.IsNull("上年度营业收入") AndAlso e.DataRow.IsNull("上年度结余") Then '是否为空
e.DataRow("本年度应提取额") = Nothing '如果为空,则为空
e.DataRow("每月提取额") = Nothing '如果为空,则为空
End If
If e.DataRow("上年度营业收入") <= 10000000 Then
Dim drq As DataRow = DataTables("安全费用提取比例").find("行业类型 = '" & e.DataRow("行业类型") & "' and 营业收入档次1 <= " & e.DataRow("上年度营业收入") & " And 营业收入档次2 > " & e.DataRow("上年度营业收入")) '填写上年度结余
If drq IsNot Nothing Then
e.DataRow("本年度应提取额") = e.DataRow("上年度营业收入") * drq("提取比例") '+ e.DataRow("上年度结余") '此处重复,12月余额直接计入下年1月
e.DataRow("每月提取额") = e.DataRow("本年度应提取额")/12
End If
End If
If e.DataRow("上年度营业收入") > 10000000 AndAlso e.DataRow("上年度营业收入") <= 100000000 Then
Dim drq As DataRow = DataTables("安全费用提取比例").find("行业类型 = '" & e.DataRow("行业类型") & "' and 营业收入档次1 <= " & e.DataRow("上年度营业收入") & " And 营业收入档次2 > " & e.DataRow("上年度营业收入"))
Dim drk As DataRow = DataTables("安全费用提取比例").find("行业类型 = '" & e.DataRow("行业类型") & "' and 营业收入档次2 = 10000000")
If drq IsNot Nothing Then
e.DataRow("本年度应提取额") = (e.DataRow("上年度营业收入") - 10000000) * drq("提取比例") + 10000000 * drk("提取比例") '+ e.DataRow("上年度结余") '此处重复,12月余额直接计入下年1月
e.DataRow("每月提取额") = e.DataRow("本年度应提取额")/12
End If
End If
End If
End Select
原来使用的是阿里云,现在改成本机ACCESS,原来的时候能自动计算:本年度应提额、每月提取额,自从改成ACCESS后不自动计算了。请老师帮忙看看代码哪里有问题,应如何更改?谢谢!