Select e.DataCol.Name
Case "编码日期","项目模式","省份","城市代码","合同甲方"
If e.DataRow.IsNull("编码日期") Or e.DataRow.IsNull("项目模式") Or e.DataRow.IsNull("城市代码") Or e.DataRow.IsNull("合同甲方") OrElse e.DataRow.IsNull("省份") Then
e.DataRow("过渡编号") = Nothing
Else
Dim d As Date = e.DataRow("编码日期")
Dim y As Integer = d.Year
Dim m As Integer = d.Month
Dim dd As Integer = d.Day
Dim Days As Integer = Date.DaysInMonth(y,m)
Dim fd As Date = New Date(y,1,1) '获得该年的第一天
Dim ld As Date = New Date(y+1,1,1) '获得该明的第一天
Dim bh As String = e.DataRow("项目模式")
Dim max As String
Dim idx As Integer
Dim flt As String
flt = "过渡编号 like '" & bh & "%' And 编码日期 >= #" & fd & "# And 编码日期 <= #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify")
bh &= Format(d,"yy") '生成编号的前缀
max = e.DataTable.Compute("Max(过渡编号)",flt) '取得该年的相同项目模式的最大编号
If max > "" Then '如果存在最大单据编号
idx = CInt(max.Substring(bh.length)) + 1 '获得最大单据编号的后四位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("过渡编号") = bh & Format(idx,"000")
End If
End Select
Select e.DataCol.Name
Case "编码日期","项目模式","省份","城市代码","合同甲方","过渡编号"
If e.DataRow.IsNull("编码日期") Or e.DataRow.IsNull("项目模式") Or e.DataRow.IsNull("城市代码") Or e.DataRow.IsNull("合同甲方") Or e.DataRow.IsNull("省份") OrElse e.DataRow.IsNull("过渡编号") Then
e.DataRow("项目编号") = Nothing
Else
Dim d As Date = e.DataRow("编码日期")
Dim flt2 As String = e.DataRow("过渡编号")
Dim bb As String = e.DataRow("项目模式") & e.DataRow("省份") & e.DataRow("城市代码") & e.DataRow("合同甲方")
e.DataRow("项目编号") = bb & Format(d,"yyMMdd") & flt2.SubString(6,3)
End If
End Select