Foxtable(狐表)用户栏目专家坐堂 → 不同用户不同编号


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

主题:不同用户不同编号

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


加好友 发短信
等级:幼狐 帖子:160 积分:1214 威望:0 精华:0 注册:2015/7/1 17:35:00
不同用户不同编号  发帖心情 Post By:2016/5/27 14:14:00 [只看该作者]

请问如果a用户登录就用当天日期-000 作为编号,b用户用当天日期-100作为编号..o.
例如a用户:20160527-0001    20160527-0002
      b用户:20160527-1001    20160527-1002
........................
请问如何修改下面代码才能使得报价单编号不重复
 If e.DataCol.Name = "报价日期" Then
    If e.DataRow.IsNull("报价日期") Then
        e.DataRow("报价单编号") = Nothing
    Else
        Dim bh As String = Format(e.DataRow("报价日期"),"yyyyMMdd") '取得编号的8位前缀
        If e.DataRow("报价单编号").StartsWith(bh) = False '如果编号的前8位不符
            Dim max As String
            Dim idx As Integer
            max = e.DataTable.Compute("Max(报价单编号)","报价日期 = #" & e.DataRow("报价日期") & "# And [_Identify] <> " & e.DataRow("_Identify")) '取得该天的最大编号
            If max > "" Then '如果存在最大编号
                idx = CInt(max.Substring(9,4)) + 1 '获得最大编号的后三位顺序号,并加1
            Else
                idx = 1 '否则顺序号等于1
            End If
            If user.name = "a"
                e.DataRow("报价单编号") = bh & "-" & Format(idx,"0000")
            Else If user.name = "b"
                e.DataRow("报价单编号") = bh & "-" & Format(idx,"1000")
            Else If user.name = "c"
                e.DataRow("报价单编号") = bh & "-" & Format(idx,"2000")
            Else
                e.DataRow("报价单编号") = bh & "-" & Format(idx,"8000")
                
            End If
        End If
    End If
End If
[此贴子已经被作者于2016/5/27 14:14:48编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/5/27 14:45:00 [只看该作者]

必须要加一列存放用户的名称

 

If e.DataCol.Name = "报价日期" Then
    If e.DataRow.IsNull("报价日期") Then
        e.DataRow("报价单编号") = Nothing
    Else
        Dim bh As String = Format(e.DataRow("报价日期"),"yyyyMMdd") '取得编号的8位前缀
        If e.DataRow("报价单编号").StartsWith(bh) = False '如果编号的前8位不符
            Dim max As String
            Dim idx As Integer
            max = e.DataTable.Compute("Max(报价单编号)","报价日期 = #" & e.DataRow("报价日期") & "# and 用户 = '"& user.name & "' And [_Identify] <> " & e.DataRow("_Identify")) '取得该天的最大编号
            If max > "" Then '如果存在最大编号
                idx = CInt(max.Substring(bh.length+1)) + 1 '获得最大编号的后三位顺序号,并加1
            Else
                idx = 1 '否则顺序号等于1
            End If
            If user.name = "a"
                e.DataRow("报价单编号") = bh & "-0" & Format(idx,"000")
            Else If user.name = "b"
                e.DataRow("报价单编号") = bh & "-1" & Format(idx,"000")
            Else If user.name = "c"
                e.DataRow("报价单编号") = bh & "-2" & Format(idx,"000")
            Else
                e.DataRow("报价单编号") = bh & "-8" & Format(idx,"000")
            End If
            e.DataRow("用户") = user.name
        End If
    End If
End If


 回到顶部
帅哥哟,离线,有人找我吗?
woshiabc
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:160 积分:1214 威望:0 精华:0 注册:2015/7/1 17:35:00
  发帖心情 Post By:2016/5/27 15:11:00 [只看该作者]

 你好,最后结果变成1000,1101 , 1111,最后溢出了

 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/5/27 15:14:00 [只看该作者]

If e.DataCol.Name = "报价日期" Then
    If e.DataRow.IsNull("报价日期") Then
        e.DataRow("报价单编号") = Nothing
    Else
        Dim bh As String = Format(e.DataRow("报价日期"),"yyyyMMdd") '取得编号的8位前缀
        If e.DataRow("报价单编号").StartsWith(bh) = False '如果编号的前8位不符
            Dim max As String
            Dim idx As Integer
            max = e.DataTable.Compute("Max(报价单编号)","报价日期 = #" & e.DataRow("报价日期") & "# and 用户 = '"& user.name & "' And [_Identify] <> " & e.DataRow("_Identify")) '取得该天的最大编号
            If max > "" Then '如果存在最大编号
                idx = CInt(max.Substring(bh.length+2)) + 1 '获得最大编号的后三位顺序号,并加1
            Else
                idx = 1 '否则顺序号等于1
            End If
            If user.name = "a"
                e.DataRow("报价单编号") = bh & "-0" & Format(idx,"000")
            Else If user.name = "b"
                e.DataRow("报价单编号") = bh & "-1" & Format(idx,"000")
            Else If user.name = "c"
                e.DataRow("报价单编号") = bh & "-2" & Format(idx,"000")
            Else
                e.DataRow("报价单编号") = bh & "-8" & Format(idx,"000")
            End If
            e.DataRow("用户") = user.name
        End If
    End If
End If


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/5/27 15:18:00 [只看该作者]

或者这样也可以

 


If e.DataCol.Name = "报价日期" Then
    If e.DataRow.IsNull("报价日期") Then
        e.DataRow("报价单编号") = Nothing
    Else
        Dim bh As String = Format(e.DataRow("报价日期"),"yyyyMMdd") '取得编号的8位前缀
        If e.DataRow("报价单编号").StartsWith(bh) = False '如果编号的前8位不符
            Dim max As String
            Dim idx As Integer
            If user.name = "a"
                bh = bh & "-0"
            Else If user.name = "b"
                bh = bh & "-1"
            Else If user.name = "c"
                bh = bh & "-2"
            Else
                bh = bh & "-8"
               
            End If
            max = e.DataTable.Compute("Max(报价单编号)","报价单编号 like '" & bh & "%' And [_Identify] <> " & e.DataRow("_Identify")) '取得该天的最大编号
           
            If max > "" Then '如果存在最大编号
                idx = CInt(max.Substring(bh.length)) + 1 '获得最大编号的后三位顺序号,并加1
            Else
                idx = 1 '否则顺序号等于1
            End If
            e.DataRow("报价单编号") = bh & Format(idx,"000")
        End If
    End If
End If


 回到顶部