一个窗体里的代码,有几处不同的小问题。
1、窗口AAA里的afterload事件(行定位问题)
If Ztm="sgxiugai" Then
'进入数据更新状态
'将已填数据从数据库读出到界面中
Dim rread As Row = Tables("car_accident").current
e.Form.Controls("车号").value = rread("sg_carname")
e.Form.Controls("肇事日期").value = rread("sg_rq")
..........................
Else
'如果状态为非修改,则新增行
Dim r As Row = Tables("car_accident").AddNew
End If
窗口BBB,ztm = “sgadd”
窗口CCC,ztm=“sgxiugai”
如果先使用窗口CCC打开窗口AAA,不进行任何操作,直接关闭窗口AAA.然后通过窗口BBB打开窗口AAA,则程序会定位数据到的打开窗口CCC时的记录,而不是执行新增功能。此时需要关闭窗口AAA,在从窗口BBB打开窗口AAA才正常。
窗口CCC代码:
Ztm="sgxiugai"
Dim dr As DataRow = Tables("事故查询").Current.DataRow
Dim wz As Integer = Tables("accident").FindRow(dr)
If wz >=0 Then
Tables("accident").Position = wz
End If
2、year问题
Dim sgs As Integer '今年总数量
sgs = DataTables("accident").Compute("Count(rq)"," Year(rq)= Year(GetDate()) ")
报错内容:表达式包含未定义的函数调用 Year(). year不是系统内部自带函数吗,为什么不能使用
Dim y As Integer = Date.Today.Year
Dim y1 As New Date(y, 1, 1)
Dim y2 As New Date(y, 12, 31)
sgs= DataTables("accident").Compute("Count([rq])", "sg_rq >= # " & y1 & " # And rq < # " & y2 & " # " )
这种方式可以执行。
3、统计数据不正确
Dim sfz As String = e.Form.Controls("身份证号码").value
Dim y As Integer = Date.Today.Year
Dim y1 As New Date(y, 1, 1)
Dim y2 As New Date(y, 12, 31)
Dim sgs As Integer '今年事故数
sgs= DataTables("accident").Compute("Count([rq])", "rq >= # " & y1 & " # And rq < # " & y2 & " # And sfz = '& sfz &' " )
[此贴子已经被作者于2020/4/18 22:56:22编辑过]