using DevExpress.XtraEditors; using System.Collections.Generic; using System.Windows.Forms; namespace HL_FristAidPlatform_Public { /// /// 操作提醒 /// public static class OperationReminder { /// /// 操作提示字典 /// public static Dictionary Dictionary = new Dictionary(); /// /// 提醒消息分割字符 /// private static char SplitFlag = ';'; /// /// 生成提醒消息 /// /// 已产生的提醒内容 /// 需要判断的控件值:文本控件或者时间控件 /// 需要生成的提醒消息 public static void GenerateOperationRreminder(ref string operationRreminder, string valueStr, string messageStr) { //文本控件或者时间控件 if (string.IsNullOrEmpty(valueStr.Trim())) { operationRreminder += messageStr + SplitFlag; } } /// /// 生成提醒消息 /// /// 已产生的提醒内容 /// 需要判断的控件值:单选控件 /// 需要生成的提醒消息 public static void GenerateOperationRreminder(ref string operationRreminder, long valueInt, string messageStr) { //单选控件 if (valueInt <= 0) { operationRreminder += messageStr + SplitFlag; } } /// /// 生成提醒消息 /// /// 消息字典,采用键值对模式 /// 当前消息的唯一键,有值时在原有基础上累加,空值直接生成完整的提醒语句 /// 需要累加的新提醒消息 /// 标记: /// 1:先判断传的值是否为空,是才增加提醒消息 /// 2:不用判断传的值是否为空,直接累加消息 /// /// 展示消息的控件 /// 需要判断的控件值 public static string Generate(Dictionary 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; } /// /// 格式化提醒消息 /// /// 患者姓名 /// 提醒消息 /// 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); } } /// /// 格式化提醒消息 /// /// 患者姓名 /// 提醒消息 /// 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); } } } }