StableVersion4.3/HL_FristAidPlatform_Public/Form/Form_PublisAddPatient.cs

354 lines
16 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using DevExpress.XtraEditors;
using Microsoft.AspNetCore.SignalR.Client;
using System;
using System.Configuration;
using System.Data;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HL_FristAidPlatform_Public
{
public partial class Form_PublisAddPatient : XtraForm
{
public long SystemModuleID;
public string PatientGuid;
public Form_AddPatient_Apoplexy apoplexy;
public Form_AddPatient_ChestP chestPain;
public Form_AddPatient_Trauma trauma;
public Form_PreTriage preTriage;
public Form_AddPatient_CriticalPregnant CriticalPregnant;
public int flag;
public Microsoft.AspNetCore.SignalR.Client.HubConnection connection;
public Form_PublisAddPatient(long systemModel, string patientGuid)
{
InitializeComponent();
SystemModuleID = systemModel;
PatientGuid = patientGuid;
}
private void Form_PublisAddPatient_Load(object sender, EventArgs e)
{
BindSystemModule();
MdiChildrenClose();
if (SystemModuleID > 0)
{
listBox_SystemModule.SelectedValue = SystemModuleID;
}
listBox_SystemModule.SelectedValue = Information.SystemModuleInfo.ID;
if (listBox_SystemModule.SelectedValue.ToString() == PublicClassForDataBase.Config10001)
{
MdiChildrenClose();
panelContent.Controls.Clear();
chestPain = new Form_AddPatient_ChestP(PatientGuid);
chestPain.WindowState = FormWindowState.Maximized;
chestPain.MdiParent = this;
chestPain.TopLevel = false;// 将子窗体设置为非顶级控件
chestPain.FormBorderStyle = FormBorderStyle.None;//设置无边框
chestPain.Dock = DockStyle.Fill; //容器大小随着调整窗体大小自动变化
chestPain.Show();
panelContent.Controls.Add(chestPain);
flag = 2;
}
if (listBox_SystemModule.SelectedValue.ToString() == PublicClassForDataBase.Config10002)
{
MdiChildrenClose();
panelContent.Controls.Clear();
if (!ShowChildrenForm("Form_AddPatient_Apoplexy"))
{
apoplexy = new Form_AddPatient_Apoplexy(PatientGuid);
apoplexy.WindowState = FormWindowState.Maximized;
apoplexy.MdiParent = this;
apoplexy.TopLevel = false;// 将子窗体设置为非顶级控件
apoplexy.FormBorderStyle = FormBorderStyle.None;//设置无边框
apoplexy.Dock = DockStyle.Fill; //容器大小随着调整窗体大小自动变化
apoplexy.Show();
panelContent.Controls.Add(apoplexy);
flag = 3;
}
}
if (listBox_SystemModule.SelectedValue.ToString() == PublicClassForDataBase.Config10003)
{
MdiChildrenClose();
panelContent.Controls.Clear();
if (!ShowChildrenForm("Form_AddPatient_Trauma"))
{
trauma = new Form_AddPatient_Trauma(PatientGuid);
trauma.WindowState = FormWindowState.Maximized;
trauma.MdiParent = this;
trauma.TopLevel = false;// 将子窗体设置为非顶级控件
trauma.FormBorderStyle = FormBorderStyle.None;//设置无边框
trauma.Dock = DockStyle.Fill; //容器大小随着调整窗体大小自动变化
trauma.Show();
panelContent.Controls.Add(trauma);
flag = 4;
}
}
//急诊分诊
if (SystemModuleID.ToString() == PublicClassForDataBase.Config10007)
{
MdiChildrenClose();
panelContent.Controls.Clear();
if (!ShowChildrenForm("Form_PreTriage"))
{
preTriage = new Form_PreTriage();
preTriage.WindowState = FormWindowState.Maximized;
preTriage.MdiParent = this;
preTriage.TopLevel = false;// 将子窗体设置为非顶级控件
preTriage.FormBorderStyle = FormBorderStyle.None;//设置无边框
preTriage.Dock = DockStyle.Fill; //容器大小随着调整窗体大小自动变化
preTriage.Show();
panelContent.Controls.Add(preTriage);
flag = 5;
}
}//高危孕产妇
if (SystemModuleID.ToString() == PublicClassForDataBase.Config10004)
{
MdiChildrenClose();
panelContent.Controls.Clear();
if (!ShowChildrenForm("Form_AddPatient_CriticalPregnant"))
{
CriticalPregnant = new Form_AddPatient_CriticalPregnant();
CriticalPregnant.WindowState = FormWindowState.Maximized;
CriticalPregnant.MdiParent = this;
CriticalPregnant.TopLevel = false;// 将子窗体设置为非顶级控件
CriticalPregnant.FormBorderStyle = FormBorderStyle.None;//设置无边框
CriticalPregnant.Dock = DockStyle.Fill; //容器大小随着调整窗体大小自动变化
CriticalPregnant.Show();
panelContent.Controls.Add(CriticalPregnant);
flag = 6;
}
}
SystemModuleID = int.Parse(listBox_SystemModule.SelectedValue.ToString());
}
public async void SignalRConnection()
{
connection = new HubConnectionBuilder().WithUrl(ConfigurationManager.AppSettings["WebApiUrl"] + "signalr/chatHub")
.Build();
await connection.StartAsync();
connection.Closed += async (error) =>
{
await Task.Delay(new Random().Next(0, 5) * 1000);
await connection.StartAsync();
};
}
/// <summary>
/// 绑定所属系统模块
/// </summary>
private void BindSystemModule()
{
try
{
string Url = string.Format("/api/admin/T_SYS_SystemModule/GetRightListByHospitalID?hospitalID={0}&isHaveTimeAxis=0", Information.Hospital.ID);
DataTable ResultDT = DBHelpClass.Get(Url);
if (ResultDT != null && ResultDT.Rows.Count > 0)
{
DataTable BindData = new DataTable();
BindData.Columns.Add("ID", Type.GetType("System.String"));
BindData.Columns.Add("SystemName", Type.GetType("System.String"));
BindData.Columns.Add("IconData", Type.GetType("System.Byte[]"));
foreach (DataRow item in ResultDT.Rows)
{
DataRow newRow = BindData.NewRow();
newRow["ID"] = item["ID"];
newRow["SystemName"] = item["ShortName"] + "患者";
if (!string.IsNullOrEmpty(PublicClass.ToString(item["IconData"], "")))
{
newRow["IconData"] = Convert.FromBase64String(item["IconData"].ToString());
}
else
{
newRow["IconData"] = null;
}
BindData.Rows.Add(newRow);
}
listBox_SystemModule.DataSource = BindData;
listBox_SystemModule.ValueMember = "ID";
listBox_SystemModule.DisplayMember = "SystemName";
}
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "绑定所属系统模块:\r\n" + ex);
}
}
private void listBox_SystemModule_Click(object sender, EventArgs e)
{
SystemModuleID = PublicClass.ToInt64(listBox_SystemModule.SelectedValue, 0);
if (SystemModuleID > 0)
{
//胸痛中心
if (SystemModuleID.ToString() == PublicClassForDataBase.Config10001)//chestPain
{
MdiChildrenClose();
panelContent.Controls.Clear();
if (!ShowChildrenForm("Form_AddPatient_ChestP"))
{
chestPain = new Form_AddPatient_ChestP(PatientGuid);
chestPain.WindowState = FormWindowState.Maximized;
chestPain.MdiParent = this;
chestPain.TopLevel = false;// 将子窗体设置为非顶级控件
chestPain.FormBorderStyle = FormBorderStyle.None;//设置无边框
chestPain.Dock = DockStyle.Fill; //容器大小随着调整窗体大小自动变化
chestPain.Show();
panelContent.Controls.Add(chestPain);
flag = 2;
}
}
//卒中中心
else if (SystemModuleID.ToString() == PublicClassForDataBase.Config10002)
{
MdiChildrenClose();
panelContent.Controls.Clear();
if (!ShowChildrenForm("Form_AddPatient_Apoplexy"))
{
apoplexy = new Form_AddPatient_Apoplexy(PatientGuid);
apoplexy.WindowState = FormWindowState.Maximized;
apoplexy.MdiParent = this;
apoplexy.TopLevel = false;// 将子窗体设置为非顶级控件
apoplexy.FormBorderStyle = FormBorderStyle.None;//设置无边框
apoplexy.Dock = DockStyle.Fill; //容器大小随着调整窗体大小自动变化
apoplexy.Show();
panelContent.Controls.Add(apoplexy);
flag = 3;
}
}
//创伤中心
else if (SystemModuleID.ToString() == PublicClassForDataBase.Config10003)
{
MdiChildrenClose();
panelContent.Controls.Clear();
if (!ShowChildrenForm("Form_AddPatient_Trauma"))
{
trauma = new Form_AddPatient_Trauma(PatientGuid);
trauma.WindowState = FormWindowState.Maximized;
trauma.MdiParent = this;
trauma.TopLevel = false;// 将子窗体设置为非顶级控件
trauma.FormBorderStyle = FormBorderStyle.None;//设置无边框
trauma.Dock = DockStyle.Fill; //容器大小随着调整窗体大小自动变化
trauma.Show();
panelContent.Controls.Add(trauma);
flag = 4;
}
}
//急诊分诊
else if (SystemModuleID.ToString() == PublicClassForDataBase.Config10020)
{
MdiChildrenClose();
panelContent.Controls.Clear();
if (!ShowChildrenForm("Form_PreTriage"))
{
preTriage = new Form_PreTriage();
preTriage.WindowState = FormWindowState.Maximized;
preTriage.MdiParent = this;
preTriage.TopLevel = false;// 将子窗体设置为非顶级控件
preTriage.FormBorderStyle = FormBorderStyle.None;//设置无边框
preTriage.Dock = DockStyle.Fill; //容器大小随着调整窗体大小自动变化
preTriage.Show();
panelContent.Controls.Add(preTriage);
flag = 5;
}
}
//高危孕产妇
else if (SystemModuleID.ToString() == PublicClassForDataBase.Config10004)
{
MdiChildrenClose();
panelContent.Controls.Clear();
if (!ShowChildrenForm("Form_AddPatient_CriticalPregnant"))
{
CriticalPregnant = new Form_AddPatient_CriticalPregnant();
CriticalPregnant.WindowState = FormWindowState.Maximized;
CriticalPregnant.MdiParent = this;
CriticalPregnant.TopLevel = false;// 将子窗体设置为非顶级控件
CriticalPregnant.FormBorderStyle = FormBorderStyle.None;//设置无边框
CriticalPregnant.Dock = DockStyle.Fill; //容器大小随着调整窗体大小自动变化
CriticalPregnant.Show();
panelContent.Controls.Add(CriticalPregnant);
flag = 6;
}
}
}
}
private bool ShowChildrenForm(string p_ChildrenFormText)
{
int i;
//依次检测当前窗体的子窗体
for (i = 0; i < MdiChildren.Length; i++)
{
//判断当前子窗体的Text属性值是否与传入的字符串值相同
if (MdiChildren[i].Name == p_ChildrenFormText)
{
//如果值相同则表示此子窗体为想要调用的子窗体激活此子窗体并返回true值
MdiChildren[i].Activate();
return true;
}
}
//如果没有相同的值则表示要调用的子窗体还没有被打开返回false值
return false;
}
public void MdiChildrenClose()
{
//关闭所有已经打开的子窗体
if (MdiChildren.Length > 0)
{
foreach (Form myForm in this.MdiChildren)
{
myForm.Close();
}
}
}
public void ColseThis()
{
this.Close();
}
private void simpleButton2_Click(object sender, EventArgs e)
{
if (SystemModuleID == 0 || SystemModuleID == long.Parse(PublicClassForDataBase.Config10001))
{
if (chestPain.Save())
{
XtraMessageBox.Show("保存成功");
this.Close();
}
}
if (SystemModuleID == long.Parse(PublicClassForDataBase.Config10002))
{
if (apoplexy.Save())
{
XtraMessageBox.Show("保存成功");
this.Close();
}
}
if (SystemModuleID == long.Parse(PublicClassForDataBase.Config10003))
{
if (trauma.Save())
this.Close();
}
if (SystemModuleID == long.Parse(PublicClassForDataBase.Config10020))
{
if (preTriage.Save())
{
this.Close();
}
}
if (SystemModuleID == long.Parse(PublicClassForDataBase.Config10004))
{
if (CriticalPregnant.Save())
{
this.Close();
}
}
}
}
}