/******************************
* 说明:弹出框
* 创建人:龚宇超
* 创建日期:2017-08-09
* 修改人:
* 修改日期:
* 修改备注:
* 版本:1.0.0.0
******************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.XtraEditors;
using Lskj.Data;
using System.Windows.Forms;
using System.Diagnostics;
using Lskj.Business.Impl;
using Lskj.Control.Model;
using Lskj.Business;
namespace Lskj.Control
{
///
/// 系统消息框
///
public sealed class MessageUtil
{
///
/// 说明:弹出Ok对话框
/// 创建人:龚宇超
/// 创建日期:2017-08-09
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
///
public static DialogResult Show(string msg)
{
if (!string.IsNullOrEmpty(msg) && msg.Contains("与另一个进程被死锁在"))
msg = "网络连接超时,请稍候再试!";
if (Business.Impl.LanguageTranslation.Translatable)
{
msg = Business.Impl.LanguageTranslation.GetTranslatedText(msg);
}
return XtraMessageBox.Show(msg, ResourceKeys.SystemTip, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
///
/// 说明:弹出报错信息提示框
/// 创建人:曹屹峰
/// 创建日期:2021-09-10
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
///
public static DialogResult Show(string msg, string errorMessage )
{
if (!string.IsNullOrEmpty(errorMessage) && errorMessage.Contains("与另一个进程被死锁在"))
{
errorMessage = "网络连接超时,请稍候再试!";
if (Business.Impl.LanguageTranslation.Translatable)
{
errorMessage = Business.Impl.LanguageTranslation.GetTranslatedText(errorMessage);
}
return XtraMessageBox.Show(errorMessage, ResourceKeys.SystemTip, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
if (!string.IsNullOrEmpty(errorMessage) && errorMessage.Contains("事务在触发器中结束。批处理已中止"))
{
if (Business.Impl.LanguageTranslation.Translatable)
{
errorMessage = Business.Impl.LanguageTranslation.GetTranslatedText(errorMessage);
}
return XtraMessageBox.Show(errorMessage, ResourceKeys.SystemTip, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
DevExpress.XtraEditors.Controls.Localizer.Active = new MessboxClass();
MessageBoxButtons msgButton = MessageBoxButtons.YesNo;
DialogResult dr = new DialogResult();
if (Business.Impl.LanguageTranslation.Translatable)
{
msg = Business.Impl.LanguageTranslation.GetTranslatedText(msg);
}
dr = XtraMessageBox.Show(msg, ResourceKeys.SystemTip, msgButton, MessageBoxIcon.Information);
if (dr != DialogResult.Yes && !string.IsNullOrWhiteSpace(errorMessage))
{
errorMessage = ErrorMessage.StackTrace;
if (SystemInfo.Instance.HideErrorSQL)
{
errorMessage= errorMessage.Split(new string[] { "SQL=[" }, StringSplitOptions.None)[0];
}
XtraMessageBox.Show(errorMessage, ResourceKeys.SystemTip, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
DevExpress.XtraEditors.Controls.Localizer.Active = null;
return DialogResult.OK;
}
///
/// 说明:弹出Ok对话框
/// 创建人:龚宇超
/// 创建日期:2017-12-07
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The ex.
/// DialogResult.
public static DialogResult Show(Exception ex)
{
if (Debugger.IsAttached)
{
string msg = ex == null ? ResourceKeys.UnKownErrorTip : ex.StackTrace;
if (!string.IsNullOrEmpty(msg) && msg.Contains("与另一个进程被死锁在"))
msg = "网络连接超时,请稍候再试!";
if (Business.Impl.LanguageTranslation.Translatable)
{
msg = Business.Impl.LanguageTranslation.GetTranslatedText(msg);
}
return XtraMessageBox.Show(ex.Message, ResourceKeys.SystemTip, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
string msg = ex == null ? ResourceKeys.UnKownErrorTip : ex.Message; //ResourceKeys.SystemErrorTip + "\r\n" + ex.Message + "\r\n" + ex.StackTrace;
if (!string.IsNullOrEmpty(msg) && msg.Contains("与另一个进程被死锁在"))
msg = "网络连接超时,请稍候再试!";
if (Business.Impl.LanguageTranslation.Translatable)
{
msg = Business.Impl.LanguageTranslation.GetTranslatedText(msg);
}
//DialogResult result = Show(ex.Message, MessageBoxButtons.OKCancel);
//if (result == DialogResult.OK)
//{
// // 写入数据到lscrm
// bool isSuccess = BaseImpl.AddExceptionToLsCrm(msg);
// Show(isSuccess ? ResourceKeys.ExceptionSaveSuccess : ResourceKeys.ExceptionSaveFault);
//}
return Show(msg);
}
}
///
/// 说明:弹出是否对话框
/// 创建人:龚宇超
/// 创建日期:2017-08-09
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The MSG.
/// The buttons.
public static DialogResult Show(string msg, MessageBoxButtons buttons)
{
if (Business.Impl.LanguageTranslation.Translatable)
{
msg = Business.Impl.LanguageTranslation.GetTranslatedText(msg);
}
return XtraMessageBox.Show(msg, ResourceKeys.SystemTip, buttons, M