天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

48 lines
1.5 KiB

using System;
using System.Windows.Forms;
namespace QMAPP.WinForm
{
public static class MessageHelper
{
public static void ShowEx(Exception ex)
{
ex = GetInnerException(ex);
var str = ex.ToString().Length > 100 ? ex.Message : ex.ToString();
MessageBox.Show(str, "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop);
LogHelper.Write(ex.ToString());
}
private static Exception GetInnerException(Exception ex)
{
while (true)
{
if (ex.InnerException == null) return ex;
ex = ex.InnerException;
}
}
public static void ShowError(string msg)
{
MessageBox.Show(msg, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
LogHelper.Write(msg);
}
public static void ShowWarning(string msg)
{
MessageBox.Show(msg, "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
public static bool ShowQuestion(string msg)
{
var result = MessageBox.Show(msg, "问题", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
return result == DialogResult.Yes;
}
public static void ShowInfo(string msg)
{
if (string.IsNullOrEmpty(msg)) return;
MessageBox.Show(msg, "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}