Dim y As Integer = Date.Today.Year
Dim m As Integer = Date.Today.Month
Dim d1 As New Date(y, m-1, 1)
Dim d2 As New Date(y, m-1, Date.DaysInMonth(y,m)) '获取该月的最后一天
Dim dr As DataRow
dr=DataTables("车间反馈原材料异常明细").find("[日期] >= #" & d1 & "# And [日期] <= #" & d2 & "#")
If dr IsNot Nothing Then
Dim g As New GroupTableBuilder("统计表1", DataTables("车间反馈原材料异常明细"))
Dim Filter As String
g.Filter = "日期 >= #" & d1 & "# And 日期 <= #" & d2 & "#"
g.Groups.AddDef("责任部门")
g.Groups.AddDef("物料名称")
g.Totals.AddDef("责任部门", AggregateEnum.Count, "不合格批次")
g.GrandProportion = True
Tables("主界面窗口_Table2").DataSource = g.BuildDataSource()
Tables("主界面窗口_Table2").sort = "不合格批次 desc"
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t As Table = Tables("主界面窗口_Table2") '定义一个变量t引用数据表
Chart = e.Form.Controls("Chart1") ' 引用窗口中的图表
Chart.ChartType = ChartTypeEnum.Bar '图表类型该为Bar(条形)
Chart.HeaderText = m-1 & "月份车间反馈原材料不合格批次"
Chart.AxisX.Major = 2
Chart.AxisY.Major = 2
Chart.SeriesList.Clear() '清除图表原来的图系
Chart.AxisX.ClearValueLabel
Series = Chart.SeriesList.Add() '增加第一个图系
Series.Length = t.Rows.Count '图系的数据点数等于表的行数
Series.X(0) = 0 '指定水平坐标
Series.Y(0) = 0
Chart.AxisX.SetValueLabel(0, "")
For i As Integer = 0 To t.rows.count-1 '指定每个数据点的位置
Series.X(i) = i'指定水平坐标
Series.Y(i) = t.Rows(i)("不合格批次") '指定垂直坐标
Chart.AxisX.SetValueLabel(i, t.Rows(i)("责任部门"))
Next
Chart.SeriesList(0).fillcolor = Color.lightblue
chart.AxisX.GridMajorVisible=False
chart.AxisY.GridMajorVisible=False
Chart.AxisX.AnnoWithLabels = True '启用字符标示
Chart.LegendCompass= CompassEnum.South '图列显示在南方(底端)
Series.DataLabelText = "{#YVAL}"
Chart.AxisX.AnnoRotation = -45 'X轴标示逆时针旋转45度
Chart.AxisX.Font=new font("宋体",10,FontStyle.Bold )
chart.HeaderFont=new font("宋体",12,FontStyle.Bold )
End If
Dim dr1 As DataRow
dr1=DataTables("来料检验原材料不合格明细").find("[日期] >= #" & d1 & "# And [日期] <= #" & d2 & "#")
If dr1 IsNot Nothing Then
Dim g1 As New GroupTableBuilder("统计表2", DataTables("来料检验原材料不合格明细"))
g1.Filter = "日期 >= #" & d1 & "# And 日期 <= #" & d2 & "#"
g1.Groups.AddDef("供应商")
g1.Totals.AddDef("供应商", AggregateEnum.Count, "不合格批次")
g1.GrandProportion = True
Tables("主界面窗口_Table3").DataSource = g1.BuildDataSource()
Tables("主界面窗口_Table3").sort = "不合格批次 desc"
Dim Chart1 As WinForm.Chart '定义一个图表变量
Dim Series1 As WinForm.ChartSeries '定义一个图系变量
Dim t1 As Table = Tables("主界面窗口_Table3") '定义一个变量t引用数据表
Chart1 = e.Form.Controls("Chart2") ' 引用窗口中的图表
Chart1.ChartType = ChartTypeEnum.Bar '图表类型该为Bar(条形)
Chart1.HeaderText = m-1 & "月份来料检验原材料不合格批次"
Chart1.AxisX.Major = 2
Chart1.AxisY.Major = 2
Chart1.SeriesList.Clear() '清除图表原来的图系
Chart1.AxisX.ClearValueLabel
Series1 = Chart1.SeriesList.Add() '增加第一个图系
Series1.Length = t1.Rows.Count '图系的数据点数等于表的行数
Series1.X(0) = 0 '指定水平坐标
Series1.Y(0) = 0
Chart1.AxisX.SetValueLabel(0, "")
For i As Integer = 0 To t1.rows.count-1 '指定每个数据点的位置
Series1.X(i) = i'指定水平坐标
Series1.Y(i) = t1.Rows(i)("不合格批次") '指定垂直坐标
Chart1.AxisX.SetValueLabel(i, t1.Rows(i)("供应商"))
Next
Chart1.SeriesList(0).fillcolor = Color.lightblue
chart1.AxisX.GridMajorVisible=False
chart1.AxisY.GridMajorVisible=False
Chart1.AxisX.AnnoWithLabels = True '启用字符标示
Chart1.LegendCompass= CompassEnum.South '图列显示在南方(底端)
Series1.DataLabelText = "{#YVAL}"
Chart1.AxisX.AnnoRotation = -45 'X轴标示逆时针旋转45度
Chart1.AxisX.Font=new font("宋体",10,FontStyle.Bold )
chart1.HeaderFont=new font("宋体",12,FontStyle.Bold )
End If