StableVersion4.3/HL_FristAidPlatform_Trauma/Form_HospitalTransferStatis...

222 lines
9.0 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.Threading.Tasks;
using System.Windows.Forms;
namespace HL_FristAidPlatform_Trauma
{
public partial class Form_HospitalTransferStatisics : XtraForm
{
public TablePanel tab;
public Form_HospitalTransferStatisics()
{
InitializeComponent();
}
private void Form_HospitalTransferStatisics_Load(object sender, EventArgs e)
{
time_starTime.TimeValue = DateTime.Now.AddMonths(-5).ToString();
time_endTime.TimeValue = DateTime.Now.ToString();
GetHospitalTransferStatisics();
GetTimeQualityControlModelStatics();
}
private void simpleButton2_Click(object sender, EventArgs e)
{
GetHospitalTransferStatisics();
GetTimeQualityControlModelStatics();
}
public void GetHospitalTransferStatisics()
{
if (string.IsNullOrEmpty(time_starTime.TimeValue))
{
XtraMessageBox.Show("查询起始时间不能为空");
return;
}
if (string.IsNullOrEmpty(time_endTime.TimeValue))
{
XtraMessageBox.Show("查询结束时间不能为空");
return;
}
chartControl1.Series.Clear();
chartControl1.Titles.Clear();
Series series1 = new Series("院前急救转运时间(分钟)", ViewType.Spline);
ChartTitle chartTitle1 = new ChartTitle();
chartTitle1.Text = "院前急救转运时间统计";
chartControl1.Titles.Add(chartTitle1);
List<DoubleDataSetModel> model = DBHelpClass.GetList<DoubleDataSetModel>(string.Format("api/service/T_Service_Trauma_MassiveDataStatistics/GetHospitalTransferStatisics?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")));
List<Double> lst = new List<Double>();
if (model != null)
{
for (int j = 0; j < model.Count(); j++)
{
lst.Add(model[j].Number);
series1.Points.Add(new SeriesPoint(model[j].TimeDate, model[j].Number));
}
}
chartControl1.Series.AddRange(series1);
((LineSeriesView)series1.View).MarkerVisibility = DefaultBoolean.True;
((LineSeriesView)series1.View).LineMarkerOptions.Kind = MarkerKind.Circle;
XYDiagram xyDia = chartControl1.Diagram as XYDiagram;
xyDia.AxisX.DateTimeScaleOptions.ScaleMode = ScaleMode.Manual;
xyDia.AxisX.DateTimeScaleOptions.MeasureUnit = DateTimeMeasureUnit.Month;
int max = 0;
max= (int)lst.Max(i => i);
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;
((XYDiagram)(chartControl1.Diagram)).EnableAxisXScrolling = true;//启用横轴滚动条
}
public void GetTimeQualityControlModelStatics()
{
if (string.IsNullOrEmpty(time_starTime.TimeValue))
{
XtraMessageBox.Show("查询起始时间不能为空");
return;
}
if (string.IsNullOrEmpty(time_endTime.TimeValue))
{
XtraMessageBox.Show("查询结束时间不能为空");
return;
}
List<TimeQualityDTO> list = DBHelpClass.GetList<TimeQualityDTO>(string.Format("api/service/T_Service_Trauma_MassiveDataStatistics/GetTimeQualityControlModelStatics?hospitalGuid={0}&startTime={1}&endTime={2}&type={3}", Information.Hospital.GUID, Convert.ToDateTime(time_starTime.TimeValue).ToString("yyyy-MM") + "-01", Convert.ToDateTime(time_endTime.TimeValue).ToString("yyyy-MM") + "-01", 1));
if (list != null)
{
List<TimeQualityDTO> lst = new List<TimeQualityDTO>();
lst = list.Where(a => a.Name == "院前急救转运时间").ToList();
if (lst.Count > 0)
{
lst = lst.OrderBy(i => i.Month).ToList();
CreateTabPanel(lst.Count, lst);
}
}
}
/// <summary>
/// 创建动态表格
/// </summary>
/// <param name="total">数据条数</param>
/// <param name="dt">数据</param>
public void CreateTabPanel(int total, List<TimeQualityDTO> list)
{
panel1.Controls.Clear();
int columnCount = 4; //列数
int rowCount = total;//行数
//if ((total % columnCount) > 0) rowCount++;
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.Absolute, 30));
}
//tab.AutoScroll = true;
tab.Dock = DockStyle.Top;
tab.AutoSize = true;
tab.BackColor = Color.White;
tab.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
for (int i = 0; i < rowCount; i++)//循环行
{
LabelControl lbl1 = new LabelControl();
lbl1.Dock = DockStyle.Fill;
lbl1.AutoSizeMode = LabelAutoSizeMode.None;
lbl1.Appearance.TextOptions.HAlignment = HorzAlignment.Center;
lbl1.ForeColor = Color.FromArgb(81, 90, 110);
lbl1.Appearance.Font = new Font("Tahoma", 11);
lbl1.Text = list[i].Month.Replace("-", "年") + "月";
tab.SetCell(lbl1, i, 0);
LabelControl lbl2 = new LabelControl();
lbl2.Dock = DockStyle.Fill;
lbl2.AutoSizeMode = LabelAutoSizeMode.None;
lbl2.Appearance.TextOptions.HAlignment = HorzAlignment.Center;
lbl2.ForeColor = Color.FromArgb(81, 90, 110);
lbl2.Appearance.Font = new Font("Tahoma", 11);
lbl2.Text = list[i].Max;
tab.SetCell(lbl2, i, 1);
LabelControl lbl3 = new LabelControl();
lbl3.Dock = DockStyle.Fill;
lbl3.AutoSizeMode = LabelAutoSizeMode.None;
lbl3.Appearance.TextOptions.HAlignment = HorzAlignment.Center;
lbl3.ForeColor = Color.FromArgb(81, 90, 110);
lbl3.Appearance.Font = new Font("Tahoma", 11);
lbl3.Text = list[i].Min;
tab.SetCell(lbl3, i, 2);
LabelControl lbl4 = new LabelControl();
lbl4.Dock = DockStyle.Fill;
lbl4.AutoSizeMode = LabelAutoSizeMode.None;
lbl4.Appearance.TextOptions.HAlignment = HorzAlignment.Center;
lbl4.ForeColor = Color.FromArgb(81, 90, 110);
lbl4.Appearance.Font = new Font("Tahoma", 11);
lbl4.Text = list[i].Middle;
tab.SetCell(lbl4, i, 3);
tab.Controls.AddRange(new Control[] { lbl1, lbl2, lbl3, lbl4 });
}
panel1.Controls.Add(tab);
}
private void simpleButton5_Click(object sender, EventArgs e)
{
time_starTime.TimeValue = DateTime.Now.AddMonths(-2).ToString();
time_endTime.TimeValue = DateTime.Now.ToString();
GetHospitalTransferStatisics();
GetTimeQualityControlModelStatics();
}
private void simpleButton1_Click(object sender, EventArgs e)
{
time_starTime.TimeValue = DateTime.Now.AddMonths(-5).ToString();
time_endTime.TimeValue = DateTime.Now.ToString();
GetHospitalTransferStatisics();
GetTimeQualityControlModelStatics();
}
private void simpleButton4_Click(object sender, EventArgs e)
{
time_starTime.TimeValue = DateTime.Now.AddMonths(-11).ToString();
time_endTime.TimeValue = DateTime.Now.ToString();
GetHospitalTransferStatisics();
GetTimeQualityControlModelStatics();
}
}
}