If e.DataCol.Name = "time" Then
If e.DataRow.IsNull("time") Then
e.DataRow("rukudanhao") = Nothing
Else
Dim bh As String = "入库" & Format(e.DataRow("time"),"yyyyMMdd") '取得rukudanhao的8位前缀
If e.DataRow("rukudanhao").StartsWith(bh) = False '如果rukudanhao的前8位不符
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(rukudanhao)","time = #" & e.DataRow("time") & "# And [_Identify] <> " & e.DataRow("_Identify")) '取得该天的最大rukudanhao
If max > "" Then '如果存在最大rukudanhao
idx = CInt(max.Substring(11,3)) + 1 '获得最大rukudanhao的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("rukudanhao") = bh & "-" & Format(idx,"000")
End If
End If
End If