using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using HL_FristAidPlatform_ChestPain.Properties;
using HL_FristAidPlatform_DTO;
using HL_FristAidPlatform_MultiSystemPublic;
using HL_FristAidPlatform_Public;
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
namespace HL_FristAidPlatform_ChestPain
{
///
/// 时间轴
///
public partial class Form_ChestPain_TimeAxis : XtraForm
{
#region 变量
///
/// 当前病人编号
///
public string Cur_PatientGuid;
///
/// 当前病人所属院区编号(GUID)
///
private string Cur_HospitalGuid;
///
/// 当前病人时间节点记录源
///
private DataTable Cur_PatientTimeAxisDT = new DataTable();
///
/// 胸痛患者急救综合界面
///
private Form_ChestPain_PatientMain From_Main = null;
///
/// 总行数
///
private int TotalLines = 0;
///
/// 每行节点总个数
///
private int TotalPerRow = 14;
///
/// 最后行总个数
///
private int LastRowTotal = 0;
///
/// 每列X轴递增间隔
///
private int IncrementalInterval_X = 80;
///
/// 每行Y轴递增间隔
///
private int IncrementalInterval_Y = 190;
///
/// 图标起始点X坐标
///
private int LocationX_Start = 80;
///
/// 图标起始点Y坐标
///
private int LocationY_Start = 60;
#endregion
///
/// 抢救时间轴
///
/// 院区编号(GUID)
/// 病人编号(GUID)
public Form_ChestPain_TimeAxis(Form_ChestPain_PatientMain form, string _hospitalGuid = "", string _patientGuid = "")
{
InitializeComponent();
Cur_PatientGuid = _patientGuid;
Cur_HospitalGuid = _hospitalGuid;
From_Main = form;
}
#region 事件
///
/// 窗体加载
///
///
///
private void Form_ChestPain_TimeAxis_Load(object sender, EventArgs e)
{
BindData();
}
///
/// 绑定数据
///
private void BindData()
{
try
{
string Url = string.Format("api/service/T_Service_ChestPain_PatientsTimeAxis/GetPatientDetailTime?patientGuid={0}&isDisplayTimeAxis=0", Cur_PatientGuid);
Cur_PatientTimeAxisDT = DBHelpClass.GetJsonText(Url);
if (Cur_PatientTimeAxisDT.Rows.Count > 0)
{
Cur_PatientTimeAxisDT = PublicClass.RestartSorting(Cur_PatientTimeAxisDT, "OrderBy");
//每行总个数
TotalPerRow = PublicClass.ToInt32(Cur_PatientTimeAxisDT.Rows[0]["TotalPerRow"], 14);
//每列X轴递增间隔
IncrementalInterval_X = PublicClass.ToInt32(Cur_PatientTimeAxisDT.Rows[0]["IncrementalInterval_X"], 80);
//每行Y轴递增间隔
IncrementalInterval_Y = PublicClass.ToInt32(Cur_PatientTimeAxisDT.Rows[0]["IncrementalInterval_Y"], 190);
//图标起始点X坐标
LocationX_Start = PublicClass.ToInt32(Cur_PatientTimeAxisDT.Rows[0]["LocationX_Start"], 80);
//图标起始点Y坐标
LocationY_Start = PublicClass.ToInt32(Cur_PatientTimeAxisDT.Rows[0]["LocationY_Start"], 60);
//总行数
TotalLines = (Cur_PatientTimeAxisDT.Rows.Count / TotalPerRow);
//最后行总个数
LastRowTotal = Cur_PatientTimeAxisDT.Rows.Count % TotalPerRow;
if (LastRowTotal > 0) //除不尽时增加一行
{
TotalLines += 1;
}
//绕行方式
string IsGreenChannel = PublicClass.ToString(Cur_PatientTimeAxisDT.Rows[0]["IsGreenChannel"], "");
string IsGreenChannelStr = "未绕行";
switch (IsGreenChannel)
{
case "1":
IsGreenChannelStr = "未绕行";
break;
case "2":
IsGreenChannelStr = "单绕";
break;
case "3":
IsGreenChannelStr = "双绕";
break;
case "4":
IsGreenChannelStr = "三绕";
break;
default:
break;
}
//开启新线程
this.Invoke(new ThreadStart(() => DrawLine(Cur_PatientTimeAxisDT, overwritePanel_Info)));
this.Invoke(new ThreadStart(() => DrawNode(Cur_PatientTimeAxisDT)));
//获取患者类型
string HospitalMode = PublicClass.ToString(Cur_PatientTimeAxisDT.Rows[0]["HospitalMode"], "");
Url = string.Format("api/base/T_Base_HospitalMode/GetListBySystemModuleIDAndValue?systemModuleID={0}&value={1}", PublicClassForDataBase.Config10001, HospitalMode);
DataTable HospitalModeDT = DBHelpClass.Get(Url);
if (HospitalModeDT.Rows.Count > 0)
{
lbl_Title.Text = string.Format("胸痛患者救治时间轴【{0}-{1}】", PublicClass.ToString(HospitalModeDT.Rows[0]["Content"], ""), IsGreenChannelStr);
}
}
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "绑定数据:\r\n" + ex);
}
}
///
/// 窗体关闭
///
///
///
private void Form_TimeAxis_FormClosed(object sender, FormClosedEventArgs e)
{
this.Dispose();
}
///
/// 刷新时间轴
///
///
///
private void link_Refurbish_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
//groupControl_1.Controls.Clear();
overwritePanel_Info.Controls.Clear();
Form_ChestPain_TimeAxis_Load(sender, e);
}
#endregion
#region 详细时间节点
///
/// 详细节点绘制--点
///
/// 节点源
private void DrawNode(DataTable _patientTimeAxisDT)
{
//急救跟踪
DetailTime(_patientTimeAxisDT, PublicClassForDataBase.Config64, overwritePanel_Info);
}
///
/// 图标 先绘制
///
/// 数据源
/// 所属父级节点编号
private void DetailTime(DataTable _patientTimeAxisDT, string _timeParentID, Control _groupControl)
{
try
{
#region 急救跟踪绘制
int xName = 0;//节点名称X轴坐标对比变量 相对节点坐标而言
int xTime = 0;//实际时间X轴坐标对比变量 相对节点坐标而言
int yName = 0;//节点名称Y轴坐标对比变量 相对节点坐标而言
int yTime = 0;//实际时间Y轴坐标对比变量 相对节点坐标而言
int xAdd = 0;//参考时长、实际时长X轴坐标
int LineAdd_Y = 26;//每行文字的间隔 1:时间 2:时间节点名称 3:参考时长 4:实际时长
if (_patientTimeAxisDT != null && _patientTimeAxisDT.Rows.Count > 0)
{
if (TotalLines >= 1)
{
for (int line = 1; line <= TotalLines; line++)
{
#region 参考时长和实际时长 标题
//参考时长Label显示
LabelControl referenceTimeLabelText = new LabelControl
{
Name = "referenceTimeLabelText" + line,
Text = "参考时长",
Location = new Point(10, (IncrementalInterval_Y * (line - 1)) + 3 * LineAdd_Y + LocationY_Start),
Size = new Size(100, 30),
Visible = true,
};
_groupControl.Controls.Add(referenceTimeLabelText);
//实际时长Label显示
LabelControl actualTimeLabelText = new LabelControl
{
Name = "actualTimeLabelText" + line,
Text = "实际时长",
Location = new Point(10, (IncrementalInterval_Y * (line - 1)) + 4 * LineAdd_Y + LocationY_Start),
Size = new Size(100, 30),
Visible = true,
};
_groupControl.Controls.Add(actualTimeLabelText);
#endregion
}
//循环动态画时间轴
for (int i = 0; i < _patientTimeAxisDT.Rows.Count; i++)
{
int ColorFlag = 0;//颜色标记: 0:黑色(正常) 1:橙色 2:红色
int Interval = PublicClass.ToInt32(_patientTimeAxisDT.Rows[i]["Interval"], 0);//时间控制要求指标-间隔(T_Base_TimeAxis)
int Form_Flag = PublicClass.ToInt32(_patientTimeAxisDT.Rows[i]["Form_Flag"], 0);//所属界面标记,参考枚举类型Enumerate.ChestPainTimeAxis_Form和Enumerate.ApoplexyTimeAxis_Form(T_Base_TimeAxis)
bool ContrastTimeIsDefault = false;//当前节点参考时间是否为默认时间(表示上一个时间节点未填写),如果是则直接显示错误
string ID = PublicClass.ToString(_patientTimeAxisDT.Rows[i]["ID"], "");//编号(T_Base_TimeAxis的ID)
string TimeName = PublicClass.ToString(_patientTimeAxisDT.Rows[i]["TimeName"], "");//时间节点名称(T_Base_TimeAxis)
bool IsCalculateActualLength = true;//是否计算实际时长
string ActualLength = "";//实际时长
string ActualLengthError = "";//错误时提示
string ContrastTimeAxisID = PublicClass.ToString(_patientTimeAxisDT.Rows[i]["ContrastTimeAxisID"], "");//参考时间节点编号(T_Base_TimeAxis)
string RecordingTime = PublicClass.ToString(_patientTimeAxisDT.Rows[i]["RecordingTime"], "");//实际发生时间(T_Service_ChestPain_PatientsTimeAxis)
int cur_line = i / TotalPerRow;//所在行 +1
int cur_column = i % TotalPerRow;//所在列
int LocationX = 0;//当前单个节点X轴坐标
int LocationY = 0;//当前单个节点Y轴坐标
//奇数行 1、3、5
if (cur_line % 2 != 0)
{
//X轴坐标 原坐标+递减
LocationX = (TotalPerRow - cur_column) * IncrementalInterval_X;
//Y轴坐标 原坐标+递减
LocationY = LocationY_Start + (cur_line * IncrementalInterval_Y);
}
//偶数线 0、2、4
else
{
//X轴坐标 原坐标+递增列
LocationX = LocationX_Start + (cur_column * IncrementalInterval_X);
//Y轴坐标 原坐标+递增行
LocationY = LocationY_Start + (cur_line * IncrementalInterval_Y);
}
TimeSpan TimeSpan = new TimeSpan();
//参考间隔不为0 取参考节点值
if (Interval > 0 && !string.IsNullOrEmpty(RecordingTime))
{
DataTable Cur_FirstAIDInfoDT = DBHelpClass.Get(string.Format("api/service/T_Service_ChestPain_FirstAIDInfo/GetByPatientGuid?patientGuid={0}", Cur_PatientGuid));
string CW_Coming_Way_Code = PublicClass.ToString(Cur_FirstAIDInfoDT.Rows[0]["CW_Coming_Way_Code"], "");
DataRow[] dataRowsContrast = null;
if (CW_Coming_Way_Code == "2" && TimeName == "首份心电图时间")
{
//转院患者的首次医疗接触时间为转出医院的首次医疗接触时间
dataRowsContrast = _patientTimeAxisDT.Select("ID='84'");
}
else
{
dataRowsContrast = _patientTimeAxisDT.Select("ID='" + ContrastTimeAxisID + "'");
}
if (dataRowsContrast.Length > 0)
{
DateTime ContrastTime = PublicClass.ToDateTime(dataRowsContrast[0]["RecordingTime"], PublicClass.DefaultTime);
TimeSpan = PublicClass.DiffMinutes(ContrastTime, PublicClass.ToDateTime(RecordingTime, PublicClass.DefaultTime));
if (ContrastTime == PublicClass.DefaultTime)
{
IsCalculateActualLength = true;
ContrastTimeIsDefault = true;
}
}
}
//参考间隔为0 取上一个节点的值
else
{
#region 没有参考值时不计算实际时长
//if (i > 0)
//{
// DateTime ContrastTime = PublicClass.ToDateTime(_patientTimeAxisDT.Rows[i - 1]["RecordingTime"], PublicClass.DefaultTime);
// //上个节点有填写 才对比
// if (ContrastTime != PublicClass.DefaultTime)
// {
// TimeSpan = PublicClass.DiffMinutes(ContrastTime, PublicClass.ToDateTime(RecordingTime, PublicClass.DefaultTime));
// }
// if (ContrastTime == PublicClass.DefaultTime)
// {
// ContrastTimeIsDefault = true;
// ActualLengthError = "--";
// }
//}
#endregion
IsCalculateActualLength = true;
ContrastTimeIsDefault = true;
}
if (Interval > 0)
{
if (!string.IsNullOrEmpty(RecordingTime))
{
DateTime date = Convert.ToDateTime(RecordingTime).AddMinutes(Interval);
UpdateNormalTime(date, Convert.ToDateTime(RecordingTime), int.Parse(ID));//更新参考时间
}
}
//显示图标
ColorFlag = ShowImage(Interval, TimeSpan, i, ID, LocationX, LocationY, RecordingTime, Form_Flag, _groupControl, IsCalculateActualLength, out ActualLength);
#region 颜色
Color color = Color.Black;
if (ColorFlag == 1)
{
color = Color.LightSalmon;
}
else if (ColorFlag == 2)
{
color = Color.Red;
}
#endregion
//实际发生时间不为空时格式化
if (!string.IsNullOrEmpty(RecordingTime))
{
RecordingTime = Convert.ToDateTime(RecordingTime).ToString("MM月dd日 HH:mm");
}
#region 坐标
xName = Convert.ToInt32(TimeName.Length * 3.5);//每个字符12个像素 汉字
xTime = Convert.ToInt32(RecordingTime.Length * 2);//每个字符6个像素 数字
//Y轴 奇数偶数判断 等于0为偶数,放图标底下
if (i % 2 == 0)
{
yName = 35;
yTime = 55;
}
else
{
yName = -30;
yTime = -15;
}
#endregion
//1:显示节点时间
LabelControl labelTime = new LabelControl
{
Name = "labelTime" + i.ToString(),
Text = RecordingTime,
Location = new Point(LocationX - xTime, LocationY + yTime),
Size = new Size(20, 30),
ForeColor = color,
Visible = true
};
_groupControl.Controls.Add(labelTime);
//2:显示节点名称
LabelControl labelName = new LabelControl
{
Name = "labelName" + i.ToString(),
Text = TimeName,
Location = new Point(LocationX - xName, LocationY + yName),
Size = new Size(20, 30),
Visible = true
};
_groupControl.Controls.Add(labelName);
#region 参考时长
//3:参考时长Label显示
LabelControl referenceTimeLabel = new LabelControl
{
Name = "referenceTimeLabel" + i.ToString(),
Text = Interval != 0 ? Interval + "min" : "",
Location = new Point(LocationX + xAdd, LocationY + 3 * LineAdd_Y),
Size = new Size(100, 30),
ForeColor = Color.Green,
Visible = true
};
_groupControl.Controls.Add(referenceTimeLabel);
//如果参考时间为默认时间,直接为红色
if (ContrastTimeIsDefault)
{
ActualLength = ActualLengthError;
color = Color.Red;
}
//4:实际时长Label显示
LabelControl actualTimeLabel = new LabelControl
{
Name = "actualTimeLabel" + i.ToString(),
Text = ActualLength != "0min" ? ActualLength : "",
Location = new Point(LocationX + xAdd, LocationY + 4 * LineAdd_Y),
Size = new Size(100, 30),
ForeColor = color,
Visible = true,
};
_groupControl.Controls.Add(actualTimeLabel);
#endregion
}
}
}
#endregion
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "急救跟踪绘制:\r\n" + ex);
}
}
///
/// 显示图标
///
/// 参考间隔
/// 两个节点间实际间隔
/// 第几个:用于图标控件名称,确保唯一性
/// 节点编号
/// X轴坐标
/// Y轴坐标
/// 发生的时间:控制是否显示灰色图标
/// 维护界面(跳转界面)
/// 所属绘制控件
/// 是否计算实际时长
/// 实际时长
/// 返回的颜色标记: 0:黑色(正常) 1:橙色 2:红色
public int ShowImage(int interval, TimeSpan timeSpan, int number, string timeAxisID, int x, int y, string recordingTime, int form_Flag, Control overwritePanel, bool isCalculateActualLength, out string actualLength)
{
//图标的Tag值,传递:时间节点编号+记录时间+维护界面标记 #分割
string TagStr = timeAxisID + "#" + recordingTime + "#" + form_Flag;
//返回的颜色标记: 0:黑色(正常) 1:橙色 2:红色
int ColorFlag = 0;
//赋予默认值
actualLength = "";
//未录入:灰色
if (PublicClass.ToDateTime(recordingTime, PublicClass.DefaultTime) == PublicClass.DefaultTime)
{
SimpleButton simpleButton = new SimpleButton
{
Name = "Timebutton" + number,
ButtonStyle = BorderStyles.NoBorder,
BackgroundImage = Resources.未填28,
BackgroundImageLayout = ImageLayout.Center,
Location = new Point(x, y),
Tag = TagStr,
Size = new Size(28, 28)
};
//simpleButton.Click += SimpleButton_Click;
simpleButton.MouseDown += SimpleButton_MouseDown;
overwritePanel.Controls.Add(simpleButton);
simpleButton.BringToFront();//置顶
}
//录入--异常:红色;正常:绿色
else
{
if (isCalculateActualLength)
{
//计算已经耗时
actualLength = Convert.ToInt32(timeSpan.TotalMinutes).ToString() + "min";
}
//【没有设置间隔参考】或者
if (interval == 0)
{
//间隔时间超过系统参数设置的参考间隔
int TotalMinutes = PublicClass.ToInt32(PublicClassForDataBase.Config112, 0);
if (TotalMinutes > 0)
{
if (Convert.ToInt32(timeSpan.TotalMinutes) > PublicClass.ToInt32(PublicClassForDataBase.Config112, 0))
{
SimpleButton simpleButton = new SimpleButton
{
Name = "Timebutton" + number,
ButtonStyle = BorderStyles.NoBorder,
BackgroundImage = Resources.错误28,
BackgroundImageLayout = ImageLayout.Center,
Location = new Point(x, y),
Tag = TagStr,
Size = new Size(28, 28)
};
//simpleButton.Click += SimpleButton_Click;
simpleButton.MouseDown += SimpleButton_MouseDown;
overwritePanel.Controls.Add(simpleButton);
simpleButton.BringToFront();//置顶
ColorFlag = 2;
actualLength = "警告";
}
else
{
SimpleButton simpleButton = new SimpleButton
{
Name = "Timebutton" + number,
ButtonStyle = BorderStyles.NoBorder,
BackgroundImage = Resources.正常28,
BackgroundImageLayout = ImageLayout.Center,
Location = new Point(x, y),
Tag = TagStr,
Size = new Size(28, 28)
};
//simpleButton.Click += SimpleButton_Click;
simpleButton.MouseDown += SimpleButton_MouseDown;
overwritePanel.Controls.Add(simpleButton);
simpleButton.BringToFront();//置顶
}
}
else
{
SimpleButton simpleButton = new SimpleButton
{
Name = "Timebutton" + number,
ButtonStyle = BorderStyles.NoBorder,
BackgroundImage = Resources.正常28,
BackgroundImageLayout = ImageLayout.Center,
Location = new Point(x, y),
Tag = TagStr,
Size = new Size(28, 28)
};
//simpleButton.Click += SimpleButton_Click;
simpleButton.MouseDown += SimpleButton_MouseDown;
overwritePanel.Controls.Add(simpleButton);
simpleButton.BringToFront();//置顶
}
}
//【有设置时间间隔】
else
{
//对比时间不早于参考时间
if (timeSpan.TotalMinutes > 0)
{
//【参考间隔>=实际间隔】
if (interval >= Convert.ToInt32(timeSpan.TotalMinutes))
{
SimpleButton simpleButton = new SimpleButton
{
Name = "Timebutton" + number,
ButtonStyle = BorderStyles.NoBorder,
BackgroundImage = Resources.正常28,
BackgroundImageLayout = ImageLayout.Center,
Location = new Point(x, y),
Tag = TagStr,
Size = new Size(28, 28)
};
//simpleButton.Click += SimpleButton_Click;
simpleButton.MouseDown += SimpleButton_MouseDown;
overwritePanel.Controls.Add(simpleButton);
simpleButton.BringToFront();//置顶
}
//【参考间隔<实际间隔】
else if (interval < Convert.ToInt32(timeSpan.TotalMinutes))
{
SimpleButton simpleButton = new SimpleButton
{
Name = "Timebutton" + number,
ButtonStyle = BorderStyles.NoBorder,
BackgroundImage = Resources.错误28,
BackgroundImageLayout = ImageLayout.Center,
Location = new Point(x, y),
Tag = TagStr,
Size = new Size(28, 28)
};
//simpleButton.Click += SimpleButton_Click;
simpleButton.MouseDown += SimpleButton_MouseDown;
overwritePanel.Controls.Add(simpleButton);
simpleButton.BringToFront();//置顶
ColorFlag = 2;
}
}
//对比时间早于参考时间
else
{
SimpleButton simpleButton = new SimpleButton
{
Name = "Timebutton" + number,
ButtonStyle = BorderStyles.NoBorder,
BackgroundImage = Resources.错误28,
BackgroundImageLayout = ImageLayout.Center,
Location = new Point(x, y),
Tag = TagStr,
Size = new Size(28, 28)
};
//simpleButton.Click += SimpleButton_Click;
simpleButton.MouseDown += SimpleButton_MouseDown;
overwritePanel.Controls.Add(simpleButton);
simpleButton.BringToFront();//置顶
ColorFlag = 2;
}
}
}
return ColorFlag;
}
///
/// 时间轴点击事件
///
///
///
private void SimpleButton_MouseDown(object sender, MouseEventArgs e)
{
//Tag值
string TagStr = PublicClass.ToString(((Control)sender).Tag, "");
//时间节点编号
long ID = 0;
//记录时间
string RecordingTime = "";
//维护界面标记
int Form_Flag = 0;
//Tag值不为空
if (!string.IsNullOrEmpty(TagStr))
{
string[] TagStrArray = TagStr.Split('#');
ID = PublicClass.ToInt64(TagStrArray[0], 0);
RecordingTime = PublicClass.ToString(TagStrArray[1], "");
Form_Flag = PublicClass.ToInt32(TagStrArray[2], 0);
}
//EventArgs继承自MouseEventArgs,所以可以强转
//把EventArgs强制转换成MouseEventArgs就可以判断鼠标左右键了
MouseEventArgs Mouse_e = (MouseEventArgs)e;
//判断点击鼠标左键或右键
if (Mouse_e.Button == MouseButtons.Left)
{
//执行事件
MouseClick_Left(ID, Form_Flag);
}
else if (Mouse_e.Button == MouseButtons.Right)
{
//执行事件
MouseClick_Right(ID, RecordingTime);
}
link_Refurbish_LinkClicked(sender, null);
}
///
/// 鼠标左键单击
///
/// 时间节点编号
/// 维护界面标记
private void MouseClick_Left(long ID, int Form_Flag)
{
try
{
#region 时间轴点击事件
//时间节点编号不为空
if (ID > 0)
{
//维护界面标记不为空
if (Form_Flag > 0)
{
From_Main.ClickMenu(Form_Flag);
}
}
#endregion
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "鼠标左键单击:\r\n" + ex);
}
}
///
/// 鼠标右键单击
///
/// 时间节点编号
/// 记录时间
private void MouseClick_Right(long ID, string RecordingTime)
{
try
{
//弹出的时间公用界面用更改后的时间值
string time = "";
Form_SelectTime form = new Form_SelectTime(RecordingTime);
if (form.ShowDialog() == DialogResult.OK)
{
time = form.time;
}
if (!string.IsNullOrEmpty(time))
{
#region 更新到业务表
List list = new List();
T_Service_ChestPain_PatientsTimeAxisDTO model = new T_Service_ChestPain_PatientsTimeAxisDTO();
string Url = "api/service/T_Service_ChestPain_PatientsTimeAxis/UpdateRecordingTimeByPatientIDAndTimeAxisID";
model.RecordingTime = time;
model.PatientGuid = Cur_PatientGuid;
model.TimeAxisID = ID;
model.NormalTime = PublicClass.DateTimeNow();//赋值但不更新
list.Add(model);
//初始化两个工厂
ClientFactory httpClient = new HttpClientFactory();
Client client = httpClient.VisitFactory();
//访问
ListEntity t = client.Post(Url, list);
if (t.Success)
{
//更改之后重新获取数据源
Url = string.Format("api/service/T_Service_ChestPain_PatientsTimeAxis/GetPatientDetailTime?patientGuid={0}&isDisplayTimeAxis=0", Cur_PatientGuid);
Cur_PatientTimeAxisDT = DBHelpClass.GetJsonText(Url);
PublicClass.RestartSorting(Cur_PatientTimeAxisDT, "OrderBy");
DrawNode(Cur_PatientTimeAxisDT);
}
#endregion
}
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "鼠标右键单击:\r\n" + ex);
}
}
///
/// 绘制线
///
/// 数据源
/// 容器
private void DrawLine(DataTable dataTable, Control control)
{
int xAdd = LocationX_Start + 20;//线 起始点X坐标
int yAdd = LocationY_Start + 17;//线 起始点Y坐标
#region 线
if (dataTable != null && dataTable.Rows.Count > 0)
{
//有多行
if (TotalLines > 1)
{
//从1开始
for (int i = 1; i <= TotalLines; i++)
{
//奇数线
if (i % 2 != 0)
{
#region 横线 从左向右
int Point_X = xAdd;//X轴坐标
int Point_Y = yAdd + IncrementalInterval_Y * (i - 1);//Y轴坐标
//长度 每个间隔*(总个数-1)
int Size_W = IncrementalInterval_X * (TotalPerRow - 1);
if (i == TotalLines)
{
Size_W = IncrementalInterval_X * (LastRowTotal - 1);
}
int Size_H = 1;//高度 横线为1px
Label label = new Label
{
Text = "lbl_line" + i,
Name = "lbl_line" + i,
BorderStyle = BorderStyle.FixedSingle,
Location = new Point(Point_X, Point_Y),
Size = new Size(Size_W, Size_H)
};
control.Controls.Add(label);
label.SendToBack();//置底
#endregion
#region 竖线
//不是最后一行时绘制竖线
if (i != TotalLines)
{
//竖线
int Point_X_Vertical = 13 + IncrementalInterval_X * (TotalPerRow);//X轴坐标
int Point_Y_Vertical = yAdd + IncrementalInterval_Y * (i - 1);//Y轴坐标
int Size_W_Vertical = 1;//长度 横线为1px
int Size_H_Vertical = IncrementalInterval_Y;//高度
Label label_Vertical = new Label
{
Text = "lbl_line" + i,
Name = "lbl_line" + i,
BorderStyle = BorderStyle.FixedSingle,
Location = new Point(Point_X_Vertical, Point_Y_Vertical),
Size = new Size(Size_W_Vertical, Size_H_Vertical)
};
control.Controls.Add(label_Vertical);
label_Vertical.SendToBack();//置底
}
#endregion
}
//偶数线
else
{
#region 横线 从右向左
int Point_X = xAdd;
//是最后一行时绘制竖线
if (i == TotalLines)
{
//X轴坐标 起始坐标+(每行总个数-当前行个数)*每行间隔
Point_X = xAdd + (TotalPerRow - LastRowTotal) * IncrementalInterval_X;
}
//Y轴坐标 起始点Y坐标+间隔*(当前行数-1)
int Point_Y = yAdd + IncrementalInterval_Y * (i - 1);
//长度 每个间隔*(总个数-1)
int Size_W = IncrementalInterval_X * (TotalPerRow - 1);
if (i == TotalLines)
{
Size_W = IncrementalInterval_X * (LastRowTotal - 1);
}
int Size_H = 1;//高度 横线为1px
Label label = new Label
{
Text = "lbl_line" + i,
Name = "lbl_line" + i,
BorderStyle = BorderStyle.FixedSingle,
Location = new Point(Point_X, Point_Y),
Size = new Size(Size_W, Size_H)
};
control.Controls.Add(label);
label.SendToBack();//置底
#endregion
#region 竖线
//不是最后一行时绘制竖线
if (i != TotalLines)
{
//竖线
int Point_X_Vertical = xAdd - 8;//X轴坐标
int Point_Y_Vertical = yAdd + IncrementalInterval_Y * (i - 1);//Y轴坐标
int Size_W_Vertical = 1;//长度 横线为1px
int Size_H_Vertical = IncrementalInterval_Y;//高度
Label label_Vertical = new Label
{
Text = "lbl_line" + i,
Name = "lbl_line" + i,
BorderStyle = BorderStyle.FixedSingle,
Location = new Point(Point_X_Vertical, Point_Y_Vertical),
Size = new Size(Size_W_Vertical, Size_H_Vertical)
};
control.Controls.Add(label_Vertical);
label_Vertical.SendToBack();//置底
}
#endregion
}
}
}
//只有一行
else
{
#region 横线
int Point_X = xAdd;//X轴坐标
int Point_Y = yAdd;//Y轴坐标
int Size_W = xAdd + IncrementalInterval_X * (TotalPerRow - 1);//长度
int Size_H = 1;//高度 横线为1px
Label label = new Label
{
Text = "lbl_line_1",
Name = "lbl_line_1",
BorderStyle = BorderStyle.FixedSingle,
Location = new Point(Point_X, Point_Y),
Size = new Size(Size_W, Size_H)//横线高度为1px
};
control.Controls.Add(label);
label.SendToBack();//置底
#endregion
}
}
#endregion
}
#endregion
#region 方法
///
/// 更新正常时间
///
/// 参考时间
/// 操作记录时间
///
public void UpdateNormalTime(DateTime date, DateTime recordingTime, int timeAxidID)
{
try
{
string timeUrl = "api/service/T_Service_ChestPain_PatientsTimeAxis/UpdateNormalTime";
ClientFactory httpClient = new HttpClientFactory();
Client client = httpClient.VisitFactory();
List listEntity = new List();
T_Service_ChestPain_PatientsTimeAxisDTO timeAxisDTO = new T_Service_ChestPain_PatientsTimeAxisDTO();
timeAxisDTO.PatientGuid = Cur_PatientGuid;
timeAxisDTO.TimeAxisID = timeAxidID;
timeAxisDTO.PatientGuid = Cur_PatientGuid;
timeAxisDTO.NormalTime = date.ToString(PublicClass.TimeToString);
timeAxisDTO.RecordingTime = recordingTime.ToString(PublicClass.TimeToString);
listEntity.Add(timeAxisDTO);
ListEntity t = client.Post(timeUrl, listEntity);
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "更新正常时间:\r\n" + ex);
}
}
#endregion
protected override void CreateHandle()
{
if (!IsHandleCreated)
{
try
{
base.CreateHandle();
}
catch { }
finally
{
if (!IsHandleCreated)
{
base.RecreateHandle();
}
}
}
}
}
}