以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  代码不执行,求助!  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=54789)

--  作者:yancheng
--  发布时间:2014/8/4 18:41:00
--  代码不执行,求助!
 下载信息  [文件大小:   下载次数: ]
点击浏览该文件:测试上下班时间.rar


Select Case e.DataCol.name
    Case "下班时间"
        Dim t1 As TimeSpan
        t1 = e.NewValue - e.DataRow("上班时间")
        If t1.Hours< 0 Then
            MessageBox.show("\'下班时间\'不能早于\'上班时间\',请输入正确的时间!","提示!")
            e.Cancel=True
        End If
    Case "上班时间"
        Dim t1 As TimeSpan
        t1 = e.DataRow("下班时间")- e.NewValue
        If t1.Hours< 0 Then
            MessageBox.show("\'下班时间\'不能早于\'上班时间\',请输入正确的时间!","提示!")
            e.Cancel=True
        End If
End Select
写在表事件datacolchaning
上面的代码:上班时间,可以运行。为什么:下班时间,变动后,不运行代码呢?
[此贴子已经被作者于2014-8-4 18:41:57编辑过]

--  作者:有点甜
--  发布时间:2014/8/4 19:25:00
--  
Select Case e.DataCol.name
    Case "下班时间"
        If e.NewValue <> Nothing AndAlso e.DataRow.IsNull("上班时间") = False Then
            If new Date(1900,1,1,cdate(e.NewValue).hour, cdate(e.NewValue).minute,1) < new Date(1900,1,1,cdate(e.DataRow("上班时间")).hour,cdate(e.DataRow("上班时间")).minute, 1) Then
                MessageBox.show("\'下班时间\'不能早于\'上班时间\',请输入正确的时间!","提示1!")
                e.Cancel=True
            End If
        End If
    Case "上班时间"
        If e.NewValue <> Nothing AndAlso e.DataRow.IsNull("下班时间") = False Then
            If new Date(1900,1,1,cdate(e.NewValue).hour, cdate(e.NewValue).minute,1) > new Date(1900,1,1,cdate(e.DataRow("下班时间")).hour,cdate(e.DataRow("下班时间")).minute, 1) Then
                MessageBox.show("\'下班时间\'不能早于\'上班时间\',请输入正确的时间!","提示2!")
                e.Cancel=True
            End If
        End If
End Select