原来的代码这么改一下,容错性比较好:
Dim dr As DataRow = e.DataRow
Select Case e.DataCol.Name
Case "fens","danj"
dr("zhongj") = dr("fens") * dr("danj")
Case "qsrq","zzrq","baom"
If e.DataRow.IsNull("qsrq") = False AndAlso e.DataRow.IsNull("zzrq") = False Then
Dim dt1 As Date = e.DataRow("qsrq")
Dim dt2 As Date = e.DataRow("zzrq")
Dim m As Integer = (dt2.year - dt1.year) * 12 + (dt2.month- dt1.month)
If (dt2 - dt1.AddMonths(y)).TotalDays > 10 Then
m = m + 1
End If
Dim yj As Double
If e.DataRow("baom") = "大同日报" Then
yj = 24
Else If e.DataRow("baom") = "大同晚报" Then
yj = 16.5
End If
e.DataRow("danj") = m * yj
End If
End Select
关于查询窗口设计,看看:
http://www.foxtable.com/help/topics/1058.htm