工程编号 | 合同编号 | 子目号 | 子目名称 | 计价开始时间 | 计价结束时间 | 登记时间 | 计价编号 | | |
承包-201904-0001 | 105084303B-2020-GCFB-01 | 202-1-a | 清表 | 2020-01-01 | 2020-01-20 | 2020-01-23 | 105084303B-2020-GCFB-01-y13-01 | | |
承包-201904-0001 | 105084303B-2020-GCFB-01 | 202-1-a | 清表 | 2020-01-21 | 2020-02-20 | 2020-02-25 | 105084303B-2020-GCFB-01-y13-02 | | |
承包-201904-0001 | 105084303B-2020-GCFB-01 | 202-1-a | 清表 | 2020-02-21 | 2020-03-20 | 2020-03-21 | 105084303B-2020-GCFB-01-y13-03 | | |
承包-201904-0001 | 105084303B-2020-GCFB-01 | 202-1-a | 清表 | 2020-03-21 | 2020-04-20 | 2020-04-22 | 105084303B-2020-GCFB-01-y13-04 | | |
老师您好!请教一下,如何根据时间段来自动编号?
我在
DataColChanged事件中:
Select e.DataCol.Name
Case "登记时间","工程编号" ,"合同编号","子目号","计价开始时间","计价结束时间","计价编号"
If e.DataRow.IsNull("登记时间") OrElse e.DataRow.IsNull("合同编号") OrElse e.DataRow.IsNull("工程编号") OrElse e.DataRow.IsNull("计价开始时间") OrElse e.DataRow.IsNull("计价结束时间") Then
e.DataRow("计价编号") = Nothing
Else
Dim d As Date = e.DataRow("登记时间")
Dim d1 As Date = e.DataRow("计价开始时间")
Dim d2 As Date = e.DataRow("计价结束时间")
'Dim dr1 As DataRow
'Dim dr2 As DataRow
Dim bh As String = e.DataRow("合同编号") & "-" & "Y13" & "-" '生成编号的前缀
If e.DataRow("计价编号").StartsWith(bh) = False '如果单据编号前缀不符
Dim max As String
Dim idx As Integer
Dim flt As String
flt = "合同编号 = '" & e.DataRow("合同编号") & " ' and 子目号 = '" & e.DataRow("子目号") & "' And #" & d2 & "# >#" & d1 & "# And [_Identify] <> " & e.DataRow("_Identify")
max = e.DataTable.Compute("Max(计价编号)",flt)
If max > "" Then
idx = CInt(max.Substring(27,2)) + 1 '获得最大单据编号的后二位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("计价编号") = bh & Format(idx,"00")
End If
End If
End Select
可是这样不会出来,请老师,帮我看看如何实现?