Foxtable(狐表)用户栏目专家坐堂 → [求助]自动流水号不增加


  共有3573人关注过本帖树形打印复制链接

主题:[求助]自动流水号不增加

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


加好友 发短信
等级:超级版主 帖子:107718 积分:547917 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2022/3/25 14:05:00 [显示全部帖子]

调试

Select e.DataCol.Name
    Case "zdrq"
        If e.DataRow.IsNull("zdrq") OrElse e.DataRow.IsNull("xmdm") Then
            e.DataRow("sjid") = Nothing
        Else
            Dim d As Date = e.DataRow("zdrq")
            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 = New Date(y,m,Days) '获得该月的最后一天
            Dim bh As String = e.DataRow("xmdm") & "-" & Format(d,"yyyyMMdd") & "-" '生成编号的前缀
msgbox(bh )
            If e.DataRow("sjid").StartsWith(bh) = False '如果单据编号前缀不符
                Dim max As String
                Dim idx As Integer
                Dim flt As String
                flt = "xmdm = '"& e.DataRow("xmdm") & "' And zdrq >= #" & fd & "# And zdrq <= #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify")
msgbox(flt )
                max = e.DataTable.Compute("Max(sjid)",flt) '取得该月的相同项目代码的最大单据编号
msgbox(max )
                If max > "" Then '如果存在最大单据编号
                    idx = CInt(max.Substring(max.length - 5)) + 1 '获得最大单据编号的后五位顺序号,并加1
                Else
                    idx = 1 '否则顺序号等于1
                End If
msgbox(idx )
                e.DataRow("sjid") = bh & Format(idx,"00000")
                e.DataRow.Save
            End If
        End If
End Select


 回到顶部