开发一、k3cloud内服务工单过滤在库批号
功能介绍:当店面前台点击批号时,会自动过滤掉物料在库存中不存在的批号,弹出的批号主当列表中显示的只是在库的批号,如果不存在批号列表显示空
插件代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kingdee.BOS;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Core.SqlBuilder;
using Kingdee.BOS.Core.Metadata;
using System.ComponentModel;
using Kingdee.BOS.App.Data;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Util;
using Kingdee.K3.SCM.ServiceHelper;
namespace YaTai.k3.AfterSales.GD.BusinessPlugIn.SaleWorker
{
[Kingdee.BOS.Util.HotUpdate]
[Description("过滤在库批号")]
public class InventoryLot : AbstractBillPlugIn
{
/// <summary>
/// 显示基础资料列表之前调用
/// 通过重载本事件,可以设置必要的过滤条件,以限定检索范围;
/// </summary>
/// <param name="e"></param>
public override void BeforeF7Select(BeforeF7SelectEventArgs e)
{
switch (e.FieldKey.ToUpperInvariant())
{
case "F_PAEZ_LOT":
string forgId = "";
if((forgId=(this.View.Model.GetValue("F_PAEZ_OrgId") as DynamicObject)["Id"].ToString())!="")
{
//通过字段的Key[大写]来区分不同的基础资料
DynamicObjectCollection doc = GetQueryDatas(forgId,(this.View.Model.GetValue("F_PAEZ_BASE5", e.Row) as DynamicObject)["msterID"].ToString());
if (doc.Count > 0)
{
List<string> lot = new List<string>();
foreach (DynamicObject item in doc)
{
lot.Add(item["FLOT"].ToString());
}
string lots = string.Join(",", lot.ToArray());
e.ListFilterParameter.Filter = string.Format("FlotId in({0})", lots); //过滤的字段使用对应基础资料的字段的Key,支持ksql语法
}
else
{
e.ListFilterParameter.Filter ="1=2";
}
}
else
{
this.View.ShowMessage("库存组织是必填项!");
}
break;
case "":
break;
default:
break;
}
}
/// <summary>
/// queryservice取数方案,通过业务对象来获取数据,推荐使用
/// </summary>
/// <returns></returns>
public DynamicObjectCollection GetQueryDatas(string forgId,string F_PAEZ_BASE5)
{
QueryBuilderParemeter paramCatalog = new QueryBuilderParemeter()
{
FormId = "STK_Inventory",//取数的业务对象
FilterClauseWihtKey = string.Format(" FStockOrgId={0} and FMaterialId={1} and fbaseqty>0", forgId, F_PAEZ_BASE5),//过滤条件,通过业务对象的字段Key拼装过滤条件
SelectItems = SelectorItemInfo.CreateItems("FLOT", "FMaterialName", "Fid"),//要筛选的字段【业务对象的字段Key】,可以多个,如果要取主键,使用主键名
};
DynamicObjectCollection dyDatas = Kingdee.BOS.ServiceHelper.QueryServiceHelper.GetDynamicObjectCollection(this.Context, paramCatalog);
return dyDatas;
}
}
}