Foxtable(狐表)用户栏目专家坐堂 → 自动编号问题?


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

主题:自动编号问题?

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2019/6/27 9:11:00 [显示全部帖子]

'已知订单日期,自动得出订单编号,年月日编号:
Select Case User.Group
    Case "财务"
        If e.DataCol.Name = "订单日期" Then
            If e.DataRow.IsNull("订单日期") Then
                e.DataRow("订单编号") = Nothing
            Else
                Dim bh1 As String = "DT" & Format(e.DataRow("订单日期"),"yyMMdd") '取得订单编号的8位前缀
                If e.DataRow("订单编号").StartsWith(bh1) = False '如果订单编号的前8位不符
                    Dim max1 As String
                    Dim idx1 As Integer
                    Dim d1 As Date = e.DataRow("订单日期").Date
                    max1 = e.DataTable.Compute("Max(订单编号)","订单编号 like '" & bh1 & "%' and 订单日期 >= #" & d1 & "# And 订单日期 < #" & d1.adddays(1) & "# And [_Identify] <> " & e.DataRow("_Identify")) '取得该月的最大编号
                    If max1 > "" Then '如果存在最大订单编号
                        idx1 = CInt(max1.Substring(max1.length-3,3)) + 1 '获得最大过磅编号的后三位顺序号,并加1
                    Else
                        idx1 = 1 '否则顺序号等于1
                    End If
                    e.DataRow("订单编号") = bh1 & Format(idx1,"000")
                End If
            End If
        End If
    Case Else
        If e.DataCol.Name = "订单日期" Then
            If e.DataRow.IsNull("订单日期") Then
                e.DataRow("订单编号") = Nothing
            Else
                Dim bh2 As String = "DY" & Format(e.DataRow("订单日期"),"yyMMdd") '取得订单编号的8位前缀
                If e.DataRow("订单编号").StartsWith(bh2) = False '如果订单编号的前8位不符
                    Dim max2 As String
                    Dim idx2 As Integer
                    Dim d2 As Date = e.DataRow("订单日期").Date
                    max2 = e.DataTable.Compute("Max(订单编号)","订单编号 like '" & bh2 & "%' and 订单日期 >= #" & d2 & "# And 订单日期 < #" & d2.adddays(1) & "# And [_Identify] <> " & e.DataRow("_Identify")) '取得该月的最大编号
                    If max2 > "" Then '如果存在最大订单编号
                        idx2 = CInt(max2.Substring(max2.length-3,3)) + 1 '获得最大过磅编号的后三位顺序号,并加1
                    Else
                        idx2 = 1 '否则顺序号等于1
                    End If
                    e.DataRow("订单编号") = bh2 & Format(idx2,"000")
                End If
            End If
        End If
End Select

 回到顶部