以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]自动流水号不增加 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=175972) |
-- 作者:ynhyxin -- 发布时间:2022/3/25 13:54:00 -- [求助]自动流水号不增加 要实现收据编号的后5位是流水号。 现在是: 编码是帮助里的: \'收据编号自动录入 (项目代码-制单日期-流水号) Select e.DataCol.Name Case "zdrq","sjid" 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") & "-" \'生成编号的前缀 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") max = e.DataTable.Compute("Max(sjid)",flt) \'取得该月的相同项目代码的最大单据编号 If max > "" Then \'如果存在最大单据编号 idx = CInt(max.Substring(13,5)) + 1 \'获得最大单据编号的后五位顺序号,并加1 Else idx = 1 \'否则顺序号等于1 End If e.DataRow("sjid") = bh & Format(idx,"00000") e.DataRow.Save End If End If End Select 能帮我看看是错在什么地方吗?谢谢! |
-- 作者:有点蓝 -- 发布时间: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 |
-- 作者:ynhyxin -- 发布时间:2022/3/25 14:33:00 -- 谢谢!看懂啦! |