以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  请帮忙看下,谢谢  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=12625)

--  作者:狐友
--  发布时间:2011/9/9 15:27:00
--  请帮忙看下,谢谢
如何根据批号,生成生产日期 ,和到期日(到期日=生产日期+7天)谢谢
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目3.table


--  作者:紙上不談兵
--  发布时间:2011/9/9 15:47:00
--  
If e.DataCol.Name = "批号" Then
    Dim dr as datarow
    If dr.IsNull("批号") Then
        dr("生产日期") = Nothing
        dr("到期日") = Nothing
    Else
        Dim s As String= "20" & dr("批号")
        s= Mid(s,1,4) & "-" & Mid(s,5,2) & "-" & Mid(s,7,2)       
        dr("生产日期") = Cdate(s)
        dr("到期日") = dr("生产日期").adddays(7)
    End If
End If

--  作者:狐友
--  发布时间:2011/9/9 16:20:00
--  

出现错误,未将对象引用设置到对象实例


--  作者:狐狸爸爸
--  发布时间:2011/9/9 16:27:00
--  
If e.DataCol.Name = "批号" Then
    Dim dr As DataRow = e.DataRow
    If dr.IsNull("批号") Then
        dr("生产日期") = Nothing
        dr("到期日") = Nothing
    Else
        Dim s As String= "20" & dr("批号")
        s= Mid(s,1,4) & "-" & Mid(s,5,2) & "-" & Mid(s,7,2)      
        dr("生产日期") = Cdate(s)
        dr("到期日") = dr("生产日期").adddays(7)
    End If
End If

--  作者:yangming
--  发布时间:2011/9/9 16:33:00
--  

放到表属性:DataColChanged 事件中

If e.DataCol.Name = "批号" Then
    If e.DataRow.IsNull("批号") Then
        e.DataRow("生产日期") = Nothing
        e.DataRow("到期日") = Nothing
    Else
        Dim s As String= "20" & e.DataRow("批号")
        s= Mid(s,1,4) & "-" & Mid(s,5,2) & "-" & Mid(s,7,2)
        e.DataRow("生产日期") =CDate(s)
        e.DataRow("到期日") = e.DataRow("生产日期").adddays(7)
    End If
End If