StableVersion4.3/HL_FristAidPlatform_Apoplexy/Statistics/Form_GenderAgeDistribution.cs

158 lines
6.2 KiB
C#
Raw Permalink Normal View History

2024-03-11 09:47:34 +08:00
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;
using static HL_FristAidPlatform_Public.TimeControl;
namespace HL_FristAidPlatform_Apoplexy
{
public partial class Form_GenderAgeDistribution : XtraForm
{
public DateTime dt = DateTime.Now;
public Form_GenderAgeDistribution()
{
InitializeComponent();
}
private void Form_RSDNT_Load(object sender, EventArgs e)
{
time_starTime.TimeValue = dt.Year + "-01".ToString();
time_endTime.TimeValue = dt.Year + "-12".ToString();
GetRSDNTList();
}
/// <summary>
///
/// </summary>
public void GetRSDNTList()
{
try
{
string startTime = "";
string endTime = "";
int type = 1;
if (type == 0)
{
if (!string.IsNullOrEmpty(time_starTime.TimeValue.ToString()))
{ startTime = Convert.ToDateTime(time_starTime.TimeValue).ToString("yyyy"); }
else { XtraMessageBox.Show("请输入查询时间"); return; }
}
if (type == 1)
{
if (!string.IsNullOrEmpty(time_starTime.TimeValue.ToString()) && !string.IsNullOrEmpty(time_endTime.TimeValue.ToString()))
{
startTime = Convert.ToDateTime(time_starTime.TimeValue).ToString("yyyy-MM");
endTime = Convert.ToDateTime(time_endTime.TimeValue).ToString("yyyy-MM");
}
else
{
XtraMessageBox.Show("请输入查询时间区间"); return;
}
}
string url = string.Format("api/service/T_Service_Apoplexy_Statistics/GetGenderAgeDistribution?hospitalGuid={0}&startTime={1}&endTime={2}&type={3}", Information.Hospital.GUID,startTime, endTime,type);
GenderAgeDistributionDTO model = DBHelpClass.GetDateModel<GenderAgeDistributionDTO>(url);
chartControl1.Series.Clear();
chartControl1.Titles.Clear();
Series series1 = new Series("男性", ViewType.Bar);
Series series2 = new Series("女性", ViewType.Bar);
ChartTitle chartTitle1 = new ChartTitle();
chartTitle1.Text = "患者人群性别年龄分布";
chartControl1.Titles.Add(chartTitle1);
if (model != null )
{
for (int i = 0; i < model.list.Count; i++)
{
series1.Points.Add(new SeriesPoint(model.list[i].key, new string[] { model.list[i].valueOne }));
series2.Points.Add(new SeriesPoint(model.list[i].key, new string[] { model.list[i].valueTwo }));
}
}
BarSeriesView bsv = (BarSeriesView)series1.View;
bsv.BarWidth = 0.2;
BarSeriesView bsv1 = (BarSeriesView)series2.View;
bsv1.BarWidth = 0.2;
chartControl1.Series.AddRange(new Series[] { series1,series2 });
XYDiagram xyDia = chartControl1.Diagram as XYDiagram;
xyDia.AxisX.DateTimeScaleOptions.ScaleMode = ScaleMode.Manual;
int max = 0;
for (int i = 0; i < model.list.Count(); i++)
{
if (int.Parse(model.list[i].valueOne) > max)
max = int.Parse(model.list[i].valueOne);
if (int.Parse(model.list[i].valueTwo) > max)
max = int.Parse(model.list[i].valueTwo);
}
int tempone = max / 5;
int temptwo = max % 5;
if (temptwo == 0)
{
max = tempone * 5;
}
else
{
max = (tempone + 1) * 5;
}
if (max == 0)
max = 10;
xyDia.AxisY.WholeRange.MaxValue = max;
xyDia.AxisY.NumericScaleOptions.GridOffset = 0;
xyDia.AxisY.NumericScaleOptions.GridSpacing = max / 5;
xyDia.AxisX.DateTimeScaleOptions.MeasureUnit = DateTimeMeasureUnit.Month;
((XYDiagram)(chartControl1.Diagram)).EnableAxisXScrolling = true;//启用横轴滚动条
}
catch (Exception)
{
throw;
}
}
private void sButton_ThisMonth_Click_1(object sender, EventArgs e)
{
sButton_ThisMonth.Appearance.BackColor = Color.FromArgb(43, 133, 228);
sButton_ThisYear.Appearance.BackColor = Color.FromArgb(114, 165, 231);
sButton_Query.Appearance.BackColor = Color.FromArgb(114, 165, 231);
time_starTime.TimeValue = dt.AddYears(-1).Year + "-01".ToString();
time_endTime.TimeValue = dt.AddYears(-1).Year + "-12".ToString();
GetRSDNTList();
}
private void sButton_ThisYear_Click(object sender, EventArgs e)
{
sButton_ThisYear.Appearance.BackColor = Color.FromArgb(43, 133, 228);
sButton_ThisMonth.Appearance.BackColor = Color.FromArgb(114, 165, 231);
sButton_Query.Appearance.BackColor = Color.FromArgb(114, 165, 231);
time_starTime.TimeValue = dt.Year + "-01".ToString();
time_endTime.TimeValue = dt.Year + "-12".ToString();
GetRSDNTList();
}
private void sButton_Query_Click(object sender, EventArgs e)
{
sButton_Query.Appearance.BackColor = Color.FromArgb(43, 133, 228);
sButton_ThisMonth.Appearance.BackColor = Color.FromArgb(114, 165, 231);
sButton_ThisYear.Appearance.BackColor = Color.FromArgb(114, 165, 231);
GetRSDNTList();
}
}
}