StableVersion4.3/HL_FristAidPlatform_Trauma/Form_ResidenceTimeStatisics.cs

361 lines
15 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_ResidenceTimeStatisics : XtraForm
{
private int curPage = 1;
private int type = 0;
private int pageSize = 20;
private int totalNumber = 0;
public int section;
public TablePanel tab;
public Form_ResidenceTimeStatisics()
{
InitializeComponent();
}
private void Form_ResidenceTimeStatisics_Load(object sender, EventArgs e)
{
time_starTime.TimeValue = DateTime.Now.AddMonths(-5).ToString();
time_endTime.TimeValue = DateTime.Now.ToString();
lbl_typeOne.BackColor = Color.FromArgb(0, 143, 255);
lbl_typeOne.ForeColor = Color.White;
lbl_typeTwo.BackColor = Color.FromArgb(232, 249, 225);
lbl_typeTwo.ForeColor = Color.FromArgb(81, 90, 110);
type = 0;
lbl_sectionOne.BackColor = Color.FromArgb(0, 143, 255);
lbl_sectionOne.ForeColor = Color.White;
lbl_sectionTwo.BackColor = Color.FromArgb(232, 249, 225);
lbl_sectionTwo.ForeColor = Color.FromArgb(81, 90, 110);
section = 0;
ResidenceTimeStatisics();
GetTimeQualityControlModelStatics();
GetResidenceTimeList();
}
private void simpleButton2_Click(object sender, EventArgs e)
{
ResidenceTimeStatisics();
GetTimeQualityControlModelStatics();
GetResidenceTimeList();
}
private void lbl_ct_Click(object sender, EventArgs e)
{
lbl_typeOne.BackColor = Color.FromArgb(0, 143, 255);
lbl_typeOne.ForeColor = Color.White;
lbl_typeTwo.BackColor = Color.FromArgb(232, 249, 225);
lbl_typeTwo.ForeColor = Color.FromArgb(81, 90, 110);
type = 0;
lbl_sectionOne.Text = "门/急诊停留时间≤30min";
lbl_sectionTwo.Text = "门/急诊停留时间>30min";
GetTimeQualityControlModelStatics();
GetResidenceTimeList();
}
private void lbl_chestx_Click(object sender, EventArgs e)
{
lbl_typeTwo.BackColor = Color.FromArgb(0, 143, 255);
lbl_typeTwo.ForeColor = Color.White;
lbl_typeOne.BackColor = Color.FromArgb(232, 249, 225);
lbl_typeOne.ForeColor = Color.FromArgb(81, 90, 110);
type = 1;
lbl_sectionOne.Text = "门/急诊输血准备时间≤30min";
lbl_sectionTwo.Text = "门/急诊输血准备时间>30min";
GetTimeQualityControlModelStatics();
GetResidenceTimeList();
}
public void ResidenceTimeStatisics()
{
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);
Series series2 = new Series("门/急诊输血准备时间)", ViewType.Spline);
ChartTitle chartTitle1 = new ChartTitle();
chartTitle1.Text = "";
chartControl1.Titles.Add(chartTitle1);
List<InspectionStaisicsDTO> model = DBHelpClass.GetList<InspectionStaisicsDTO>(string.Format("api/service/T_Service_Trauma_MassiveDataStatistics/ResidenceTimeStatisics?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 (model != null)
{
for (int j = 0; j < model.Count(); j++)
{
if (model[j].InspectionType == "1")
{
if (model[j].InspectionList.Count > 0)
{
for (int i = 0; i < model[j].InspectionList.Count; i++)
{
series1.Points.Add(new SeriesPoint(model[j].InspectionList[i].TimeDate, model[j].InspectionList[i].Number));
}
}
}
if (model[j].InspectionType == "2")
{
if (model[j].InspectionList.Count > 0)
{
for (int i = 0; i < model[j].InspectionList.Count; i++)
{
series2.Points.Add(new SeriesPoint(model[j].InspectionList[i].TimeDate, model[j].InspectionList[i].Number));
}
}
}
}
}
chartControl1.Series.AddRange(series1, series2);
((LineSeriesView)series1.View).MarkerVisibility = DefaultBoolean.True;
((LineSeriesView)series1.View).LineMarkerOptions.Kind = MarkerKind.Circle;
((LineSeriesView)series2.View).MarkerVisibility = DefaultBoolean.True;
XYDiagram xyDia = chartControl1.Diagram as XYDiagram;
xyDia.AxisX.DateTimeScaleOptions.ScaleMode = ScaleMode.Manual;
xyDia.AxisX.DateTimeScaleOptions.MeasureUnit = DateTimeMeasureUnit.Month;
((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 + "-01").AddMonths(1).ToString("yyyy-MM-dd"), 0));
if (list != null)
{
for (int i = 0; i < list.Count; i++)
{
if (type == 0)
{
if (list[i].Name == "门/急诊停留时间")
{
lbl_max.Text = list[i].Max;
lbl_min.Text = list[i].Min;
lbl_avg.Text = list[i].Avg;
lbl_middle.Text = list[i].Middle;
}
}
if (type == 1)
{
if (list[i].Name == "门/急诊输血准备时间")
{
lbl_max.Text = list[i].Max;
lbl_min.Text = list[i].Min;
lbl_avg.Text = list[i].Avg;
lbl_middle.Text = list[i].Middle;
}
}
}
}
}
public void GetResidenceTimeList()
{
if (string.IsNullOrEmpty(time_starTime.TimeValue))
{
XtraMessageBox.Show("查询起始时间不能为空");
return;
}
if (string.IsNullOrEmpty(time_endTime.TimeValue))
{
XtraMessageBox.Show("查询结束时间不能为空");
return;
}
string Url = string.Format("api/service/T_Service_TraumaPatient/GetResidenceTimeList?hospitalGuid={0}&starTime={1}&endTime={2}&type={3}&section={4}&pageIndex={5}&pageSize={6}", Information.Hospital.GUID, Convert.ToDateTime(time_starTime.TimeValue).ToString("yyyy-MM"), Convert.ToDateTime(time_endTime.TimeValue).ToString("yyyy-MM"), type, section, curPage, pageSize);
DataTable dt = DBHelpClass.Get(Url);
gridControl1.DataSource = dt;
gridView1.Appearance.EvenRow.BackColor = Color.FromArgb(245, 245, 245);
gridView1.Appearance.OddRow.BackColor = Color.FromArgb(255, 255, 255);
gridView1.OptionsView.EnableAppearanceEvenRow = true;
gridView1.OptionsView.EnableAppearanceOddRow = true;
totalNumber = DBHelpClass.TotalNumber;
userControlForPage.RefreshPager(pageSize, totalNumber, curPage);//更新分页控件显示。
}
/// <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.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 lbl_sectionOne_Click(object sender, EventArgs e)
{
lbl_sectionOne.BackColor = Color.FromArgb(0, 143, 255);
lbl_sectionOne.ForeColor = Color.White;
lbl_sectionTwo.BackColor = Color.FromArgb(232, 249, 225);
lbl_sectionTwo.ForeColor = Color.FromArgb(81, 90, 110);
section = 0;
GetResidenceTimeList();
}
private void lbl_sectionTwo_Click(object sender, EventArgs e)
{
lbl_sectionTwo.BackColor = Color.FromArgb(0, 143, 255);
lbl_sectionTwo.ForeColor = Color.White;
lbl_sectionOne.BackColor = Color.FromArgb(232, 249, 225);
lbl_sectionOne.ForeColor = Color.FromArgb(81, 90, 110);
section = 1;
GetResidenceTimeList();
}
private void userControlForPage_myPagerEvents(int curPage, int pageSize)
{
userControlForPage.myPagerEvents += MyPagerEvents;
}
private void MyPagerEvents(int curPage, int pageSize)
{
this.curPage = curPage;
this.pageSize = pageSize;
GetResidenceTimeList();
}
private void simpleButton5_Click(object sender, EventArgs e)
{
time_starTime.TimeValue = DateTime.Now.AddMonths(-2).ToString();
time_endTime.TimeValue = DateTime.Now.ToString();
ResidenceTimeStatisics();
GetTimeQualityControlModelStatics();
GetResidenceTimeList();
}
private void simpleButton1_Click(object sender, EventArgs e)
{
time_starTime.TimeValue = DateTime.Now.AddMonths(-5).ToString();
time_endTime.TimeValue = DateTime.Now.ToString();
ResidenceTimeStatisics();
GetTimeQualityControlModelStatics();
GetResidenceTimeList();
}
private void simpleButton4_Click(object sender, EventArgs e)
{
time_starTime.TimeValue = DateTime.Now.AddMonths(-11).ToString();
time_endTime.TimeValue = DateTime.Now.ToString();
ResidenceTimeStatisics();
GetTimeQualityControlModelStatics();
GetResidenceTimeList();
}
private void gridView1_CustomColumnDisplayText_1(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
{
if (e.Column.FieldName == "Gender")
{
int value = PublicClass.ToInt32(e.Value, -1);
switch (value)
{
case 0:
e.DisplayText = "未知";
break;
case 1:
e.DisplayText = "男";
break;
case 2:
e.DisplayText = "女";
break;
default:
e.DisplayText = "";
break;
}
}
}
}
}