二开案例.表单插件.单据体上移下移数据行

【案例演示】采购订单,针对明细信息单据体,上移下移数据行。

【实现步骤】
<1>编写表单插件,代码如下。
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;
using Kingdee.BOS.Util;
using System;
using System.ComponentModel;
namespace Jac.XkDemo.BOS.Business.PlugIn
{
/// <summary>
/// 【表单插件】单据体上移下移数据行
/// </summary>
[Description("【表单插件】单据体上移下移数据行"), HotUpdate]
public class MoveUpAndMoveDownPlugIn : AbstractDynamicFormPlugIn
{
#region var
/// <summary>
/// 单据体的Key
/// </summary>
private string EntryEntityKey = "FPOOrderEntry";
#endregion
/// <summary>
/// 分录行菜单点击事件
/// </summary>
/// <param name="e"></param>
public override void EntryBarItemClick(BarItemClickEventArgs e)
{
base.EntryBarItemClick(e);
if (e.BarItemKey.Equals("tbMoveUp", StringComparison.OrdinalIgnoreCase))
{
if (string.IsNullOrEmpty(this.View.BillBusinessInfo.GetEntity(EntryEntityKey).SeqFieldKey))
{
MoveEntryRow(this.View, EntryEntityKey, true);
}
else
{
MoveEntryRowBySeq(this.View, EntryEntityKey, true);
}
}
if (e.BarItemKey.Equals("tbMoveDown", StringComparison.OrdinalIgnoreCase))
{
if (string.IsNullOrEmpty(this.View.BillBusinessInfo.GetEntity(EntryEntityKey).SeqFieldKey))
{
MoveEntryRow(this.View, EntryEntityKey, false);
}
else
{
MoveEntryRowBySeq(this.View, EntryEntityKey, false);
}
}
}
/// <summary>
/// 移动分录行
/// </summary>
/// <param name="view"></param>
/// <param name="key"></param>
/// <param name="isUp"></param>
private static void MoveEntryRow(IDynamicFormView view, string key, bool isUp)
{
var rowIndex = view.Model.GetEntryCurrentRowIndex(key);
if (isUp)
{
// 上移
if (rowIndex <= 0)
{
return;
}
view.Model.MoveUpEntryRow(key, rowIndex);
view.GetControl<EntryGrid>(key).SetFocusRowIndex(rowIndex - 1);
view.ShowMessage("数据行已上移");
return;
}
else
{
// 下移
var rowCount = view.Model.GetEntryRowCount(key);
if (rowIndex < 0 || rowIndex >= rowCount - 1)
{
return;
}
view.Model.MoveDownEntryRow(key, rowIndex);
view.GetControl<EntryGrid>(key).SetFocusRowIndex(rowIndex + 1);
view.ShowMessage("数据行已下移");
return;
}
}
/// <summary>
/// 移动分录行
/// </summary>
/// <param name="view"></param>
/// <param name="key"></param>
/// <param name="isUp"></param>
private static void MoveEntryRowBySeq(IDynamicFormView view, string key, bool is
二开案例.表单插件.单据体上移下移数据行
声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。



