以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 项目模式+年的判断编码,有时不正常,求解 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=116726) |
-- 作者:舞楼名角 -- 发布时间:2018/3/30 1:28:00 -- 项目模式+年的判断编码,有时不正常,求解 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("项目模式") & e.DataRow("省份") & e.DataRow("城市代码") & e.DataRow("合同甲方") & Format(d,"yyMMdd") If e.DataRow("项目编码").StartsWith(bh) = False \'如果单据编号前缀不符 Dim max As String Dim idx As Integer Dim flt As String flt = "项目模式 = \'" & e.DataRow("项目模式") & "\'And 编码日期 >= \'" & fd & "\' And 编码日期 <= \'" & ld & "\' And [_Identify] <> " & e.DataRow("_Identify") max = e.DataTable.SqlCompute("Max(项目编码)",flt) \'取得该年的相同项目模式的最大编号 If max > "" Then \'如果存在最大单据编号 idx = CInt(max.Substring(bh.Length,3)) + 1 \'获得最大单据编号的后三位顺序号,并加1 Else idx = 1 \'否则顺序号等于1 End If e.DataRow("项目编码") = bh & Format(idx,"000") End If End If End Select
|
-- 作者:有点甜 -- 发布时间:2018/3/30 9:16:00 -- 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 fd As Date = New Date(y,1,1) \'获得该年的第一天 Dim ld As Date = New Date(y+1,1,1) \'获得明年的第一天 Dim bh As String = e.DataRow("项目模式") & e.DataRow("省份") & e.DataRow("城市代码") & e.DataRow("合同甲方") & Format(d,"yyMMdd") Dim max As String Dim idx As Integer Dim flt As String flt = "项目模式 = \'" & e.DataRow("项目模式") & "\' And 编码日期 >= #" & fd & "# And 编码日期 < #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify") max = e.DataTable.SqlCompute("Max(项目编码)",flt) \'取得该年的相同项目模式的最大编号 If max > "" Then \'如果存在最大单据编号 idx = CInt(max.Substring(bh.Length,3)) + 1 \'获得最大单据编号的后三位顺序号,并加1 Else idx = 1 \'否则顺序号等于1 End If e.DataRow("项目编码") = bh & Format(idx,"000") End If End Select |