注册氚云社区,学习低代码知识,与更多氚友互动交流
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
//获取表单结构对象 H3.DataModel.BizObjectSchema schema = this.Request.Engine.BizObjectManager.GetPublishedSchema("主表id"); //new一个表单的业务对象 H3.DataModel.BizObject obj = new H3.DataModel.BizObject(this.Request.Engine, schema, this.Request.UserContext.UserId); //赋值操作 obj["SeqNo"] = this.Request.BizObject["SeqNo"] + string.Empty; obj["CreatedTime"] = this.Request.BizObject["CreatedTime"] + string.Empty; obj["OwnerId"] = this.Request.BizObject["OwnerId"] + string.Empty; obj["OwnerDeptId"] = this.Request.BizObject["OwnerDeptId"] + string.Empty; //设置业务对象的生效状态 obj.Status = H3.DataModel.BizObjectStatus.Effective; obj.Create(); //通过测试,需要现有主表才能创建子表数据,所有下面生成子表数据在更新到子表中 //创建完成之后,在修改子表内容 //下面这个是另一张表的子表数据,如果不需要的话,想直接创建,可以不用获取 H3.DataModel.BizObject[] details = (H3.DataModel.BizObject[]) this.Request.BizObject["子表id"]; //获取子表属性并强制转换为对象数组
//Load出要修改数据的主表业务对象 H3.DataModel.BizObject masterBo = H3.DataModel.BizObject.Load(H3.Organization.User.SystemUserId, this.Engine, "子表id1", obj.ObjectId, false); if(details != null && details.Length > 0) { List < H3.DataModel.BizObject > lstObject = new List<H3.DataModel.BizObject>();
//获取子表结构体对象 H3.DataModel.BizObjectSchema childSchema = masterBo.Schema.GetChildSchema("子表id1"); foreach(H3.DataModel.BizObject detail in details) {
//new一个子表业务对象,并添加到子表数据最后一行 H3.DataModel.BizObject childBo1 = new H3.DataModel.BizObject(this.Engine, childSchema, H3.Organization.User.SystemUserId); childBo1["F0000195"] = detail["F0000195"]; childBo1["F0000197"] = detail["F0000197"]; childBo1["F0000196"] = detail["F0000196"]; childBo1["F0000198"] = detail["F0000198"];
lstObject.Add(childBo1); } //将List转成对象数组,并重新赋值给主表
masterBo["子表id1"] = lstObject.ToArray(); masterBo.Update(); }
|