如果缴费情况表同一车牌号码在缴费_月租_缴费金额列当月累计数大于缴费_月租_月租单价,删除保存的这行数,我在DataColChanging事件这样写,报错:
此主题相关图片如下:qq图片20210327151822.png
Dim d As Date = e.DataRow("日期").Value
Dim y As Integer = d.Year
Dim m As Integer = d.Month
Dim Days As Integer = Date.DaysInMonth(y,m)
Dim fd As Date = New Date(y,m,1) '获得该月的第一天
Dim ld As Date = New Date(y,m,Days) '获得该月的最后一天
Select Case e.DataCol.name
Case "车牌号码"
If e.NewValue > 0 Then
Dim tr As DataRow = DataTables("缴费情况").find("[分类] = '" & e.DataRow("分类") & "' And [日期] >= #" & fd & "# And [日期] <= #" & ld & "# And [车牌号码] = '" & e.DataRow("车牌号码") & "'")
If tr IsNot Nothing Then
Dim Sum As Double = e.DataTable.SQLCompute("Sum(缴费_月租_缴费金额)","[分类] = '" & e.DataRow("分类") & "' And [日期] >= #" & fd & "# And [日期] <= #" & ld & "# And [车牌号码] = '" & e.DataRow("车牌号码") & "' And [_Identify] <> " & e.DataRow("_Identify"))
If Sum + e.NewValue > e.DataRow("缴费_月租_月租单价") Then
Messagebox.show(e.DataRow("车牌号码") & "当月已录入租金!")
e.DataRow("车牌号码") = Nothing
e.Cancel = True
e.DataRow("车牌号码").Delete()
End If
End If
End If
End Select
[此贴子已经被作者于2021/3/27 15:27:31编辑过]