|
|
|
|
|
#region CopyRight
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************
|
|
|
|
|
|
* Project:健康体检信息管理系统(PEIS)
|
|
|
|
|
|
* Author:张剑峰
|
|
|
|
|
|
* CLR Version:4.0.30319.42000
|
|
|
|
|
|
* CreateTime:2023-05-01 14:46:15
|
|
|
|
|
|
* Version:v2.0
|
|
|
|
|
|
*
|
|
|
|
|
|
* Description:
|
|
|
|
|
|
*
|
|
|
|
|
|
* History:
|
|
|
|
|
|
*
|
|
|
|
|
|
*****************************************************************
|
|
|
|
|
|
* Copyright @ 云南新八达科技有限公司 2023 All rights reserved
|
|
|
|
|
|
*****************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#endregion CopyRight
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Configuration;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
using PEIS.Entity;
|
|
|
|
|
|
|
|
|
|
|
|
namespace PEIS.Utils
|
|
|
|
|
|
{
|
|
|
|
|
|
internal class Global
|
|
|
|
|
|
{
|
|
|
|
|
|
public static String HisConnection { get; set; }
|
|
|
|
|
|
public static string HisDBName
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return Global._lstConfig.FirstOrDefault(x => x.Key == "HisDBName")?.Value ?? "his.hisdata.dbo";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 允许重复打开相同页面
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static string AllowDuplicateTabs
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return Global._lstConfig.FirstOrDefault(x => x.Key == "AllowDuplicateTabs")?.Value ?? "0";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 在团体报告中展示分组绑定项目而不是实际人员登记项目
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static string UseGroupFeeItemsInTeamReport
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return Global._lstConfig.FirstOrDefault(x => x.Key == "UseGroupFeeItemsInTeamReport")?.Value ?? "0";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 配置信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static List<Config> _lstConfig = new List<Config>();
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 体征词
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static List<Sign> _lstSign = new List<Sign>();
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 接害类型
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static List<DictHazardType> _lstDictHazardTypes = new List<DictHazardType>();
|
|
|
|
|
|
|
|
|
|
|
|
public static Hospital _hospital = new Hospital();
|
|
|
|
|
|
public static List<Conclusion> _lstConclusion = new List<Conclusion>();
|
|
|
|
|
|
public static List<User> _lstAllDept = new List<User>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static User currentUser;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 返回*.exe.cdddonfig文件中appSettings配置节的value项
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="key"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static string GetAppConfig(string key)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (string str in ConfigurationManager.AppSettings)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (str == key)
|
|
|
|
|
|
{
|
|
|
|
|
|
return ConfigurationManager.AppSettings[key];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 个人缴费单获取微信缴费URL
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static string GetWeChatPayUrl()
|
|
|
|
|
|
{
|
|
|
|
|
|
var urlConfig = DAOHelp.GetDataBySQL<Config>(@"SELECT * FROM Dict_Config WHERE[Key] = 'WechatPayUrl'");
|
|
|
|
|
|
var url = urlConfig.FirstOrDefault()?.Value;
|
|
|
|
|
|
if (!string.IsNullOrEmpty(url) && urlConfig.Count <= 1) return url;
|
|
|
|
|
|
MsgErr(@"微信缴费URL未配置,请联系系统管理员!");
|
|
|
|
|
|
return "";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 提示框
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="kind">warn/err/info</param>
|
|
|
|
|
|
/// <param name="content"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static DialogResult Msg(String kind, String content)
|
|
|
|
|
|
{
|
|
|
|
|
|
var dr = DialogResult.Cancel;
|
|
|
|
|
|
switch (kind)
|
|
|
|
|
|
{
|
|
|
|
|
|
case "warn":
|
|
|
|
|
|
dr = MessageBox.Show(content, "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case "err":
|
|
|
|
|
|
dr = MessageBox.Show(content, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case "info":
|
|
|
|
|
|
dr = MessageBox.Show(content, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
return dr;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static DialogResult MsgInfo(string content)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Msg("info", content);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static DialogResult MsgErr(string content)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Msg("err", content);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static DialogResult MsgWarn(string content)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Msg("warn", content);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否确认删除
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="content"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static bool MsgDelete(string content = "是否确认删除?")
|
|
|
|
|
|
{
|
|
|
|
|
|
var result = MessageBox.Show(content, @"删除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
|
|
|
return (result == DialogResult.Yes);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 金额数字转大写(带小数点)
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static string PriceToCn(decimal price)
|
|
|
|
|
|
{
|
|
|
|
|
|
//数字转大写
|
|
|
|
|
|
string[] n = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
|
|
|
|
|
|
string[] d = { "", "分", "角", "元", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿" };
|
|
|
|
|
|
|
|
|
|
|
|
//不同位置的数字要加单位
|
|
|
|
|
|
List<string> needReplace = new List<string> { "零拾", "零佰", "零仟", "零万", "零亿", "亿万", "零元", "零零", "零角", "零分" };
|
|
|
|
|
|
List<string> afterReplace = new List<string> { "零", "零", "零", "万", "亿", "亿", "元", "零", "零", "" };
|
|
|
|
|
|
|
|
|
|
|
|
string e = price % 1 == 0 ? "整" : ""; //金额是整数,加一个“整”结尾
|
|
|
|
|
|
string re = "";
|
|
|
|
|
|
int a = (int)(price * 100);
|
|
|
|
|
|
int k = 1;
|
|
|
|
|
|
while (a != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
//初步转换大小写
|
|
|
|
|
|
re = n[a % 10] + d[k] + re;
|
|
|
|
|
|
a = a / 10;
|
|
|
|
|
|
k = k < 11 ? k + 1 : 4;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string need = needReplace.Where(tb => re.Contains(tb)).FirstOrDefault<string>();
|
|
|
|
|
|
while (need != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
int i = needReplace.IndexOf(need);
|
|
|
|
|
|
re = re.Replace(needReplace[i], afterReplace[i]);
|
|
|
|
|
|
need = needReplace.Where(tb => re.Contains(tb)).FirstOrDefault<string>();
|
|
|
|
|
|
}//循环排除特殊情况
|
|
|
|
|
|
re = re == "" ? "零元" : re + e;
|
|
|
|
|
|
|
|
|
|
|
|
return re;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 在*.exe.config文件中appSettings配置节增加一对键、值对
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="newKey"></param>
|
|
|
|
|
|
/// <param name="newValue"></param>
|
|
|
|
|
|
public static void UpdateAppConfig(string newKey, string newValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool isModified = false;
|
|
|
|
|
|
foreach (string key in ConfigurationManager.AppSettings)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (key == newKey)
|
|
|
|
|
|
{
|
|
|
|
|
|
isModified = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Open App.Config of executable
|
|
|
|
|
|
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
|
|
|
|
|
|
// You need to remove the old settings object before you can replace it
|
|
|
|
|
|
if (isModified)
|
|
|
|
|
|
{
|
|
|
|
|
|
config.AppSettings.Settings.Remove(newKey);
|
|
|
|
|
|
}
|
|
|
|
|
|
// Add an Application Setting.
|
|
|
|
|
|
config.AppSettings.Settings.Add(newKey, newValue);
|
|
|
|
|
|
// Save the changes in App.config file.
|
|
|
|
|
|
config.Save(ConfigurationSaveMode.Modified);
|
|
|
|
|
|
// Force a reload of a changed section.
|
|
|
|
|
|
ConfigurationManager.RefreshSection("appSettings");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 通用更新UI方法 Invoke
|
|
|
|
|
|
/// 避免线程无法访问对象、UI 控件不存在或已释放
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="control"></param>
|
|
|
|
|
|
/// <param name="action"></param>
|
|
|
|
|
|
public static void InvokeControl(Control control, Action action)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (control == null || control.IsDisposed) return;
|
|
|
|
|
|
control.Invoke(new Action(action.Invoke));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static User GetRequestUser()
|
|
|
|
|
|
{
|
|
|
|
|
|
User user = new User();
|
|
|
|
|
|
|
|
|
|
|
|
Config config = _lstConfig.FirstOrDefault(p => p.Key == "" && p.Value == "1");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return user;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|