二开--销售订单物料变化后更改供应组织并取对应组织的BOM版本号
using System;
using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using System.ComponentModel;
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Core.Metadata.FieldElement;
using Kingdee.BOS.Model.DynamicForm;
using Kingdee.BOS.Web.DynamicForm;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Core.Bill.PlugIn.Args;
namespace ZJX.T_PLN_PLANORDER.Business.PlugIn
{
[Kingdee.BOS.Util.HotUpdate]
[Description("销售订单选择物料后更新供应组织和BOM版本号")]
public class SaleOrder_FZSX : AbstractBillPlugIn
{
public override void DataChanged(DataChangedEventArgs e)
{
base.DataChanged(e);
if (e.Field.Key == "FMaterialId")
{
DynamicObject matObj = this.View.Model.GetValue("FMaterialId", e.Row) as DynamicObject; //获取当前行物料数据包
if (matObj != null)
{
long FMATERIALID = Convert.ToInt64(matObj["ID"]); //获取物料ID
string matNum1 = Convert.ToString(matObj["Number"]); //#物料编码,字符串类型
DynamicObject OrgObj = matObj["F_ora_OrgId"] as DynamicObject;
if (OrgObj != null)
{
long MatOrgId = Convert.ToInt64(OrgObj["Id"]); //#物料上的供应组织,字符串类型
this.View.Model.SetValue("FSUPPLYORGID", MatOrgId, e.Row);
this.View.UpdateView("FSUPPLYORGID", e.Row);
}
string sql3 = string.Format(@"/*dialect*/SELECT TOP 1 TB.FID FROM T_BD_MATERIAL T INNER JOIN T_ENG_BOM TB ON T.FMATERIALID=TB.FMATERIALID WHERE T.F_ora_OrgId=TB.FUSEORGID
AND TB.FFORBIDSTATUS='A' AND TB.FDOCUMENTSTATUS='C' AND T.FNUMBER='{0}' ORDER BY TB.FNUMBER DESC;", matNum1);
DynamicObjectCollection Dyobjs3 = DBUtils.ExecuteDynamicObject(this.Context, sql3);
if (Dyobjs3.Count == 0)
{
this.View.Model.SetValue("BomId", "", e.Row);
return;
}
else
{
string BOMid = Convert.ToString(Dyobjs3[0]["FID"]);
this.View.Model.SetValue("BomId", BOMid, e.Row);
this.View.UpdateView("BomId", e.Row);
}
}
}
}
}
}
插件还要取消系统中的表体实体服务规则,供应组织=库存组织,不然不生效
二开--销售订单物料变化后更改供应组织并取对应组织的BOM版本号
本文2024-09-16 17:14:19发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-14419.html