Foxtable(狐表)用户栏目专家坐堂 → 编码如何生成?


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

主题:编码如何生成?

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


加好友 发短信
等级:幼狐 帖子:100 积分:1120 威望:0 精华:0 注册:2017/5/3 18:40:00
编码如何生成?  发帖心情 Post By:2017/5/9 15:00:00 [只看该作者]

If e.DataCol.Name = "产品名称" Then
    If e.DataRow.IsNull("产品名称") Then
        e.DataRow("产品编码") = Nothing
    Else
        e.DataRow("产品编码") = GetPy(e.DataRow("产品名称"))
  End If        
 Dim bh As String = Format(e.DataRow("订货日期"),"yyyyMMdd")
        If e.DataRow("订单编码").StartsWith(bh) = True
            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,3)) + 1
            Else
                idx = 1
            e.DataRow("订单编码") = bh & "-" & Format(idx,"000")
        End If
    End If
End If

请问“订货日期”自动生成“订单编码”,如“订货日期分别:20170509,20170509”自动生成“订单编码分别20170509001,20170509002”;“产品名称”自动取产品名称各字的首字母生成“产品编码”,如“麻醉包”自动生成“MZB”

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


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/5/9 15:35:00 [只看该作者]

If e.DataCol.Name = "产品名称" Then
    If e.DataRow.IsNull("产品名称") Then
        e.DataRow("产品编码") = Nothing
    Else
        e.DataRow("产品编码") = GetPinyin(e.DataRow("产品名称"), 1)
    End If
    Dim bh As String = e.DataRow("产品编码") & Format(e.DataRow("订货日期"),"yyyyMMdd")
    If e.DataRow("订单编码").StartsWith(bh) = True
        Dim max As String
        Dim idx As Integer
        max = e.DataTable.Compute("Max(订单编码)","产品名称 = '" & e.DataRow("产品名称") & "' and 订货日期= #" & e.DataRow("订货日期") & "# And [_Identify] <> " & e.DataRow("_Identify"))
        If max > "" Then
            idx = CInt(max.Substring(bh.length+1,3)) + 1
        Else
            idx = 1
            e.DataRow("订单编码") = bh & "-" & Format(idx,"000")
        End If
    End If
End If

 回到顶部