各位大神:
我自己做了个应收合同,要下推收款单。都是用的WebService接口,需要做关联反写。我接口传过来的收款单没有关联应收合同,我测试点保存的时候他可以关联应收合同。下面是代码,仿照这个帖子做的。有点着急,开了个新帖。
{{{/article/2592939}}}
为什么接口没有触发这个事件。
namespace Kingdee.bos.LZH.ExpenseRequest
{
[Description("引入收款单,建立与应收合同的关联")]
public class CreateLinkEntryForSKD : AbstractOperationServicePlugIn
{
private const string POFormId = "PUR_PurchaseOrder";
public override void BeforeExecuteOperationTransaction(BeforeExecuteOperationTransaction e)
{
base.BeforeExecuteOperationTransaction(e);
//判断是否是同步过来的单据
HashSet
Entity entity = this.BusinessInfo.GetEntity("FRECEIVEBILLSRCENTRY");
Field fldSrcFormId = this.BusinessInfo.GetField("FSrcFormId");
Field fldSrcBillNo = this.BusinessInfo.GetField("FSrcBillNo");
foreach (var billObj in e.SelectedRows)
{
//DynamicObjectCollection entryRows = entity.DynamicProperty.GetValue(billObj.DataEntity) as DynamicObjectCollection;
DynamicObject BillHeads = billObj.DataEntity;
if (BillHeads["FIsNotSE"].ToString() == "True")
{
if (BillHeads["CONTACTUNITTYPE"].ToString() == "wer_LZHHTBH")
{
Entity entryEntity = this.BusinessInfo.GetEntity("FRECEIVEBILLSRCENTRY");
DynamicObjectCollection docCustomerContactIds = entity.DynamicProperty.GetValue(billObj.DataEntity) as DynamicObjectCollection;
if (docCustomerContactIds.Count == 0)
{
decimal Amount = (decimal)BillHeads["REALRECAMOUNTFOR"];
string FCONTACTUNIT = BillHeads["CONTACTUNIT_Id"].ToString();
string sql = "/*dialect*/select FID,FBILLNO from wer_t_Cust_Entry100032 where FContractNo='" + FCONTACTUNIT + "'";
DataSet ds = DBServiceHelper.ExecuteDataSet(this.Context, sql);
DataTable dt = ds.Tables[0];
//Entity entryEntity = this.BusinessInfo.GetEntity("FRECEIVEBILLSRCENTRY");
//DynamicObjectCollection docCustomerContactIds = entity.DynamicProperty.GetValue(billObj.DataEntity) as DynamicObjectCollection;
DynamicObject Entity = new DynamicObject(entryEntity.DynamicObjectType);
int[] newIds = Kingdee.BOS.ServiceHelper.DBServiceHelper.GetSequenceInt32(this.Context, "T_AR_RECEIVEBILLSRCENTRY", 1);
Entity["id"] = newIds[0];
Entity["Seq"] = 1;
Entity["SRCBILLID"] = dt.Rows[0]["FID"].ToString();
Entity["AFTTAXTOTALAMOUNT"] = Amount;
Entity["SRCCURRENCYID_id"] = 1;
Entity["SRCCURRENCYID"] = BillHeads["CURRENCYID"];//this.View.Model.GetValue("");
Entity["PLANRECAMOUNT"] = Amount;
Entity["REALRECAMOUNT"] = Amount;
Entity["SRCBILLTYPEID"] = "wer_LZHContract";
Entity["SRCBILLNO"] = dt.Rows[0]["FBILLNO"].ToString();// FCONTACTUNITList["Name"].ToString();
docCustomerContactIds.Add(Entity);
DynamicObject srcPackageRow = docCustomerContactIds[0];
DynamicObjectCollection Link = (DynamicObjectCollection)srcPackageRow["FRECEIVEBILLSRCENTRY_Link"];
//写入FRECEIVEBILLSRCENTRY_Link合同管理信息
Entity linkEntry = this.BusinessInfo.GetEntity("FRECEIVEBILLSRCENTRY_Link");
DynamicObject linkRow = new DynamicObject(linkEntry.DynamicObjectType);
linkRow["STableName"] = "wer_t_Cust_Entry100032";
linkRow["RuleId"] = "813eb52e-5864-4742-8213-d8f9b0972d4f";
linkRow["SBillId"] = dt.Rows[0]["FID"].ToString();
linkRow["SId"] = dt.Rows[0]["FID"].ToString();
Link.Add(linkRow);
//给关联信息增加ID
IDBService dbService = ServiceHelper.GetService
dbService.AutoSetPrimaryKey(this.Context, Link.ToArray(), linkEntry.DynamicObjectType);
}
}
}
}
}
}
}
推荐阅读