以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]谁能把这段改成【表属性】的行代码啊  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=19661)

--  作者:hp001
--  发布时间:2012/5/17 13:23:00
--  [求助]谁能把这段改成【表属性】的行代码啊

谁能把这段改成【表属性】的行代码啊

这个是窗口按钮的带码

Dim t As Table=e.form.controls("table1").Table
Dim r1,r2 As Row
For  i As Integer=0 To t.rows.count-1
    If i=0
        r1=t.rows(i)
        r1("结存数量")=r1("收入数量")-r1("出货数量")
        r1("结存金额")=r1("收入金额")-r1("出货金额")
    Else
        r1=t.rows(i-1)
        r2=t.rows(i)
        r2("出货单价")=(r1("结存金额")+r2("收入金额"))/(r1("结存数量")+r2("收入金额"))
        r2("出货金额")=r2("出货单价")*r2("出货数量")
        r2("结存数量")=r1("结存数量")+r2("收入数量")-r2("出货数量")
        r2("结存金额")=r1("结存金额")+r2("收入金额")-r2("出货金额")
    End If
Next


--  作者:hp001
--  发布时间:2012/5/17 13:25:00
--  

结存数量不用考虑了,我已经考虑好了。

Select Case e.DataCol.Name
    Case "材料编号","入库数量","出库数量"
        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("材料编号") & "\'", "[_SortKey] Desc")
        If dr Is Nothing Then
            mr("结存数量") = mr("入库数量") - mr("出库数量")
            dr = mr
        End If
        drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [材料编号] = \'" & dr("材料编号") & "\'", "[_SortKey]")
        For i As Integer = 1 To drs.Count - 1
            drs(i)("结存数量") = drs(i-1)("结存数量") + drs(i)("入库数量") - 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 & "\'", "[_SortKey] Desc")
            If dr Is Nothing Then
                dr = e.DataTable.Find("[材料编号] = \'" & e.OldValue & "\'", "[_SortKey]")
                If dr IsNot Nothing Then
                    dr("结存数量") = dr("入库数量") - dr("出库数量")
                End If
            End If
            If dr IsNot Nothing Then
                drs = e.DataTable.Select("[_SortKey] >= " & dr("_SortKey") & " And [材料编号] = \'" & dr("材料编号") & "\'", "[_SortKey]")
                For i As Integer = 1 To drs.Count - 1
                    drs(i)("结存数量") = drs(i-1)("结存数量") + drs(i)("入库数量") - drs(i)("出库数量")
                Next
            End If
        End If
End Select


--  作者:狐狸爸爸
--  发布时间:2012/5/17 14:45:00
--  

看看这个:

http://www.foxtable.com/help/topics/2136.htm