Select e.DataCol.Name Case "办事处","姓名","日期" If e.DataRow.IsNull("姓名") OrElse e.DataRow.IsNull("办事处") OrElse e.DataRow.Isnull("日期") Then e.DataRow("报单号") = Nothing Else Dim d As Date = e.DataRow("日期") Dim bh As String = GetPy(e.DataRow("办事处"),True).ToUpper & "-" & GetPy(e.DataRow("姓名"),True).ToUpper & Format(d,"yyyyMMdd") & "-" '生成报单号的前缀 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 日期 >= #" & d & "# And 日期 < #" & d.AddDays(1) & "# And [_Identify] <> " & e.DataRow("_Identify") 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 If End Select
|