其他分享
首页 > 其他分享> > 关联表单显示数据、检查报错提示、根据表单数据有无进行更新创建

关联表单显示数据、检查报错提示、根据表单数据有无进行更新创建

作者:互联网

关联表单默认显示数据

    var currentRowId = this.D150516shoppingList.GetValue()[ 0 ].ObjectId; //第一行子表ID                   
        this.D150516shoppingList.UpdateRow( currentRowId, {
            "D150516shoppingList.categoryName1": "45e6e9f2-809b-4a9f-8a16-d6b19d338be9",
        });

进行前端检查报错提示

    // 提交校验
    OnValidate: function( actionControl ) {
        if( actionControl.Action == "Submit" && ActivityCode == "Activity2" ) {
            var payment2 = that.payment2.GetValue(); //已缴党费
            if(!payment2) {
                $.IShowWarn( "错误", "还未完成付款!!!" );
            }
            return payment2;
        }
        return true;
    },

根据判断另一张表是否又数据,有则进行库存的更新,无则进行表单的创建

 //和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)
        {
            //库存单的构建schema
            H3.DataModel.BizObjectSchema schema = this.Request.Engine.BizObjectManager.GetPublishedSchema("D150516Schrygddhktx2lwxq4squp2zl2");
            //new 一个库存单的对象
            H3.DataModel.BizObject targetBo = new H3.DataModel.BizObject(this.Engine, schema, this.Request.UserContext.UserId);

            //获取到入库单子表的数组对象
            H3.DataModel.BizObject[] childBo = (H3.DataModel.BizObject[]) this.Request.BizObject["D150516storageTime"];
            if(childBo != null && childBo.Length > 0)
            {
                //加一个list集合,将数据添加至集合中
                List < H3.DataModel.BizObject > childList = new List<H3.DataModel.BizObject>();
                //获取到入库单的对象信息
                H3.DataModel.BizObject targetBo2 = H3.DataModel.BizObject.Load(this.Request.UserContext.UserId, this.Engine, "D1505165b8d9780f9e349ab90537f34db37d255", this.Request.BizObjectId, false);

                // for(int i = 0; i < childBo.Length; i++)//正常循环都还是这样写的,和java差不多少,只是这里foreach比java方便不少
                // {
                //     H3.DataModel.BizObject child = childBo[i];
                // }

                foreach(H3.DataModel.BizObject child in childBo)
                {
                    //编码
                    string   childBoCoding = child["coding"] + string.Empty;
                    string sqlcoding = "select coding from i_D150516Schrygddhktx2lwxq4squp2zl2 where specification = '" + child["model"] + "'";
                    System.Data.DataTable  dt = this.Request.Engine.Query.QueryTable(sqlcoding, null);
                    // string targetBoCoding = targetBo["coding"] + string.Empty;
                    if(dt != null && dt.Rows.Count > 0 && dt.Rows[0]["coding"] + string.Empty == childBoCoding)//中括号里面接数字取数组里面的值
                    {
                        //更新库存
                        string sql = "UPDATE i_D150516Schrygddhktx2lwxq4squp2zl2 a JOIN i_D150516storageTime b ON a.coding = b.coding SET a.inventoryMains = a.inventoryMains + b.number where " +
                            " b.parentobjectid = '" + this.Request.BizObjectId + "'";
                        this.Engine.Query.QueryTable(sql, null);
                    } else
                    {   //仓库
                        targetBo["address"] = targetBo2["joinOffice"] + string.Empty;
                        //库管
                        targetBo["principal"] = targetBo2["joinPersonnel02"] + string.Empty;
                        //供应商
                        targetBo["supplier"] = targetBo2["joinPersonnel"] + string.Empty;
                        //物资名称
                        targetBo["joinMaterial"] = child["joinMaterial"] + string.Empty;
                        //一级类别
                        targetBo["category"] = child["categoryName1"] + string.Empty;
                        //二级类别
                        targetBo["joinMaterialCategory"] = child["categoryName2"] + string.Empty;
                        //规格型号
                        targetBo["specification"] = child["model"] + string.Empty;
                        //编码
                        targetBo["coding"] = child["coding"] + string.Empty;
                        //现有库存
                        targetBo["inventoryMains"] = child["number"] + string.Empty;
                        //计量单位
                        targetBo["measureUnit"] = child["measureUnit"] + string.Empty;
                        //目标表单创建
                        targetBo.Create();
                    }

                }

            }
        }
        base.OnWorkflowInstanceStateChanged(oldState, newState);
    }

 

标签:string,targetBo,H3,表单,报错,DataModel,child,数据,Empty
来源: https://www.cnblogs.com/FaustDream/p/16184510.html