public override void BeforeExecuteOperationTransaction(BeforeExecuteOperationTransaction e)
        {
            base.BeforeExecuteOperationTransaction(e);
            HashSet <string> poBillNos    = new HashSet <string>();
            Entity           entity       = this.BusinessInfo.GetEntity("FInStockEntry");
            Entity           linkEntry    = this.BusinessInfo.GetEntity("FInStockEntry_Link");
            Field            fldSrcFormId = this.BusinessInfo.GetField("FSRCBILLTYPEID");
            Field            fldSrcBillNo = this.BusinessInfo.GetField("FSrcBillNo");

            // 对单据体进行循环,取关联的源单编号
            foreach (var billObj in e.SelectedRows)
            {
                DynamicObjectCollection entryRows = entity.DynamicProperty.GetValue(billObj.DataEntity)
                                                    as DynamicObjectCollection;
                foreach (var entryRow in entryRows)
                {
                    string srcFormId    = fldSrcFormId.DynamicProperty.GetValue <string>(entryRow);
                    string srcSrcBillNo = fldSrcBillNo.DynamicProperty.GetValue <string>(entryRow);
                    if (string.IsNullOrWhiteSpace(srcFormId) || !srcFormId.EqualsIgnoreCase(POFormId))
                    {// 源单不是采购订单,略过
                        continue;
                    }
                    // 源单编号已经登记,不再重复记录,略过
                    if (poBillNos.Contains(srcSrcBillNo))
                    {
                        continue;
                    }
                    // Link已经记录了源单信息,略过
                    DynamicObjectCollection linkRows = linkEntry.DynamicProperty.GetValue(entryRow)
                                                       as DynamicObjectCollection;
                    if (linkRows.Count > 0)
                    {
                        continue;
                    }
                    poBillNos.Add(srcSrcBillNo);
                }
            }
            if (poBillNos.Count == 0)
            {
                return;
            }
            DynamicObject[] poObjs = this.LoadPurchaseOrder(poBillNos);
            if (poObjs == null || poObjs.Length == 0)
            {
                return;
            }
            Dictionary <string, Dictionary <string, DynamicObject> > dctAllBills = this.BuildDictionary(poObjs);
            string srcTableNumber = this.GetPOEntryTableNumber();
            List <DynamicObject> allNewLinkRows = new List <DynamicObject>();

            // 循环单据体,为单据体,建立起源单关联信息:
            foreach (var billObj in e.SelectedRows)
            {
                DynamicObjectCollection entryRows = entity.DynamicProperty.GetValue(billObj.DataEntity)
                                                    as DynamicObjectCollection;
                foreach (var entryRow in entryRows)
                {
                    string srcFormId    = fldSrcFormId.DynamicProperty.GetValue <string>(entryRow);
                    string srcSrcBillNo = fldSrcBillNo.DynamicProperty.GetValue <string>(entryRow);
                    if (string.IsNullOrWhiteSpace(srcFormId) || !srcFormId.EqualsIgnoreCase(POFormId))
                    {// 源单不是采购订单,略过
                        continue;
                    }
                    Dictionary <string, DynamicObject> dctOneBill = null;
                    if (dctAllBills.TryGetValue(srcSrcBillNo, out dctOneBill) == false)
                    {
                        continue;
                    }
                    DynamicObject materialObj = entryRow["MaterialId"] as DynamicObject;
                    if (materialObj == null)
                    {
                        continue;
                    }
                    string        materialNumber = Convert.ToString(materialObj["number"]);
                    DynamicObject srcRow         = null;
                    if (dctOneBill.TryGetValue(materialNumber, out srcRow) == false)
                    {
                        continue;
                    }
                    // Link已经记录了源单信息,略过
                    DynamicObjectCollection linkRows = linkEntry.DynamicProperty.GetValue(entryRow) as DynamicObjectCollection;
                    if (linkRows.Count > 0)
                    {
                        continue;
                    }
                    DynamicObject linkRow = new DynamicObject(linkEntry.DynamicObjectType);
                    linkRow["STableName"] = srcTableNumber;
                    this.FillLinkRow(srcRow, entryRow, linkRow);
                    linkRows.Add(linkRow);
                    allNewLinkRows.Add(linkRow);
                }
            }
            // 为新建的源单关联信息,设置内码
            IDBService dbService = ServiceHelper.GetService <IDBService>();

            dbService.AutoSetPrimaryKey(this.Context, allNewLinkRows.ToArray(), linkEntry.DynamicObjectType);
        }