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);
|
}
|
}
|
}
|