二开方案示例:总账凭证分录自定义排序(以摘要排序为例)
1.打开BOS IDE扩展凭证,列表添加排序菜单。
2.新增列表插件,代码如下。
using Kingdee.BOS.Core; using Kingdee.BOS.Core.DynamicForm; using Kingdee.BOS.Core.List.PlugIn; using Kingdee.BOS.Core.Metadata; using Kingdee.BOS.Orm; using Kingdee.BOS.Orm.DataEntity; using Kingdee.BOS.ServiceHelper; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Kingdee.K3.FIN.GL.Business.PlugIn.Voucher { public class VoucherOrder : AbstractListPlugIn { public override void BarItemClick(BOS.Core.DynamicForm.PlugIn.Args.BarItemClickEventArgs e) { base.BarItemClick(e); switch (e.BarItemKey.ToUpperInvariant()) { // 排序 case "ORDER": OrderByCustomizeField(); break; } } /// <summary> /// 凭证分录自定义排序 /// </summary> private void OrderByCustomizeField() { var selectRows = this.ListView.SelectedRowsInfo; if (selectRows == null || selectRows.Count == 0) { return; } // 获取凭证列表界面勾选的总账凭证id string[] vchIds = selectRows.GetPrimaryKeyValues(); // 加载所勾选总账凭证信息 FormMetadata metaData = FormMetaDataCache.GetCachedFormMetaData(this.Context, "GL_VOUCHER") as FormMetadata; DynamicObject[] lstVoucherInfo = BusinessDataServiceHelper.Load(this.Context, vchIds, metaData.BusinessInfo.GetDynamicObjectType()); for (int i = 0; i < lstVoucherInfo.Count(); i++) { // 获取该张总账凭证分录 DynamicObjectCollection entrys = lstVoucherInfo[i]["GL_VOUCHERENTRY"] as DynamicObjectCollection; if (entrys == null || entrys.Count == 0) { continue; } List<DynamicObject> rows = new List<DynamicObject>(); foreach (var row in entrys) { rows.Add(row); } // 分录按照摘要排序 rows = rows.OrderBy(o => Convert.ToString(o["FEXPLANATION"])).ToList(); // 按排序后结果重置行序号 entrys.Clear(); for (int k = 0; k < rows.Count;k++ ) { rows[k]["Seq"] = k+1; entrys.Add(rows[k]); } } var result = BusinessDataServiceHelper.Save(this.Context, metaData.BusinessInfo, lstVoucherInfo, OperateOption.Create(), OperationNumberConst.OperationNumber_Save); if (result == null || result.OperateResult == null) { return; } StringBuilder sbResult = new StringBuilder(); if (result.OperateResult.Count > 0) { foreach (var item in result.OperateResult) { sbResult.AppendLine(item.Message); } } if (result.ValidationErrors.Count > 0) { foreach (var item in result.ValidationErrors) { sbResult.AppendLine(item.Message); } } this.View.ShowMessage(sbResult.ToString()); } } }
二开方案示例:总账凭证分录自定义排序(以摘要排序为例)
1.打开BOS IDE扩展凭证,列表添加排序菜单。2.新增列表插件,代码如下。using Kingdee.BOS.Core;using Kingdee.BOS.Core.DynamicForm;usin...
点击下载文档
本文2024-09-23 01:38:57发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-147263.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章