using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Utility
{
public class Messages
{
private const string HANDLEHING = "操作提示";
private const string SYSTEMHINT = "系统提示";
public static DialogResult Ok(string message)
{
return MessageBox.Show(message, HANDLEHING + ":成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
/// <summary>
/// 失败
/// </summary>
/// <param name="message"></param>
/// <returns></returns>
public static DialogResult Fail(string message)
{
return MessageBox.Show(message, HANDLEHING + ":失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
/// <summary>
/// 信息
/// </summary>
/// <param name="message"></param>
/// <returns></returns>
public static DialogResult Info(string message)
{
return MessageBox.Show(message, HANDLEHING, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
/// <summary>
/// 问题
/// </summary>
/// <param name="message"></param>
/// <returns></returns>
public static DialogResult Question(string message)
{
return MessageBox.Show(message, SYSTEMHINT, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
}
/// <summary>
/// 确定或取消
/// </summary>
/// <param name="message"></param>
/// <returns></returns>
public static DialogResult OkCancel(string message)
{
return MessageBox.Show(message, HANDLEHING, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
}
/// <summary>
/// 是否为空
/// </summary>
/// <param name="control"></param>
/// <param name="message"></param>
/// <returns></returns>
public static bool IsNull(Control control, string message)
{
if (control.Text.Trim() == "")
{
MessageBox.Show(message + "不能为空!", HANDLEHING, MessageBoxButtons.OK, MessageBoxIcon.Information);
control.Focus();
return true;
}
return false;
}
/// <summary>
/// 是否为空
/// </summary>
/// <param name="textBox"></param>
/// <param name="message"></param>
/// <returns></returns>
public static bool IsNull(TextBox textBox, string message)
{
if (textBox.Text.Trim() == "")
{
MessageBox.Show(message + "不能为空!", HANDLEHING, MessageBoxButtons.OK, MessageBoxIcon.Information);
textBox.Focus();
textBox.SelectAll();
return true;
}
return false;
}
public static bool IsNull(ComboBox comboBox, string message)
{
if (comboBox.Text.Trim() == "")
{
MessageBox.Show(message + "不能为空!", HANDLEHING, MessageBoxButtons.OK, MessageBoxIcon.Information);
comboBox.Focus();
comboBox.DroppedDown = true;
return true;
}
return false;
}
/// <summary>
/// 暗示
/// </summary>
/// <param name="textBox"></param>
/// <param name="message"></param>
public static void Hint(TextBox textBox, string message)
{
MessageBox.Show(message, SYSTEMHINT, MessageBoxButtons.OK, MessageBoxIcon.Information);
textBox.Focus();
textBox.SelectAll();
}
public static void Hint(Control control, string message)
{
MessageBox.Show(message, SYSTEMHINT, MessageBoxButtons.OK, MessageBoxIcon.Information);
control.Focus();
}
}
}