Select e.DataCol.Name Case "新单" If e.DataCol.Name = "新单" Then If e.NewValue = True Then If e.DataRow.IsNull("批号") Then Dim lb As String = e.DataRow("编号") If e.DataRow("批号").StartsWith(lb & "-") = False '如果产品编号前缀不符 Dim max As String Dim idx As Integer max = e.DataTable.Compute("Max(批号)","编号= '" & lb & "' And [_Identify] <> " & e.DataRow("_Identify") & " And 新单 = True") '取得该编号的最大号 If max > "" Then '如果存在最大号 idx = max.IndexOf("-") + 1 idx = CInt(max.Substring(idx)) + 1 Else idx = 1 '否则顺序号等于1 End If e.DataRow("批号") = lb & "-" & Format(idx,"0000") End If End If End If End If End Select
|