销售出库单与退货通知单建立关联不上,保存时没有异常信息输出,页面关联查询时查不出信息出来
代码:
namespace JZC.SCM.LLX.ServicePlugIn
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Kingdee.BOS;
using Kingdee.BOS.Util;
using Kingdee.BOS.Core;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Core.Metadata.EntityElement;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Contracts;
using Kingdee.BOS.App;
using Kingdee.BOS.Core.Metadata.FieldElement;
[Description("销售出库单与退货通知单建立关联")]
public class SAL_OutStockCreateLinkEntryForImport : AbstractOperationServicePlugIn
{
private const string POFormId = "SAL_OUTSTOCK";
public override void BeforeExecuteOperationTransaction(Kingdee.BOS.Core.DynamicForm.PlugIn.Args.BeforeExecuteOperationTransaction e)
{
DynamicObjectCollection objects;
string str;
string str2;
DynamicObjectCollection objects2;
base.BeforeExecuteOperationTransaction(e);
HashSet
Entity entity = base.BusinessInfo.GetEntity("FEntity");
Entity entity2 = base.BusinessInfo.GetEntity("FEntity_Link");
Field field = base.BusinessInfo.GetField("FSrcType");
Field field2 = base.BusinessInfo.GetField("FSrcBillNo");
foreach (ExtendedDataEntity entity3 in e.SelectedRows)
{
objects = entity.DynamicProperty.GetValue(entity3.DataEntity) as DynamicObjectCollection;
foreach (DynamicObject obj2 in objects)
{
str = field.DynamicProperty.GetValue
str2 = field2.DynamicProperty.GetValue
if (((!string.IsNullOrWhiteSpace(str) && !string.IsNullOrWhiteSpace(str2)) && str.EqualsIgnoreCase("SAL_OUTSTOCK")) && !poBillNos.Contains(str2))
{
objects2 = entity2.DynamicProperty.GetValue(obj2) as DynamicObjectCollection;
if (objects2.Count <= 0)
{
poBillNos.Add(str2);
}
}
}
}
if (poBillNos.Count != 0)
{
DynamicObject[] poObjs = this.LoadPurchaseOrder(poBillNos);
if ((poObjs != null) && (poObjs.Length != 0))
{
Dictionary
string pOEntryTableNumber = this.GetPOEntryTableNumber();
List
foreach (ExtendedDataEntity entity3 in e.SelectedRows)
{
objects = entity.DynamicProperty.GetValue(entity3.DataEntity) as DynamicObjectCollection;
foreach (DynamicObject obj2 in objects)
{
str = field.DynamicProperty.GetValue
str2 = field2.DynamicProperty.GetValue
if ((!string.IsNullOrWhiteSpace(str) && !string.IsNullOrWhiteSpace(str2)) && str.EqualsIgnoreCase("SAL_OUTSTOCK"))
{
Dictionary
if (dictionary.TryGetValue(str2, out dictionary2))
{
DynamicObject obj3 = obj2["MaterialId"] as DynamicObject;
if (obj3 != null)
{
string key = Convert.ToString(obj3["number"]);
DynamicObject obj4 = null;
if (dictionary2.TryGetValue(key, out obj4))
{
objects2 = entity2.DynamicProperty.GetValue(obj2) as DynamicObjectCollection;
if (objects2.Count <= 0)
{
DynamicObject linkRow = new DynamicObject(entity2.DynamicObjectType);
linkRow["STableName"] = pOEntryTableNumber;
this.FillLinkRow(obj4, obj2, linkRow);
objects2.Add(linkRow);
list.Add(linkRow);
}
}
}
}
}
}
}
ServiceHelper.GetService
}
}
}
private Dictionary
{
Dictionary
foreach (DynamicObject obj2 in poObjs)
{
string key = Convert.ToString(obj2["BillNo"]);
Dictionary
DynamicObjectCollection objects = obj2["SAL_OUTSTOCKENTRY"] as DynamicObjectCollection;
foreach (DynamicObject obj3 in objects)
{
DynamicObject obj4 = obj3["MaterialId"] as DynamicObject;
if (obj4 != null)
{
string str2 = Convert.ToString(obj4["number"]);
dictionary2[str2] = obj3;
}
}
dictionary.Add(key, dictionary2);
}
return dictionary;
}
private void FillLinkRow(DynamicObject srcRow, DynamicObject toRow, DynamicObject linkRow)
{
linkRow["FlowId"] = srcRow["FBFLowId_Id"];
linkRow["FlowLineId"] = 0;
linkRow["RuleId"] = "OutStock-SalReturnNotice";
linkRow["SBillId"] = ((DynamicObject)srcRow.Parent)[0];
linkRow["SId"] = srcRow[0];
//linkRow["FlowLineId"] = 0;
//linkRow["RuleId"] = "OutStock-SalReturnNotice";
//linkRow["SBillId"] = ((DynamicObject)srcRow.Parent)[0];
//linkRow["SId"] = srcRow[0];
}
private string GetPOEntryTableNumber()
{
return ServiceHelper.GetService
}
private DynamicObject[] LoadPurchaseOrder(HashSet
{
IViewService service = ServiceHelper.GetService
string formid = "SAL_OUTSTOCK";
List
new SelectorItemInfo("FID"),
new SelectorItemInfo("FEntity_FENTRYID"),
new SelectorItemInfo("FBillNo"),
new SelectorItemInfo("FMaterialId")
};
OQLFilter ofilter = OQLFilter.CreateHeadEntityFilter(string.Format(" FBillNo IN ('{0}') ", string.Join("','", poBillNos)));
return service.Load(base.Context, formid, selector, ofilter);
}
}
}
推荐阅读