269 lines
11 KiB
C#
269 lines
11 KiB
C#
using DevExpress.Utils;
|
|
using DevExpress.Utils.Layout;
|
|
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.Text.RegularExpressions;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace HL_FristAidPlatform_EmergencyTriage
|
|
{
|
|
public partial class Form_EtiologicalStatistics : XtraForm
|
|
{
|
|
private TablePanel tab;
|
|
public Form_EtiologicalStatistics()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void Form_EtiologicalStatistics_Load(object sender, EventArgs e)
|
|
{
|
|
time_starTime.TimeValue = DateTime.Now.AddMonths(-5).ToString();
|
|
time_endTime.TimeValue = DateTime.Now.ToString();
|
|
GetEtiologicalStatistics();
|
|
}
|
|
|
|
public void GetEtiologicalStatistics()
|
|
{
|
|
if (string.IsNullOrEmpty(time_starTime.TimeValue))
|
|
{
|
|
XtraMessageBox.Show("查询起始时间不能为空");
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(time_endTime.TimeValue))
|
|
{
|
|
XtraMessageBox.Show("查询结束时间不能为空");
|
|
return;
|
|
}
|
|
List<EtiologicalModel> list = DBHelpClass.GetList<EtiologicalModel>(string.Format("api/service/T_Service_EmergencyStatistics/GetEtiologicalStatistics?hospitalGuid={0}&starTime={1}&endTime={2}", Information.Hospital.GUID, Convert.ToDateTime(time_starTime.TimeValue).ToString("yyyy-MM"), Convert.ToDateTime(time_endTime.TimeValue).ToString("yyyy-MM")));
|
|
if (list != null && list.Count > 0)
|
|
{
|
|
CreateTabPanel(list.Count, list);
|
|
chartControl1.Series.Clear();
|
|
Series series1 = new Series("", ViewType.Pie);
|
|
series1.Points.Clear();
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
series1.Points.Add(new SeriesPoint(list[i].Name, new double[] { list[i].Quantity }));
|
|
}
|
|
series1.Label.TextPattern = "{A}: {VP:p0}";
|
|
((PieSeriesLabel)series1.Label).Position = PieSeriesLabelPosition.TwoColumns;
|
|
((PieSeriesLabel)series1.Label).ResolveOverlappingMode = ResolveOverlappingMode.Default;
|
|
chartControl1.Series.Add(series1);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 创建动态表格
|
|
/// </summary>
|
|
/// <param name="total">数据条数</param>
|
|
/// <param name="dt">数据</param>
|
|
public void CreateTabPanel(int total, List<EtiologicalModel> list)
|
|
{
|
|
this.panelControl2.Controls.Clear();
|
|
int columnCount = 3; //列数
|
|
int rowCount;//行数
|
|
if ((total % columnCount) > 0)
|
|
{
|
|
rowCount = total / columnCount + 1;
|
|
}
|
|
else
|
|
{
|
|
rowCount = total / columnCount;
|
|
}
|
|
|
|
tab = new TablePanel();
|
|
tab.Columns.Clear();
|
|
for (int i = 0; i < columnCount; i++)
|
|
{
|
|
tab.Columns.Add(new TablePanelColumn(TablePanelEntityStyle.Relative, 50));
|
|
}
|
|
tab.Rows.Clear();
|
|
for (int i = 0; i < rowCount; i++)
|
|
{
|
|
tab.Rows.Add(new TablePanelRow(TablePanelEntityStyle.Relative, 50));
|
|
}
|
|
tab.Dock = DockStyle.Fill;
|
|
tab.AutoScroll = true;
|
|
tab.BackColor = Color.White;
|
|
tab.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
|
|
int id = 0;
|
|
for (int i = 0; i < rowCount; i++)
|
|
{
|
|
for (int j = 0; j < columnCount; j++)
|
|
{
|
|
if ((i * columnCount + j) < list.Count)
|
|
{
|
|
PanelControl panel = new PanelControl();
|
|
panel.Margin = new Padding(10, 5, 10, 5);
|
|
panel.Dock = DockStyle.Fill;
|
|
panel.BorderStyle = (DevExpress.XtraEditors.Controls.BorderStyles)BorderStyle.None;
|
|
panel.LookAndFeel.Style = (DevExpress.LookAndFeel.LookAndFeelStyle)FlatStyle.Flat;
|
|
panel.LookAndFeel.UseDefaultLookAndFeel = false;
|
|
panel.Name = list[i * columnCount + j].PathogenyID.ToString();
|
|
panel.Click += ControlClick;
|
|
if (i == 0 && j == 0)
|
|
{
|
|
id = list[i * columnCount + j].PathogenyID;
|
|
panel.BackColor = Color.FromArgb(38, 91, 255);
|
|
GetPathogenyStatistics(id);
|
|
}
|
|
else
|
|
{
|
|
panel.BackColor = Color.FromArgb(114, 188, 255);
|
|
}
|
|
|
|
LabelControl lbl1 = new LabelControl();
|
|
lbl1.Location = new Point(3, 3);
|
|
lbl1.ForeColor = Color.White;
|
|
lbl1.Appearance.Font = new Font("Tahoma", 11);
|
|
lbl1.Text = list[i * columnCount + j].Name;
|
|
|
|
LabelControl lbl2 = new LabelControl();
|
|
lbl2.Location = new Point((panel.Width / 2 + lbl1.Width / 2) - 20, (panel.Height / 2 - lbl1.Height / 2) - 10);
|
|
lbl2.Appearance.TextOptions.HAlignment = HorzAlignment.Center;
|
|
lbl2.ForeColor = Color.White;
|
|
lbl2.Appearance.Font = new Font("Tahoma", 16);
|
|
|
|
lbl2.Text = list[i * columnCount + j].Quantity + "例";
|
|
|
|
panel.Controls.AddRange(new Control[] { lbl1, lbl2 });
|
|
tab.Controls.AddRange(new Control[] { panel });
|
|
tab.SetCell(panel, i, j);
|
|
}
|
|
}
|
|
}
|
|
this.panelControl2.Controls.Add(tab);
|
|
}
|
|
|
|
|
|
private void ControlClick(object sender, EventArgs e)
|
|
{
|
|
string name = ((System.Windows.Forms.Control)sender).Name;
|
|
for (int index = 0; index < tab.Controls.Count; index++)
|
|
{
|
|
if (tab.Controls[index].HasChildren)
|
|
{
|
|
Control controlName;
|
|
if (tab.Controls[index].GetType().Name == "PanelControl")
|
|
{
|
|
controlName = (Control)tab.Controls[index].GetContainerControl();
|
|
if ((tab.Controls[index] as PanelControl).Name == name)
|
|
{
|
|
(tab.Controls[index] as PanelControl).BackColor = Color.FromArgb(38, 91, 255);
|
|
}
|
|
else
|
|
{
|
|
(tab.Controls[index] as PanelControl).BackColor = Color.FromArgb(114, 188, 255);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
GetPathogenyStatistics(int.Parse(name));
|
|
}
|
|
|
|
|
|
public void GetPathogenyStatistics(int id)
|
|
{
|
|
if (string.IsNullOrEmpty(time_starTime.TimeValue))
|
|
{
|
|
XtraMessageBox.Show("查询起始时间不能为空");
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(time_endTime.TimeValue))
|
|
{
|
|
XtraMessageBox.Show("查询结束时间不能为空");
|
|
return;
|
|
}
|
|
chartControl2.Series.Clear();
|
|
chartControl2.Titles.Clear();
|
|
Series series1 = new Series("趋势变化统计", ViewType.Spline);
|
|
ChartTitle chartTitle1 = new ChartTitle();
|
|
chartTitle1.Text = "趋势变化统计";
|
|
chartControl2.Titles.Add(chartTitle1);
|
|
List<PathogenyModel> list = DBHelpClass.GetList<PathogenyModel>(string.Format("api/service/T_Service_EmergencyStatistics/GetPathogenyStatistics?hospitalGuid={0}&pathogenyID={1}&startTime={2}&endTime={3}", Information.Hospital.GUID, id, Convert.ToDateTime(time_starTime.TimeValue).ToString("yyyy-MM"), Convert.ToDateTime(time_endTime.TimeValue).ToString("yyyy-MM")));
|
|
if (list != null && list.Count > 0)
|
|
{
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
series1.Points.Add(new SeriesPoint(list[i].Month, list[i].Count));
|
|
}
|
|
chartControl2.Series.AddRange(series1);
|
|
((LineSeriesView)series1.View).MarkerVisibility = DefaultBoolean.True;
|
|
((LineSeriesView)series1.View).LineMarkerOptions.Kind = MarkerKind.Circle;
|
|
XYDiagram xyDia = chartControl2.Diagram as XYDiagram;
|
|
xyDia.AxisX.DateTimeScaleOptions.ScaleMode = ScaleMode.Manual;
|
|
xyDia.AxisX.DateTimeScaleOptions.MeasureUnit = DateTimeMeasureUnit.Month;
|
|
((XYDiagram)(chartControl2.Diagram)).EnableAxisXScrolling = true;//启用横轴滚动条
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 纯数字
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
public bool IsNumber(string input)
|
|
{
|
|
Regex regex = new System.Text.RegularExpressions.Regex("^(-?[0-9]*[.]*[0-9]{0,3})$");
|
|
|
|
return regex.IsMatch(input);
|
|
}
|
|
/// <summary>
|
|
/// 病种统计
|
|
/// </summary>
|
|
public class PathogenyModel
|
|
{
|
|
public string Month { get; set; }
|
|
|
|
public string Count { get; set; }
|
|
|
|
}
|
|
public class EtiologicalModel
|
|
{
|
|
public string Name { get; set; }
|
|
public int Quantity { get; set; }
|
|
|
|
public int PathogenyID { get; set; }
|
|
}
|
|
|
|
private void simpleButton5_Click(object sender, EventArgs e)
|
|
{
|
|
time_starTime.TimeValue = DateTime.Now.AddMonths(-2).ToString();
|
|
time_endTime.TimeValue = DateTime.Now.ToString();
|
|
GetEtiologicalStatistics();
|
|
}
|
|
|
|
private void simpleButton1_Click(object sender, EventArgs e)
|
|
{
|
|
time_starTime.TimeValue = DateTime.Now.AddMonths(-5).ToString();
|
|
time_endTime.TimeValue = DateTime.Now.ToString();
|
|
GetEtiologicalStatistics();
|
|
}
|
|
|
|
private void simpleButton4_Click(object sender, EventArgs e)
|
|
{
|
|
time_starTime.TimeValue = DateTime.Now.AddMonths(-11).ToString();
|
|
time_endTime.TimeValue = DateTime.Now.ToString();
|
|
GetEtiologicalStatistics();
|
|
}
|
|
|
|
private void simpleButton2_Click(object sender, EventArgs e)
|
|
{
|
|
GetEtiologicalStatistics();
|
|
}
|
|
}
|
|
}
|