引入数据时,如何建立与源单的关联关系
金蝶云社区-冯少龙
冯少龙
0人赞赏了该文章 1,567次浏览 未经作者许可,禁止转载编辑于2016年09月23日 10:34:01

private DynamicObject[] LoadPurchaseOrder(HashSet poBillNos)
{
IViewService viewService = ServiceHelper.GetService();
string formId = "PUR_ReceiveBill";//单据标识

// 指定需要加载的采购订单字段
List fields = new List();
fields.Add(new SelectorItemInfo("FID")); // 单据主键
fields.Add(new SelectorItemInfo("FEntryID")); // 单据体主键
fields.Add(new SelectorItemInfo("FBillNo")); // 单据编号
fields.Add(new SelectorItemInfo("FBFLowId")); // 业务流程
fields.Add(new SelectorItemInfo("FMasterId")); // 物料
fields.Add(new SelectorItemInfo("FBaseUnitQty")); // 基本单位数量
fields.Add(new SelectorItemInfo("FJoinBaseQty")); // 基本单位关联数量
// 指定过滤条件
string filter = string.Format(" FBillNo IN ('{0}') ", string.Join("','", poBillNos));
OQLFilter ofilter = OQLFilter.CreateHeadEntityFilter(filter);
var objs = viewService.Load(this.Context, formId, fields, ofilter);
return objs;
}
///


/// 把采购订单单据体行构建为字典:Dictionary(单据编号, Dictionary(物料编码, 源单行));
///

///
///
private Dictionary> BuildDictionary(DynamicObject[] poObjs)
{
Dictionary> dctAllBills =
new Dictionary>();
foreach (var poObj in poObjs)
{
string billNo = Convert.ToString(poObj["BillNo"]);
Dictionary dctOneBill = new Dictionary();
DynamicObjectCollection entryRows = poObj["PUR_ReceiveEntry"] as DynamicObjectCollection;
foreach (var entryRow in entryRows)
{
DynamicObject materialObj = entryRow["FMaterialId"] as DynamicObject;//物料ID
if (materialObj == null) continue;
string materialNumber = Convert.ToString(materialObj["number"]);
dctOneBill[materialNumber] = entryRow;
}
dctAllBills.Add(billNo, dctOneBill);
}
return dctAllBills;
}

红色 代码 方法 是怎样的一个 逻辑 取不到值