以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  代码计算  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=88431)

--  作者:yifan3429
--  发布时间:2016/8/2 21:01:00
--  代码计算
If e.DataCol.Name = "单位" Then
    If e.DataRow("单位") ="立方"  Then
        e.DataRow("小计") = e.DataRow("长") * e.DataRow("宽")*e.DataRow("厚")*0.000000001 * e.DataRow("数量")  
  ElseIf e.DataRow("单位") ="平方"  Then
        e.DataRow("小计") = e.DataRow("长") * e.DataRow("宽")*0.000001*e.DataRow("数量")    
    ElseIf e.DataRow("单位") ="四面套"  Then
        e.DataRow("小计") = (e.DataRow("长") *2 )+ (e.DataRow("宽") * 2)*0.001*e.DataRow("数量")    
    ElseIf e.DataRow("单位") ="三面套"  Then
        e.DataRow("小计") = e.DataRow("长") + (e.DataRow("宽") * 2)*0.001*e.DataRow("数量")    
    ElseIf e.DataRow("单位") = "件" Then
        e.DataRow("小计") = e.DataRow("单价")*e.DataRow("数量")    
ElseIf e.DataRow("单位") = "套" Then
        e.DataRow("小计") = e.DataRow("单价")*e.DataRow("数量")    
    End If
End If

上面的代码 在输入 长  宽  厚  数量   后在调整单位会精确地计算   

但是后期调整 长  宽  厚  数量  等数据时 计算不会变化


Select e.DataCol.name
    Case "长","宽","厚" ,"数量"
        If e.DataCol.Name = "单位" Then
            If e.DataRow("单位") ="立方"  Then
                e.DataRow("小计") = e.DataRow("长") * e.DataRow("宽")*e.DataRow("厚")*0.000000001 * e.DataRow("数量")
            ElseIf e.DataRow("单位") ="平方"  Then
                e.DataRow("小计") = e.DataRow("长") * e.DataRow("宽")*0.000001*e.DataRow("数量")
            ElseIf e.DataRow("单位") ="四面套"  Then
                e.DataRow("小计") = (e.DataRow("长") *2 )+ (e.DataRow("宽") * 2)*0.001*e.DataRow("数量")
            ElseIf e.DataRow("单位") ="三面套"  Then
                e.DataRow("小计") = e.DataRow("长") + (e.DataRow("宽") * 2)*0.001*e.DataRow("数量")
            ElseIf e.DataRow("单位") = "件" Then
                e.DataRow("小计") = e.DataRow("单价")*e.DataRow("数量")
            ElseIf e.DataRow("单位") = "套" Then
                e.DataRow("小计") = e.DataRow("单价")*e.DataRow("数量")
            End If
        End If
End Select

如何让  长  宽  厚  数量 在后期变化后重新计算

请教  刷新的代码
[此贴子已经被作者于2016/8/2 22:42:05编辑过]

--  作者:狐狸爸爸
--  发布时间:2016/8/3 8:28:00
--  
Select e.DataCol.name
    Case "长","宽","厚" ,"数量"
            If e.DataRow("单位") ="立方"  Then
                e.DataRow("小计") = e.DataRow("长") * e.DataRow("宽")*e.DataRow("厚")*0.000000001 * e.DataRow("数量")
            ElseIf e.DataRow("单位") ="平方"  Then
                e.DataRow("小计") = e.DataRow("长") * e.DataRow("宽")*0.000001*e.DataRow("数量")
            ElseIf e.DataRow("单位") ="四面套"  Then
                e.DataRow("小计") = (e.DataRow("长") *2 )+ (e.DataRow("宽") * 2)*0.001*e.DataRow("数量")
            ElseIf e.DataRow("单位") ="三面套"  Then
                e.DataRow("小计") = e.DataRow("长") + (e.DataRow("宽") * 2)*0.001*e.DataRow("数量")
            ElseIf e.DataRow("单位") = "件" Then
                e.DataRow("小计") = e.DataRow("单价")*e.DataRow("数量")
            ElseIf e.DataRow("单位") = "套" Then
                e.DataRow("小计") = e.DataRow("单价")*e.DataRow("数量")
            End If
End Select