
【场景】选单时清空明细信息里面的已有分录
【案例】通过单据转换插件实现,选单时清空分录
<0>单据转换插件
```csharp
using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn;
using Kingdee.BOS.Core.Metadata.ConvertElement.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
namespace DynamicFormPlugIn.BillConvert
{
[Kingdee.BOS.Util.HotUpdate]
[System.ComponentModel.Description("选单时清空没保存的分录")]
public class ClearEntityRowWhileDraw_ServicePlugIn : AbstractConvertPlugIn
{
public static string EntityKey = "FPOOrderEntry";
public override void OnCreateDrawTarget(CreateDrawTargetEventArgs e)
{
var entity = e.TargetBusinessInfo.GetEntity(EntityKey);
if (entity == null)
return;
var billObj = e.TargetData;
if (!billObj.DynamicObjectType.Properties.ContainsKey(entity.EntryName))
return;
DynamicObjectCollection rowColl = billObj[entity.EntryName] as DynamicObjectCollection;
if (rowColl == null)
return;
for(int idx = rowColl.Count -1; idx>=0;--idx)
{
var row = rowColl[idx];