以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]输入日期判断  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=124930)

--  作者:林胤
--  发布时间:2018/9/16 20:57:00
--  [求助]输入日期判断
我在日期上面判断输入的值是不是空值的时候,老是提示我是空值。搞不清为什么,输入不是空值的话,倒是可以判断出来,也不知道哪里代码写错了。。

If e.DataCol.Name = "丝印车间" Then
    If e.NewValue Is Nothing Then
        MessageBox.show("当前日期不能为空","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    ElseIf e.NewValue < e.OldValue  Then
        e.Cancel = True
        MessageBox.show("当前日期只能往后填","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    End If
End If
Dim da1 As Date = e.NewValue
If  da1 = Nothing Then
    e.Cancel = True
    MessageBox.show("丝印车间日期:" ,"提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    If da1 <> Nothing Then
        MessageBox.show("丝印车间1","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        e.Cancel = False
    End If
End If

谁帮我判断下。 我的代码好像有两段,好像都有点问题。

--  作者:有点甜
--  发布时间:2018/9/16 21:30:00
--  

If e.DataCol.Name = "丝印车间" Then
    If e.NewValue = Nothing Then
        MessageBox.show("当前日期不能为空","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    ElseIf e.NewValue < e.OldValue  Then
        e.Cancel = True
        MessageBox.show("当前日期只能往后填","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    End If
End If

 

或者

 

If e.DataCol.Name = "丝印车间" Then
    Dim da1 As Date = e.NewValue
    If da1 = Nothing Then
        e.Cancel = True
        MessageBox.show("丝印车间日期:" ,"提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Else
        MessageBox.show("丝印车间1","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        e.Cancel = False
    End If
End If


--  作者:林胤
--  发布时间:2018/9/17 10:19:00
--  
自己学还是多少有点拿不准,我现在发现之前我写的代码没问题,但是一直报错,就把我的思维弄乱了。。

找人帮我确认后,我才发现原来是我DataColChanging跟DataColChanged冲突了。我在DataColChanged还有个代码是判断前一列是否为空的代码

If e.DataCol.Name = "丝印车间" Then
    If e.DataRow.IsNull("胶印车间")   Then
        e.DataRow("丝印车间") = Nothing
        MessageBox.show("上一道印刷工序未确认","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    End If
End If

2个代码都执行就报错了。。还是要优化下

--  作者:有点甜
--  发布时间:2018/9/17 10:24:00
--  
报什么错?报错截图发上来看看。或者,直接做一个项目发上来测试。
--  作者:林胤
--  发布时间:2018/9/17 10:52:00
--  
刚才调试了下,发现DataColChanging的代码写的时候,不能返回空值,不然会一直报错。只能写取消操作,这样跟DataColChanged的代码冲突就会少点。
--  作者:有点甜
--  发布时间:2018/9/17 11:03:00
--  

直接做一个项目发上来测试。


--  作者:林胤
--  发布时间:2018/9/17 12:21:00
--  
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:订单管理.table

我早上优化了下代码,测试了下。功能可以执行了,但是我还要多测下,看看哪里不严谨。

表B的代码是优化过的。

--  作者:林胤
--  发布时间:2018/9/17 12:21:00
--  
表B是我优化过的代码。。
--  作者:有点甜
--  发布时间:2018/9/17 12:28:00
--  
以下是引用林胤在2018/9/17 12:21:00的发言:
表B是我优化过的代码。。

 

测试没问题就好。如果有问题,请具体说明怎么操作(输入什么),想得到什么效果。


--  作者:林胤
--  发布时间:2018/9/17 13:18:00
--  
我弄这个就是一个订单跟踪表而已,输入什么倒是没有什么要求,就是一些分组输入及编辑权限而已。最终应该还会设计个窗口查询。

我现在最差的就是把编程习惯,我本来是想说把视频跟帮助看完再来动手,后面想想还是边动好。。这样才好熟悉编程习惯。