以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  窗口中,有条件汇总代码  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=89340)

--  作者:zhangning
--  发布时间:2016/8/19 11:57:00
--  窗口中,有条件汇总代码

图片点击可在新窗口打开查看此主题相关图片如下:c1.png
图片点击可在新窗口打开查看
想编写汇总按钮代码:在检索期间和部门输入内容后,单击“汇总”按钮,就会在总人数处汇总人数,在总加班H汇总部门的所有人员的加班数,不会写代码,请老师帮写写呗,跟老师学学。
[此贴子已经被作者于2016/8/19 12:33:31编辑过]

--  作者:zhangning
--  发布时间:2016/8/19 12:51:00
--  
Dim dt As DataTable = DataTables("出勤汇总")
Dim Total As Double
Dim bumens As List(Of String)
bumens = dt.GetValues("部门")
For Each bumen As String In bumens
    Total = dt.Compute("Sum(加班合计H)", "[部门] = \'" & bumen & "\'")
    e.Form.Controls("TextBox3").Text = Total
Next

以上是 以部门为条件的,没有加入时间条件,请问老师如何加入时间条件,谢谢!

--  作者:大红袍
--  发布时间:2016/8/19 14:17:00
--  

 查询,参考

 

http://www.foxtable.com/webhelp/scr/1058.htm

 


--  作者:zhangning
--  发布时间:2016/8/19 14:42:00
--  
老师,查询的代码已经搞定了,没有问题,
只是右边部门统计处 的汇总

Dim dt As DataTable = DataTables("出勤汇总")
Dim Total As Double
Dim bumens As List(Of String)
bumens = dt.GetValues("部门")
For Each bumen As String In bumens
    Total = dt.Compute("Sum(加班合计H)", "[部门] = \'" & bumen & "\'")
    e.Form.Controls("TextBox3").Text = Total
    Total = dt.Compute("Sum(欠勤合计H)", "[部门] = \'" & bumen & "\'")
    e.Form.Controls("TextBox4").Text = Total
    Total = dt.Compute("count(姓名)", "[部门] = \'" & bumen & "\'")
    e.Form.Controls("TextBox2").Text = Total

Next

如何才能加上 “检索期间”的条件呢





--  作者:大红袍
--  发布时间:2016/8/19 14:46:00
--  

直接写

 

Dim dt As DataTable = DataTables("出勤汇总")

Dim Filter As String = "[部门] = \'" & e.Form.Controls("cccc").Value & "\' and 日期 >= #" & e.Form.Controls("aaa").Value & "# and 日期 <= #" & e.Form.Controls("bbb").Value & "#"

e.Form.Controls("TextBox3").Text = dt.Compute("Sum(加班合计H)", filter)


--  作者:zhangning
--  发布时间:2016/8/19 15:14:00
--  
按照老师说的,解决了,谢谢!