Foxtable(狐表)用户栏目专家坐堂 → 求助:流水账代码


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

主题:求助:流水账代码

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/7/15 10:37:00 [显示全部帖子]

Select Case e.DataCol.Name
    Case "项目名称","工程单位名称","费用类别","费用类别1","进度金额"
        Dim dr As DataRow
        Dim mr As DataRow = e.DataRow
        Dim drs As List(of DataRow)
        dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [项目名称] = '" & mr("项目名称") & "' And [工程单位名称] = '" & mr("工程单位名称") & "' And [费用类别] = '" & mr("费用类别") & "' And [费用类别1] = '" & mr("费用类别1") & "'", "[_SortKey] Desc")
        If dr Is Nothing Then
            mr("累计进度") = mr("进度金额")
            dr = mr
        End If
        drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [项目名称] = '" & dr("项目名称") & "' And [工程单位名称] = '" & dr("工程单位名称") & "' And [费用类别] = '" & dr("费用类别") &  "' And [费用类别1] = '" & dr("费用类别1") & "'", "[_SortKey]")
        For i As Integer = 1 To drs.Count - 1
            drs(i)("累计进度") = drs(i-1)("累计进度") + drs(i)("进度金额")
        Next
        If e.DataCol.Name = "项目名称" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
            dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [项目名称] = '" & e.OldValue & "' And [工程单位名称] = '" & e.OldValue & "' And [费用类别] = '" & e.OldValue & "' And [费用类别1] = '" & e.OldValue & "'", "[_SortKey] Desc")
            If dr Is Nothing Then
                dr = e.DataTable.Find("[项目名称] = '" & e.OldValue & "And [工程单位名称] = '" & e.OldValue & "' And [费用类别] = '" & e.OldValue & "' And [费用类别1] = '" & e.OldValue & "'", "[_SortKey]")
                If dr IsNot Nothing Then
                    dr("累计进度") = dr("进度金额")
                End If
            End If
            If dr IsNot Nothing Then
                drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [项目名称] = '" & dr("项目名称") & "' And [工程单位名称] = '" & dr("工程单位名称") & "' And [费用类别] = '" & dr("费用类别") & "' And [费用类别1] = '" & dr("费用类别1") & "'", "[_SortKey]")
                For i As Integer = 1 To drs.Count - 1
                    drs(i)("累计进度") = drs(i-1)("累计进度") + drs(i)("进度金额")
                Next
            End If
        End If
End Select


Dim Key As Decimal
Dim Index As Integer
Dim Filter As String
Dim r As Row
Index = Math.Min(e.OldIndex, e.NewIndex)
Key = e.Table.Rows(Index)("_SortKey")
r = e.Table.Rows(e.NewIndex)
Filter = "[_SortKey] >= " & Key & " And [项目名称] = '" & r("项目名称") &  " And [工程单位名称] = '" & r("工程单位名称") &  " And [费用类别] = '" & r("费用类别") &  " And [费用类别1] = '" & r("费用类别1") & "'"
e.Table.DataTable.DataCols("进度金额").RaiseDataColChanged(Filter)

 

 


e.DataRow("进度金额") = 0


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/7/15 10:38:00 [显示全部帖子]

 最基本的问题,左右都要加入单引号。

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/7/15 11:02:00 [显示全部帖子]

 在这里加入对应的修改的列,即可

 

Case "项目名称","工程单位名称","费用类别","费用类别1","进度金额"


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/7/15 11:23:00 [显示全部帖子]

 这样写,如果出错,就请上传例子。

 

