首先,注意:这是一个表单插件
通过该表单插件,捕获指定按钮的点击事件,在该点击事件中获取当前选中的账表的行记录
-
首先设置账表的单据体:允许多选
-
参考:https://vip.kingdee.com/article/330754769167828480?productLineId=1&isKnowledge=2&lang=zh-CN
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.Report.PlugIn;
using Kingdee.BOS.Util;
using System.ComponentModel;
using System.Data;
using System.Linq;namespace WeiWaiFaLiaoQingDan2
{/// <summary>/// 【账表表单插件】账表获取选中行/// </summary>[Description("【账表表单插件】账表获取选中行")]public class GetSelectedRowsSysReportPlugIn : AbstractSysReportPlugIn{public override void BarItemClick(BarItemClickEventArgs e){base.BarItemClick(e);if (e.BarItemKey.EqualsIgnoreCase("tbCreateTransfer")){base.BarItemClick(e);if (e.BarItemKey.EqualsIgnoreCase("tbCreateTransfer")){// SelectedDataRows存储了账表当前选中行(BOSIDE开启属性【允许多选】后,支持选中多行)var selectedDataRows = this.SysReportView.SelectedDataRows;if (selectedDataRows == null || selectedDataRows.Length == 0){this.View.ShowMessage("没有选择任何数据,请先选择数据!");return;}string msg = "";foreach (DataRow row in selectedDataRows){msg += GetDataRowFormatString(row);}this.View.ShowMessage("当前选中行数据包:" + msg);}}}private string GetDataRowFormatString(DataRow row){return string.Join(",", row.Table.Columns.Cast<DataColumn>().Select(co => string.Format("{0}:{1}", co.ColumnName, row[co.ColumnName])));}}}