Foxtable(狐表)用户栏目专家坐堂 → 项目模式+年的判断编码,有时不正常,求解


  共有1602人关注过本帖树形打印复制链接

主题:项目模式+年的判断编码,有时不正常,求解

帅哥哟,离线,有人找我吗?
舞楼名角
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:84 积分:1129 威望:0 精华:0 注册:2014/11/13 16:20:00
项目模式+年的判断编码,有时不正常,求解  发帖心情 Post By: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

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By: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

 回到顶部