以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 读取表数据条件 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=150978) |
-- 作者:yangwenghd -- 发布时间:2020/6/11 18:40:00 -- 读取表数据条件 老师,能帮忙看看这段吗?如果在执行红色代码前能增加一个条件吗? 比如 添加一个 订单性质列为自营内容才执行,为什么不对呢 For Each ndr As DataRow In dt_cwhz.Select("") Dim i As Integer = ndr("年份") Dim j As Integer = ndr("月份") If i > 0 AndAlso j > 0 Then Dim d As Date = new Date(i, j, 1) Dim filter As String = "业务往来_订单日期>= #" & d & "# and 业务往来_订单日期< #" & d.AddMonths(1) & "#" If e.DataRow("业务往来_订单性质") = "自营" Then ndr("经营_增加销售") = val(dt_ddfb.compute("sum(订单核算_合计)", filter)) ndr("经营_增加利润") = val(dt_ddfb.compute("sum(订单核算_毛利)", filter)) ndr("经营_税费") = val(dt_ddfb.compute("sum(订单核算_增值税费)", filter)) ndr("经营_返点") = val(dt_ddfb.compute("sum(订单核算_合计返点)", filter)) ndr("经营_运费") = val(dt_ddfb.compute("sum(订单核算_运费)", filter)) ndr("负债_对公增加") = val(dt_ddfb.compute("sum(订单核算_采购合计)", filter)) filter = "回款日期 >= #" & d & "# and 回款日期 < #" & d.AddMonths(1) & "#" ndr("经营_回收货款") = val(dt_hkjl.compute("sum(收款金额)", filter)) End If \'Dim afdr As DataRow = dt_tzjl.Find(filter, "记录参数_操作时间 desc,[_Identify] desc") filter = "记录参数_操作时间 >= #" & d & "# and 记录参数_操作时间 < #" & d.AddMonths(1) & "#" ndr("投资_增加金额") = val(dt_tzjl.compute("sum(购入_增投合计)", filter)) ndr("投资_减少金额") = val(dt_tzjl.compute("sum(售出_撤资合计)", filter)) Dim afdr As DataRow = dt_tzjl.Find(filter, "记录参数_操作时间 desc,[_Identify] desc") filter = "收益日期 >= #" & d & "# and 收益日期 < #" & d.AddMonths(1) & "#" ndr("投资_其它收益") = val(dt_tzsy.compute("sum(收益金额)", filter)) Dim afdra As DataRow = dt_tzsy.Find(filter, "收益日期 desc,[_Identify] desc") filter = "项目信息_更新日期 >= #" & d & "# and 项目信息_更新日期 < #" & d.AddMonths(1) & "#" \'Dim afdrb As DataRow = dt_hqsj.Find(filter, "项目信息_更新日期 desc,[_Identify] desc") Dim afdrb As DataRow = dt_hqsj.Find(filter, "项目信息_更新日期 desc,[_Identify] desc,项目信息_变动编号 desc") If afdrb IsNot Nothing Then ndr("投资_溢价收益") = afdrb("核算记录_溢价收益") ndr("投资_在运资金") = afdrb("核算记录_在投资金") Else ndr("投资_溢价收益") = 0 ndr("投资_在运资金") = 0 End If |
-- 作者:有点蓝 -- 发布时间:2020/6/11 20:52:00 -- if e.DataRow("业务往来_订单性质") = "自营" Then 改为 if ndr("业务往来_订单性质") = "自营" Then
|
-- 作者:yangwenghd -- 发布时间:2020/6/12 15:21:00 -- 老师 能在帮忙看看吗?还是不对,就是让订单附表 的业务往来_订单性质内容为自营才执行下面的代码,如果不是就不执行。感谢 感谢 For Each ndr As DataRow In dt_cwhz.Select("") Dim i As Integer = ndr("年份") Dim j As Integer = ndr("月份") If i > 0 AndAlso j > 0 Then Dim d As Date = new Date(i, j, 1) Dim filter As String = "业务往来_订单日期>= #" & d & "# and 业务往来_订单日期< #" & d.AddMonths(1) & "#" If Tables("订单附表")Compute("业务往来_订单性质") = "自营" Then \'订单附表是被读取的表, ndr("经营_增加销售") = val(dt_ddfb.compute("sum(订单核算_合计)", filter)) ndr("经营_增加利润") = val(dt_ddfb.compute("sum(订单核算_毛利)", filter)) ndr("经营_税费") = val(dt_ddfb.compute("sum(订单核算_增值税费)", filter)) ndr("经营_返点") = val(dt_ddfb.compute("sum(订单核算_合计返点)", filter)) ndr("经营_运费") = val(dt_ddfb.compute("sum(订单核算_运费)", filter)) ndr("负债_对公增加") = val(dt_ddfb.compute("sum(订单核算_采购合计)", filter)) filter = "回款日期 >= #" & d & "# and 回款日期 < #" & d.AddMonths(1) & "#" ndr("经营_回收货款") = val(dt_hkjl.compute("sum(收款金额)", filter)) End If
[此贴子已经被作者于2020/6/12 15:21:19编辑过]
|
-- 作者:yangwenghd -- 发布时间:2020/6/12 15:39:00 -- 或者可以这个样子吗?老师,在被读取的后面加上一天条件。比如蓝色的代码,后面可以加一个条件吗 For Each ndr As DataRow In dt_cwhz.Select("") Dim i As Integer = ndr("年份") Dim j As Integer = ndr("月份") If i > 0 AndAlso j > 0 Then Dim d As Date = new Date(i, j, 1) Dim filter As String = "业务往来_订单日期>= #" & d & "# and 业务往来_订单日期< #" & d.AddMonths(1) & "#" ndr("经营_增加销售") = val(dt_ddfb.compute("sum(订单核算_合计)", filter)) ndr("经营_增加利润") = val(dt_ddfb.compute("sum(订单核算_毛利)", filter) and Compute("业务往来_订单性质") = "自营" Then) ndr("经营_税费") = val(dt_ddfb.compute("sum(订单核算_增值税费)", filter)) ndr("经营_返点") = val(dt_ddfb.compute("sum(订单核算_合计返点)", filter)) ndr("经营_运费") = val(dt_ddfb.compute("sum(订单核算_运费)", filter)) ndr("负债_对公增加") = val(dt_ddfb.compute("sum(订单核算_采购合计)", filter)) filter = "回款日期 >= #" & d & "# and 回款日期 < #" & d.AddMonths(1) & "#" ndr("经营_回收货款") = val(dt_hkjl.compute("sum(收款金额)", filter)) |
-- 作者:有点蓝 -- 发布时间:2020/6/12 15:58:00 -- Dim filter As String = "业务往来_订单日期>= #" & d & "# and 业务往来_订单日期< #" & d.AddMonths(1) & "# and 业务往来_订单性质=\'自营\'" |