Select Case e.DataCol.Name
    Case "项目名称","工程单位名称","费用类别","费用类别1","进度金额"
        Dim dr As DataRow
        Dim mr As DataRow = e.DataRow
        Dim drs As List(of DataRow)
        dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [项目名称] = '" & mr("项目名称") & "' And [工程单位名称] = '" & mr("工程单位名称") & "' And [费用类别] = '" & mr("费用类别") & "' And [费用类别1] = '" & mr("费用类别1") & "'", "[_SortKey] Desc")
        If dr Is Nothing Then
            mr("累计进度") = mr("进度金额")
            dr = mr
        End If
        drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [项目名称] = '" & dr("项目名称") & "' And [工程单位名称] = '" & dr("工程单位名称") & "' And [费用类别] = '" & dr("费用类别") &  "' And [费用类别1] = '" & dr("费用类别1") & "'", "[_SortKey]")
        For i As Integer = 1 To drs.Count - 1
            drs(i)("累计进度") = drs(i-1)("累计进度") + drs(i)("进度金额")
        Next
        If e.DataCol.Name = "项目名称" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
            dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [项目名称] = '" & e.OldValue & "' And [工程单位名称] = '" & dr("工程单位名称") & "' And [费用类别] = '" & dr("费用类别") &  "' And [费用类别1] = '" & dr("费用类别1") & "'", "[_SortKey] Desc")
            If dr Is Nothing Then
                dr = e.DataTable.Find("[项目名称] = '" & e.OldValue & "'  And [工程单位名称] = '" & dr("工程单位名称") & "' And [费用类别] = '" & dr("费用类别") &  "' And [费用类别1] = '" & dr("费用类别1") & "'", "[_SortKey]")
                If dr IsNot Nothing Then
                    dr("累计进度") = dr("进度金额")
                End If
            End If
            If dr IsNot Nothing Then
                drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [项目名称] = '" & dr("项目名称") & "' And [工程单位名称] = '" & dr("工程单位名称") & "' And [费用类别] = '" & dr("费用类别") & "' And [费用类别1] = '" & dr("费用类别1") & "'", "[_SortKey]")
                For i As Integer = 1 To drs.Count - 1
                    drs(i)("累计进度") = drs(i-1)("累计进度") + drs(i)("进度金额")
                Next
            End If
        End If
        If e.DataCol.Name = "费用类别1" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
            dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [项目名称] = '" & dr("项目名称") & "' And [工程单位名称] = '" & dr("工程单位名称") & "' And [费用类别] = '" & dr("费用类别") &  "' And [费用类别1] = '" & e.Oldvalue & "'", "[_SortKey] Desc")
            If dr Is Nothing Then
                dr = e.DataTable.Find("[项目名称] = '" & dr("项目名称") & "' And [工程单位名称] = '" & dr("工程单位名称") & "' And [费用类别] = '" & dr("费用类别") &  "' And [费用类别1] = '" & e.Oldvalue & "'", "[_SortKey]")
                If dr IsNot Nothing Then
                    dr("累计进度") = dr("进度金额")
                End If
            End If
            If dr IsNot Nothing Then
                drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [项目名称] = '" & dr("项目名称") & "' And [工程单位名称] = '" & dr("工程单位名称") & "' And [费用类别] = '" & dr("费用类别") & "' And [费用类别1] = '" & dr("费用类别1") & "'", "[_SortKey]")
                For i As Integer = 1 To drs.Count - 1
                    drs(i)("累计进度") = drs(i-1)("累计进度") + drs(i)("进度金额")
                Next
            End If
        End If
        If e.DataCol.Name = "费用类别" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
            dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [项目名称] = '" & dr("项目名称") & "' And [工程单位名称] = '" & dr("工程单位名称") & "' And [费用类别] = '" & e.OldValue  &  "' And [费用类别1] = '" & dr("费用类别1") & "'", "[_SortKey] Desc")
            If dr Is Nothing Then
                dr = e.DataTable.Find("[项目名称] = '" & dr("项目名称") & "' And [工程单位名称] = '" & dr("工程单位名称") & "' And [费用类别] = '" & e.OldValue  &  "' And [费用类别1] = '" & dr("费用类别1") & "'", "[_SortKey]")
                If dr IsNot Nothing Then
                    dr("累计进度") = dr("进度金额")
                End If
            End If
            If dr IsNot Nothing Then
                drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [项目名称] = '" & dr("项目名称") & "' And [工程单位名称] = '" & dr("工程单位名称") & "' And [费用类别] = '" & dr("费用类别") & "' And [费用类别1] = '" & dr("费用类别1") & "'", "[_SortKey]")
                For i As Integer = 1 To drs.Count - 1
                    drs(i)("累计进度") = drs(i-1)("累计进度") + drs(i)("进度金额")
                Next
            End If
        End If
        If e.DataCol.Name = "工程单位名称" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
            dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [项目名称] = '" & dr("项目名称") & "' And [工程单位名称] = '" & e.OldValue & "' And [费用类别] = '" & dr("费用类别") &  "' And [费用类别1] = '" & dr("费用类别1") & "'", "[_SortKey] Desc")
            If dr Is Nothing Then
                dr = e.DataTable.Find("[项目名称] = '" & dr("项目名称") & "' And [工程单位名称] = '" & e.OldValue & "' And [费用类别] = '" & dr("费用类别") &  "' And [费用类别1] = '" & dr("费用类别1") & "'", "[_SortKey]")
                If dr IsNot Nothing Then
                    dr("累计进度") = dr("进度金额")
                End If
            End If
            If dr IsNot Nothing Then
                drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [项目名称] = '" & dr("项目名称") & "' And [工程单位名称] = '" & dr("工程单位名称") & "' And [费用类别] = '" & dr("费用类别") & "' And [费用类别1] = '" & dr("费用类别1") & "'", "[_SortKey]")
                For i As Integer = 1 To drs.Count - 1
                    drs(i)("累计进度") = drs(i-1)("累计进度") + drs(i)("进度金额")
                Next
            End If
        End If
       
