StableVersion4.3/HL_FristAidPlatform_Frame/Main/Form_Main.cs

1112 lines
42 KiB
C#
Raw 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 HL_FristAidPlatform_DTO;
using HL_FristAidPlatform_PreHospitalEmergency;
using HL_FristAidPlatform_Public;
using HL_FristAidPlatform_SYS;
using Microsoft.AspNetCore.SignalR.Client;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Deployment.Application;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Speech.Synthesis;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HL_FristAidPlatform_Frame
{
public partial class Form_Main : XtraForm
{
public delegate void MyDelegate(string content);
SpeechSynthesizer synthesizer = new SpeechSynthesizer();
public Form_TaskInfo f_task;
//AutoSizeFormClass autoSizeForm = new AutoSizeFormClass();//屏幕分辨率
float x, y;
#region 变量
/// <summary>
/// 当前用户菜单集合
/// </summary>
private DataTable MenuTabe = new DataTable();
/// <summary>
/// 等待窗体
/// </summary>
private Loading loading = new Loading();
//定义一个连接对象
public HubConnection connection;
public DataTable dt;
public bool falg = true;
#endregion
public Form_Main()
{
InitializeComponent();
SignalRConnection();
x = this.Width;
y = this.Height;
this.Resize += Form_Main_Resize;
this.Load += Form_Main_Load;
}
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();
};
}
public void ShowFormTask()
{
Task.Run(() =>
{
while (true)
{
if (falg)
{
string url = string.Format("/api/service/T_Service_FirstAid_AlarmTaskInfo/GetTaskInfo?guid={0}", Information.Hospital.GUID);
dt = DBHelpClass.GetJsonText(url);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
//如果只需要某个表中的某一行
DataTable dtNew = new DataTable();
dtNew = dt.Copy();
dtNew.Rows.Clear();//清空表数据
dtNew.ImportRow(dt.Rows[i]);//这是加入的是第一行
ShowTaskAsync(dtNew);
}
falg = false;
}
}
}
Thread.Sleep(10000);
}
});
}
/// <summary>
/// 窗体加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private async void Form_Main_Load(object sender, EventArgs e)
{
try
{
sevenSegmentClock1.Start();
Form_Message form_Message = new Form_Message(Information.User.ID);
//发送上线信息
await connection.InvokeAsync("OnLine", Information.User.ID.ToString());
// 从中心调用客户端方法 一种订阅,可以从集线器方法中取消订阅
connection.On<object>("ReceiveUpdate", (message) =>
{
Invoke(new Action(() =>
{
string Content = "";
Content = message.ToString();
if (Content.Contains("出警任务"))
{
alertControl.Show(this, "出警任务", Content, Content, null, Information.User.ID);
}
if (Content.Contains("绿色通道"))
{
alertControl.Show(this, "绿色通道", Content, Content, null, Information.User.ID);
}
if (Content.Contains("远程会诊"))
{
Content = Content.Substring(0, Content.LastIndexOf("|"));
alertControl.Show(this, "远程会诊", Content, Content, null, Information.User.ID);
message = Content;
}
synthesizer.Speak(message.ToString());
//SpeechLisen speechLisen = new SpeechLisen();
//speechLisen.Tts(message.ToString());
//DataTable MessageTabe = DBHelpClass.Get(string.Format("api/service/T_Service_Notice/GetListByUserID?userID={0}&readState={1}", Information.User.ID, 0));
//if (MessageTabe != null && MessageTabe.Rows.Count > 0)
//{
// string TypeName = PublicClass.ToString(MessageTabe.Rows[0]["TypeName"], "");
// string Content = PublicClass.ToString(MessageTabe.Rows[0]["Content"], "");
// string ID = PublicClass.ToString(MessageTabe.Rows[0]["ID"], "");
// alertControl.Show(this, TypeName, Content, Content, null, ID);
// speechLisen.Tts(Content);
//}
//form_Message.ShowDialog();
}));
});
//绑定数据源
BindData();
//tsslbl_SystemModule.Text = DateTime.Now.ToString("D") + " " + CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(DateTime.Now.DayOfWeek) + DateTime.Now.ToString("HH:mm:ss");
//弹窗选择模块
Form_SelectSystemModule frm = new Form_SelectSystemModule(Information.User.ID, Information.Hospital.ID, 1);
if (frm.ShowDialog() == DialogResult.OK)
{
if (frm.IsOpenSystemModule)
{
loading.ShowMessage();
Information.SystemModuleInfo.ID = frm.Cur_SelSystemModuleID;
Information.SystemModuleInfo.ModuleName = frm.Cur_SelSystemModuleName;
//更新标题与绑定菜单
BindTitle();
//创建菜单
CreateGroup();
loading.HideMessage();
}
else
{
ReLogin(sender, e);
}
}
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "新消息定时器:\r\n" + ex);
}
GetIndex();
}
private void ShowTaskAsync(DataTable dt)
{
try
{
if (this.InvokeRequired)
{
this.Invoke(new MethodInvoker(delegate { ShowTaskAsync(dt); }));
return;
}
if (f_task == null)
{
f_task = new Form_TaskInfo(dt);
f_task.Owner = this;
//定阅这个事件
//f_task.my += new Form_TaskInfo.Refresh(RefreshMethod);
f_task.Show();
}
else
{
f_task.Activate();
}
}
catch (Exception ex)
{
throw ex;
}
}
public void RefreshMethod()
{
ShowFormTask();
}
private bool SHowOpen(string frmName)
{
foreach (Form frm in Application.OpenForms)
{
if (frm.Name == frmName)
{
frm.Activate();
if (frm.WindowState == FormWindowState.Minimized)
{
frm.WindowState = FormWindowState.Normal;
}
return true;
}
}
return false;
}
public void Form_Resize(object sender, EventArgs e)
{
float newx = Width / FormAutoSize.X;
float newy = Height / FormAutoSize.Y;
FormAutoSize.setControls(newx, newy, this);
}
/// <summary>
/// 绑定公共数据
/// </summary>
private void BindData()
{
try
{
#region 时间
//labelControl_Day.Text = "今天是:" + DateTime.Now.ToString("D") + " " + CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(DateTime.Now.DayOfWeek);
//labelControl_Time.Text = "当前时间:" + DateTime.Now.ToString("HH:mm:ss");
timer_Time.Start();
#endregion
//判断医院LogoImageData是否为空
if (!string.IsNullOrEmpty(Information.Hospital.LogoImageData))
{
MemoryStream ms = new MemoryStream(Convert.FromBase64String(Information.Hospital.LogoImageData));
Image img = Image.FromStream(ms);
Bitmap Cur_BgImageData_Bitmap = new Bitmap(img, pic_Logo.Width, pic_Logo.Height);
pic_Logo.Image = Cur_BgImageData_Bitmap;
}
//为空表示没有上传图片 则默认为系统项目中文件
else
{
pic_Logo.Image = Properties.Resources.hospitallogo;
}
//欢迎语
string WelcomeStr = string.Format("欢迎您:{0}({1}{2})", Information.User.FullName, Information.User.DepartmentsName, Information.User.PositionName);
lbl_Title.Text = string.Format("{0}-{1}", Information.Hospital.Name, Information.SystemInfo.SystemName);
//头像
if (Information.User.Portrait.Length > 0)
{
MemoryStream ms = new MemoryStream(Information.User.Portrait);
Image img = Image.FromStream(ms);
//pictureEdit_Portrait.Image = img;
}
//标题
Text = string.Format("{0}({1})", Information.Hospital.Name, Information.SystemInfo.SystemName);
notifyIcon.Text = Text;
//状态栏
tsslbl_HospitalName.Text = "使用单位:" + Information.Hospital.Name + " 当前用户:" + Information.User.FullName + "(" + Information.User.LoginName + ")";
Version myVersion = null;
if (ApplicationDeployment.IsNetworkDeployed)
myVersion = ApplicationDeployment.CurrentDeployment.CurrentVersion;
//版权
tsslbl_Copyright.Text = Information.SystemInfo.SystemName + "(" + Information.SystemInfo.SystemEdition + ")" + " 版权所有:" + Information.SystemInfo.CompanyName + " 系统版本:" + myVersion;
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "绑定公共数据:\r\n" + ex);
}
}
/// <summary>
/// 更新系统标题
/// </summary>
private void BindTitle()
{
lbl_Title.Text = Information.SystemModuleInfo.ModuleName.ToString();
// lbl_Title.Text = string.Format("{0}-{1}({2})", Information.Hospital.Name, Information.SystemInfo.SystemName, Information.SystemModuleInfo.ModuleName);
//获取菜单源
BindMenu();
}
/// <summary>
/// 绑定菜单
/// </summary>
private void BindMenu()
{
try
{
string Url = string.Empty;
//是否受系统模块限制
bool IsHaveUserID = false;
if (!string.IsNullOrEmpty(PublicClassForDataBase.Config102))
{
//配置为0所有用户菜单都不受系统模块限制
if (PublicClassForDataBase.Config102 == "0")
{
IsHaveUserID = true;
}
//配置为-1所有用户都受系统模块限制加载菜单
else if (PublicClassForDataBase.Config102 == "-1")
{
IsHaveUserID = false;
}
//菜单受系统模块限制
else
{
string[] Config102Array = PublicClassForDataBase.Config102.Split('#');
foreach (string str in Config102Array)
{
if (str == Information.User.ID.ToString())
{
//存在则不受限制
IsHaveUserID = true;
break;
}
}
}
}
//当前参数设置为空时,菜单受系统模块限制
else
{
IsHaveUserID = false;
}
//如果存在指定的用户集合中将获取菜单,否则只获取当前模块下的菜单
if (IsHaveUserID)
{
Url = string.Format("/api/admin/T_SYS_Menu/GetListByUserID?userID={0}", Information.User.ID);
}
else
{
Url = string.Format("/api/admin/T_SYS_Menu/GetListByUserID?userID={0}&systemModuleID={1}", Information.User.ID, Information.SystemModuleInfo.ID);
}
//菜单
MenuTabe = DBHelpClass.Get(Url);
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "绑定菜单:\r\n" + ex);
}
}
/// <summary>
/// 退出系统
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Main_FormClosing(object sender, FormClosingEventArgs e)
{
try
{
if (XtraMessageBox.Show("您确定要退出系统么?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{
e.Cancel = true;
}
else
{
this.Hide();
this.Dispose();//释放资源:托盘图标立即消失
#region 退出成功记录登录信息
List<T_SYS_UserDTO> list = new List<T_SYS_UserDTO>();
T_SYS_UserDTO model = new T_SYS_UserDTO();
string Url = "/api/admin/T_SYS_User/UpdateLoginInfo";
model.ID = Information.User.ID;
model.IsOnline = 1;
list.Add(model);
//初始化两个工厂
ClientFactory<T_SYS_UserDTO> httpClient = new HttpClientFactory<T_SYS_UserDTO>();
Client<T_SYS_UserDTO> client = httpClient.VisitFactory();
//访问
client.Post(Url, list);
#endregion
//退出当前线程上的消息循环,并关闭该线程上的所有窗口
System.Environment.Exit(0);
}
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "退出系统:\r\n" + ex);
}
}
/// <summary>
/// 时钟
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>0
//private void timer_Time_Tick(object sender, EventArgs e)
//{
// tsslbl_SystemModule.Text = DateTime.Now.ToString("D") + " " + CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(DateTime.Now.DayOfWeek) + DateTime.Now.ToString("HH:mm:ss");
//}
#region 反射公用方法
/// <summary>
/// 打开新的子窗体
/// </summary>
/// <param name="Namespace">窗体所在命名空间</param>
/// <param name="FormName">窗体的名称</param>
/// <param name="MdiParentForm">父窗体</param>
public void CreateForm(string Namespace, string FormName, Form MdiParentForm)
{
loading.ShowMessage();
try
{
if (!ShowChildForm(FormName, MdiParentForm))
{
string path = Namespace;//项目的Assembly选项名称
string name = Namespace + "." + FormName; //类的名字
Form doc = (Form)Assembly.Load(path).CreateInstance(name);
if (doc != null)
{
if (doc.IsMdiContainer)
{
doc.ShowDialog();
}
else
{
doc.WindowState = FormWindowState.Maximized;
doc.MdiParent = MdiParentForm;
doc.Show();
}
}
}
}
catch (Exception ex)
{
XtraMessageBox.Show("打开菜单失败!原因可能是当前环境下没有该菜单的动态库,请确认菜单信息是否设置正确!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
PublicClass.WriteErrorLog(this.Text, "打开新的子窗体:\r\n" + ex);
}
loading.HideMessage();
}
/// <summary>
/// 防止子窗体再度打开
/// </summary>
/// <param name="p_ChildrenFormText"></param>
/// <param name="MdiParentForm"></param>
/// <returns></returns>
public static bool ShowChildForm(string p_ChildrenFormText, Form MdiParentForm)
{
int i;
//依次检测当前窗体的子窗体
for (i = 0; i < MdiParentForm.MdiChildren.Length; i++)
{
//判断当前子窗体的Text属性值是否与传入的字符串值相同
if (MdiParentForm.MdiChildren[i].Name == p_ChildrenFormText)
{
//如果值相同则表示此子窗体为想要调用的子窗体激活此子窗体并返回true值
MdiParentForm.MdiChildren[i].Activate();
return true;
}
}
//如果没有相同的值则表示要调用的子窗体还没有被打开返回false值
return false;
}
#endregion
#region 获取菜单
/// <summary>
/// 创建菜单分组
/// </summary>
private void CreateGroup()
{
if (MenuTabe != null && MenuTabe.Rows.Count > 0)
{
navBar_Menu.Groups.Clear();//清除菜单组
navBar_Menu.Items.Clear();//清除菜单项
DataTable dt = MenuTabe;
DataRow[] drs = dt.Select("ParentID=0", "OrderBy");//获取所有分组
int i = 0;
foreach (DataRow dr in drs)
{
i++;
DevExpress.XtraNavBar.NavBarGroup Nbg = new DevExpress.XtraNavBar.NavBarGroup();
Nbg.Caption = dr["MenuName"].ToString();
#region 图标
if (!string.IsNullOrEmpty(PublicClass.ToString(dr["IconData"], "")))
{
MemoryStream ms = new MemoryStream(Convert.FromBase64String(dr["IconData"].ToString()));
Image img = Image.FromStream(ms);
Nbg.SmallImage = img;
}
else
{
Nbg.SmallImage = null;
}
#endregion
if (i == 1)
Nbg.Expanded = true;//打开第一层
navBar_Menu.Groups.Add(Nbg);
CreateSubLevel(Convert.ToInt32(dr["ID"]), Nbg);
}
}
else
{
XtraMessageBox.Show("您的账号未授予任何权限,请联系管理员!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
/// <summary>
/// 构建下层 navbar subLevel
/// </summary>
/// <param name="_MenuId">组ID</param>
/// <param name="PassGroup)">NavBarGroup名称</param>
private void CreateSubLevel(int _MenuId, DevExpress.XtraNavBar.NavBarGroup PassGroup)
{
if (MenuTabe != null && MenuTabe.Rows.Count > 0)
{
DataTable dt = MenuTabe;
int _listSqu = 0;
foreach (DataRow dr in dt.Select("ParentID = '" + _MenuId + "'"))
{
DevExpress.XtraNavBar.NavBarItem Nbi = new DevExpress.XtraNavBar.NavBarItem();
Nbi.Caption = dr["MenuName"].ToString();
Nbi.Name = dr["DllName"].ToString();
Nbi.Tag = dr["FunctionName"].ToString();
Nbi.SmallImageIndex = _listSqu;
#region 图标
if (!string.IsNullOrEmpty(PublicClass.ToString(dr["IconData"], "")))
{
MemoryStream ms = new MemoryStream(Convert.FromBase64String(dr["IconData"].ToString()));
Image img = Image.FromStream(ms);
Nbi.SmallImage = img;
}
else
{
Nbi.SmallImage = null;
}
#endregion
PassGroup.ItemLinks.Add(Nbi);
Nbi.LinkClicked += new DevExpress.XtraNavBar.NavBarLinkEventHandler(Nbi_LinkClicked);
_listSqu++;
}
}
}
/// <summary>
/// 单击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Nbi_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
{
string Namespace = ((DevExpress.XtraNavBar.NavElement)sender).Name;
string FormName = ((DevExpress.XtraNavBar.NavElement)sender).Tag.ToString();
CreateForm(Namespace, FormName, this);
}
#endregion
#region 消息提醒
/// <summary>
/// 已读消息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void alertControl_ButtonClick(object sender, DevExpress.XtraBars.Alerter.AlertButtonClickEventArgs e)
{
try
{
//已读
if (e.ButtonName == "btn_Read")
{
long NoticeID = PublicClass.ToInt64(e.Info.Tag, 0);
UpdateReadState(NoticeID);
}
}
catch (Exception ex)
{
PublicClass.WriteErrorLog(this.Text, "已读消息:\r\n" + ex);
}
}
private void alertControl_AlertClick(object sender, DevExpress.XtraBars.Alerter.AlertClickEventArgs e)
{
long NoticeID = PublicClass.ToInt64(e.Info.Tag, 0);
UpdateReadState(NoticeID);
Form_Message frm = new Form_Message(Information.User.ID, NoticeID);
frm.ShowDialog();
}
/// <summary>
/// 更新消息阅读状态
/// </summary>
/// <param name="noticeID">消息编号(ID)</param>
/// <returns></returns>
private bool UpdateReadState(long noticeID)
{
if (noticeID != 0)
{
List<T_Service_NoticeReceivingDTO> list = new List<T_Service_NoticeReceivingDTO>();
T_Service_NoticeReceivingDTO model = new T_Service_NoticeReceivingDTO();
//初始化两个工厂
ClientFactory<T_Service_NoticeReceivingDTO> httpClient = new HttpClientFactory<T_Service_NoticeReceivingDTO>();
Client<T_Service_NoticeReceivingDTO> client = httpClient.VisitFactory();
string Url = "api/service/T_Service_NoticeReceiving/UpdateReadState";
model.NoticeID = noticeID;
model.UserID = Information.User.ID;
model.FirstReadingTime = PublicClass.DateTimeNow();
model.TotalReading = 0;
list.Add(model);
//访问
return client.Post(Url, list).Success;
}
else
{
return false;
}
}
#endregion
#region 非菜单窗口
/// <summary>
/// 打开消息列表
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelControl_Index_Click(object sender, EventArgs e)
{
Form_Message frm = new Form_Message(Information.User.ID);
frm.ShowDialog();
}
/// <summary>
/// 开始急诊接诊记录
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelControl_StartConsultation_Click(object sender, EventArgs e)
{
Form_ScanTime frm = new Form_ScanTime();
frm.ShowDialog();
}
/// <summary>
/// 新增急救
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelControl_AddPatient_Click(object sender, EventArgs e)
{
//Form_AddPatient frm = new Form_AddPatient();
//frm.ShowDialog();
Form_PublisAddPatient form_Publis = new Form_PublisAddPatient(Information.SystemModuleInfo.ID, "");
form_Publis.ShowDialog();
}
/// <summary>
/// 个人信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelControl_UserInfo_Click(object sender, EventArgs e)
{
Form_UserEdit form = new Form_UserEdit(2, Information.User.ID);
form.ShowDialog();
}
/// <summary>
/// 重新登录
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelControl_RelogIn_Click(object sender, EventArgs e)
{
if (XtraMessageBox.Show("您确定需要重新登录吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
return;
ReLogin(sender, e);
}
/// <summary>
/// 重新登录
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ReLogin(object sender, EventArgs e)
{
//关闭所有已经打开的子窗体
if (MdiChildren.Length > 0)
{
foreach (Form myForm in this.MdiChildren) myForm.Close();
navBar_Menu.Groups.Clear();//清除菜单组
navBar_Menu.Items.Clear();//清除菜单项
}
//重启登录界面
Form_Login Login = new Form_Login();
Login.StartPosition = FormStartPosition.CenterScreen;
if (DialogResult.OK == Login.ShowDialog())
{
Form_Main_Load(sender, e);
}
}
/// <summary>
/// 操作指南
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelControl_OperationManual_Click(object sender, EventArgs e)
{
Form_OperationManual frm = new Form_OperationManual();
frm.Show();
}
/// <summary>
/// 防止打开多个窗体
/// </summary>
/// <param name="p_ChildrenFormText">窗体名称</param>
/// <returns></returns>
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;
}
#endregion
#region 系统模块相关
/// <summary>
/// 切换系统
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelControl_SwitchingSystem_Click(object sender, EventArgs e)
{
SwitchingSystem(sender, e);
}
/// <summary>
/// 切换系统
/// </summary>
private void SwitchingSystem(object sender, EventArgs e)
{
//选择模块
Form_SelectSystemModule frm = new Form_SelectSystemModule(Information.User.ID, Information.Hospital.ID, 2);
if (frm.ShowDialog() == DialogResult.OK)
{
if (frm.IsOpenSystemModule)
{
Information.SystemModuleInfo.ID = frm.Cur_SelSystemModuleID;
Information.SystemModuleInfo.ModuleName = frm.Cur_SelSystemModuleName;
//绑定数据源
BindData();
BindTitle();
CreateGroup();
//关闭所有已经打开的子窗体
if (MdiChildren.Length > 0)
{
foreach (Form myForm in this.MdiChildren)
myForm.Close();
}
GetIndex();
}
else
{
ReLogin(sender, e);
}
}
}
#endregion
/// <summary>
/// 显示首页
/// </summary>
public void GetIndex()
{
if (!ShowChildrenForm("Form_Index"))
{
labelControl1.Visible = true;
labelControl_AddPatient.Visible = true;
//胸痛系统首页
if (Information.SystemModuleInfo.ID.ToString() == PublicClassForDataBase.Config10001)
{
Form form = PublicHelp.GetReflection("HL_FristAidPlatform_ChestPain", "Form_Index");
form.WindowState = FormWindowState.Maximized;
form.MdiParent = this;
form.Show();
}
//卒中系统首页
else if (Information.SystemModuleInfo.ID.ToString() == PublicClassForDataBase.Config10002)
{
Form form = PublicHelp.GetReflection("HL_FristAidPlatform_Apoplexy", "Form_Index");
form.WindowState = FormWindowState.Maximized;
form.MdiParent = this;
form.Show();
}
//创伤系统首页
else if (Information.SystemModuleInfo.ID.ToString() == PublicClassForDataBase.Config10003)
{
Form form = PublicHelp.GetReflection("HL_FristAidPlatform_Trauma", "Form_Index");
form.WindowState = FormWindowState.Maximized;
form.MdiParent = this;
form.Show();
}
//孕产妇系统首页
else if (Information.SystemModuleInfo.ID.ToString() == PublicClassForDataBase.Config10004)
{
Form form = PublicHelp.GetReflection("HL_FristAidPlatform_CriticalPregnant", "Form_Index");
form.WindowState = FormWindowState.Maximized;
form.MdiParent = this;
form.Show();
}
//新生儿系统首页
else if (Information.SystemModuleInfo.ID.ToString() == PublicClassForDataBase.Config10005)
{
Form_Index form = new Form_Index();
form.WindowState = FormWindowState.Maximized;
form.MdiParent = this;
form.Show();
}
else if (Information.SystemModuleInfo.ID.ToString() == PublicClassForDataBase.Config10007)
{
labelControl1.Visible = true;
string url = string.Format("/api/admin/T_SYS_User/Is120User?id={0}", Information.User.ID);
string res = DBHelpClass.GetDateOfStr(url);
if (res.Contains("true"))
{
Task.Run(() =>
{
ShowFormTask();
});
}
Form_CurrentTaskInfo form = new Form_CurrentTaskInfo();
form.WindowState = FormWindowState.Maximized;
form.MdiParent = this;
form.Show();
}
//胸痛救治单元
else if (Information.SystemModuleInfo.ID.ToString() == PublicClassForDataBase.Config10008)
{
labelControl1.Visible = false;
labelControl_AddPatient.Visible = false;
Form form = PublicHelp.GetReflection("SC_FristAidPlatform_ChestPainUnit", "Form_Index");
form.WindowState = FormWindowState.Maximized;
form.MdiParent = this;
form.Show();
}
}
}
#region 系统托盘右键菜单
/// <summary>
/// 查看消息通知
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TSM_SeeMessage_Click(object sender, EventArgs e)
{
Form_Message frm = new Form_Message(Information.User.ID);
frm.ShowDialog();
}
/// <summary>
/// 修改个人信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TSM_UpdateInfo_Click(object sender, EventArgs e)
{
Form_UserEdit form = new Form_UserEdit(2, Information.User.ID);
form.ShowDialog();
}
/// <summary>
/// 配置本地参数
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void TSM_LocalSettings_Click(object sender, EventArgs e)
{
Form_LocalSettings frm = new Form_LocalSettings();
frm.ShowDialog();
}
#endregion
/// <summary>
/// 接警
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void labelControl1_Click(object sender, EventArgs e)
{
Form_Call call = new Form_Call();
Form_CurrentTaskInfo taskInfo = new Form_CurrentTaskInfo();
call.Owner = taskInfo;
call.Show();
}
private void labelControl_Time_Click(object sender, EventArgs e)
{
DateTime dateTime;
string message;
if (SystemTime.Synchronization(PublicClassForDataBase.Config10015, out dateTime, out message))
{
MessageBox.Show("校时成功!");
}
else
{
MessageBox.Show("校时失败,请联系管理员!");
}
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
SwitchingSystem(sender, e);
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (XtraMessageBox.Show("您确定需要重新登录吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
return;
ReLogin(sender, e);
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form_UserEdit form = new Form_UserEdit(2, Information.User.ID);
form.ShowDialog();
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form_OperationManual frm = new Form_OperationManual();
frm.Show();
}
private void Form_Main_Resize(object sender, EventArgs e)
{
int SH = Screen.PrimaryScreen.Bounds.Height;
int SW = Screen.PrimaryScreen.Bounds.Width;
//Size = new Size(SW, SH);
//float kx = this.Width / x;
//float ky = this.Height / y;
//setTag(this);
//setControls(kx, ky, this);
}
private void setControls(float kx, float ky, Control cons)
{
foreach (Control con in cons.Controls)
{
string[] tag = con.Tag.ToString().Split(';');
con.Width = Convert.ToInt32(Convert.ToSingle(tag[0]) * kx);
con.Height = Convert.ToInt32(Convert.ToSingle(tag[1]) * ky);
con.Left = Convert.ToInt32(Convert.ToSingle(tag[2]) * kx);
con.Top = Convert.ToInt32(Convert.ToSingle(tag[3]) * ky);
//con.Font = new Font(con.Font.Name, Convert.ToSingle(tag[4]) * kx, con.Font.Style, con.Font.Unit);
if (con.Controls.Count > 0)
{
setControls(kx, ky, con);
}
}
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
Form_LocalSettings frm = new Form_LocalSettings();
frm.ShowDialog();
}
/// <summary>
/// 检查更新测试
/// </summary>
private void InstallUpdateSyncWithInfo()
{
UpdateCheckInfo info = null;
if (ApplicationDeployment.IsNetworkDeployed)
{
ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
try
{
info = ad.CheckForDetailedUpdate();
}
catch (DeploymentDownloadException dde)
{
MessageBox.Show("此时无法下载应用程序的新版本 \n\n请检查网络连接或稍后再试. Error: " + dde.Message);
return;
}
catch (InvalidDeploymentException ide)
{
MessageBox.Show("无法检查应用程序的新版本. ClickOnce部署已损坏. 请重新部署应用程序并重试!. Error: " + ide.Message); return;
}
catch (InvalidOperationException ioe) { MessageBox.Show("This application cannot be updated. It is likely not a ClickOnce application. Error: " + ioe.Message); return; }
if (info.UpdateAvailable)
{
Boolean doUpdate = true;
if (!info.IsUpdateRequired)
{
DialogResult dr = MessageBox.Show("有更新可用. 是否要立即更新应用程序?", "Update Available", MessageBoxButtons.OKCancel);
if (!(DialogResult.OK == dr))
{
doUpdate = false;
}
}
else
{
// Display a message that the app MUST reboot. Display the minimum required version.
MessageBox.Show("此应用程序检测到您当前的强制更新 " + "版本到版本 " + info.MinimumRequiredVersion.ToString() + ". 应用程序现在将安装更新并重新启动.", "Update Available", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
if (doUpdate)
{
try
{
ad.Update();
MessageBox.Show("应用程序已升级,现在将重新启动.");
Application.Restart();
}
catch (DeploymentDownloadException dde)
{
MessageBox.Show("无法安装应用程序的最新版本. \n\n请检查网络连接或稍后再试. Error: " + dde);
return;
}
}
}
}
}
private void setTag(Control cons)
{
foreach (Control con in cons.Controls)
{
//con.Tag = con.Width + ";" + con.Height + ";" + con.Left + ";" + con.Top + ";" + con.Font.Size;
con.Tag = con.Width + ";" + con.Height + ";" + con.Left + ";" + con.Top;
if (con.Controls.Count > 0)
{
setTag(con);
}
Console.WriteLine(con.Name);
}
}
}
}