以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  怎样改代码  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=76828)

--  作者:sf020cf
--  发布时间:2015/11/5 17:43:00
--  怎样改代码

Dim nms As String() = {"项目","客户","司机","车牌"}
Tables("数据_Table1").DataSource = dt1
With DataTables("数据汇总_Table1").DataCols  
    .Add("车辆_配载率",Gettype(Integer), "IsNull([Sum(装载量)],0) / ISNULL([Sum(体积)],0)" )
  
End With

 

这样写不行 计算不出 我想要结果是百分比显示的


--  作者:大红袍
--  发布时间:2015/11/5 17:47:00
--  
 请贴出完整可以测试的代码。
--  作者:sf020cf
--  发布时间:2015/11/5 17:53:00
--  

Dim sd As WinForm.DateTimePicker
Dim ed As WinForm.DateTimePicker
sd = e.Form.Controls("DateTimePicker1")
ed = e.Form.Controls("DateTimePicker2")
Dim cpbh As String = e.Form.Controls("项目").Value
If cpbh = "" Then
DataTables("应付款项").LoadFilter=" [出车日期] >= #" & sd.Value & "#  and [出车日期] <= #" & ed.Value & "#"
DataTables("应付款项").Load

Else
DataTables("应付款项").LoadFilter=" [出车日期] >= #" & sd.Value & "#  and [出车日期] <= #" & ed.Value & "# and [项目] like \'%" & cpbh & "%\' "
DataTables("应付款项").Load

End If
Dim bd1 As New GroupTableBuilder("统计表1",DataTables("应付款项"))
Dim dt1 As fxDataSource
bd1.Groups.AddDef("项目")
bd1.Groups.AddDef("客户")
bd1.Groups.AddDef("送货地址")
bd1.Groups.AddDef("司机")
bd1.Groups.AddDef("车牌")
bd1.Totals.AddDef("体积","订单_体积")
bd1.Totals.AddDef("重量","订单_重量")
bd1.Totals.AddDef("装载量","车辆_装载量")
bd1.Totals.AddDef("罚款金额","订单_罚款")
bd1.Totals.AddDef("合计","订单_合计")
dt1 = bd1.BuildDataSource()

Dim nms As String() = {"项目","客户","司机","车牌"}
Tables("数据汇总_Table1").DataSource = dt1
With DataTables("数据汇总_Table1").DataCols 
    .Add("车辆_配载率",Gettype(Integer), "IsNull([Sum(装载量)],0) / ISNULL([Sum(体积)],0)" )
  
End With
Tables("数据汇总_Table1").AutoSizeCols()
Dim tjSum As Integer = DataTables("应付款项").Compute("Sum(体积)")
Dim zlSum As Integer = DataTables("应付款项").Compute("Sum(重量)")
Dim fkSum As Integer = DataTables("应付款项").Compute("Sum(罚款金额)")
Dim yfSum As Integer = DataTables("应付款项").Compute("Sum(合计)")
e.Form.Controls("Label2").Text = tjSum
e.Form.Controls("Label4").Text = zlSum
e.Form.Controls("Label6").Text = fkSum
e.Form.Controls("Label8").Text = yfSum


--  作者:大红袍
--  发布时间:2015/11/5 17:55:00
--  

Tables("数据汇总_Table1").DataSource = dt1
With DataTables("数据汇总_Table1").DataCols
    .Add("车辆_配载率",Gettype(Double), "IsNull(装载量,0) / ISNULL(体积,0)" )
End With

DataTables("数据汇总_Table1").DataCols("车辆_配载率").SetFormat("0.00%")


--  作者:sf020cf
--  发布时间:2015/11/5 17:58:00
--  

要总装载量除以总体积

 


--  作者:大红袍
--  发布时间:2015/11/5 18:03:00
--  
.Add("车辆_配载率",Gettype(Double), "IsNull(车辆_装载量,0) / ISNULL(订单_体积,0)" )