例如:
订单编号 接单日期
DD20210427-001 2021-04-27 00:00:00
DD20210427-002 2021-04-27 00:00:00
DD20210427-003 2021-04-27 00:00:00
我在点击重置列之后,订单编号自动变成如下:
订单编号 接单日期
DD20210427-004 2021-04-27 00:00:00
DD20210427-005 2021-04-27 00:00:00
DD20210427-006 2021-04-27 00:00:00
这样的后果是订单编号变动后,无法进行统计和跟踪。
问:如何在点击重置列之后,系统内的订单编号不会被更新?
我的代码是,在表事件中的“DataColChanged”中写入了如下代码:
If e.DataCol.Name = "接单日期" Then
If e.DataRow.IsNull("接单日期") Then
e.DataRow("编号") = Nothing
Else
Dim bh As String = Format(e.DataRow("接单日期"),"yyyyMMdd") '取得编号的8位前缀
If e.DataRow("编号").StartsWith(bh) = False '如果编号的前8位不符
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(编号)"," 接单日期 = #" & e.DataRow("接单日期") & "# And [_Identify] <> " & e.DataRow("_Identify")) '取得该天的最大编号
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(11,3)) + 1 '获得最大编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("编号") ="DD" & bh & "-" & Format(idx,"000")
End If
End If
End If