Foxtable(狐表)用户栏目专家坐堂 → [求助]编号问题


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

主题:[求助]编号问题

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


加好友 发短信
等级:一尾狐 帖子:463 积分:4163 威望:0 精华:0 注册:2011/4/5 16:54:00
[求助]编号问题  发帖心情 Post By:2015/6/2 11:50: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,1,1) '获得该月的第一天
            Dim ld As Date = New Date(y,12,31) '获得该月的最后一天
            Dim bh As String = e.DataRow("社区代码") & "-" & Format(d,"yyyy") & "-" '生成编号的前缀
            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.SQLCompute("Max(保单编号)",flt) '取得该月的相同工程代码的最大单据编号
                If max > "" Then '如果存在最大单据编号
                    idx = CInt(max.Substring(18,4)) + 1 '获得最大单据编号的后四位顺序号,并加1
                Else
                    idx = 1 '否则顺序号等于1
                End If
                e.DataRow("保单编号") = bh & Format(idx,"0000")
            End If
        End If
End Select


 回到顶部