以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 这样的功能代码怎么写呢?请大师指点~~~ (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=49201) |
-- 作者:youngk -- 发布时间:2014/4/14 10:05:00 -- 这样的功能代码怎么写呢?请大师指点~~~ 我设计了一个独立窗口,里面有起始时间、结束时间、客户名称、货物种类等可以选择的值,同时还有几个值是要根据这些条件对表进行统计的。我应该如何着手写代码呢? |
-- 作者:youngk -- 发布时间:2014/4/14 10:05:00 -- 此主题相关图片如下:qq图片20140414100454.jpg |
-- 作者:youngk -- 发布时间:2014/4/14 10:07:00 -- 统计条件并不是每次都全部有的哦,说明下 |
-- 作者:Bin -- 发布时间:2014/4/14 10:07:00 -- http://www.foxtable.com/help/topics/1284.htm 条件拼接和查询条件也是类似的http://www.foxtable.com/help/topics/1058.htm 新手建议先按部就班看帮助,就不会有这种疑问了. 实在不会可以上例子.
|
-- 作者:lsy -- 发布时间:2014/4/14 10:07:00 -- 例子上来,说明白想如何查询,如何统计。 |
-- 作者:babaala -- 发布时间:2014/4/14 10:24:00 -- 我希望你们完善一下图表功能,不能按照每根bar来单独着色,还有画线功能也是一样,比方说正负是红色,负数是绿色等等。 |
-- 作者:youngk -- 发布时间:2014/4/14 14:27:00 -- Dim dt As DataTable = DataTables("进出库信息记录") Dim tbl As Table = Tables("进出库信息记录") Dim form4 As winform.form = forms("常用信息统计") Dim d1 As Date = Form4.controls("DateTimePicker1").value Dim d2 As Date = Form4.controls("DateTimePicker2").value Dim lbl2 As winform.control = Form4.controls("label2") Dim lbl4 As winform.control = Form4.controls("label4") Dim lbl6 As winform.control = Form4.controls("label6") Dim lbl8 As winform.control = Form4.controls("label8") Dim lbl10 As winform.control = Form4.controls("label10") Dim lbl12 As winform.control = Form4.controls("label12") Dim Tatol As Decimal Dim tatol1 As Decimal Dim tatol2 As Decimal Dim Tatol3 As Decimal Dim tatol4 As Decimal Dim tatol5 As Decimal Dim Tatol6 As Decimal Dim Tatol7 As Decimal If e.Form.controls("DateTimePicker2").value Is Nothing Then e.Form.controls("Label2").text = 0 e.Form.controls("Label4").text = 0 e.Form.controls("Label6").text = 0 e.Form.controls("Label8").text = 0 e.Form.controls("Label10").text = 0 e.Form.controls("Label12").text = 0 End If If e.Form.controls("DateTimePicker2").value IsNot Nothing And e.Form.controls("DateTimePicker1").value Is Nothing Then Tatol = Tables("进出库信息记录").compute("sum(吨位)","([进出库分类]= \'进库\' or [进出库分类]= \'对过\') and [日期] = \'"& e.Form.controls("DateTimePicker2").Value & "\'") e.Form.controls("Label2").text = Round2(Tatol,2) tatol1=dt.compute("sum(吨位)","([进出库分类]=\'进库\' Or [进出库分类]=\'转存\') And [日期] <= \'"& e.Form.controls("DateTimePicker2").Value & "\'") tatol2=dt.compute("sum(吨位)","[进出库分类]=\'出库\'And [日期] <= \'"& e.Form.controls("DateTimePicker2").Value & "\'") tatol3 = tatol1-tatol2 e.Form.controls("Label4").text = Round2(Tatol3,2) Tatol4 = Tables("进出库信息记录").compute("sum(车船数)","[到发方式]=\'火车\' and [日期] = \'"& e.Form.controls("DateTimePicker2").Value & "\'") e.Form.controls("Label6").text = Round2(Tatol4,2) Tatol5 = Tables("进出库信息记录").compute("sum(过磅吨位)","[日期] = \'"& e.Form.controls("DateTimePicker2").Value & "\'") e.Form.controls("Label8").text = Round2(Tatol5,2) Tatol6 = Tables("进出库信息记录").compute("sum(车船数)","[到发方式]=\'船舶\' and [日期] = \'"& e.Form.controls("DateTimePicker2").Value & "\'") e.Form.controls("Label10").text = Round2(Tatol6,2) Tatol7 = Tables("进出库信息记录").compute("sum(二码头对过)","[日期] = \'"& e.Form.controls("DateTimePicker2").Value & "\'") e.Form.controls("Label12").text = Round2(Tatol7,2) End If If e.Form.controls("DateTimePicker2").value IsNot Nothing And e.Form.controls("DateTimePicker1").value IsNot Nothing Then If e.Form.controls("ComboBox1").value Is Nothing And e.Form.controls("ComboBox2").value Is Nothing And e.Form.controls("ComboBox3").value Is Nothing Then Tatol = Tables("进出库信息记录").compute("sum(吨位)","([进出库分类]= \'进库\' or [进出库分类]= \'对过\') and [日期] >= \'"& e.Form.controls("DateTimePicker1").Value & "\'and [日期] <= \'"& e.Form.controls("DateTimePicker2").Value & "\'") e.Form.controls("Label2").text = Round2(Tatol,2) tatol1=dt.compute("sum(吨位)","([进出库分类]=\'进库\' Or [进出库分类]=\'转存\') And [日期] <= \'"& e.Form.controls("DateTimePicker2").Value & "\'") tatol2=dt.compute("sum(吨位)","[进出库分类]=\'出库\'And [日期] <= \'"& e.Form.controls("DateTimePicker2").Value & "\'") tatol3 = tatol1-tatol2 e.Form.controls("Label4").text = Round2(Tatol3,2) Tatol4 = Tables("进出库信息记录").compute("sum(车船数)","[到发方式]=\'火车\' and [日期] >= \'"& e.Form.controls("DateTimePicker1").Value & "\'and [日期] <= \'"& e.Form.controls("DateTimePicker2").Value & "\'") e.Form.controls("Label6").text = Round2(Tatol4,2) Tatol5 = Tables("进出库信息记录").compute("sum(过磅吨位)","[日期] >= \'"& e.Form.controls("DateTimePicker1").Value & "\'and [日期] <= \'"& e.Form.controls("DateTimePicker2").Value & "\'") e.Form.controls("Label8").text = Round2(Tatol5,2) Tatol6 = Tables("进出库信息记录").compute("sum(车船数)","[到发方式]=\'船舶\' and [日期] >= \'"& e.Form.controls("DateTimePicker1").Value & "\'and [日期] <= \'"& e.Form.controls("DateTimePicker2").Value & "\'") e.Form.controls("Label10").text = Round2(Tatol6,2) Tatol6 = Tables("进出库信息记录").compute("sum(二码头对过)","[日期] >= \'"& e.Form.controls("DateTimePicker1").Value & "\'and [日期] <= \'"& e.Form.controls("DateTimePicker2").Value & "\'") e.Form.controls("Label12").text = Round2(Tatol7,2) End If If e.Form.controls("ComboBox1").value IsNot Nothing And e.Form.controls("ComboBox2").value Is Nothing And e.Form.controls("ComboBox3").value Is Nothing Then Tatol = Tables("进出库信息记录").compute("sum(吨位)","([进出库分类]= \'进库\' or [进出库分类]= \'对过\') and ([日期] <= \'"& e.Form.controls("DateTimePicker2").Value & "\'and [日期] >= \'"& e.Form.controls("DateTimePicker2").Value & "\')") e.Form.controls("Label2").text = Round2(Tatol,2) tatol1=dt.compute("sum(吨位)","([进出库分类]=\'进库\' Or [进出库分类]=\'转存\') And [日期] <= \'"& e.Form.controls("DateTimePicker2").Value & "\'") tatol2=dt.compute("sum(吨位)","[进出库分类]=\'出库\'And [日期] <= \'"& e.Form.controls("DateTimePicker2").Value & "\'") tatol3 = tatol1-tatol2 e.Form.controls("Label4").text = Round2(Tatol3,2) Tatol4 = Tables("进出库信息记录").compute("sum(车船数)","[到发方式]=\'火车\' and ([日期] <= \'"& e.Form.controls("DateTimePicker2").Value & "\'and [日期] >= \'"& e.Form.controls("DateTimePicker2").Value & "\')") e.Form.controls("Label6").text = Round2(Tatol4,2) Tatol5 = Tables("进出库信息记录").compute("sum(过磅吨位)","[日期] <= \'"& e.Form.controls("DateTimePicker2").Value & "\'and [日期] >= \'"& e.Form.controls("DateTimePicker2").Value & "\'") e.Form.controls("Label8").text = Round2(Tatol5,2) Tatol6 = Tables("进出库信息记录").compute("sum(车船数)","[到发方式]=\'船舶\' and ([日期] <= \'"& e.Form.controls("DateTimePicker2").Value & "\'and [日期] >= \'"& e.Form.controls("DateTimePicker2").Value & "\')") e.Form.controls("Label10").text = Round2(Tatol6,2) Tatol6 = Tables("进出库信息记录").compute("sum(二码头对过)","[日期] = \'"& e.Form.controls("DateTimePicker2").Value & "\'") e.Form.controls("Label12").text = Round2(Tatol7,2) End If |
-- 作者:youngk -- 发布时间:2014/4/14 14:27:00 -- 请大师看一下,这个代码可以简化不? |
-- 作者:Bin -- 发布时间:2014/4/14 14:30:00 -- 建议 IF判断中把统计的值赋值给变量 最后最后再把变量赋值给控件, 不用每个IF条件中都赋值一次
|
-- 作者:youngk -- 发布时间:2014/4/14 14:52:00 -- 我也是这样的想法 但是怎么做到呢?是不是用这样的代码啊: With e.Form.Controls("cmbProduct") If .Value IsNot Nothing Then Filter = "产品 = \'" & .Value & "\'" End If End With With e.Form.Controls("cmbCustomer") If .Value IsNot Nothing Then If Filter > "" Then Filter = Filter & " And " End If Filter = Filter & "客户 = \'" & .Value & "\'" End If End With |