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”