主表单关联目标表单进行赋值操作(主子表)
主表单关联目标表单进行赋值操作
//和OnLoad平级,为重写方法 protected override void OnWorkflowInstanceStateChanged(H3.Workflow.Instance.WorkflowInstanceState oldState, H3.Workflow.Instance.WorkflowInstanceState newState) { //流程审批结束事件(先执行业务规则,在执行该方法)。 if(oldState == H3.Workflow.Instance.WorkflowInstanceState.Running && newState == H3.Workflow.Instance.WorkflowInstanceState.Finished) { // string activity = this.Request.ActivityCode; // string userId = this.Request.UserContext.UserId; //只在流程结束执行,自动在入库单填充数据 // if(this.Request.BizObject.actionName == "Submit" && activity == "ActivityEnd") //{ //办公耗材入库单的构建schema H3.DataModel.BizObjectSchema schema = this.Request.Engine.BizObjectManager.GetPublishedSchema("D1505165b8d9780f9e349ab90537f34db37d255"); //new办公耗材入库单一个对象 H3.DataModel.BizObject targetBo = new H3.DataModel.BizObject(this.Engine, schema, this.Request.UserContext.UserId); //获取到采购申请单子表的对象 H3.DataModel.BizObject[] childBo2 = (H3.DataModel.BizObject[]) this.Request.BizObject["D150516shoppingList"]; if(childBo2 != null && childBo2.Length > 0) { //加一个list集合,将数据天聪至集合中 ListchildList = new List (); //获取到采购申请单的对象 H3.DataModel.BizObject targetBo2 = H3.DataModel.BizObject.Load(this.Request.UserContext.UserId, this.Engine, "D150516purchasingApplication", this.Request.BizObjectId, false); foreach(H3.DataModel.BizObject child in childBo2) { //获取到办公耗材入库单子表的对象 H3.DataModel.BizObject childBo = new H3.DataModel.BizObject(this.Request.Engine, schema.GetChildSchema("D150516storageTime"), this.Request.UserContext.UserId); //办公耗材入库单的办公耗材采购申请单号对应采购申请单的办公耗材采购申请单号 targetBo["godown"] = this.Request.BizObjectId + string.Empty; //采购日期 targetBo["purchaseTime"] = this.Request.BizObject["time"] + string.Empty; //总金额 targetBo["totalMoney"] = this.Request.BizObject["totalAmount"] + string.Empty; //物料名称 childBo["joinMaterial"] = child["materialName"] + string.Empty; //类别 childBo["kind"] = child["kind"] + string.Empty; //一级类别 childBo["categoryName1"] = child["categoryName1"] + string.Empty; //二级类别 childBo["categoryName2"] = child["categoryNamecategoryName2"] + string.Empty; //区域 childBo["dictionaryState"] = child["address"] + string.Empty; //编码 childBo["coding"] = child["coding"] + string.Empty; //单价 childBo["price"] = child["price"] + string.Empty; //数量 childBo["number"] = child["number"] + string.Empty; //计量单位 childBo["measureUnit"] = child["measuringUnit"] + string.Empty; //规格型号 childBo["model"] = child["specifications"] + string.Empty; //总价 childBo["totalPrices"] = child["totalPrice"] + string.Empty; //供应商 childBo["joinPersonnel"] = child["joinPersonnel"] + string.Empty; //将数据添加到子表 childList.Add(childBo); } //存入子表数据 格式为H3.DataModel.BizObject[] targetBo["D150516storageTime"] = childList.ToArray(); //目标表单创建 targetBo.Create(); } } // } base.OnWorkflowInstanceStateChanged(oldState, newState); }