注册氚云社区,学习低代码知识,与更多氚友互动交流
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 ytbjm 于 2020-8-2 08:27 编辑
protected override void OnSubmit(string actionName, H3.SmartForm.SmartFormPostValue postValue, H3.SmartForm.SubmitSmartFormResponse response)
{
//获取一个Engine管理对象
H3.IEngine engine = this.Engine;
//表单编码
string **SchemaCode = "***";
//表单数据Id
string **BoId = "***";
//子表控件编码
string childSchemaCode = "****";
//Load出要修改数据的主表业务对象
H3.DataModel.BizObject **Bo = H3.DataModel.BizObject.Load(H3.Organization.User.SystemUserId, engine, **SchemaCode, **BoId, false);
//获取子表结构体对象
H3.DataModel.BizObjectSchema childSchema = **Bo.Schema.GetChildSchema(childSchemaCode);
//定义新的子表数据集合
List < H3.DataModel.BizObject > newChildBoList = new List<H3.DataModel.BizObject>();
//获取子表内已有数据
H3.DataModel.BizObject[] childBoArray = (H3.DataModel.BizObject[]) **Bo[childSchemaCode];
if(childBoArray != null && childBoArray.Length > 0)
{
foreach(H3.DataModel.BizObject itemBo in childBoArray)
{
//将子表内已有数据循环添加到新的子表数据集合里
newChildBoList.Add(itemBo);
}
}
//new一个子表业务对象,并添加到子表数据第一行
H3.DataModel.BizObject childBo1 = new H3.DataModel.BizObject(engine, childSchema, H3.Organization.User.SystemUserId);
if(actionName == "Submit" && this.Request.ActivityCode == "Activity2")
{
childBo1["F0000018"] = this.Request.BizObject["F0000006"]; //工序号
childBo1["F0000019"] = this.Request.BizObject["F0000007"]; //工序名称
childBo1["F0000022"] = this.Request.BizObject["F0000010"]; //开始时间
childBo1["F0000023"] = this.Request.BizObject["F0000011"]; //完成时间
childBo1["F0000025"] = this.Request.BizObject["F0000012"]; //作业时间
childBo1["F0000026"] = this.Request.BizObject["F0000021"]; //作业人数
childBo1["F0000027"] = this.Request.BizObject["F0000013"]; //工时
childBo1["F0000028"] = this.Request.BizObject["F0000015"]; //班组
childBo1["F0000036"] = this.Request.BizObject["F0000017"]; //班组长
// childBo1["F0000031"] = this.Request.BizObject["F0000018"]; //责任人
// childBo1["F0000034"] = this.Request.BizObject["F0000019"]; //实际开始时间
// childBo1["F0000035"] = this.Request.BizObject["F0000020"]; //实际完成时间
childBo1["F0000032"] = this.Request.BizObject["F0000023"]; //工序计数
childBo1["F0000033"] = this.Request.BizObject["F0000026"]; //完工计数
}
if(actionName == "Submit" && this.Request.ActivityCode == "Activity11")
{
childBo1["F0000018"] = this.Request.BizObject["F0000006"]; //工序号
childBo1["F0000019"] = this.Request.BizObject["F0000007"]; //工序名称
childBo1["F0000022"] = this.Request.BizObject["F0000010"]; //开始时间
childBo1["F0000023"] = this.Request.BizObject["F0000011"]; //完成时间
childBo1["F0000025"] = this.Request.BizObject["F0000012"]; //作业时间
childBo1["F0000026"] = this.Request.BizObject["F0000021"]; //作业人数
childBo1["F0000027"] = this.Request.BizObject["F0000013"]; //工时
childBo1["F0000028"] = this.Request.BizObject["F0000015"]; //班组
childBo1["F0000036"] = this.Request.BizObject["F0000017"]; //班组长
childBo1["F0000031"] = this.Request.BizObject["F0000018"]; //责任人
// childBo1["F0000034"] = this.Request.BizObject["F0000019"]; //实际开始时间
// childBo1["F0000035"] = this.Request.BizObject["F0000020"]; //实际完成时间
childBo1["F0000032"] = this.Request.BizObject["F0000023"]; //工序计数
childBo1["F0000033"] = this.Request.BizObject["F0000026"]; //完工计数
}
if(actionName == "Submit" && this.Request.ActivityCode == "Activity20")
{
childBo1["F0000018"] = this.Request.BizObject["F0000006"]; //工序号
childBo1["F0000019"] = this.Request.BizObject["F0000007"]; //工序名称
childBo1["F0000022"] = this.Request.BizObject["F0000010"]; //开始时间
childBo1["F0000023"] = this.Request.BizObject["F0000011"]; //完成时间
childBo1["F0000025"] = this.Request.BizObject["F0000012"]; //作业时间
childBo1["F0000026"] = this.Request.BizObject["F0000021"]; //作业人数
childBo1["F0000027"] = this.Request.BizObject["F0000013"]; //工时
childBo1["F0000028"] = this.Request.BizObject["F0000015"]; //班组
childBo1["F0000036"] = this.Request.BizObject["F0000017"]; //班组长
childBo1["F0000031"] = this.Request.BizObject["F0000018"]; //责任人
childBo1["F0000034"] = this.Request.BizObject["F0000019"]; //实际开始时间
childBo1["F0000035"] = this.Request.BizObject["F0000020"]; //实际完成时间
childBo1["F0000032"] = this.Request.BizObject["F0000023"]; //工序计数
childBo1["F0000033"] = this.Request.BizObject["F0000026"]; //完工计数
}
newChildBoList.Insert (0, childBo1);
//new一个子表业务对象,并添加到子表数据最后一行
// H3.DataModel.BizObject childBo2 = new H3.DataModel.BizObject(engine, childSchema, H3.Organization.User.SystemUserId);
// childBo2["F0000002"] = "yyyyyy";
//newChildBoList.Add(childBo2);
//将新的子表数据集合赋值到子表控件
**Bo[childSchemaCode] = newChildBoList.ToArray();
//修改主表业务对象,系统会自动识别出上面子表数据被修改了,执行完Update方法,新的子表数据就会被保存到数据库
**Bo.Update();
|