台州海关TD3600上线版本

This commit is contained in:
terry.wang
2025-11-26 17:20:53 +08:00
parent ccaffc1014
commit 80be2ed45e
961 changed files with 1395034 additions and 0 deletions

335
JJMediSys/MainForm.cs Normal file
View File

@@ -0,0 +1,335 @@
using DevExpress.XtraNavBar;
using DevExpress.XtraTab;
using log4net;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace JJMediSys
{
public partial class MainForm : Form
{
public static ILog logger = LogManager.GetLogger("WebLogger");
public static Size TabPageSize;
private static Dictionary<string, XtraTabPage> TabPageDic = new Dictionary<string, XtraTabPage>();
public string InJsonStr = "{\"Response\": {\"Groups\": [{\"GroupName\": \"常用功能\",\"Items\": [{\"ItemName\": \"门诊采血\",\"Show\": 1,\"iconindex\":0},{\"ItemName\": \"本地当日打印记录\",\"Show\": 1,\"iconindex\":3},{\"ItemName\": \"记录查询\",\"Show\": 1,\"iconindex\":3},{\"ItemName\": \"数据统计\",\"Show\": 1,\"iconindex\":6}]},{\"GroupName\": \"门诊工作站\",\"Items\": [{\"ItemName\": \"门诊采血\",\"Show\": 1,\"iconindex\":0},{\"ItemName\": \"本地当日打印记录\",\"Show\": 1,\"iconindex\":3},{\"ItemName\": \"记录查询\",\"Show\": 1,\"iconindex\":3},{\"ItemName\": \"数据统计\",\"Show\": 1,\"iconindex\":6}]},{\"GroupName\": \"体检工作站\",\"Items\": [{\"ItemName\": \"体检采血\",\"Show\": 1,\"iconindex\":0},{\"ItemName\": \"体检打包\",\"Show\": 1,\"iconindex\":2},{\"ItemName\": \"标签查询\",\"Show\": 1,\"iconindex\":3}]},{\"GroupName\": \"住院工作站\",\"Items\": [{\"ItemName\": \"住院采血\",\"Show\": 1,\"iconindex\":0},{\"ItemName\": \"住院打包\",\"Show\": 1,\"iconindex\":2},{\"ItemName\": \"标签查询\",\"Show\": 1,\"iconindex\":3}]},{\"GroupName\": \"系统设置\",\"Items\": [{\"ItemName\": \"系统参数设置\",\"Show\": 1,\"iconindex\":4},{\"ItemName\": \"查看传感器状态\",\"Show\": 1,\"iconindex\":5},{\"ItemName\": \"硬件参数控制\",\"Show\": 1,\"iconindex\":1},{\"ItemName\": \"标签设置\",\"Show\": 1,\"iconindex\":7},{\"ItemName\": \"Lis日志查询\",\"Show\": 1,\"iconindex\":3},{\"ItemName\": \"设备事件\",\"Show\": 1,\"iconindex\":3}]}]}}";
public static XtraTabPage selectedTabPage;
public static MainForm MainHandle;
public static int DevStat = -1;
public static int DBStat = -1;
public bool TimeFirstin = true;
public struct STRGroup
{
public string GroupName { get; set; }
public List<STRItem> Items { get; set; }
}
public struct STRItem
{
public string ItemName { get; set; }
public int Show { get; set; }
public int iconindex { get; set; }
}
public MainForm()
{
InitializeComponent();
}
private void MainForm_Load(object sender, EventArgs e)
{
MainHandle = this;
PanelUser.Location = new Point(this.Width - PanelUser.Width-20, 10);
panelnavbar.Size = new Size((int)(this.Width * 0.1), (int)(this.Height * 0.9));
panelnavbar.Location = new Point(2, (int)(this.Height * 0.05));
panelTabpage.Size = new Size((int)(this.Width * 0.89), (int)(this.Height * 0.9));
panelTabpage.Location = new Point(8+ (int)(this.Width * 0.1), (int)(this.Height * 0.05));
TabPageSize = panelTabpage.Size;
JObject jObject = (JObject)JsonConvert.DeserializeObject(InJsonStr);
List<STRGroup> sTRGroups = (List<STRGroup>)JsonConvert.DeserializeObject<List<STRGroup>>(jObject["Response"]["Groups"].ToString());
foreach(STRGroup sTRGroup in sTRGroups)
{
NavBarGroup Group = new NavBarGroup();
//Group.Appearance.Options.UseFont = true;
// Group.Appearance.Font = new Font("微软雅黑", 13);
//Group.Appearance.ForeColor = Color.Red;
Group.Name = sTRGroup.GroupName;
Group.Caption = sTRGroup.GroupName;
if(Group.Caption.Equals("常用功能"))
Group.Expanded = true;
else
Group.Expanded = false;
foreach (STRItem sTRItem in sTRGroup.Items)
{
if(sTRItem.Show==1)
{
NavBarItem item = new NavBarItem(sTRItem.ItemName);
item.LinkClicked += NavBarCtrol_LinkClicked;
item.Appearance.Font = new System.Drawing.Font("Segoe UI", 12F);
item.Appearance.Options.UseFont = true;
item.ImageOptions.SmallImage = ItemimageList.Images[sTRItem.iconindex];
Group.ItemLinks.Add(item);
}
}
NavBarCtrol.Groups.Add(Group);
}
AddTabpage(TabCtrol, "系统参数设置", "系统参数设置", "JJMediSys.SystemSet");
AddTabpage(TabCtrol, "门诊采血", "门诊采血", "JJMediSys.MZCY");
LabDoctorName.Text = Login.nurseDeskInfo.NurseName;
}
private void NavBarCtrol_LinkClicked(object sender, NavBarLinkEventArgs e)
{
if(e.Link.Caption.Equals("门诊采血"))
{
AddTabpage(TabCtrol, e.Link.Caption, e.Link.Caption, "JJMediSys.MZCY");
}
else if (e.Link.Caption.Equals("记录查询"))
{
AddTabpage(TabCtrol, e.Link.Caption, e.Link.Caption, "JJMediSys.DataHistory");
}
else if (e.Link.Caption.Equals("数据统计"))
{
AddTabpage(TabCtrol, e.Link.Caption, e.Link.Caption, "JJMediSys.STATS");
}
else if (e.Link.Caption.Equals("系统参数设置"))
{
AddTabpage(TabCtrol, e.Link.Caption, e.Link.Caption, "JJMediSys.SystemSet");
}
else if (e.Link.Caption.Equals("查看传感器状态"))
{
AddTabpage(TabCtrol, e.Link.Caption, e.Link.Caption, "JJMediSys.SensorStatus");
}
else if (e.Link.Caption.Equals("硬件参数控制"))
{
AddTabpage(TabCtrol, e.Link.Caption, e.Link.Caption, "JJMediSys.DevParamSet");
}
else if (e.Link.Caption.Equals("本地当日打印记录"))
{
AddTabpage(TabCtrol, e.Link.Caption, e.Link.Caption, "JJMediSys.DaylyHistory");
}
else if (e.Link.Caption.Equals("标签设置"))
{
AddTabpage(TabCtrol, e.Link.Caption, e.Link.Caption, "JJMediSys.RecpSetTool");
}
else if (e.Link.Caption.Equals("Lis日志查询"))
{
AddTabpage(TabCtrol, e.Link.Caption, e.Link.Caption, "JJMediSys.LisLog");
}
else if (e.Link.Caption.Equals("设备事件"))
{
AddTabpage(TabCtrol, e.Link.Caption, e.Link.Caption, "JJMediSys.EventLog");
}
}
/// <summary>
/// 新增选项卡页
/// </summary>
/// <param name="tabControl">选项卡控件</param>
/// <param name="tabPageName">当期选项卡页name名称</param>
/// <param name="tabText">当前选项卡页Text标题</param>
/// <param name="newFormName">当前选项卡中的新窗体</param>
public void AddTabpage(XtraTabControl tabControl, string tabPageName, string tabText, string newFormName)
{
if (IsTabpageExsit(tabControl, tabPageName))
{
return;
}
XtraTabPage newPage = new XtraTabPage();
newPage.Name = tabPageName;
newPage.Text = tabText;
newPage.Tooltip = tabPageName;
newPage.Controls.Add(AddNewForm(newFormName));
tabControl.TabPages.Add(newPage);
TabPageDic.Add(tabPageName, newPage);
tabControl.SelectedTabPage = newPage;
}
/// <summary>
/// 移除选项卡页
/// </summary>
/// <param name="tabControl"></param>
/// <param name="tabPageName"></param>
/// <param name="e"></param>
public void RemoveTabPage(XtraTabControl tabControl, EventArgs e)
{
DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs args = (DevExpress.XtraTab.ViewInfo.ClosePageButtonEventArgs)e;
string name = args.Page.Tooltip;
if (name.Equals("系统参数设置"))
{
return;
}
foreach (XtraTabPage item in tabControl.TabPages)
{
if (item.Name == name)
{
tabControl.TabPages.Remove(item);
item.Dispose();
TabPageDic.Remove(name);
return;
}
}
}
/// <summary>
/// 判断选项卡是否已经存在
/// </summary>
/// <param name="tabControl">选项卡控件</param>
/// <param name="tabPageName">选项卡名称</param>
/// <returns></returns>
private bool IsTabpageExsit(XtraTabControl tabControl, string tabPageName)
{
foreach (var item in TabPageDic)
{
if (item.Key == tabPageName)
{
tabControl.SelectedTabPage = item.Value;
return true;
}
}
return false;
}
/// <summary>
/// 在选项卡中生成窗体
/// </summary>
/// <param name="form">窗体名称</param>
private Form AddNewForm(string formName)
{
Form newForm = (Form)Assembly.GetExecutingAssembly().CreateInstance(formName);
newForm.FormBorderStyle = FormBorderStyle.None;
newForm.TopLevel = false;
//newForm.Parent = ((XtraTabControl)sender).SelectedTabPage;
newForm.ControlBox = false;
newForm.Dock = DockStyle.Fill;
newForm.Visible = true;
return newForm;
}
private void TabCtrol_CloseButtonClick(object sender, EventArgs e)
{
RemoveTabPage(TabCtrol, e);
}
private void TabCtrol_SelectedPageChanged(object sender, TabPageChangedEventArgs e)
{
selectedTabPage = TabCtrol.SelectedTabPage;
if(selectedTabPage.Name.Equals("系统参数设置")) //调用一次状态刷新
{
}
}
private void BResetPassword_Click(object sender, EventArgs e)
{
SetPassword setPassword = new SetPassword();
setPassword.ShowDialog();
}
private void BLogOut_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("是否退出当前账号", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
this.Hide();
Login.loginhandle.WindowReload();
Login.loginhandle.Show();
}
}
public void WindowReload()
{
LabDoctorName.Text = Login.nurseDeskInfo.NurseName;
}
public static bool ifWindowOpen(string WindName)
{
foreach (XtraTabPage item in MainHandle.TabCtrol.TabPages)
{
if (item.Name == WindName)
{
return true;
}
}
return false;
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
this.Hide();
if(ifWindowOpen("门诊采血"))
{
MZCY.ThreadRun = false;
}
Thread.Sleep(500);
}
private void StatusFrash_Tick(object sender, EventArgs e)
{
if(TimeFirstin)
{
StatusFrash.Interval = 10000;
TimeFirstin = false;
DoDBMySql.IsConnectionValid();
}
if(DevStat==-1&&PicStatusDev.BackgroundImage!= JJMediSys.Properties.Resources.)
{
PicStatusDev.BackgroundImage = JJMediSys.Properties.Resources.;
}else if (DevStat == 0 && PicStatusDev.BackgroundImage != JJMediSys.Properties.Resources.)
{
PicStatusDev.BackgroundImage = JJMediSys.Properties.Resources.;
}
if(DBStat==-1)
{
DoDBMySql.IsConnectionValid();
}
if (DBStat == -1 && PicStatusDB.BackgroundImage != JJMediSys.Properties.Resources.)
{
LabSqlNote.Visible = true;
PicStatusDB.BackgroundImage = JJMediSys.Properties.Resources.;
}
else if (DBStat == 0 && PicStatusDB.BackgroundImage != JJMediSys.Properties.Resources.)
{
LabSqlNote.Visible = false;
PicStatusDB.BackgroundImage = JJMediSys.Properties.Resources.;
}
}
private void toolTip1_Popup(object sender, PopupEventArgs e)
{
}
private void piclogo_MouseHover(object sender, EventArgs e)
{
toolTip1.SetToolTip(piclogo, "九聚智能采血终端应用软件v2.0");
}
}
}