Select e.DataCol.Name Case "订单号" If e.DataRow.IsNull("订单号") Then e.DataRow("合同序号") = Nothing Else 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")) '取得该订单号的最大合同序号 If max > "" Then '如果存在最大合同序号 idx = max.IndexOf("-") + 1 idx = CInt(max.Substring(idx)) + 1 Else idx = 1 '否则顺序号等于1 End If e.DataRow("合同序号") = lb & "-" & Format(idx,"000") End If End If End Select
|