From 2066a7e10e20433f7445431d6d34a9026c29f663 Mon Sep 17 00:00:00 2001 From: lu <99954486@qq.com> Date: 星期一, 23 十二月 2024 08:43:43 +0800 Subject: [PATCH] 细节 --- DevApp/Gs.DevApp/ToolBox/MsgHelper.cs | 96 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 96 insertions(+), 0 deletions(-) diff --git a/DevApp/Gs.DevApp/ToolBox/MsgHelper.cs b/DevApp/Gs.DevApp/ToolBox/MsgHelper.cs new file mode 100644 index 0000000..7e42e87 --- /dev/null +++ b/DevApp/Gs.DevApp/ToolBox/MsgHelper.cs @@ -0,0 +1,96 @@ +锘縰sing System; +using System.Windows.Forms; + +namespace Gs.DevApp.ToolBox +{ + /// <summary> + /// 绯荤粺娑堟伅鎻愮ず绐椾綋 + /// </summary> + public class MsgHelper + { + /// <summary> + /// 鎵撳紑瀵硅瘽妗� + /// </summary> + /// <param name="msg">鏈瀵硅瘽鍐呭</param> + /// <returns></returns> + public static bool AskQuestion(string msg) + { + DialogResult r; + r = MessageBox.Show(msg, "鎻愮ず", + MessageBoxButtons.YesNo, + MessageBoxIcon.Question, + MessageBoxDefaultButton.Button2); + return r == DialogResult.Yes; + } + + /// <summary> + /// 閿欒娑堟伅鎻愮ず妗� + /// </summary> + /// <param name="msg">閿欒娑堟伅鍐呭</param> + public static void ShowError(string msg) + { + MessageBox.Show(msg, "璀﹀憡", + MessageBoxButtons.OK, + MessageBoxIcon.Hand, + MessageBoxDefaultButton.Button1); + } + + /// <summary> + /// 鏄剧ず绯荤粺寮傚父 + /// </summary> + /// <param name="e">绯荤粺寮傚父</param> + public static void ShowException(Exception e) + { + var s = e.Message; + var innerMsg = string.Empty; + + if (e.InnerException != null) + { + innerMsg = e.InnerException.Message; + s += "\n" + innerMsg; + } + + Warning(s); + } + + public static void ShowException(Exception ex, string customMessage) + { + //if (ex is CustomException) + //{ + // ShowException(ex); + //} + //else if (customMessage != "") + //{ + // Warning(customMessage); + //} + //else + //{ + // Warning(ex.Message); + //} + } + + /// <summary> + /// 淇℃伅鎻愮ず妗� + /// </summary> + /// <param name="msg">鏈鏄剧ず鐨勬秷鎭�</param> + public static void ShowInformation(string msg) + { + MessageBox.Show(msg, "淇℃伅", + MessageBoxButtons.OK, + MessageBoxIcon.Asterisk, + MessageBoxDefaultButton.Button1); + } + + /// <summary> + /// 璀﹀憡鎻愮ず妗� + /// </summary> + /// <param name="msg">璀﹀憡鍐呭</param> + public static void Warning(string msg) + { + MessageBox.Show(msg, "璀﹀憡", + MessageBoxButtons.OK, + MessageBoxIcon.Exclamation, + MessageBoxDefaultButton.Button1); + } + } +} \ No newline at end of file -- Gitblit v1.9.3