StableVersion4.3/HL_ChestPain_Statistics/Form_Approach.cs

151 lines
6.1 KiB
C#

using DevExpress.Utils;
using DevExpress.XtraCharts;
using DevExpress.XtraEditors;
using HL_FristAidPlatform_DTO;
using HL_FristAidPlatform_Public;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HL_FristAidPlatform_ChestPain_Statistics
{
public partial class Form_Approach : XtraForm
{
public Form_Approach()
{
InitializeComponent();
}
private void Form_Approach_Load(object sender, EventArgs e)
{
time_starTime.TimeValue = DateTime.Now.AddMonths(-5).ToString();
time_endTime.TimeValue = DateTime.Now.ToString();
GetStatisticsData();
}
private void simpleButton5_Click(object sender, EventArgs e)
{
time_starTime.TimeValue = DateTime.Now.AddMonths(-2).ToString();
time_endTime.TimeValue = DateTime.Now.ToString();
GetStatisticsData();
}
private void simpleButton1_Click(object sender, EventArgs e)
{
time_starTime.TimeValue = DateTime.Now.AddMonths(-5).ToString();
time_endTime.TimeValue = DateTime.Now.ToString();
GetStatisticsData();
}
private void simpleButton4_Click(object sender, EventArgs e)
{
time_starTime.TimeValue = DateTime.Now.AddMonths(-11).ToString();
time_endTime.TimeValue = DateTime.Now.ToString();
GetStatisticsData();
}
private void simpleButton2_Click(object sender, EventArgs e)
{
GetStatisticsData();
}
public void GetStatisticsData()
{
if (string.IsNullOrEmpty(time_starTime.TimeValue))
{
XtraMessageBox.Show("查询起始时间不能为空");
return;
}
if (string.IsNullOrEmpty(time_endTime.TimeValue))
{
XtraMessageBox.Show("查询结束时间不能为空");
return;
}
chartControl1.Series.Clear();
int max = 0;
Series series1 = new Series("120来院", ViewType.Bar);
Series series2 = new Series("自行来院", ViewType.Bar);
Series series3 = new Series("院内发病", ViewType.Bar);
Series series4 = new Series("外院转运", ViewType.Bar);
List<MassiveDataStatisticsDTO> list = DBHelpClass.GetList<MassiveDataStatisticsDTO>(string.Format("/api/service/T_Service_ChestPain_Prehospital/GetChestPainToHospitalWay?hosptialGuid={0}&startTime={1}&endTime={2}", Information.Hospital.GUID,Convert.ToDateTime(time_starTime.TimeValue).ToString("yyyy-MM-dd"), Convert.ToDateTime(time_endTime.TimeValue).ToString("yyyy-MM-dd")));
if (list != null)
{
for (int i = 0; i < list.Count; i++)
{
if (list[i].name == "120来院")
{
lbl_CallCount.Text = list[i].value.ToString();
series1.Points.Add(new SeriesPoint(list[i].name, list[i].value));
}
if (list[i].name == "自行来院")
{
lbl_ZXLYCount.Text = list[i].value.ToString();
series2.Points.Add(new SeriesPoint(list[i].name, list[i].value));
}
if (list[i].name == "院内发病")
{
lbl_YNFBCount.Text = list[i].value.ToString();
series3.Points.Add(new SeriesPoint(list[i].name, list[i].value));
}
if (list[i].name == "转院")
{
lbl_WYZYCount.Text = list[i].value.ToString();
series4.Points.Add(new SeriesPoint(list[i].name, list[i].value));
}
}
max = list.Max(i => i.value);
chartControl2.Series.Clear();
chartControl2.Titles.Clear();
Series series = new Series("占比统计", ViewType.Pie);
series.Points.Add(new SeriesPoint("120来院", int.Parse(lbl_CallCount.Text)));
series.Points.Add(new SeriesPoint("自行来院", int.Parse(lbl_ZXLYCount.Text)));
series.Points.Add(new SeriesPoint("院内发病", int.Parse(lbl_YNFBCount.Text)));
series.Points.Add(new SeriesPoint("外院转运", int.Parse(lbl_WYZYCount.Text)));
ChartTitle chartTitle11 = new ChartTitle();
chartTitle11.Text = "占比统计";
series.Label.TextPattern = "{A}: {VP:p0}";
((PieSeriesLabel)series.Label).Position = PieSeriesLabelPosition.TwoColumns;
((PieSeriesLabel)series.Label).ResolveOverlappingMode = ResolveOverlappingMode.Default;
chartControl2.Series.AddRange(series);
}
BarSeriesView bsv = (BarSeriesView)series1.View;
bsv.BarWidth = 0.2;
BarSeriesView bsv1 = (BarSeriesView)series2.View;
bsv1.BarWidth = 0.2;
BarSeriesView bsv2 = (BarSeriesView)series3.View;
bsv2.BarWidth = 0.2;
BarSeriesView bsv3 = (BarSeriesView)series4.View;
bsv3.BarWidth = 0.2;
chartControl1.Series.AddRange(new Series[] { series1, series2, series3, series4 });
int tempone = max / 5;
int temptwo = max % 5;
if (temptwo == 0)
{
max = tempone * 5;
}
else
{
max = (tempone + 1) * 5;
}
if (max == 0)
{
max = 10;
}
XYDiagram xyDia = chartControl1.Diagram as XYDiagram;
xyDia.AxisY.WholeRange.MaxValue = max;
xyDia.AxisY.NumericScaleOptions.GridOffset = 0;
xyDia.AxisY.NumericScaleOptions.GridSpacing = max / 5;
((XYDiagram)(chartControl1.Diagram)).EnableAxisXScrolling = true;//启用横轴滚动条
}
}
}