Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共6 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[求助]通过代码增加Var变量(在5楼)

1楼
yyzlxc 发表于:2011/9/20 21:39:00

原代码是当去向为空时,归还日期为系统日期,现在想改成取自设备目录表、设备管理窗口、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

[此贴子已经被作者于2011-9-21 9:15:19编辑过]
2楼
程兴刚 发表于:2011/9/20 21:43:00

您需要通过全局变量来实现,因为别的表的那个窗口在本代码执行时没有打开吧?

 

先用全局变量保存DateTimePicker1的值再引用就ok了!

[此贴子已经被作者于2011-9-20 21:44:54编辑过]
3楼
yyzlxc 发表于:2011/9/20 21:50:00

谢谢程老师的回复,全局变量我没有做过,请程老师帮助指教一下,谢谢了。

 

 


[此贴子已经被作者于2011-9-20 23:23:51编辑过]
4楼
yyzlxc 发表于:2011/9/20 23:23:00

在原代码中加了一条,达到所需效果,在这里再次谢谢程老师!!

 

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

5楼
yyzlxc 发表于:2011/9/21 9:14:00

通过代码增加Var变量

将设备目录表、设备管理窗口、DateTimePicker1控件的值与全局变量mydate关联,代码应该如何写?放在哪个事件里?请各位老师指教。谢谢!!

6楼
狐狸爸爸 发表于:2011/9/21 11:12:00

http://www.foxtable.com/help/topics/1860.htm

 

共6 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02344 s, 2 queries.