南骏 池
2024-09-01 fc1b563df6d0405a24e7898c997bd52472ae9154
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using 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);
        }
    }
}