上传文件时触发事件原创
金蝶云社区-希有
希有
1人赞赏了该文章 1,206次浏览 未经作者许可,禁止转载编辑于2021年04月28日 17:14:18

一、继承表单事件

二、重写CustomEvents()方法

public override void CustomEvents(CustomEventsArgs e)

        {

            if (e.Key.EqualsIgnoreCase("FBatchUploadFile"))

            {

                this.View.GetControl("FBatchUploadFile").SetCustomPropertyValue("NeedCallback", true);

                this.View.GetControl("FBatchUploadFile").SetCustomPropertyValue("IsRequesting", false);

                if (e.EventName.EqualsIgnoreCase("FileChanged"))

                {   // 文件上传完毕

                    // 取文件上传参数,文件名

                    JSONObject uploadInfo = KDObjectConverter.DeserializeObject<JSONObject>(e.EventArgs);

                    if (uploadInfo != null)

                    {

                        JSONArray json = new JSONArray(uploadInfo["NewValue"].ToString());

                        if (json.Count > 0)

                        {

                            FileNameList.Clear();

                            foreach (object item in json) {

                                Hashtable FileNameTb = new Hashtable();

                                //FileNameTb.Clear();

                                // 取上传的文件名

                                string ServerFileName = (item as Dictionary<string, object>)["ServerFileName"].ToString();

                                string FileName = (item as Dictionary<string, object>)["FileName"].ToString();

                                this._fullFileName = this.GetFullFileName(ServerFileName);

                                FileNameTb.Add("FileName", FileName);

                                FileNameTb.Add("FullFileName", this._fullFileName);                                

                                FileNameList.Add(FileNameTb);

                            }

                            // 解锁确定按钮

                            this.View.GetControl("FButtonConfirm").Enabled = true;

                        }

                        else

                        {

                            // 锁定确定按钮

                            this.View.GetControl("FButtonConfirm").Enabled = false;

                        }

                    }

                }

            }

        }

赞 1