一、列表插件
列表插件弹出动态表单,传递参数,填充单据体数据原创
319次浏览
编辑于2024年09月30日 16:26:31
using Kingdee.BOS.Core.DynamicForm; using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; using Kingdee.BOS.Core.List.PlugIn; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace YC.YD.K3.BusinessPlugIn.ListPlugIn.SFC { [Kingdee.BOS.Util.HotUpdate] [Description("装箱单列表插件")] public class InBoxListPlugIn:AbstractListPlugIn { StringBuilder str = new StringBuilder(); public override void BarItemClick(BarItemClickEventArgs e) { base.BarItemClick(e); switch (e.BarItemKey.ToUpperInvariant()) { case "F_PETL_BUTTON": var disFidList = this.ListView.SelectedRowsInfo.Select(t => t.PrimaryKeyValue).Distinct<string>().ToList(); if (disFidList.Count > 0) { string strFid = string.Join(",", disFidList.ToArray()); DynamicFormShowParameter showParam = new DynamicFormShowParameter(); showParam.FormId = "k68e0686b6d5f4a9f830332443194fe73";// 装箱单拆箱动态表单唯一标识 showParam.CustomParams.Add("fids", strFid);// 向动态表单传递的参数 this.View.ShowForm(showParam, new Action<FormResult>((formResult) => { if (formResult != null && formResult.ReturnData != null) { } })); } else { this.View.ShowErrMessage("未选中任何行!", "未选中任何行!", MessageBoxType.Error); e.Cancel = true; } break; default: break; } } } }
二、动态表单插件
using Kingdee.BOS; using Kingdee.BOS.Core.DynamicForm; using Kingdee.BOS.Core.DynamicForm.PlugIn; using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; using Kingdee.BOS.Core.Metadata; using Kingdee.BOS.Core.Metadata.EntityElement; using Kingdee.BOS.Orm; using Kingdee.BOS.Orm.DataEntity; using Kingdee.BOS.ServiceHelper; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; namespace YC.YD.K3.BusinessPlugIn.DynamicFormPlugIn.SFC { [Kingdee.BOS.Util.HotUpdate] [Description("装箱单动态表单插件")] public class InBoxDynamicFormPlugIn: AbstractDynamicFormPlugIn { public override void OnLoad(EventArgs e) { base.OnLoad(e); string fids = this.View.OpenParameter.GetCustomParameter("fids").ToString(); if (!string.IsNullOrWhiteSpace(fids)) { string sql = string.Format(@"SELECT F_T_SERIAL '序列号',F_B_MaterialId '物料ID',F_B_UnitID '计量单位ID',FEntryId,F_T_MoNo '生产订单单号' FROM Y_QUA_InBoxE WHERE FID IN ('" + fids + "')"); DataTable dt = DBServiceHelper.ExecuteDataSet(this.Context, sql).Tables[0]; Entity entity = this.View.BillBusinessInfo.GetEntity("F_PJWR_Entity"); //转换成行 DynamicObjectCollection rows = this.Model.GetEntityDataObject(entity); if (dt.Rows.Count > 0) { rows.Clear(); for (int i = 0; i < dt.Rows.Count; i++) { DynamicObject row = new DynamicObject(entity.DynamicObjectType); entity.SeqDynamicProperty.SetValue(row, i + 1); row["F_B_MaterialId_Id"] = dt.Rows[i]["物料ID"].ToString(); FormMetadata FormMetadata1 = MetaDataServiceHelper.GetFormMetaData(this.Context, "BD_MATERIAL");// 物料 DynamicObject dynamicObject1 = BusinessDataServiceHelper.LoadSingle(this.Context, dt.Rows[i]["物料ID"].ToString(), FormMetadata1.BusinessInfo.GetDynamicObjectType()); row["F_B_MaterialId"] = dynamicObject1; row["F_B_UnitId_Id"] = dt.Rows[i]["计量单位ID"].ToString(); FormMetadata FormMetadata2 = MetaDataServiceHelper.GetFormMetaData(this.Context, "BD_UNIT");// 计量单位 DynamicObject dynamicObject2 = BusinessDataServiceHelper.LoadSingle(this.Context, dt.Rows[i]["计量单位ID"].ToString(), FormMetadata2.BusinessInfo.GetDynamicObjectType()); row["F_B_UnitId"] = dynamicObject2; row["F_T_SerialNo"] = dt.Rows[i]["序列号"].ToString(); row["F_T_FEntryId"] = dt.Rows[i]["FEntryId"].ToString(); row["F_T_MoNo"] = dt.Rows[i]["生产订单单号"].ToString(); rows.Add(row); } } } } public override void ButtonClick(ButtonClickEventArgs e) { //点击单据上的按钮,获取单据上字段值,更新数据库 base.ButtonClick(e); switch (e.Key.ToUpper()) { case "F_BU_CONFIRMED": break; case "F_BU_CANCEL": this.View.Close(); break; default: break; } } } }
赞 0
0人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!
推荐阅读