Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
原代码是当去向为空时,归还日期为系统日期,现在想改成取自设备目录表、设备管理窗口、DateTimePicker1控件的值,代码应该如何修改,请各位老师指教,谢谢!!(附原代码)
Select Case e.DataCol.Name
Case "去向"
If e.DataRow.IsNull("去向") And e.DataRow.IsNull("使用单位") Then
e.DataRow("归还日期")=Nothing
Else
Dim dr As DataRow = DataTables("设备目录").Find("[设备编号] = '" & e.DataRow("设备编号") & "'")
If e.DataRow.IsNull("去向") Then
e.DataRow("归还日期") = Date.Today
If dr IsNot Nothing Then
dr("使用单位") = e.DataRow("使用单位")
End If
Else
dr("使用单位") = e.DataRow("产权单位")
End If
End If
End Select
您需要通过全局变量来实现,因为别的表的那个窗口在本代码执行时没有打开吧?
先用全局变量保存DateTimePicker1的值再引用就ok了!
谢谢程老师的回复,全局变量我没有做过,请程老师帮助指教一下,谢谢了。
在原代码中加了一条,达到所需效果,在这里再次谢谢程老师!!
If e.DataRow.IsNull("去向") And e.DataRow.IsNull("使用单位") Then
e.DataRow("归还日期")=Nothing
Else
Dim dr As DataRow = DataTables("设备目录").Find("[设备编号] = '" & e.DataRow("设备编号") & "'")
Dim mydate As Date = Forms("设备管理").Controls("DateTimePicker1").Text
If e.DataRow.IsNull("去向") Then
e.DataRow("归还日期") = mydate
If dr IsNot Nothing Then
dr("使用单位") = e.DataRow("使用单位")
End If
Else
dr("使用单位") = e.DataRow("产权单位")
End If
End If
End Select
通过代码增加Var变量
将设备目录表、设备管理窗口、DateTimePicker1控件的值与全局变量mydate关联,代码应该如何写?放在哪个事件里?请各位老师指教。谢谢!!