//=========================================================================提交后Activity4新增目标表单物资信息================================================================================================================ if(childPaCategory != null && childPaCategory.Length > 0) { foreach(H3.DataModel.BizObject child in childPaCategory) { //供应商名称主表赋值给子表 if((child["nameMaterial"] + string.Empty != null || child["nameMaterial"] + string.Empty != "") && (child["supplier"] + string.Empty == null || child["supplier"] + string.Empty == "") && (this.Request.BizObject["joinPersonnel"] + string.Empty != null || this.Request.BizObject["joinPersonnel"] + string.Empty != "")) { child["supplier"] = this.Request.BizObject["joinPersonnel"] + string.Empty; } } } // 新增物资的方法,在审批供应商时加载出所有数据 if(actionName == "Submit" && this.Request.ActivityCode == "Activity4") { if(childPaCategory != null && childPaCategory.Length > 0) { // 加一个list集合,将数据添加至集合中 List < H3.DataModel.BizObject > list = new List<H3.DataModel.BizObject>(); //判断子表数据是否为空,不为空则保存 if(childBoList != null) { //先将原来的子表数据存起来 list.AddRange(childBoList); } foreach(H3.DataModel.BizObject child in childPaCategory) { //new物资目录一个对象 H3.DataModel.BizObject targetBoCategory3 = new H3.DataModel.BizObject(this.Engine, schemaCategory3, this.Request.UserContext.UserId); //物资名称 targetBoCategory3["nameMaterial"] = child["nameMaterial"] + string.Empty; //规格型号 targetBoCategory3["specification"] = child["specification"] + string.Empty; //物资出厂码 targetBoCategory3["MaterialFactoryCode"] = child["F1"] + string.Empty; //物资类别 targetBoCategory3["categoryName1"] = child["categoryName1"] + string.Empty; //物资类别负责人 targetBoCategory3["principal"] = child["principal"] + string.Empty; //供应商名称 targetBoCategory3["joinPersonnel"] = child["supplier"] + string.Empty; //计量单位 targetBoCategory3["measurement"] = child["measuringUnit"] + string.Empty; //设置业务对象数据为生效状态 targetBoCategory3.Status = H3.DataModel.BizObjectStatus.Effective; //目标表单创建 targetBoCategory3.Create(); //=========================================================================提交后Activity4更新本表单物资信息================================================================================================================ string sqlchildBo = "select * from i_D150516category3 where ObjectId='" + targetBoCategory3.ObjectId + "'"; System.Data.DataTable dt = this.Request.Engine.Query.QueryTable(sqlchildBo, null); foreach(System.Data.DataRow row in dt.Rows) { //new一个采购清单业务对象 H3.DataModel.BizObject childBoList1 = new H3.DataModel.BizObject(this.Request.Engine, schemation.GetChildSchema("D150516shoppingList"), H3.Organization.User.SystemUserId); { //数据添加采购清单 //规格型号 childBoList1["specifications"] = row["ObjectId"]; //物资名称 childBoList1["materialName"] = row["nameMaterial"]; //物资出厂码 childBoList1["MaterialFactoryCode"] = row["MaterialFactoryCode"]; //物资编码 childBoList1["MaterialFactoryCodes"] = row["SeqNo"]; //物资类别 childBoList1["categoryName1"] = row["categoryName1"]; //计量单位 childBoList1["measuringUnit"] = row["measurement"]; list.Add(childBoList1); } //将新的子表数据集合赋值到子表控件 targetBoPA["D150516shoppingList"] = list.ToArray(); //更新主表数据 targetBoPA.Update(); } } } }
写在base.OnSubmit(actionName, postValue, response);后面以免照成新增后,目标子表无法被自动填充
objectid根据目标新建表单获得对应的数据id
一条数据填充一条子表行,因此要放在同一个循环中
要和清除子表行合作使用,否则会有一个空白行,这样会照成一个问题,会让其他表单向本表单添加数据,子表数据会被清除
前端判断
if( $.SmartForm.ResponseContext.FormMode == 2 ) {
controlManager1.ClearRows();//清除子表行
}