【实现步骤】
<1>编写单据插件,代码如下。
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Util;
using System.ComponentModel;
namespace Jac.XkDemo.BOS.Business.PlugIn
{
/// 【单据插件】使用指定编码规则生成单据编号
[Description("【单据插件】使用指定编码规则生成单据编号"), HotUpdate]
public class GetBillNoByRuleBillPlugIn : AbstractBillPlugIn
{
/// 主菜单点击事件
public override void BarItemClick(BarItemClickEventArgs e)
{
base.BarItemClick(e);
if (e.BarItemKey.EqualsIgnoreCase("GetBillNo"))
{
var ruleId = "5c2d7c846390e9";// 指定规则
var field = this.View.BillBusinessInfo.GetField("F_Jac_Text");// 指定字段
var billNos = BusinessDataServiceHelper.GetBillNoByField(this.Context, this.View.BillBusinessInfo, new[] { this.Model.DataObject }, true, ruleId, field, null);
if (billNos != null && billNos.Count > 0)
{
this.Model.SetValue(field.Key, billNos[0].BillNo);
}
}
}
}
}
推荐阅读