BOM清单正查单据中增加获取物料采购价格的功能

BOM清单正查动态表单中,想增加一个字段,点击按钮后,获取子项物料对应的最新采购订单价格:

现在提示错误:
[{"operation":"ENG_BomQueryForward2.MBIClick.tbGetPrice"}]
发生时间:16:56:16
错误来源: Kingdee.BOS.DataEntity
错误信息:实体类型K28fdb471中不存在名为FBottomEntity的属性
===================================================
调用堆栈:
在 Kingdee.BOS.Orm.DataEntity.DynamicObject.get_Item(String propertyName)
在 LD.K3.MFG.Wlqdzc.ListGetPrice.GetPrice.ImportPrice() 位置 e:BosSrcLD.K3.MFG.Wlqdzc.ListGetPriceLD.K3.MFG.Wlqdzc.ListGetPriceGetPrice.cs:行号 57
在 LD.K3.MFG.Wlqdzc.ListGetPrice.GetPrice.BarItemClick(BarItemClickEventArgs e) 位置 e:BosSrcLD.K3.MFG.Wlqdzc.ListGetPriceLD.K3.MFG.Wlqdzc.ListGetPriceGetPrice.cs:行号 47
在 Kingdee.BOS.Core.DynamicForm.PlugIn.DynamicFormViewPlugInProxy.FireBarItemClick(BarItemClickEventArgs e)
在 Kingdee.BOS.Web.DynamicForm.DynamicWebFormView.BarItemClick(String parentKey, String barItemKey, BarDataManager bar, Int32 bartype)
在 Kingdee.BOS.Web.DynamicForm.DynamicWebFormView.MainBarItemClick(String barItemKey)
在 Kingdee.BOS.Web.DynamicForm.DynamicWebFormControl

源代码如下:(二开小白一枚,实在是不知道如何下手,请各位高手救人啊。)
using Kingdee.BOS;
using Kingdee.BOS.Core.CommonFilter;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;
using Kingdee.BOS.Core.Enums;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.BOS.Core.Metadata.FieldElement;
using Kingdee.BOS.Core.Metadata.FormElement;
using Kingdee.BOS.Core.NetworkCtrl;
using Kingdee.BOS.Core.Report;
using Kingdee.BOS.Core.SqlBuilder;
using Kingdee.BOS.Core.Util;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Orm.Metadata.DataEntity;
using Kingdee.BOS.Resource;
using Kingdee.BOS.ServiceHelper;
using Kingdee.K3.BD.ServiceHelper;
using Kingdee.K3.FIN.Business.PlugIn;
using Kingdee.K3.FIN.Core;
using Kingdee.K3.FIN.Core.Object;
using Kingdee.K3.FIN.Core.Parameters;
using Kingdee.K3.FIN.HS.Common.BusinessEntity;
using Kingdee.K3.FIN.HS.ServiceHelper;
using Kingdee.K3.FIN.ServiceHelper;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace LD.K3.MFG.Wlqdzc.ListGetPrice
{
public class GetPrice : AbstractDynamicFormPlugIn
{

public override void BarItemClick(BarItemClickEventArgs e)
{
string a = e.BarItemKey.ToUpper();
if (a == "TBGETPRICE")
{
ImportPrice();
}
}
private void ImportPrice()
{
Int32 vorgId = Convert.ToInt32(this.Context.CurrentOrganizationInfo.ID);
DynamicObject billObj = this.Model.DataObject;
//DynamicObjectCollection entityRows = billObj["FBottomEntity"] as DynamicObjectCollection;
DynamicObjectCollection entityRows = (DynamicObjectCollection)this.View.Model.DataObject["FBottomEntity"];

foreach (var entityRow in entityRows)
{
String vmaterialId = Convert.ToString(entityRow["MaterialId"]);
String vbomId = Convert.ToString(entityRow["BomId"]);
entityRow["F_LD_Last_Gr_Price"] = GetPoPrice(vorgId, vmaterialId, vbomId);
}
this.View.UpdateView("FBottomEntity");
}
private decimal GetPoPrice(Int32 orgId, String materialId, String bomId)
{
decimal lastPoprice = 0;
StringBuilder sql = new StringBuilder();
string sp = "rn";
sql.Append("select ftaxprice fromv_ld_last_po_price").Append(sp);
sql.Append("where Fpurchaseorgid= ").Append(orgId).Append(sp);
sql.Append("and Fmaterialid = ").Append(materialId).Append(sp);
sql.Append("and Fbomid = ").Append(bomId).Append(sp);
DataSet ds1 = DBServiceHelper.ExecuteDataSet(this.Context, sql.ToString());
if (ds1.Tables[0].Rows.Count > 0)
{
foreach (DataRow row in ds1.Tables[0].Rows)
{
lastPoprice = Convert.ToDecimal(row["ftaxprice"]);
}
}
return lastPoprice;
}
}
}

 

问题名称:BOM清单正查单据中增加获取物料采购价格的功能

点击链接查看答案:

https://club.kingdee.com/forum.php?mod=viewthread&tid=1347512

未经允许不得转载:友商问答 » BOM清单正查单据中增加获取物料采购价格的功能

赞 (0)