氚云后台代码小栗子,点击按钮进行计算并同步数据到另外一张表单

    protected override void OnSubmit(string actionName, H3.SmartForm.SmartFormPostValue postValue, H3.SmartForm.SubmitSmartFormResponse response)
    {
        if(actionName == "BtnJiShuan")
        {
            //评估数据对象
            BizObject pgsjObj = this.Request.BizObject;
            if((string) pgsjObj["F0000045"] == "已计算")
            {
                return;
            }

            BizObjectSchema schema = this.Request.Engine.BizObjectManager.GetPublishedSchema("D101303ZXDF");
            BizObject zxdfobj = new BizObject(this.Request.Engine, schema, this.Request.UserContext.UserId);

            pgsjObj["F0000045"] = "已计算";
            //赋值
            zxdfobj["F0000011"] = this.Request.BizObjectId;//关联
            zxdfobj["F0000001"] = pgsjObj["F0000001"];//标题
            //明细赋值
            BizObject[] details = (BizObject[]) pgsjObj["D101303PGSJMX"]; //获取子表属性并强制转换为对象数组
            if(details != null && details.Length > 0)
            {
                List < H3.DataModel.BizObject > lstObject = new List<H3.DataModel.BizObject>();
                foreach(BizObject detail in details)
                {
                    string type = (string) detail["F0000046"];
                    BizObjectSchema mxschema = this.Request.Engine.BizObjectManager.GetPublishedSchema("D101303ZXDFMX");
                    BizObject zxdfmxobj = new BizObject(this.Request.Engine, mxschema, this.Request.UserContext.UserId);
                    zxdfmxobj["F0000002"] = detail["F0000044"];
                    double r = 0.00;
                    zxdfmxobj["F0000008"] = r;
                    lstObject.Add(zxdfmxobj);
                }
                double avgmss = summss / countmss;
                double avgxs = sumxs / countxs;
                double avgxz = sumxz / countxz;

                zxdfobj["D101303ZXDFMX"] = lstObject.ToArray();
                zxdfobj.Status = BizObjectStatus.Effective;
                zxdfobj.Create();
                pgsjObj.Update();
            }
        }
        base.OnSubmit(actionName, postValue, response);
    }
View Code

 

posted @ 2021-09-08 12:37  瓜甜  阅读(233)  评论(1编辑  收藏  举报