一段计算出勤补贴的代码,代码出错。
不同的核算标准和单位,其满勤补贴和缺勤扣除的标准也不同,"√"为满勤,得满勤补贴;"-1"为缺勤一天,得"满勤补贴" -" 缺勤扣除","-2"为缺勤2天,得"满勤补贴" -" 缺勤扣除"*2,以此类推。此段代码运行出错,请各位老师帮助指教,谢谢!!
'报酬明细_DataColChanged
Select Case e.DataCol.Name
Case "核算标准","单位"
Dim dr As DataRow = e.DataRow
Dim pr As DataRow
Dim mqbt As Double
If dr.IsNull("核算标准") OrElse dr.IsNull("单位") Then
mqbt = Nothing
Else
Dim filter As String
filter = "核算标准 = '" & dr("核算标准") & "' And 单位 = '" & dr("单位") & "'"
pr = DataTables("核算标准").Find(filter)
If pr IsNot Nothing Then
mqbt =CDbl( pr("满勤补贴"))
End If
End If
End Select
Select Case e.DataCol.Name
Case "核算标准","单位"
Dim dr As DataRow = e.DataRow
Dim pr As DataRow
Dim qqkc As Double
If dr.IsNull("核算标准") OrElse dr.IsNull("单位") Then
qqkc = Nothing
Else
Dim filter As String
filter = "核算标准 = '" & dr("核算标准") & "' And 单位 = '" & dr("单位") & "'"
pr = DataTables("核算标准").Find(filter)
If pr IsNot Nothing Then
qqkc = CDbl(pr("缺勤扣除"))
End If
End If
End Select
If e.DataCol.Name = "出勤状况" Then
If e.DataRow("出勤状况") = "√" Then
e.DataRow("出勤补贴") = "mqbt"
ElseIf e.DataRow("出勤状况") = "-1"
e.DataRow("出勤补贴") = "mqbt-qqkc*1"
ElseIf e.DataRow("出勤状况") = "-2"
e.DataRow("出勤补贴") = "mqbt-qqkc*2"
ElseIf e.DataRow("出勤状况") = "-3"
e.DataRow("出勤补贴") = "mqbt-qqkc*3"
ElseIf e.DataRow("出勤状况") = "-4"
e.DataRow("出勤补贴") = "mqbt-qqkc*4"
ElseIf e.DataRow("出勤状况") = "-5"
e.DataRow("出勤补贴") = "mqbt-qqkc*5"
Else
e.DataRow("出勤补贴") = Nothing
End If
End If
出错截图:

此主题相关图片如下:k.png
[此贴子已经被作者于2011-10-16 21:58:54编辑过]
忘了上传项目,现补上,请各位老师指教,谢谢!!
[此贴子已经被作者于2011-10-16 20:36:39编辑过]
Select Case e.DataCol.Name
Case "核算标准","单位"
Dim dr As DataRow = e.DataRow
Dim pr As DataRow
Dim mqbt As Double
If dr.IsNull("核算标准") OrElse dr.IsNull("单位") Then
'mqbt = Nothing
Else
Dim filter As String
filter = "核算标准 = '" & dr("核算标准") & "' And 单位 = '" & dr("单位") & "'"
pr = DataTables("核算标准").Find(filter)
If pr IsNot Nothing Then
mqbt =CDbl( pr("满勤补贴"))
End If
End If
End Select
Select Case e.DataCol.Name
Case "核算标准","单位"
Dim dr As DataRow = e.DataRow
Dim pr As DataRow
Dim qqkc As Double
If dr.IsNull("核算标准") OrElse dr.IsNull("单位") Then
qqkc = Nothing
Else
Dim filter As String
filter = "核算标准 = '" & dr("核算标准") & "' And 单位 = '" & dr("单位") & "'"
pr = DataTables("核算标准").Find(filter)
If pr IsNot Nothing Then
qqkc = CDbl(pr("缺勤扣除"))
End If
End If
End Select
If e.DataCol.Name = "出勤状况" Then
If e.DataRow("出勤状况") = "√" Then
e.DataRow("出勤补贴") = mqbt
ElseIf e.DataRow("出勤状况") = "-1"
e.DataRow("出勤补贴") = mqbt-qqkc*1
ElseIf e.DataRow("出勤状况") = "-2"
e.DataRow("出勤补贴") = mqbt-qqkc*2
ElseIf e.DataRow("出勤状况") = "-3"
e.DataRow("出勤补贴") = mqbt-qqkc*3
ElseIf e.DataRow("出勤状况") = "-4"
e.DataRow("出勤补贴") = mqbt-qqkc*4
ElseIf e.DataRow("出勤状况") = "-5"
e.DataRow("出勤补贴") = mqbt-qqkc*5
Else
e.DataRow("出勤补贴") = Nothing
End If
End If
谢谢czy老师的回复。但是好像还不行,结果全部为零,问题不知出在哪里。
Dim mqbt As Double
Dim qqkc As Double
Dim dr As DataRow = e.DataRow
Dim pr As DataRow
Dim filter As String
Select Case e.DataCol.Name
Case "核算标准","单位","出勤状况"
If dr.IsNull("核算标准") = False And dr.IsNull("单位") = False And dr.IsNull("出勤状况") = False Then
filter = "核算标准 = '" & dr("核算标准") & "' And 单位 = '" & dr("单位") & "'"
pr = DataTables("核算标准").Find(filter)
If pr IsNot Nothing Then
mqbt = CDbl(pr("满勤补贴"))
qqkc = CDbl(pr("缺勤扣除"))
If dr("出勤状况") = "√" Then
dr("出勤补贴") = mqbt
ElseIf Val(dr("出勤状况")) = 0
dr("出勤补贴") = Nothing
Else
dr("出勤补贴") = mqbt-qqkc*Math.Abs(Val(e.DataRow("出勤状况")))
End If
End If
End If
End Select
还得加一行代码:
Dim mqbt,qqkc As Double
Dim dr As DataRow = e.DataRow
Dim pr As DataRow
Dim filter As String
Select Case e.DataCol.Name
Case "核算标准","单位","出勤状况"
If dr.IsNull("核算标准") = False And dr.IsNull("单位") = False And dr.IsNull("出勤状况") = False Then
filter = "核算标准 = '" & dr("核算标准") & "' And 单位 = '" & dr("单位") & "'"
pr = DataTables("核算标准").Find(filter)
If pr IsNot Nothing Then
mqbt = CDbl(pr("满勤补贴"))
qqkc = CDbl(pr("缺勤扣除"))
If dr("出勤状况") = "√" Then
dr("出勤补贴") = mqbt
ElseIf Val(dr("出勤状况")) = 0
dr("出勤补贴") = Nothing
Else
dr("出勤补贴") = mqbt-qqkc*Math.Abs(Val(e.DataRow("出勤状况")))
End If
End If
Else
dr("出勤补贴") = Nothing
End If
End Select
谢谢czy老师的指教,代码通过,完全达到预期效果,再次衷心感谢czy老师的热情帮助!!