打开动态表单后获取返回值

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

打开动态表单后获取返回值

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

 

                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());
                        }
                    }
                });
            }
        }
    }
}


打开动态表单后获取返回值

第一种情况是打开系统已有得单据通过表单/列表形式打开,这种情况下获取返回值就比较简单,如下 ListShowParameter list...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息