打开动态表单后获取返回值原创
金蝶云社区-浅笑黯然
浅笑黯然
22人赞赏了该文章 1.1万次浏览 未经作者许可,禁止转载编辑于2022年06月17日 10:41:23

第一种情况是打开系统已有得单据通过表单/列表形式打开,这种情况下获取返回值就比较简单,如下

 

                ListShowParameter listShowParameter = new ListShowParameter();
                listShowParameter.FormId = "ENG_BOM";
                listShowParameter.MultiSelect = true;
                listShowParameter.IsLookUp = true;
                listShowParameter.PageId = Guid.NewGuid().ToString();
                listShowParameter.ParentPageId = base.View.PageId;
                listShowParameter.OpenStyle.ShowType = Kingdee.BOS.Core.DynamicForm.ShowType.Modal;
                //方法2,传result返回
                this.View.ShowForm(listShowParameter, delegate (FormResult result)
                {
                    //读取返回值
                    object returnData = result.ReturnData;
                    //判断是否是RowCollection
                    if (returnData is ListSelectedRowCollection)
                    {
                        //如果是,执行,转换格式
                        ListSelectedRowCollection listSelectedRowCollection = returnData as ListSelectedRowCollection;
                        //如果不是空值,说明有返回值
                        if (listSelectedRowCollection != null)
                        {
                            List<string> bom = new List<string>();
                            for (int i = 0; i < listSelectedRowCollection.Count; i++)
                            {
                                //获取值.i代表第几行值
                                DynamicObjectDataRow datarow = (DynamicObjectDataRow)listSelectedRowCollection[i].DataRow;
                                bom.Add(datarow.DynamicObject["FNUMBER"].ToString());
                            }
                            //去重——因为列表中选择单据时如果单据有多行明细,这个时候你选单时把明细也选进去了这里就会返回重复得数据
                            for (int i = 0; i < bom.Count; i++)//外循环是循环的次数
                            {
                                for (int j = bom.Count - 1; j > i; j--)//内循环是 外循环一次比较的次数
                                {
                                    if (bom[i] == bom[j])
                                    {
                                        bom.RemoveAt(j);
                                    }
                                }
                            }
                        }
                    }
                });


第二种就是自己新建得动态表单,要获取返回值,这个时候有俩种方式,第一种方法是直接在对应单据内通过parentfrom获取到对应得数据,论坛内应该有大家可以去找一下,第二种方法是现在动态表单内传值,再在对应单据内获取,这里我们将第二种方法

动态表单内

    public override void BarItemClick(BarItemClickEventArgs e)
        {
            base.BarItemClick(e);
            if (e.BarItemKey.Equals("RZCN_Confirm"))
            {
                string aa = this.Model.GetValue("F_RZCN_Account").ToString() + ";" + this.Model.GetValue("F_RZCN_PassWord").ToString();
                this.View.ReturnToParentWindow(aa);
            }
        }

对应的单据内

public override void BarItemClick(BarItemClickEventArgs e)
        {
            base.BarItemClick(e);
            if (e.BarItemKey.Equals("RZCN_SubmitCBS"))
            {
                DynamicFormShowParameter formpa = new DynamicFormShowParameter();
                formpa.FormId = "RZCN_CBSSignIn";
                this.View.ShowForm(formpa, delegate (FormResult result)
                {
                //定义接收值,转换成(DynamicObjectCollection)类型
                    string returnData = result.ReturnData.ToString();
                  
                    //如果不为空,执行
                    if (returnData != null)
                    {
                        string[] sgin = returnData.Split(';');
                        string zh = sgin[0];
                        string mm = ConfidentialDataSecurityUtil.CipherText(sgin[1]);
                        LoginInfo info = new LoginInfo();
                        info.Username = zh;
                        info.Password = mm;
                        LoginResult results = LoginServiceHelper.CheckLoginInfo(this.Context, info);
                        if (string.IsNullOrEmpty(results.Message))
                        {
                            this.View.ShowMessage("是否确认", MessageBoxOptions.YesNo, ret =>
                            {
                                if (ret == MessageBoxResult.No)
                                {
                                    e.Cancel = true; return;
                                }
                            });
                        }
                        else
                        {
                            this.View.ShowMessage(results.Message.ToString());
                        }
                    }
                });
            }
        }
    }
}


图标赞 22
22人点赞
还没有人点赞,快来当第一个点赞的人吧!
图标打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!