有几个问题:
二次开发做的A单据有2条分录体记录,按每一个分录体记录生成的B单据(这里有2条分录体记录,生成2个B单据);
从A单据分录体生成到B单据的单头信息,源单类型和源单编号都在表头
目前是配置单据转换,手工下推是没有问题。
客户需求A单据审核时自动下推生成,通过写插件的方式,A单据和B单据间的关联关系没有写进去
代码如下:
Entity linkEntry = billView.BusinessInfo.GetEntity("FBillHead_Link");
Field fldSrcFormId = billView.BusinessInfo.GetField("F_SB_SourceBillType");//源单类型
Field fldSrcBillNo = billView.BusinessInfo.GetField("F_SB_SourceBillNo");//源单编号
List
string srcTableNumber = this.GetSEEntryTableNumber();
DynamicObjectCollection linkRows = this.View.Model.GetEntityDataObject(linkEntry);
DynamicObject linkRow = new DynamicObject(linkEntry.DynamicObjectType);
linkRow["STableName"] = srcTableNumber;
string StrSql = string.Format(@"select t1.FENTRYID,t1.fid,t1.F_SB_Qty from SB_t_CustomizedBill t
inner join SB_t_CustomizedBillEntry t1 on t.fid=t1.fid
where t.FBillNo IN ('{0}') and t1.F_SB_Item={1}", FBILLNO, logICItemID);
DataSet ds = DBUtils.ExecuteDataSet(this.Context, StrSql);
int fid=int.Parse(ds.Tables[0].Rows[0]["fid"].ToString());
int fentryid=int.Parse(ds.Tables[0].Rows[0]["FENTRYID"].ToString());
this.FillLinkRow(fid,fentryid , decimal.Parse(ds.Tables[0].Rows[0]["F_SB_Qty"].ToString()), linkRow);
linkRows.Add(linkRow);
allNewLinkRows.Add(linkRow);
IDBService dbService = ServiceHelper.GetService
dbService.AutoSetPrimaryKey(this.Context, allNewLinkRows.ToArray(), linkEntry.DynamicObjectType);
private void FillLinkRow(int FID, int FENTRYID, decimal F_SB_Qty, DynamicObject linkRow)
{
//linkRow["FlowId"] = srcRow["FBFLowId_Id"];
linkRow["FlowLineId"] = 0;
linkRow["RuleId"] = "SB_DesignBill-CustomizedBill";
linkRow["SBillId"] = FID;
linkRow["SId"] = FENTRYID;
// 原始携带量
linkRow["F_SB_QtyOld"] = F_SB_Qty;
linkRow["F_SB_Qty"] = F_SB_Qty;
}
推荐阅读