以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  数据查询  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=117769)

--  作者:outcat
--  发布时间:2018/4/18 22:33:00
--  数据查询

此主题相关图片如下:121.png
按此在新窗口浏览图片

上图中的年、月 g.VGroups.AddDef("日期",DateGroupEnum.Year, "{0}年")

                 g.VGroups.AddDef("日期", "{0}月")是这样取值的

这个统计表的年月怎么取值,我要查询指定月份的记录

我在查询记录的AfterLoad 写了如下代码,查询出错,请老师指导一下

If Forms("其它采购月汇总").opened

Dim cr As Row = Tables("其它采购月汇总_Table1").Current

 

    Dim dt1,dt2 As Date

    dt1 = new Date(cr("{0}"),cr("{0}"),1)

    dt2 = new Date(cr("{0}"),cr("{0}"),Date.DaysInMonth(cr("{0}"),cr("0}")))

   

    Tables("其它采购记录_Table1").Filter = "供应商 = \'" & cr("供应商") & "\' and 日期 >= #" & dt1 & "# and 日期 <= #" & dt2 & "#"

End If


--  作者:有点甜
--  发布时间:2018/4/18 22:46:00
--  
建议你根据条件,重新生成【交叉统计】。贴出你生成交叉统计的代码。
--  作者:outcat
--  发布时间:2018/4/18 23:12:00
--  
查询记录不再生成交叉统计

图片点击可在新窗口打开查看此主题相关图片如下:22.png
图片点击可在新窗口打开查看

图片点击可在新窗口打开查看此主题相关图片如下:21.png
图片点击可在新窗口打开查看



--  作者:outcat
--  发布时间:2018/4/18 23:13:00
--  

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:代码.txt



--  作者:有点甜
--  发布时间:2018/4/18 23:14:00
--  

没理解你的意思,没看到代码,不知道你所指。

 

能否做一个实例发上来说明问题?


--  作者:outcat
--  发布时间:2018/4/18 23:25:00
--  
查询代码
Dim Value As String =e.Sender.SelectedValue
e.Form.Controls("Table1").Visible = True
Select Case Value
    Case "全部"
        Dim g As New CrossTableBuilder("统计表1", DataTables("其它采购总表"))
        Dim cg As fxDataSource
        g.HGroups.AddDef("供应商")
        g.VGroups.AddDef("日期",DateGroupEnum.Year, "{0}年")
        g.VGroups.AddDef("日期", "{0}月")
        g.Totals.AddDef("总金额","金额")
        g.Totals.AddDef("日期",AggregateEnum.Count,"采购单数")
        g.HorizontalTotal = True
        g.VerticalTotal = True
        g.Build()
        cg=g.BuildDataSource
        \'Tables("供应商订货月报表_Table1").Visible = True
        Tables("其它采购月汇总_Table1").DataSource = cg
        Tables("其它采购月汇总_Table1").Cols("供应商").Width = 145
    Case "按条件查询"
        Dim Filter As String
        Dim g As New CrossTableBuilder("统计表1",DataTables("其它采购总表"))
        With e.Form.Controls("供应商")
            If .Value IsNot Nothing Then
                Filter = "供应商 = \'" & .Value & "\'"
            End If
        End With
       
        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
       
        g.Filter = Filter
        Dim cg As fxDataSource
        g.HGroups.AddDef("供应商")
        g.VGroups.AddDef("日期",DateGroupEnum.Year, "{0}年")
        g.VGroups.AddDef("日期", "{0}月")
        g.Totals.AddDef("总金额","金额")
        g.Totals.AddDef("日期",AggregateEnum.Count,"采购单数")
        g.HorizontalTotal = True
        g.VerticalTotal = True
        g.Build()
        cg=g.BuildDataSource
        Tables("其它采购月汇总_Table1").DataSource = cg
        Tables("其它采购月汇总_Table1").Cols("供应商").Width = 145
End Select
 
现在的的明细记录代码
If Forms("其它采购月汇总").opened
Tables("其它采购记录_Table1").Filter = "供应商 = \'" & Tables("其它采购月汇总_Table1").Current("供应商")&"\' "
End if
 
我现在就是想在查询指定月份的记录

--  作者:outcat
--  发布时间:2018/4/18 23:29:00
--  
你现在看看代码,如果我还没有表达好,完了我发项目你给看一下,意思呢就是在汇总界面下,查指定月份的单子,现在呢只会做该供应商所有月份的单子,指定月份的单子查询做不出来
--  作者:有点甜
--  发布时间:2018/4/19 9:03:00
--  

 

[此贴子已经被作者于2018/4/19 9:04:32编辑过]

--  作者:有点甜
--  发布时间:2018/4/19 9:13:00
--  

1、

 

Dim Value As String =e.Sender.SelectedValue
e.Form.Controls("Table1").Visible = True
vars("filter") = "1=1"
Select Case Value
    Case "全部"
        Dim g As New CrossTableBuilder("统计表1", DataTables("其它采购总表"))
        Dim cg As fxDataSource
        g.HGroups.AddDef("供应商")
        g.VGroups.AddDef("日期",DateGroupEnum.Year, "{0}年")
        g.VGroups.AddDef("日期", "{0}月")
        g.Totals.AddDef("总金额","金额")
        g.Totals.AddDef("日期",AggregateEnum.Count,"采购单数")
        g.HorizontalTotal = True
        g.VerticalTotal = True
        g.Build()
        cg=g.BuildDataSource
        \'Tables("供应商订货月报表_Table1").Visible = True
        Tables("其它采购月汇总_Table1").DataSource = cg
        Tables("其它采购月汇总_Table1").Cols("供应商").Width = 145
vars("filter") = "1=1"
    Case "按条件查询"
        Dim Filter As String = "1=1"
        Dim g As New CrossTableBuilder("统计表1",DataTables("其它采购总表"))
        With e.Form.Controls("供应商")
            If .Value IsNot Nothing Then
                Filter = "供应商 = \'" & .Value & "\'"
            End If
        End With
       
        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
       
        g.Filter = Filter
vars("filter") = Filter
        Dim cg As fxDataSource
        g.HGroups.AddDef("供应商")
        g.VGroups.AddDef("日期",DateGroupEnum.Year, "{0}年")
        g.VGroups.AddDef("日期", "{0}月")
        g.Totals.AddDef("总金额","金额")
        g.Totals.AddDef("日期",AggregateEnum.Count,"采购单数")
        g.HorizontalTotal = True
        g.VerticalTotal = True
        g.Build()
        cg=g.BuildDataSource
        Tables("其它采购月汇总_Table1").DataSource = cg
        Tables("其它采购月汇总_Table1").Cols("供应商").Width = 145
End Select
 
2、
 
If Forms("其它采购月汇总").opened
    Tables("其它采购记录_Table1").Filter = "供应商 = \'" & Tables("其它采购月汇总_Table1").Current("供应商") & "\' and " & vars("filter")
End if