-- 作者:pz1256
-- 发布时间:2014/9/5 0:17:00
-- 自动生成编号出错
此主题相关图片如下:qq图片20140905001353.jpg
 欲自动生成编号,可是为什么只能自动编两个单号,并且还是先生成01,后生成00.这代码中哪里错了呢?求指错。
Select e.DataCol.Name Case "确定订单" If e.NewValue = True Then e.DataRow.Locked = True End If Case "下单时间","影楼名称" If e.DataRow.IsNull("下单时间") OrElse e.DataRow.IsNull("影楼名称") Then e.DataRow("订单编号") = Nothing Else Dim d As Date = e.DataRow("下单时间") Dim max As String Dim idx As Integer Dim flt As String Dim bh As String = e.DataRow("影楼代码") & Format(d,"yyyyMMdd") & "-" \'生成编号的前缀 flt = "影楼代码 = \'"& e.DataRow("影楼代码") & "\'and 下单时间 = #" & e.DataRow("下单时间") & "# And [_Identify] <> " & e.DataRow("_Identify") max = e.DataTable.Compute("Max(订单编号)",flt) \'取得该天的同影楼的最大单据编号 If max > "" Then \'如果存在最大单据编号 idx = max.Substring ( max.IndexOf ("-"),3) +1 \'获得最大单据编号的后三位顺序号,并加1 Else idx = 1 \'否则顺序号等于1 End If e.DataRow("订单编号") = bh & Format(idx,"00") End If End Select
|
-- 作者:狐狸爸爸
-- 发布时间:2014/9/5 8:31:00
--
Select e.DataCol.Name Case "确定订单" If e.NewValue = True Then e.DataRow.Locked = True End If Case "下单时间","影楼名称" If e.DataRow.IsNull("下单时间") OrElse e.DataRow.IsNull("影楼名称") Then e.DataRow("订单编号") = Nothing Else Dim d As Date = e.DataRow("下单时间") Dim max As String Dim idx As Integer Dim flt As String Dim bh As String = e.DataRow("影楼代码") & Format(d,"yyyyMMdd") & "-" \'生成编号的前缀 flt = "影楼代码 = \'"& e.DataRow("影楼代码") & "\'and 下单时间 = #" & e.DataRow("下单时间") & "# And [_Identify] <> " & e.DataRow("_Identify") max = e.DataTable.Compute("Max(订单编号)",flt) \'取得该天的同影楼的最大单据编号 If max > "" Then \'如果存在最大单据编号 idx = max.Substring ( max.IndexOf ("-")+1,2) +1 \'获得最大单据编号的后三位顺序号,并加1 Else idx = 1 \'否则顺序号等于1 End If e.DataRow("订单编号") = bh & Format(idx,"00") End If End Select
|