老师好,我想在商品名称列的字段中只取字符开头的一个字符(只取3个)谢谢老师。
Select e.DataCol.Name
Case "项目","商品名称"
If e.DataRow.IsNull("项目") OrElse e.DataRow.Isnull("商品名称") Then
e.DataRow("商品ID") = Nothing
Else
Dim lb As String = getpy(e.DataRow("项目"), True).toupper & "-" & getpy(e.DataRow("商品名称")) & "-"
Dim max As String = e.DataTable.Compute("Max(商品ID)","商品id like '" & lb & "%' And _Identify<> '" & e.DataRow("_Identify") & "'") '取得该类别的最大编号
Dim idx = 1
If max > "" Then
idx = cint(max.SubString(lb.length))+1
End If
e.DataRow("商品ID") = lb & format(idx, "000")
End If
End Select
老师,用黄色标出的补满三拼音多了裁
能源
自来水
NY-ZLS-001
能源
国电
NY-GD-001
能源
燃气
NY-RQ-001
Select e.DataCol.Name
Case "项目","商品名称"
If e.DataRow.IsNull("项目") OrElse e.DataRow.Isnull("商品名称") Then
e.DataRow("商品ID") = Nothing
Else
' ''Dim lb As String = getpy(e.DataRow("商品名称")) & "-" & e.DataRow("型号") & "-" & e.DataRow("规格") & "-"
Dim lb As String = getpy(e.DataRow("项目"), True).toupper & "-" & getpy(e.DataRow("商品名称"), True) & "-"
Dim max As String = e.DataTable.Compute("Max(商品ID)","商品id like '" & lb & "%' And _Identify<> '" & e.DataRow("_Identify") & "'") '取得该类别的最大编号
Dim idx = 1
If max > "" Then
idx = cint(max.SubString(lb.length))+1
End If
e.DataRow("商品ID") = lb & format(idx, "000")
End If
End Select
[此贴子已经被作者于2024/1/8 20:45:11编辑过]
Dim lb As String = getpy(e.DataRow("项目"), True).toupper & "-" & Left(getpy(e.DataRow("商品名称")),3).PadRight(3,getpy(user.name, True)(0)) & "-"