Select Case e.DataCol.name Case "日期", "客户编码" If e.DataRow("日期") = Nothing OrElse e.DataRow("客户编码") = Nothing Then e.DataRow("出库单序码") = Nothing Else Dim fdr As DataRow = e.DataTable.find("日期 = #" & e.DataRow("日期") & "# and 客户编码 ='" & e.DataRow("客户编码") & "' and 出库单序码 Is not null") If fdr IsNot Nothing Then e.DataRow("出库单序码") = fdr("出库单序码") Else Dim bh As String = Format(e.DataRow("日期"),"yyyyMMdd") & "-" & e.DataRow("客户编码") & "-" '取得编号的8位前缀 If e.DataRow("出库单序码").StartsWith(bh) = False '如果编号的前8位不符 Dim max As String Dim idx As Integer = 0 For Each dr As DataRow In e.DataTable.Select("出库单序码 is not null and 日期 = #" & e.DataRow("日期") & "# And [_Identify] <> " & e.DataRow("_Identify")) If right(dr("出库单序码"), 3) > idx Then idx = right(dr("出库单序码"), 3) End If Next idx += 1 e.DataRow("出库单序码") = bh & Format(idx,"000") End If End If End If End Select
|