Foxtable(狐表)用户栏目专家坐堂 → [求助]自动编号代码有错误吗?


  共有6781人关注过本帖平板打印复制链接

主题:[求助]自动编号代码有错误吗?

帅哥哟,离线,有人找我吗?
likui412282
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:50 积分:447 威望:0 精华:0 注册:2013/3/25 12:18:00
[求助]自动编号代码有错误吗?  发帖心情 Post By:2013/4/6 10:14:00 [只看该作者]

If e.DataCol.Name = "订货日期" Then
    If e.DataRow.IsNull("订货日期") Then
        e.DataRow("订单编号") = Nothing
    Else
        Dim d As Date = e.DataRow("订货日期")
        Dim y As Integer = d.Year
        Dim m As Integer = d.Month
        Dim Days As Integer = Date.DaysInMonth(y,m,d)
        Dim fd As Date = New Date(y,m,1)
        Dim ld As Date = New Date(y,m,Days)
        Dim bh As String = Format(d,"yyyyMMdd")
        If e.DataRow("订单编号").StartsWith(bh) = False
            Dim max As String
            Dim idx As Integer
            max = e.DataTable.Compute("Max(订单编号)","订货日期 >= #" & fd & "# And 订货日期 <= #" & ld & "#") 

            If max > "" Then 

                idx = CInt(max.Substring(7,3)) + 1 

            Else
                idx = 1 

            End If
            e.DataRow("订单编号") = bh & "-" & Format(idx,"000")
        End If
    End If
End If


 回到顶部