以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 将临时表绑定窗体SQLtable,当前窗体直接闪退…… (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=173761) |
-- 作者:cnsjroom -- 发布时间:2021/12/15 1:31:00 -- 将临时表绑定窗体SQLtable,当前窗体直接闪退…… 将临时表绑定窗体SQLtable,当前窗体直接闪退……两个临时表生成的数据有正常显示在表中,临时表如何绑定到SQLtable中呢?确保窗体依旧保留 Dim dtb As New DataTableBuilder("统计") dtb.AddDef("公司名", Gettype(String), 32) dtb.AddDef("年份", Gettype(String), 32) dtb.AddDef("月份", Gettype(String), 32) dtb.AddDef("出库数量", Gettype(Double)) dtb.AddDef("出库单价", Gettype(Double)) dtb.AddDef("出库金额", Gettype(Double)) dtb.AddDef("入库数量", Gettype(Double)) dtb.AddDef("入库单价", Gettype(Double)) dtb.AddDef("入库金额", Gettype(Double)) \'dtb.AddDef("合计数量", Gettype(Double)) \'dtb.AddDef("合计金额", Gettype(Double)) dtb.Build() Dim dtb1 As New DataTableBuilder("统计1") dtb1.AddDef("公司名", Gettype(String), 32) dtb1.AddDef("年份", Gettype(String), 32) \'dtb1.AddDef("月份", Gettype(String), 32) dtb1.AddDef("出库数量", Gettype(Double)) \'dtb1.AddDef("出库单价", Gettype(Double)) dtb1.AddDef("出库金额", Gettype(Double)) dtb1.AddDef("入库数量", Gettype(Double)) \'dtb1.AddDef("入库单价", Gettype(Double)) dtb1.AddDef("入库金额", Gettype(Double)) \'dtb1.AddDef("合计数量", Gettype(Double)) \'dtb1.AddDef("合计金额", Gettype(Double)) dtb1.Build() Dim Products As List(Of String()) Products = DataTables("出入库").GetValues("对方|年份|月份") Dim t As Table=Tables("统计") Dim t1 As Table=Tables("统计1") For Each Product As String() In Products t.AddNew t.Current("公司名")=Product(0) t.Current("年份")=Product(1) t.Current("月份")=Product(2) Dim dr As DataRow =DataTables("出入库").find("对方= \'" & Product(0) & "\'and 年份= \'" & Product(1) & "\' and 月份= \'" & Product(2) & "\'and 类别 Like \'%出库%\'" ) If dr IsNot Nothing Then t.Current("出库单价")=dr("物品单价") t.Current("出库数量")=dr("物品数量") t.Current("出库金额")=t.Current("出库单价")*t.Current("出库数量") End If Dim dr1 As DataRow =DataTables("出入库").find("对方= \'" & Product(0) & "\'and 年份= \'" & Product(1) & "\' and 月份= \'" & Product(2) & "\'and 类别 Like \'%入库%\'" ) If dr1 IsNot Nothing Then t.Current("入库单价")=dr1("物品单价") t.Current("入库数量")=dr1("物品数量") t.Current("入库金额")=t.Current("入库单价")*t.Current("入库数量") End If Next Dim Products1 As List(Of String) Products1 = DataTables("出入库").GetValues("对方") For Each Product1 As String In Products1 Output.Show(Product1) Dim Products11 As List(Of String) Products11 = DataTables("出入库").GetValues("年份","对方=\'"& Product1 &"\'") For Each Product11 As String In Products11 t1.AddNew t1.Current("公司名")=Product1 t1.Current("年份")=Product11 t1.Current("出库数量")=DataTables("出入库").Compute("sum(物品数量)","对方= \'" & Product1 & "\'and 年份= \'" & Product11 & "\' And 类别 Like \'%出库%\'" ) t1.Current("出库金额")=DataTables("出入库").Compute("sum(金额)","对方= \'" & Product1 & "\'and 年份= \'" & Product11 & "\' And 类别 Like \'%出库%\'" ) t1.Current("入库数量")=DataTables("出入库").Compute("sum(物品数量)","对方= \'" & Product1 & "\'and 年份= \'" & Product11 & "\' And 类别 Like \'%入库%\'" ) t1.Current("入库金额")=DataTables("出入库").Compute("sum(金额)","对方= \'" & Product1 & "\'and 年份= \'" & Product11 & "\' And 类别 Like \'%入库%\'" ) Next Next Tables("窗口1_table2").DataSource = DataTables("统计") Tables("窗口1_table3").DataSource = DataTables("统计1") [此贴子已经被作者于2021/12/15 1:32:24编辑过]
|
-- 作者:有点蓝 -- 发布时间:2021/12/15 8:41:00 -- 1、给新增行赋值应该这样 For Each Product As String() In Products dim r as row = t.AddNew r("公司名")=Product(0) r("年份")=Product(1) 2、先绑定,然后对窗口表操作 dtb.AddDef("入库单价", Gettype(Double)) dtb.AddDef("入库金额", Gettype(Double)) \'dtb.AddDef("合计数量", Gettype(Double)) \'dtb.AddDef("合计金额", Gettype(Double)) Tables("窗口1_table2").DataSource = dtb.BuildDataSource () Dim t As Table=Tables("窗口1_table2") For Each Product As String() In Products dim r as row = t.AddNew r("公司名")=Product(0) r("年份")=Product(1) |