以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  窗口代码错误  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=141616)

--  作者:东方威思顿
--  发布时间:2019/10/7 8:40:00
--  窗口代码错误
之前登陆的时候都显示正常,今天登陆的时候提示代码错误,请老师帮忙看看是哪里出现了错误:
.NET Framework 版本:4.0.30319.42000
Foxtable 版本:2019.6.18.1
错误所在事件:窗口,主界面窗口,AfterLoad
详细错误信息:
年、月和日参数描述无法表示的 DateTime。
代码如下:
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

--  作者:有点蓝
--  发布时间:2019/10/7 8:42:00
--  
Dim d1 As New Date(y, m, 1)
Dim d2 As New Date(y, m, Date.DaysInMonth(y,m)) \'获取该月的最后一天