End Select


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/7/15 11:34:00 [显示全部帖子]

 例子发上来。

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/7/15 11:54:00 [显示全部帖子]

 代码

 

Select Case e.DataCol.Name
    Case "项目名称","工程单位名称","费用类别","费用类别1","进度金额"
        Dim dr As DataRow
        Dim mr As DataRow = e.DataRow
        Dim drs As List(of DataRow)
        dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [项目名称] = '" & mr("项目名称") & "' And [工程单位名称] = '" & mr("工程单位名称") & "' And [费用类别] = '" & mr("费用类别") & "' And [费用类别1] = '" & mr("费用类别1") & "'", "[_SortKey] Desc")
        If dr Is Nothing Then
            mr("累计进度") = mr("进度金额")
            dr = mr
        End If
        drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [项目名称] = '" & dr("项目名称") & "' And [工程单位名称] = '" & dr("工程单位名称") & "' And [费用类别] = '" & dr("费用类别") &  "' And [费用类别1] = '" & dr("费用类别1") & "'", "[_SortKey]")
        For i As Integer = 1 To drs.Count - 1
            drs(i)("累计进度") = drs(i-1)("累计进度") + drs(i)("进度金额")
        Next
        If e.DataCol.Name = "项目名称" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
            dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [项目名称] = '" & e.OldValue & "' And [工程单位名称] = '" & e.DataRow("工程单位名称") & "' And [费用类别] = '" & e.DataRow("费用类别") &  "' And [费用类别1] = '" & e.DataRow("费用类别1") & "'", "[_SortKey] Desc")
            If dr Is Nothing Then
                dr = e.DataTable.Find("[项目名称] = '" & e.OldValue & "'  And [工程单位名称] = '" & e.DataRow("工程单位名称") & "' And [费用类别] = '" & e.DataRow("费用类别") &  "' And [费用类别1] = '" & e.DataRow("费用类别1") & "'", "[_SortKey]")
                If dr IsNot Nothing Then
                    dr("累计进度") = dr("进度金额")
                End If
            End If
            If dr IsNot Nothing Then
                drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [项目名称] = '" & dr("项目名称") & "' And [工程单位名称] = '" & dr("工程单位名称") & "' And [费用类别] = '" & dr("费用类别") & "' And [费用类别1] = '" & dr("费用类别1") & "'", "[_SortKey]")
                For i As Integer = 1 To drs.Count - 1
                    drs(i)("累计进度") = drs(i-1)("累计进度") + drs(i)("进度金额")
                Next
            End If
        End If
        If e.DataCol.Name = "费用类别1" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
            dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [项目名称] = '" & e.DataRow("项目名称") & "' And [工程单位名称] = '" & e.DataRow("工程单位名称") & "' And [费用类别] = '" & e.DataRow("费用类别") &  "' And [费用类别1] = '" & e.Oldvalue & "'", "[_SortKey] Desc")
            If dr Is Nothing Then
                dr = e.DataTable.Find("[项目名称] = '" & e.DataRow("项目名称") & "' And [工程单位名称] = '" & e.DataRow("工程单位名称") & "' And [费用类别] = '" & e.DataRow("费用类别") &  "' And [费用类别1] = '" & e.Oldvalue & "'", "[_SortKey]")
                If dr IsNot Nothing Then
                    dr("累计进度") = dr("进度金额")
                End If
            End If
            If dr IsNot Nothing Then
                drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [项目名称] = '" & dr("项目名称") & "' And [工程单位名称] = '" & dr("工程单位名称") & "' And [费用类别] = '" & dr("费用类别") & "' And [费用类别1] = '" & dr("费用类别1") & "'", "[_SortKey]")
                For i As Integer = 1 To drs.Count - 1
                    drs(i)("累计进度") = drs(i-1)("累计进度") + drs(i)("进度金额")
                Next
            End If
        End If
        If e.DataCol.Name = "费用类别" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
            dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [项目名称] = '" & e.DataRow("项目名称") & "' And [工程单位名称] = '" & e.DataRow("工程单位名称") & "' And [费用类别] = '" & e.OldValue  &  "' And [费用类别1] = '" & e.DataRow("费用类别1") & "'", "[_SortKey] Desc")
            If dr Is Nothing Then
                dr = e.DataTable.Find("[项目名称] = '" & e.DataRow("项目名称") & "' And [工程单位名称] = '" & e.DataRow("工程单位名称") & "' And [费用类别] = '" & e.OldValue  &  "' And [费用类别1] = '" & e.DataRow("费用类别1") & "'", "[_SortKey]")
                If dr IsNot Nothing Then
                    dr("累计进度") = dr("进度金额")
                End If
            End If
            If dr IsNot Nothing Then
                drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [项目名称] = '" & dr("项目名称") & "' And [工程单位名称] = '" & dr("工程单位名称") & "' And [费用类别] = '" & dr("费用类别") & "' And [费用类别1] = '" & dr("费用类别1") & "'", "[_SortKey]")
                For i As Integer = 1 To drs.Count - 1
                    drs(i)("累计进度") = drs(i-1)("累计进度") + drs(i)("进度金额")
                Next
            End If
        End If
        If e.DataCol.Name = "工程单位名称" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
            dr = e.DataTable.Find("[_SortKey] < " & mr("_SortKey") & " And [项目名称] = '" & e.DataRow("项目名称") & "' And [工程单位名称] = '" & e.OldValue & "' And [费用类别] = '" & e.DataRow("费用类别") &  "' And [费用类别1] = '" & e.DataRow("费用类别1") & "'", "[_SortKey] Desc")
            If dr Is Nothing Then
                dr = e.DataTable.Find("[项目名称] = '" & e.DataRow("项目名称") & "' And [工程单位名称] = '" & e.OldValue & "' And [费用类别] = '" & e.DataRow("费用类别") &  "' And [费用类别1] = '" & e.DataRow("费用类别1") & "'", "[_SortKey]")
                If dr IsNot Nothing Then
                    dr("累计进度") = dr("进度金额")
                End If
            End If
            If dr IsNot Nothing Then
                drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [项目名称] = '" & dr("项目名称") & "' And [工程单位名称] = '" & dr("工程单位名称") & "' And [费用类别] = '" & dr("费用类别") & "' And [费用类别1] = '" & dr("费用类别1") & "'", "[_SortKey]")
                For i As Integer = 1 To drs.Count - 1
                    drs(i)("累计进度") = drs(i-1)("累计进度") + drs(i)("进度金额")
                Next
            End If
        End If
       
End Select


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/7/15 14:08:00 [显示全部帖子]

 本来就累计啊,测试没发现问题。

 回到顶部