Dim cmb1 As WinForm.ComboBox=e.form.Controls("Cmb_kind")
Dim cmb2 As WinForm.ComboBox= e.Form.Controls("Cmb_tongji")
Dim txt As String= cmb1.Text
Dim txt1 As String=cmb2.text
Dim dtp1 As WinForm.DateTimePicker= e.Form.Controls("DateTimePicker1")
Dim d1 As Date=dtp1.value
Dim dtp2 As WinForm.DateTimePicker= e.Form.Controls("DateTimePicker2")
Dim d2 As Date=dtp2.value
Dim sql As String
If e.Form.Controls("Rdo_dengji").checked=False And e.Form.Controls("Rdo_ruyuan").checked=False Then
MessageBox.Show("为提高统计的准确性,请选择统计时段种类","提示",MessageBoxButtons.OK,MessageBoxIcon.warning)
Return
End If
If d1=Nothing Then
MessageBox.Show("为提高统计的准确性,请选择统计开始时间","提示",MessageBoxButtons.OK,MessageBoxIcon.warning)
Return
End If
If d2=Nothing Then
MessageBox.Show("为提高统计的准确性,请选择统计截止时间","提示",MessageBoxButtons.OK,MessageBoxIcon.warning)
Return
End If
If txt="" Then
MessageBox.Show("为提高统计的准确性,请选择患者种类","提示",MessageBoxButtons.OK,MessageBoxIcon.warning)
Return
End If
If txt1="" Then
MessageBox.Show("为提高统计的准确性,请选择统计项目","提示",MessageBoxButtons.OK,MessageBoxIcon.warning)
Return
End If
If e.Form.Controls("Rdo_dengji").checked=True Then
If txt="预约患者(登记时间)" Then
sql="select * from {基本情况} where 登记日期>#d1# and 登记日期<#d2#"
Else If txt="住院患者(登记时间)" Then
sql="select * from {基本情况} where 情况说明='已入院' and 登记日期>#d1# and 登记日期<#d2#"
Else If txt="推迟入院(登记时间)" Then
sql="select * from {基本情况} where 情况说明='推迟入院' and 登记日期>#d1# and 登记日期<#d2#"
Else If txt="失访患者(登记时间)" Then
sql="select * from {基本情况} where 情况说明='无法联系' and 登记日期>#d1# and 登记日期<#d2#"
End If
End If
If e.Form.Controls("Rdo_ruyuan").checked=True Then
If txt="入院患者(入院时间)" Then
sql="select * from {基本情况} where 情况说明='已入院' and 预约日期>#d1# and 预约日期<#d2#"
Else If txt="预约患者(入院时间)" Then
sql="select * from {基本情况} where (情况说明='已入院' or 情况说明='') And 预约日期>#d1# And 预约日期<#d2#"
End If
End If
If e.form.Controls("Cmb_tongji").Text="性别" Then
Dim g As New GroupTableBuilder("统计表1", sql)
g.Caption = "性别统计"
g.Groups.AddDef("性别", "", "性别")
g.Totals.AddDef("姓名", AggregateEnum.Count,"","病例数")
forms("统计图形").Open
Forms("统计图形").Controls("Table1").Table.DataSource = g.BuildDataSource()
Dim Chart As WinForm.Chart '定义一个图表变量
Dim Series As WinForm.ChartSeries '定义一个图系变量
Dim t As Table = Tables("统计图形_table1") '定义一个变量t引用数据表
Chart= e.form.Controls("Chart1") ' 引用窗口中的图表
Chart.VisualEffect = True '加上这一行,让你的图表更漂亮
Chart.ChartType = ChartTypeEnum.Pie '图表1类型改为Bar(条形)
Chart.SeriesList.Clear()
For Each r As Row In t.Rows
Series = Chart.SeriesList.Add() '增加一个图系
Series.Length = 1 '一个系列只能包括一个值
Series.Text = r("性别") & "(" & r("姓名") & ")" '设置图系的标题
Series.Y(0) = r("姓名") '指定值
Next
Chart.LegendVisible = True '显示图列
Chart.LegendCompass= CompassEnum.East '图列显示在东方(右方)
End If