-- 作者:chen3728060
-- 发布时间:2017/5/23 10:47:00
-- 为啥CurrentChanged事件里多了生成图表代码,会导致行号刷新不出来,合计列也是
我把图表生成的代码,放在了Button1的事件里
首先看一个没有把Button1放在currentChanged里的情况。中间的大表是一个SqlGroupTable的库存汇总表,右边是一个根据库存汇总表选择某一行后,提取所有库存流水的sqlQuery表
此主题相关图片如下:无图表.gif
上面我是库存汇总表和对应的库存流水表都提取完成后,自己手动点button1生成图表。这个过程是没有任何问题的
然后我就把Button1写进去 库存汇总表 的CurrentChange里,
Dim b1 As WinForm.Button = e.Form.Controls("Button1") b1.PerformClick
此主题相关图片如下:有图标.gif
然后就出现这样的情况了,行号不出现,绿色的合计列也不出现,要鼠标移动过去才会出现,是我的代码有问题吗?
库存汇总表的 CurrentChanged 事件:
Dim r As Row = Tables("StoreReport_TableStore").Current If r IsNot Nothing Then Dim b As New SQLJoinTableBuilder("ReStore","StoreFlow") b.C b.AddCols("StoreFlowID") b.AddCols("StoreFlowTime") b.AddCols("StoreFlowType") b.AddCols("StoreFlowQty") b.AddCols("StoreFlowRemark") b.Filter="ItemID = \'" & r("ItemID") & "\'" Dim t As Table = Tables("StoreReport_TableReStore") t.DataSource = b.BuildDataSource t.Cols("StoreFlowID").Caption="单据ID" t.Cols("StoreFlowTime").Caption="日期" \'t.Cols("StoreTime").DataCol.SetDateTimeFormat(DateTimeFormatEnum.DateTime) t.Cols("StoreFlowQty").Caption ="数量" t.Cols("StoreFlowType").Caption ="单据类型" t.Cols("StoreFlowRemark").Caption ="单据备注" t.DataTable.BuildHeader t.Sort ="StoreFlowTime desc ,StoreFlowID desc" t.AutoSizeCols \'主表里找到这个行,因为我要显示它的图片---- If DataTables.Contains("ItemInfo") =False Then DataTables.Load("ItemInfo") End If Dim Filter As String ="ItemID = \'" & r("ItemID") & "\'" If DataTables("ItemInfo").find(Filter) Is Nothing Then DataTables("ItemInfo").AppendLoad(Filter,False) End If Dim p As Integer p = Tables("ItemInfo").FindRow(Filter)\'从第一行开始查找 If p >= 0 Then \'如果找到的话 Tables("ItemInfo").Position = p \'定位到找到的行. End If \'主表里找到这个行,因为我要显示它的图片----
Dim b1 As WinForm.Button = e.Form.Controls("Button1") b1.PerformClick End If
生成图表的Button1代码:
\'图表--- Dim g As new GroupTableBuilder("Fl",DataTables("StoreReport_TableReStore")) g.Groups.AddDef("StoreFlowTime",DateGroupEnum.day,"day")\'根据日期按年分组 g.Totals.AddDef("StoreFlowQty") Dim da As Date = Functions.Execute("SqlDate") da = Da.AddDays(-15) g.Filter = "StoreFlowQty < 0 and StoreFlowType <> \'盘点\' and StoreFlowTime >=#" & da & "#" Dim gt As DataTable = g.Build If gt.DataRows.Count > 0 Then e.Form.Controls("chart1").Visible =True Dim Chart As WinForm.Chart Dim Series As WinForm.ChartSeries Chart= e.Form.Controls("Chart1") \' 引用窗口中的图表 Chart.SeriesList.Clear() \'清除图表原来的图系 Chart.VisualEffect = True Chart.HeaderText ="近15天出货数量折线图" Chart.AxisY.Min = 0 Chart.AxisY.Major = 1 Chart.AxisY.GridMajorVisible =True Chart.AxisX.GridMajorVisible =True Chart.AxisX.Major = 1 Chart.AxisX.DateType = True \'X轴是日期型 Chart.AxisX.AnnoRotation = - 45 \'X轴标示逆时针旋转45度 Series = Chart.SeriesList.Add() Series.Length = gt.DataRows.Count For i As Integer = 0 To gt.DataRows.Count -1 Series.X(i) = gt.DataRows(i)("day") +1 Series.Y(i) = - gt.DataRows(i)("StoreFlowQty") Next Chart.SeriesList(0).MarkSize =3 Chart.SeriesList(0).LineColor= Color.orange Else e.Form.Controls("chart1").Visible =False End If \'图表---
[此贴子已经被作者于2017/5/23 10:49:01编辑过]
|