StableVersion4.3/HL_FristAidPlatform_Apoplexy/Statistics/Form_PerCapitaCost.cs

144 lines
5.3 KiB
C#

using DevExpress.XtraCharts;
using DevExpress.XtraEditors;
using HL_FristAidPlatform_DTO;
using HL_FristAidPlatform_Help;
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_PerCapitaCost : XtraForm
{
public DateTime dt = DateTime.Now;
public Form_PerCapitaCost()
{
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 == 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;
}
}
List<AverageResultModelDTO> lst1 = DBHelpClass.GetList<AverageResultModelDTO>(string.Format("api/service/T_Service_Apoplexy_PerCapitaCost/StatisticalPerCapitaExpenses?hospitalGuid={0}&startTime={1}&endTime={2}&type={3}", Information.Hospital.GUID, startTime, endTime, type));
chartControl1.Series.Clear();
Series series1 = new Series("住院人均费用趋势图", ViewType.Bar);
series1.Points.Clear();
if (lst1 != null && lst1.Count > 0)
{
for (int i = 0; i < lst1.Count; i++)
{
series1.Points.Add(new SeriesPoint(lst1[i].Key,new double[] {Convert.ToDouble(lst1[i].Value) } ));
}
}
//调整柱状图柱体宽度
BarSeriesView bsv = (BarSeriesView)series1.View;
bsv.BarWidth = 0.2;
chartControl1.Series.AddRange(new Series[] { series1 });
XYDiagram xyDia = chartControl1.Diagram as XYDiagram;
xyDia.AxisX.DateTimeScaleOptions.ScaleMode = ScaleMode.Manual;
//设置数据在图表的格式
int max = 0;
for (int i = 0; i < lst1.Count(); i++)
{
if (double.Parse(lst1[i].Value) > max)
max = (int)(double.Parse(lst1[i].Value));
}
int tempone = max / 5;
int temptwo = max % 5;
if (temptwo == 0)
{
max = tempone * 5;
}
else
{
max = (tempone + 1) * 5;
}
if (max == 0)
max = 100;
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 ex)
{
throw ex;
}
}
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();
}
}
}