Foxtable(狐表)用户栏目专家坐堂 → [求助]流水账相关


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

主题:[求助]流水账相关

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


加好友 发短信
等级:婴狐 帖子:19 积分:208 威望:0 精华:0 注册:2016/8/29 10:35:00
[求助]流水账相关  发帖心情 Post By:2016/9/9 20:33:00 [只看该作者]

代码如下

If e.DataCol.Name="第一列" Then
    If e.DataRow("_sortkey")=0 Then
        e.DataRow("第二列")=0-e.DataRow("第一列")
    Else
        Dim cunt As Integer = Tables("表A").Rows.Count
        For Each drs As DataRow In e.DataTable.Select("[_sortkey]>=" & e.DataRow("_sortkey"))
            Dim i As Integer= e.DataRow("_sortkey")
            Dim dr As DataRow= DataTables("表A").Find("[_sortkey]=" & i-1)
           e.DataRow("第二列")=dr("第二列")-e.DataRow("第一列")
           
        Next
    End If
End If

实现的是修改列一的数据得出列2的数据,列2=上一行列2-本行列1

想了很久实在是想不出来


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


加好友 发短信
等级:婴狐 帖子:19 积分:208 威望:0 精华:0 注册:2016/8/29 10:35:00
  发帖心情 Post By:2016/9/9 20:53:00 [只看该作者]

If e.DataCol.Name="第一列" Then
    If e.DataRow("_sortkey")=0 Then
        e.DataRow("第二列")=0-e.DataRow("第一列")
    Else
        Dim cunt As Integer = Tables("表A").Rows.Count
        For i As Integer =e.DataRow("_sortkey") To cunt
            Dim dr As DataRow= DataTables("表A").Find("[_sortkey]=" & i-1)
            DataTables("表A").DataRows(i-1)("第二列")=dr("第二列")-DataTables("表A").DataRows(i-1)("第一列")
        Next
    End If
End If

 

最终还是想出来了,但是代码太繁琐了,希望大神指点一下


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


加好友 发短信
等级:超级版主 帖子:109347 积分:556379 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2016/9/10 8:56:00 [只看该作者]

试试

If e.DataCol.Name="第一列" Then
    If e.DataRow("_sortkey")=0 Then
        e.DataRow("第二列")=0-e.DataRow("第一列")
    Else
        Dim drs As List(of DataRow)  = e.DataTable.Select("[_SortKey] >= " & e.DataRow("_SortKey"),"_SortKey")
        Dim dr As DataRow= e.DataTable.Find("[_sortkey] < " & e.DataRow("_SortKey"),"_SortKey desc")
        drs(0)("第二列") = dr("第二列") - drs(0)("第一列")
        For i As Integer = 1 To drs.Count - 1
            drs(i)("第二列") = drs(i-1)("第二列") - drs(i)("第一列")
        Next
    End If
End If

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


加好友 发短信
等级:婴狐 帖子:19 积分:208 威望:0 精华:0 注册:2016/8/29 10:35:00
  发帖心情 Post By:2016/9/10 9:31:00 [只看该作者]

谢谢,我昨天试了一下我自己的那段代码,不知道哪里还有问题,新插入的行不能正常运算,保存后就可以了

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


加好友 发短信
等级:超级版主 帖子:109347 积分:556379 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2016/9/10 9:49:00 [只看该作者]

上例子测试

 回到顶部