StableVersion4.3/HL_FristAidPlatform_Public/Public/OperationRreminder.cs

179 lines
6.7 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 System.Collections.Generic;
using System.Windows.Forms;
namespace HL_FristAidPlatform_Public
{
/// <summary>
/// 操作提醒
/// </summary>
public static class OperationReminder
{
/// <summary>
/// 操作提示字典
/// </summary>
public static Dictionary<string, string> Dictionary = new Dictionary<string, string>();
/// <summary>
/// 提醒消息分割字符
/// </summary>
private static char SplitFlag = '';
/// <summary>
/// 生成提醒消息
/// </summary>
/// <param name="operationRreminder">已产生的提醒内容</param>
/// <param name="valueStr">需要判断的控件值:文本控件或者时间控件</param>
/// <param name="messageStr">需要生成的提醒消息</param>
public static void GenerateOperationRreminder(ref string operationRreminder, string valueStr, string messageStr)
{
//文本控件或者时间控件
if (string.IsNullOrEmpty(valueStr.Trim()))
{
operationRreminder += messageStr + SplitFlag;
}
}
/// <summary>
/// 生成提醒消息
/// </summary>
/// <param name="operationRreminder">已产生的提醒内容</param>
/// <param name="valueStr">需要判断的控件值:单选控件</param>
/// <param name="messageStr">需要生成的提醒消息</param>
public static void GenerateOperationRreminder(ref string operationRreminder, long valueInt, string messageStr)
{
//单选控件
if (valueInt <= 0)
{
operationRreminder += messageStr + SplitFlag;
}
}
/// <summary>
/// 生成提醒消息
/// </summary>
/// <param name="dictionary">消息字典,采用键值对模式</param>
/// <param name="key">当前消息的唯一键,有值时在原有基础上累加,空值直接生成完整的提醒语句</param>
/// <param name="newMsg">需要累加的新提醒消息</param>
/// <param name="checkType">标记:
/// 1:先判断传的值是否为空,是才增加提醒消息
/// 2:不用判断传的值是否为空,直接累加消息
/// </param>
/// <param name="control">展示消息的控件</param>
/// <param name="valueStr">需要判断的控件值</param>
public static string Generate(Dictionary<string, string> dictionary, string key, string newMsg, int checkType, Control control = null, string valueStr = "")
{
//Key不为空时对消息进行累加为空则生成完整的提示消息返回
if (!string.IsNullOrEmpty(key))
{
//判断集合中是否含有某一个键ContainsKey()
if (dictionary.ContainsKey(key))
{
//存在即删除
dictionary.Remove(key);
}
//消息不为空时
if (!string.IsNullOrEmpty(newMsg))
{
switch (checkType)
{
//需要判断为空并且传的值也为空则累加新的消息
case 1:
if (string.IsNullOrEmpty(valueStr.Trim()))
{
dictionary.Add(key, newMsg + SplitFlag);
}
break;
//直接累加消息
case 2:
dictionary.Add(key, newMsg + SplitFlag);
break;
default:
break;
}
}
}
//循环字典生成提示语句
string msgStr = string.Empty;
foreach (string item in dictionary.Keys)
{
msgStr += dictionary[item];
}
//控件不为空时展示到对应的控件上
if (control != null)
{
control.Text = msgStr;
}
return msgStr;
}
/// <summary>
/// 格式化提醒消息
/// </summary>
/// <param name="patientName">患者姓名</param>
/// <param name="operationRreminderStr">提醒消息</param>
/// <returns></returns>
public static void Format(string patientName, string operationRreminderStr)
{
string returnStr = string.Empty;
int i = 1;
if (!string.IsNullOrEmpty(operationRreminderStr))
{
returnStr = string.Format("当前患者【{0}】数据填报校验未通过!详情如下:\r\n\r\n", patientName);
string[] itemIDArray = operationRreminderStr.Split(SplitFlag);
foreach (string item in itemIDArray)
{
if (!string.IsNullOrEmpty(item))
{
returnStr += i + "、" + item + "";
i++;
if (i % 3 == 1)
{
returnStr += "\r\n";
}
}
}
XtraMessageBox.Show(returnStr, "数据校验提醒", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
/// <summary>
/// 格式化提醒消息
/// </summary>
/// <param name="patientName">患者姓名</param>
/// <param name="operationRreminderStr">提醒消息</param>
/// <returns></returns>
public static void FormatOperationRreminder(string patientName, string operationRreminderStr)
{
string returnStr = string.Empty;
int i = 1;
if (!string.IsNullOrEmpty(operationRreminderStr))
{
returnStr = string.Format("当前患者【{0}】数据填报校验未通过!详情如下:\r\n\r\n", patientName);
string[] itemIDArray = operationRreminderStr.Split(SplitFlag);
foreach (string item in itemIDArray)
{
if (!string.IsNullOrEmpty(item))
{
returnStr += i + "、" + item + "";
i++;
if (i % 3 == 1)
{
returnStr += "\r\n";
}
}
}
XtraMessageBox.Show(returnStr, "数据校验提醒", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
}