插件调用源数据方式生成单据和修改单据代码原创
138次浏览
编辑于2024年09月30日 16:09:05
/// <summary> /// 采购入库单单据生成 /// </summary> /// <param name="ctx">上下文</param> /// <param name="model">采购入库单实体</param> /// <returns></returns> public IOperationResultModel CreateSTK_InStock_Single(Context ctx, STK_InStockModel model) { IOperationResult result = null; FormMetadata Metadata = MetaDataServiceHelper.GetFormMetaData(ctx, "STK_InStock");//采购入库单单据的唯一标识 DynamicObject Head = Metadata.BusinessInfo.GetDynamicObjectType().CreateInstance() as DynamicObject; String billId = this.ChangeBillTypeNameToId(ctx, model.BillTypeName); #region 单据头-基本信息 FormMetadata OrderFormMetadata1 = MetaDataServiceHelper.GetFormMetaData(ctx, "ORG_Organizations");// 组织机构 DynamicObject dynamicObject1 = BusinessDataServiceHelper.LoadSingle(ctx,model.StockOrgId, OrderFormMetadata1.BusinessInfo.GetDynamicObjectType()); Head["BillTypeID_Id"] = billId; Head["DATE"] = model.Date; Head["BusinessType"] = model.BusinessType; Head["StockOrgId_Id"] = model.StockOrgId; Head["StockOrgId"] = dynamicObject1; Head["DemandOrgId_Id"] = model.DemandOrgId; Head["PurchaseOrgId_Id"] = model.PurchaseOrgId; Head["PurchaseDeptId_Id"] = model.PurchaseDeptId; Head["SupplierId_Id"] = model.SupplierId; Head["APSTATUS"] = model.APSTATUS; Head["TransferBizType"] = model.TransferBizType; Head["CorrespondOrgId_Id"] = model.CorrespondOrgId; Head["SplitBillType"] = model.SplitBillType; Head["SupplyId_Id"] = model.SupplyId; Head["SettleId_Id"] = model.SettleId; Head["ChargeId_Id"] = model.ChargeId; Head["CreateDate"] = DateTime.Now;//创建日期 #endregion #region 单据头-财务信息 DynamicObjectCollection dc1 = Head["InStockFin"] as DynamicObjectCollection; DynamicObject obj1 = dc1.DynamicCollectionItemPropertyType.CreateInstance() as DynamicObject; obj1["SettleOrgId_Id"] = model.SettleOrgId; obj1["PayOrgId_Id"] = model.PayOrgId; obj1["SettleCurrId_Id"] = model.SettleCurrId; obj1["OwnerTypeIdHead"] = model.OwnerTypeIdHead; obj1["OwnerIdHead_Id"] = model.OwnerIdHead; obj1["PriceTimePoint"] = model.PriceTimePoint; obj1["LocalCurrId_Id"] = model.LocalCurrId; obj1["ExchangeTypeId_Id"] = model.ExchangeTypeId; obj1["ExchangeRate"] = model.ExchangeRate; obj1["IsIncludedTax"] = model.IsIncludedTax; obj1["ISPRICEEXCLUDETAX"] = model.ISPRICEEXCLUDETAX; dc1.Add(obj1); #endregion #region 单据体 List<STK_InStockEModel> entrys = new List<STK_InStockEModel>(); DynamicObjectCollection dc3 = Head["InStockEntry"] as DynamicObjectCollection; foreach (var entry in entrys) { DynamicObject obj3 = dc3.DynamicCollectionItemPropertyType.CreateInstance() as DynamicObject; obj3["MaterialId_Id"] = entry.MaterialId; obj3["UnitID_Id"] = entry.UnitID; obj3["MustQty"] = entry.MustQty; obj3["RealQty"] = entry.RealQty; obj3["StockId_Id"] = entry.StockId; obj3["StockLocId_Id"] = entry.StockLocId; obj3["StockStatusId_Id"] = entry.StockStatusId; obj3["BaseUnitID_Id"] = entry.BaseUnitID; obj3["BaseUnitQty"] = entry.BaseUnitQty; obj3["StockFlag"] = entry.StockFlag; obj3["OWNERTYPEID"] = entry.OWNERTYPEID; obj3["OWNERID_Id"] = entry.OWNERID; obj3["KeeperTypeID"] = entry.KeeperTypeID; obj3["KeeperID_Id"] = entry.KeeperID; obj3["PriceUnitID_Id"] = entry.PriceUnitID; obj3["PriceUnitQty"] = entry.PriceUnitQty; obj3["TaxRate"] = entry.TaxRate; obj3["PriceCoefficient"] = entry.PriceCoefficient; obj3["JOINSTATUS"] = entry.JOINSTATUS; obj3["InvoicedStatus"] = entry.InvoicedStatus; obj3["PriceBaseQty"] = entry.PriceBaseQty; obj3["RemainInStockQty"] = entry.RemainInStockQty; obj3["RemainInStockBaseQty"] = entry.RemainInStockBaseQty; obj3["RemainInStockUnitId_Id"] = entry.RemainInStockUnitId; obj3["APNotJoinQty"] = entry.APNotJoinQty; dc3.Add(obj3); } #endregion OperateOption operateOption = OperateOption.Create(); result = BusinessDataServiceHelper.Save(ctx, Metadata.BusinessInfo, Head, null, ""); return this.MyIOperationResult(result); }
FormMetadata Metadata = MetaDataServiceHelper.GetFormMetaData(this.Context, "k9861e8979fcb4da9895bc28fbf65ac49");//通过单据唯一标识获取单据模板 DynamicObject Head = BusinessDataServiceHelper.LoadSingle(this.Context, fid, Metadata.BusinessInfo.GetDynamicObjectType()); DynamicObjectCollection dc = Head["FEntity"] as DynamicObjectCollection;//单据体 int seq = dc.Select(r => Convert.ToInt32(r["seq"])).Max() + 1;//单据体序号 DynamicObject obj = dc.DynamicCollectionItemPropertyType.CreateInstance() as DynamicObject;//新增一条 obj["Seq"] = seq; obj["F_T_Date"] = rec.date; obj["F_DE_Temperature"] = rec.temp; dc.Add(obj); OperateOption operateOption = OperateOption.Create(); IOperationResult result = BusinessDataServiceHelper.Save(_ctx, Metadata.BusinessInfo, Head, null, "");//保存单据 if (result.IsSuccess) { ret.isSuccess = true; ret.msg = "发送成功!"; } else { ret.isSuccess = false; ret.msg = "发送失败!"; }
赞 0
0人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!
推荐阅读