单据转换插件提示消息原创
金蝶云社区-eris
eris
13人赞赏了该文章 2151次浏览 未经作者许可,禁止转载编辑于2021年03月11日 10:45:57

说明: 单据转换运行在app层,只能通过抛出异常或结果提示消息, 最后参考代码

1,单据转换终止,显示错误,通过直接抛出异常实现,如下图:

image.png

2,单据转换终止,显示错误,通过操作结果验证错误实现

image.png

3,正常显示下游单据,并在下游单据显示提示信息,如果转换没有下游单据数据包,那么都会在上游单据显示错误信息

image.png

4,参考代码

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Linq;

using System.Text;


using Kingdee.BOS;

using Kingdee.BOS.Core;

using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn;

using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args;

using Kingdee.BOS.Core.Metadata.ConvertElement;

using Kingdee.BOS.Core.Validation;



namespace Kingdee.BOS.TestPlugIn.BillABillB

{

    [Kingdee.BOS.Util.HotUpdate]

    [Description("转换插件显示信息示例")]

    public class ConvertPlugInShowMsgDemo : AbstractConvertPlugIn

    {


 /// <summary>

        /// 假设在转换之后事件显示某些提示信息,一般有下面三种方式

        /// </summary>

        /// <param name="e"></param>

        public override void AfterConvert(AfterConvertEventArgs e)

        {

            //1,单据转换终止,显示错误,通过直接抛出异常实现

            throw new KDException("ErrorCode", "抛出异常--发生错误终止转换");


            //2,单据转换终止,显示错误,通过操作结果验证错误实现

            this.OperationResult.IsShowInfoInTargetBill = false; //不显示下游单据

            string displayToFieldKey="FFieldKey"; //字段信息

            string  billPKID=""; //上游单据内码

            int dataEntityIndex=0; //发生错误在数据包集合中的索引

            int rowIndex=0; //具体那行分录索引

            string id="FID";

            string message = "操作结果验证错误---上游单据显示错误--发生错误终止转换";

            string title="发生异常";

            ErrorLevel level = ErrorLevel.Error;//错误级别

            ValidationErrorInfo errorInfo = new ValidationErrorInfo(displayToFieldKey, billPKID, dataEntityIndex, rowIndex, id, message, title, level);

            this.OperationResult.ValidationErrors.Add(errorInfo);


            //3,正常显示下游单据,并在下游单据显示提示信息,如果转换没有下游单据数据包,那么都会在上游单据显示错误信息

            this.OperationResult.IsShowInfoInTargetBill = true; //不显示下游单据

            displayToFieldKey = "FFieldKey"; //字段信息

            billPKID = ""; //上游单据内码

            dataEntityIndex = 0; //发生错误在数据包集合中的索引

            rowIndex = 0; //具体那行分录索引

            id = "FID";

            message = "操作结果验证信息--下游单据显示错误---发生警告信息";

            title = "发生警告";

            level = ErrorLevel.Warning;//错误级别

            errorInfo = new ValidationErrorInfo(displayToFieldKey, billPKID, dataEntityIndex, rowIndex, id, message, title, level);

            this.OperationResult.ValidationErrors.Add(errorInfo);

        }

    }

}


赞 13