using Kingdee.BOS.Orm.DataEntity; using Kingdee.K3.Core.MFG.EntityHelper; using System.ComponentModel; using System; using System.Collections.Generic; using System.Linq; using System.Text; using Kingdee.BOS.Core.Bill.PlugIn; using Kingdee.BOS.ServiceHelper; using Kingdee.BOS.Util; using Kingdee.K3.Core.BD.ServiceArgs; using Kingdee.K3.MFG.Common.BusinessEntity.PRD; using Kingdee.K3.BD.ServiceHelper; using Kingdee.K3.Core.BD; using Kingdee.BOS.Core.List.PlugIn; using Kingdee.BOS.Orm; using Kingdee.BOS.Core.DynamicForm; using Kingdee.BOS.Log; using Kingdee.K3.Core.MFG; using Kingdee.BOS.Core.SqlBuilder; using Kingdee.BOS.Core.Metadata; using Kingdee.K3.MFG.ServiceHelper; using Kingdee.BOS; using Kingdee.BOS.Core.DynamicForm.PlugIn.Args; using Kingdee.BOS.Core.List; namespace Demo.BillView.PRD { [Description("提料计划列表 列表插件")] [HotUpdate] public class PODemandPlanListFilter : AbstractListPlugIn { public override void BarItemClick(BarItemClickEventArgs e) { base.BarItemClick(e); //关闭 if (e.BarItemKey.ToUpper().Equals("BTNCLOSE")) {                 //获取选择记录                 ListSelectedRowCollection selectRows = this.ListView.SelectedRowsInfo; //读取ID,放到数组 string[] ID = selectRows.GetPrimaryKeyValues(); string FID = ""; //没有选择行提示 if (ID.Length == 0) {                     //如果选择的是0,即没有选择行记录,弹窗报错,返回                     this.View.ShowMessage("请选择单据!", MessageBoxType.Notice); return; } else { //如果点击成功,循环ID for (int i = 0; i < ID.Length; i++) { FID = FID + ID[i].ToString() + ","; } FID = FID.Substring(0, FID.Length - 1); string sql = string.Format(@"/*dialect*/ update Cg_PODemandPlanBillMain set FHCloseMan = {0}, FHCloseDate = GETDATE(), FHCloseType = 1 where fid IN ({1})", Context.UserId, FID); DBServiceHelper.Execute(Context, sql); sql = string.Format(@"/*dialect*/ UPDATE A SET A.FPODemandPlanCount -= B.FHQTY FROM t_PUR_POOrderEntry A JOIN Cg_PODemandPlanBillSub B ON A.FENTRYID = B.FHPOOrderEntryID where B.FID IN (select FID FROM Cg_PODemandPlanBillMain WHERE FHCloseType = 0 AND FID IN ({0})) AND B.FCLOSESTATUS = 0 ", FID); this.View.Refresh(); this.View.ShowMessage("操作成功"); } } } public override void PrepareFilterParameter(global::Kingdee.BOS.Core.List.PlugIn.Args.FilterArgs e) { base.PrepareFilterParameter(e); //如果过滤条件含有最新结果关键字,则在此基础上处理,以支持最新结果内置方案另存增加条件(关键字是根据生产订单状态过滤) if (e.FilterString.IsNullOrEmptyOrWhiteSpace()) { int FSupplierId = GetSupplierId(); if (FSupplierId > 0) e.FilterString = $" FSUPPLIERID IN ({FSupplierId})"; } else { int FSupplierId = GetSupplierId(); if (FSupplierId > 0) e.FilterString += $" AND FSUPPLIERID IN (FSupplierId)"; } } public int GetSupplierId() { long userId = this.Context.UserId; string sql = $"/*dialect*/ select FSupplierId from T_SEC_user a join T_SCP_USERDATA b on a.FUSERID = b.FUSERID where FUSERTYPE = 2 and a.FUSERID ={userId}"; ////LogHelper.Info(sql); int FSupplierId = DBServiceHelper.ExecuteScalar(Context, sql, 0); return FSupplierId; } } }