以文本方式查看主题

-  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=50163)

--  作者:hz1717
--  发布时间:2014/4/30 14:09:00
--  求助:自动编号。
老师好:
     关于自动编号,我参照帮助文件做了,原来能生成,同时一个个顺延生成。
     但是,今天打开后,自动编号行一直生成  序号为1.
   
      代码没有动过。应该不存在问题,是什么原因。

--  作者:Bin
--  发布时间:2014/4/30 14:12:00
--  
这个需要调试分析才知道.

建议文件发上来我们看一下吧

--  作者:hz1717
--  发布时间:2014/4/30 14:29:00
--  

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:储运部仓储管理系统20140312(不能实现系统统计).zip

密码为:1

 

 

入库主表:  中   ,入库单号为自动生成。

入库类型、制单日期为必填。。

 


 


--  作者:Bin
--  发布时间:2014/4/30 14:39:00
--  
你的条件代码有缺陷,一旦到达月份最后一条就会失效了,刚好今天是4月最后一天

改成这样即可.


flt = "入库类型 = \'" & e.DataRow("入库类型") & "\' And 制单日期 >= #" & fd & "# And 制单日期 <= #" & ld & " 23:59:59# And [_Identify] <> " & e.DataRow("_Identify")


--  作者:有点甜
--  发布时间:2014/4/30 14:44:00
--  

 或者这样改

 

Select e.DataCol.Name
    Case "制单日期","入库类型"
        If e.DataRow.IsNull("制单日期") OrElse 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)
            Dim fd As Date = New Date(y,m,1) \'获得该月的第一天
            Dim ld As Date = fd.AddMonths(1)

            Dim bh As String = e.DataRow("入库类型") & "-" & Format(d,"yyyyMM") & "-" \'生成编号的前缀
            If e.DataRow("入库单号").StartsWith(bh) = False \'如果单据编号前缀不符
                Dim max As String
                Dim idx As Integer
                Dim flt As String
                flt = "入库类型 = \'" & e.DataRow("入库类型") & "\' And 制单日期 >= #" & fd & "# And 制单日期 < #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify")
                max = e.DataTable.Compute("Max(入库单号)",flt) \'取得该月的相同工程代码的最大单据编号
                If max > "" Then \'如果存在最大单据编号
                    idx = CInt(max.Substring(12,4)) + 1 \'获得最大单据编号的后四位顺序号,并加1
                Else
                    idx = 1 \'否则顺序号等于1
                End If
                e.DataRow("入库单号") = bh & Format(idx,"0000")
            End If
        End If
End Select

If e.DataCol.Name = "入库类型" Then
    e.DataRow("订单状态") = "已收货,待清点"
End If

If e.DataCol.Name = "制单日期" Then
    Dim dr As DataRow = e.DataRow
    Dim dt As Date = dr("制单日期")
    dr("预计完成时间") = dt.AddHours(24)
End If


--  作者:hz1717
--  发布时间:2014/4/30 14:48:00
--  
谢谢