以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]表的实时录入信息关联失效 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=138076) |
-- 作者:冷泉 -- 发布时间:2019/7/22 16:17:00 -- [求助]表的实时录入信息关联失效 老师您好,我库存窗口查询按钮的代码,但是点击查询后,我前面销售单或者退货单里面的代码好像就失效,正常是我选择客户编码,后面客户名称就会出来,选择商品编码,后面商品名称,规格等等那些也都会出来,现在点击这个查询按钮后,就无法出来,是不是哪里代码错误 Dim Filter As String = "商品编号 is not null" With e.Form.Controls("StartDate") If .Value IsNot Nothing Then If Filter >"" Then Filter = Filter & " And " End If Filter = Filter & "进货日期 >= #" & .Value & "#" End If End With With e.Form.Controls("EndDate") If .Value IsNot Nothing Then If Filter >"" Then Filter = Filter & " And " End If Filter = Filter & "进货日期 <= #" & .Value & "#" End If End With With e.Form.Controls("商品名称") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "商品名称 = \'" & .Value & "\'" End If End With Dim bd1 As New GroupTableBuilder("统计表1",DataTables("进货单")) Dim dt1 As fxDataSource bd1.Groups.AddDef("商品编号") \'根据商品编号分组 bd1.Groups.AddDef("商品名称") \'根据商品编号分组 bd1.Totals.AddDef("数量","进货_数量") \'对数量进行统计 bd1.Totals.AddDef("金额","进货_金额") \'对金额进行统计 bd1.Filter = Filter dt1 = bd1.BuildDataSource() Dim bd2 As New GroupTableBuilder("统计表2",DataTables("销售单")) Dim dt2 As fxDataSource bd2.Groups.AddDef("商品编号") \'根据商品编号分组 bd2.Groups.AddDef("商品名称") \'根据商品编号分组 bd2.Totals.AddDef("数量","销售_数量") \'对数量进行统计 bd2.Totals.AddDef("金额","销售_金额") \'对金额进行统计 bd2.Filter = Filter.replace("进货日期","销售日期") dt2 = bd2.BuildDataSource() Dim bd3 As New GroupTableBuilder("统计表3",DataTables("退货单")) Dim dt3 As fxDataSource bd3.Groups.AddDef("商品编号") \'根据商品编号分组 bd3.Groups.AddDef("商品名称") \'根据商品编号分组 bd3.Totals.AddDef("数量","退货_数量") \'对数量进行统计 bd3.Totals.AddDef("金额","退货_金额") \'对金额进行统计 bd3.Filter = Filter.replace("进货日期","退货日期") dt3 = bd3.BuildDataSource() Dim ns() As String = {"商品编号","商品名称"} dt1.Combine(ns,dt2,ns) \'将销售统计数据组合到进货统计数据 dt1.Combine(ns,dt3,ns) \'将退货统计数据组合到进货统计数据 Tables("库存_Table1").DataSource = dt1 \'将统计结果绑定到Table With DataTables("库存_Table1").DataCols \'用表达式列计算库存数据 .Add("库存_数量",Gettype(Integer), "IsNull([进货_数量],0) - ISNULL([销售_数量],0) + ISNULL([退货_数量],0)") .Add("库存_金额",Gettype(Double), "[库存_数量] /[进货_数量] * [进货_金额]") End With 我前面的销售单,退货单,进货单,也都设置了表属性DataColChanged事件代码,主要是希望,前面基础信息表的客户名称那些有添加新的名称或者修改,这里也可以实时更新,代码您帮我看看 If e.DataCol.Name = "客户编号" Then \'如果内容发生变动的是品名列 If e.NewValue Is Nothing Then \'如果新值是空白,也就是品名列的内容为空 e.DataRow("客户") = Nothing \'那么清空此行单价列的内容 Else Dim dr As DataRow \'否则在产品表查找同名的产品行,将找到的行赋值给变量dr dr = DataTables("客户信息").Find("[客户编号] = \'" & e.NewValue & "\'") If dr IsNot Nothing Then \'如果找到了同名的产品行,也就是dr不是Nothing e.DataRow("客户") = dr("客户") End If End If End If If e.DataCol.Name = "商品编号" Then If e.NewValue Is Nothing Then e.DataRow("商品名称") = Nothing e.DataRow("规格") = Nothing e.DataRow("单位") = Nothing e.DataRow("型号") = Nothing e.DataRow("单价") = Nothing Else Dim dr As DataRow dr = DataTables("商品信息").Find("[商品编号] = \'" & e.NewValue & "\'") If dr IsNot Nothing e.DataRow("商品名称") = dr("商品名称") e.DataRow("型号") = dr("型号") e.DataRow("规格") = dr("规格") e.DataRow("单位") = dr("单位") e.DataRow("单价") = dr("单价") End If End If End If Select Case e.DataCol.Name Case "商品名称","型号","规格","单位" Dim Filter As String = "[商品编号] = \'" & e.DataRow("商品编号") & "\'" DataTables("退货单").ReplaceFor(e.DataCol.Name, e.NewValue, Filter) End Select Select Case e.DataCol.Name Case "客户" Dim Filter As String = "[客户编号] = \'" & e.DataRow("客户编号") & "\'" DataTables("退货单").ReplaceFor(e.DataCol.Name, e.NewValue, Filter) End Select |
-- 作者:有点蓝 -- 发布时间:2019/7/22 16:44:00 -- 代码没有问题,这个查询代码也不可能会影响到表事件。应该是表格数据没有加载导致的。上传具体实例说明 |
-- 作者:冷泉 -- 发布时间:2019/7/22 17:23:00 -- 好的,已经上传了,麻烦老师看看,谢谢了
[此贴子已经被作者于2019/7/22 21:23:31编辑过]
|
-- 作者:冷泉 -- 发布时间:2019/7/22 17:37:00 -- 好像表里面金额列的表达式也失效,不能计算 |
-- 作者:有点蓝 -- 发布时间:2019/7/22 17:40:00 -- 库存窗口商品名称控件不要绑定列。作为查询条件使用的控件都不要绑定 |
-- 作者:冷泉 -- 发布时间:2019/7/22 18:36:00 -- 取消了绑定,然后列属性全部重新确定设置了有效,保存退出了重新进,又失效了,金额的表达式也是失效,老师,这个是什么原因了? |
-- 作者:冷泉 -- 发布时间:2019/7/22 18:57:00 -- 知道原因了,每次我都是按住CTRL打开的 |