以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 代码如何合并? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=177410) |
|
-- 作者:lgz518 -- 发布时间:2022/5/20 18:09:00 -- 代码如何合并? 第一部功能: Dim c As String = e.Form.Controls("ComboBox1").Text Dim d As String = " " & e.Form.Controls("ComboBox2").Text & " " Dim filter As String Dim 符号 As String If d = " like " Then If tbl.Cols(c).IsString = False Then Tables("模糊查询_订单").filter = "convert(" & c & ",\'System.String\')" & d & "\'%" & e.Form.Controls("TextBox1").Text & "%\'" Else Tables("模糊查询_订单").filter = c & d & "\'%" & e.Form.Controls("TextBox1").Text & "%\'" End If Else If tbl.Cols(c).IsString Then 符号 = "\'" ElseIf tbl.Cols(c).IsDate Then 符号 = "#" End If Tables("模").filter = c & d & 符号 & e.Form.Controls("TextBox1").Text & 符号 End If 第二部功能 Dim Filter As String 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 Tables("模糊查询_订单").Filter = Filter 问题一:上面代码,第一部和第二部分开使用是可以,现在如何实现合并在一起? 我试着做下面代码,报错提示缺少运算? Dim tbl As Table = Tables("订单") Dim c As String = e.Form.Controls("ComboBox1").Text Dim d As String = " " & e.Form.Controls("ComboBox2").Text & " " Dim d1 As String = e.Form.Controls("StartDate").Text Dim d2 As String = e.Form.Controls("EndDate").Text Dim filter As String Dim 符号 As String If d = " like " Then If tbl.Cols(c).IsString = False Then Tables("模糊查询_订单").filter = "convert(" & c & ",\'System.String\')" & d & "\'%" & e.Form.Controls("TextBox1").Text & "%\'" Else Tables("模糊查询_订单").filter = c & d & "\'%" & e.Form.Controls("TextBox1").Text & "%\'" End If Else If tbl.Cols(c).IsString Then 符号 = "\'" ElseIf tbl.Cols(c).IsDate Then 符号 = "#" d1 = "#" d2 = "#" End If Tables("订单").filter = c & d & d1 & d2 & 符号 & e.Form.Controls("TextBox1").Text & 符号 \' Tables("查询").filter = c & d & 符号 & e.Form.Controls("TextBox1").Text & 符号 End If [此贴子已经被作者于2022/5/21 21:35:09编辑过]
|
|
-- 作者:有点蓝 -- 发布时间:2022/5/21 9:08:00 -- Dim Filter As String 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 If Filter > "" Then Filter = Filter & " And " End If Dim c As String = e.Form.Controls("ComboBox1").Text Dim d As String = " " & e.Form.Controls("ComboBox2").Text & " " Dim 符号 As String If d = " like " Then If tbl.Cols(c).IsString = False Then Filter = Filter & "convert(" & c & ",\'System.String\')" & d & "\'%" & e.Form.Controls("TextBox1").Text & "%\'" Else Filter = Filter & c & d & "\'%" & e.Form.Controls("TextBox1").Text & "%\'" End If Else If tbl.Cols(c).IsString Then 符号 = "\'" ElseIf tbl.Cols(c).IsDate Then 符号 = "#" End If Filter = Filter & c & d & 符号 & e.Form.Controls("TextBox1").Text & 符号 End If Tables("模糊查询_订单").Filter = Filter
|
|
-- 作者:lgz518 -- 发布时间:2022/5/21 12:03:00 -- 老师,我想按查询条件结果进行统计,加下面红字代码,没报错,只实现查询,也不执行统计,如何实现?谢谢 由于帖子提示内容长度太大,代码分二次上传: 第一部: Dim b As New GroupTableBuilder("统计表1", DataTables("订单"))
|
|
-- 作者:lgz518 -- 发布时间:2022/5/21 12:03:00 -- 第二部 Dim 符号 As String If d = " like " Then If tbl.Cols(c).IsString = False Then Filter = Filter & "convert(" & c & ",\'System.String\')" & d & "\'%" & e.Form.Controls("TextBox1").Text & "%\'" Else Filter = Filter & c & d & "\'%" & e.Form.Controls("TextBox1").Text & "%\'" End If Else If tbl.Cols(c).IsString Then 符号 = "\'" ElseIf tbl.Cols(c).IsDate Then 符号 = "#" End If Filter = Filter & c & d & 符号 & e.Form.Controls("TextBox1").Text & 符号 End If Tables("模糊查询_订单").Filter = Filter b.Totals.AddDef("数量", "订购数量") \'添加数量列用于统计 b.Filter = Filter Tables("模糊查询_Table1").DataSource = b.BuildDataSource() |
|
-- 作者:有点蓝 -- 发布时间:2022/5/21 13:53:00 -- 没有添加分组:http://www.foxtable.com/webhelp/topics/0677.htm |
|
-- 作者:lgz518 -- 发布时间:2022/5/21 14:20:00 -- 老师,分组是查询条件,3,4楼的代码,不知道怎么实现,请老师帮忙,谢谢 |
|
-- 作者:有点蓝 -- 发布时间:2022/5/21 15:22:00 -- 没看懂,请截图说明 |
|
-- 作者:lgz518 -- 发布时间:2022/5/21 15:57:00 -- 问题一:如何实现查询统计?如下图 |
|
-- 作者:lgz518 -- 发布时间:2022/5/21 16:06:00 -- 问题二:用2楼代码,按开始日期和结束时间,没有后面条件进行查询,会报错,如下图 .NET Framework 版本:4.0.30319.42000 Foxtable 版本:2022.5.13.2 错误所在事件:窗口,模糊查询,Button6,Click 详细错误信息: 未将对象引用设置到对象的实例。 |
|
-- 作者:有点蓝 -- 发布时间:2022/5/21 16:20:00 -- 1、统计什么?按什么做分组进行统计,统计的结果应该是怎么样的? 2、没有选择分类,代码里没有判断是否选择了分类
|