MESSAGE弹窗封装类
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace aaaaa
{
/// <summary>
/// message类 封装弹窗
/// </summary>
public class Msg
{
#region 业务数据反馈
/// <summary>
/// 二次确认 2改/3除
/// </summary>
/// <param name="type">2为修改,3为删除</param>
/// <returns></returns>
public static DialogResult Confirm(int type)
{
string msg = "你确定要删除该条数据?";
if (type == 2) msg = "你确定要修改该条数据?";
DialogResult drResult = MessageBox.Show(msg, "二次确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
return drResult;
}
public static DialogResult QtpCfm()
{
string msg = "获取价格、备注将覆盖原有项?";
DialogResult drResult = MessageBox.Show(msg, "二次确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
return drResult;
}
public static void FreeMsg(string msg)
{
MessageBox.Show(msg, "提示");
}
public static void fmtMsg(string msg)
{
MessageBox.Show(msg, "参数验证");
}
public static void ParamNull(string param)
{
fmtMsg($"{param}不能为空");
}
public static void ParamAsis()
{
fmtMsg("数据未做修改");
}
#endregion
#region 操作正误反馈
/// <summary>
/// 操作反馈 1加2改3删
/// </summary>
public static void RstYes(int type)
{
string str = dostr(type);
MessageBox.Show(str + "成功", "执行结果");
}
public static void nodata()
{
MessageBox.Show("暂时没有数据", "提示");
}
public static void RstNo(int type)
{
string str = dostr(type);
MessageBox.Show(str + "失败", "执行结果");
}
public static void RstFalse(string msg)
{
MessageBox.Show("操作失败,请检查" + msg + "是否重复", "执行结果");
}
public static void RstExport()
{
MessageBox.Show("请检查是否有报价项", "导出失败");
}
#endregion
public static string dostr(int type)
{
switch (type)
{
case 1: return "添加";
case 2: return "修改";
case 3: return "删除";
case 4: return "登录";
default: return "操作";
}
}
public enum mode
{
add = 1,
update = 2,
del = 3,
login = 4
}
}
}
查看更多关于C#中MESSAGEBOX 、confirm弹窗封装类的详细内容...