If e.DataCol.Name = "下单时间" Then
If e.DataRow.IsNull("下单时间") Then
e.DataRow("订单编号") = Nothing
Else
Dim bh As String = Format(e.DataRow("下单时间"),"yyyyMMddHHmmss") '以下单日期加时间为准生成订单号前14位
If e.DataRow("订单编号").StartsWith(bh) = False '如果编号的前14位不符
Dim max As String
Dim idx As Integer
Dim d As Date = e.DataRow("下单时间")
max = e.DataTable.Compute("Max(订单编号)","下单时间 >= #" & d.Date & "# And 下单时间 < #" & d.Date.AddDays(1) & "# And [_Identify] <> " & e.DataRow("_Identify"))'取得该天的最大编号
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(15,3))+1 '获得最大编号的后四位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("订单编号") = bh & Format(idx,"000")
End If
End If
End If
代码改成这样产生了问题
此主题相关图片如下:微信截图_20170118115704.png
