private void btnAdd_Click(object sender, EventArgs e)
        {
            //清除值
            dcDeptInfo.ClearValue();
            pbLogo.Image = null;
            pbLogo.Refresh();
            logoServiceFilePath = null;
            pbPicture.Image     = null;
            pbPicture.Refresh();
            pictureServiceFilePath = null;
            logoFilePath           = "";
            pictureFilePath        = "";

            groupBox1.Enabled = true;
            deptInfo          = new DeptInfoEntity();
            List <DictEntity> isShowList = lueIsShow.Properties.DataSource as List <DictEntity>;

            if (isShowList.Count > 0)
            {
                lueIsShow.EditValue = isShowList[0].value;
            }
            List <DictEntity> isUseList = lueIsUse.Properties.DataSource as List <DictEntity>;

            if (isUseList.Count > 0)
            {
                lueIsUse.EditValue = isUseList[0].value;
            }
            lueHospital.EditValue = AppContext.Session.hospitalId;
            lueIsOpen.EditValue   = "0";
            lueIsPush.EditValue   = "0";
            lueIsBook.EditValue   = "0";
        }
        private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            if (treeList1.FocusedColumn == null)
            {
                return;
            }
            if (treeList1.FocusedNode == null)
            {
                return;
            }
            if (treeList1.FocusedColumn.Caption == "排序号" || treeList1.FocusedColumn.Caption == "打印顺序")
            {
                return;
            }
            String id = Convert.ToString(treeList1.FocusedNode.GetValue("id"));

            if (id == null)
            {
                return;
            }

            //清除值
            dcDeptInfo.ClearValue();
            pbLogo.Image = null;
            pbLogo.Refresh();
            logoServiceFilePath = null;
            pbPicture.Image     = null;
            pbPicture.Refresh();
            pictureServiceFilePath = null;
            logoFilePath           = "";
            pictureFilePath        = "";

            deptInfo = new DeptInfoEntity();
            String url = AppContext.AppConfig.serverUrl + "cms/dept/findById?id=" + id;

            cmd.ShowOpaqueLayer();
            this.DoWorkAsync(0, (o) => //耗时逻辑处理(此处不能操作UI控件,因为是在异步中)
            {
                String data = HttpClass.httpPost(url);
                return(data);
            }, null, (data) => //显示结果(此处用于对上面结果的处理,比如显示到界面上)
            {
                cmd.HideOpaqueLayer();
                JObject objT = JObject.Parse(data.ToString());
                if (string.Compare(objT["state"].ToString(), "true", true) == 0)
                {
                    deptInfo            = objT["result"].ToObject <DeptInfoEntity>();
                    deptInfo.hospitalId = deptInfo.hospital.id;
                    if (deptInfo.parent != null)
                    {
                        deptInfo.parentId = deptInfo.parent.id;
                    }
                    dcDeptInfo.SetValue(deptInfo);
                    if (deptInfo.parent == null) //没有父级元素的时候,默认选中"无"选项
                    {
                        treeParentId.EditValue = "0";
                    }
                    //显示图片
                    logoServiceFilePath    = deptInfo.logoUrl;
                    pictureServiceFilePath = deptInfo.pictureUrl;
                    //医院的机子有些请求不到路径的时候,会卡的1分钟左右,所以下载图片用异步
                    this.DoWorkAsync(0, (o) => //耗时逻辑处理(此处不能操作UI控件,因为是在异步中)
                    {
                        if (logoServiceFilePath != null && logoServiceFilePath.Length > 0)
                        {
                            try
                            {
                                WebClient web = new WebClient();
                                var bytes     = web.DownloadData(AppContext.AppConfig.serverIp + logoServiceFilePath);
                                return(bytes);
                            }
                            catch (Exception ex)
                            {
                                Xr.Log4net.LogHelper.Error(ex.Message);
                            }
                        }
                        return(null);
                    }, null, (data2) => //显示结果(此处用于对上面结果的处理,比如显示到界面上)
                    {
                        if (data2 != null)
                        {
                            this.pbLogo.Image = Bitmap.FromStream(new MemoryStream(data2 as byte[]));
                        }
                    });

                    this.DoWorkAsync(0, (o) => //耗时逻辑处理(此处不能操作UI控件,因为是在异步中)
                    {
                        if (pictureServiceFilePath != null && pictureServiceFilePath.Length > 0)
                        {
                            try
                            {
                                WebClient web        = new WebClient();
                                var bytes            = web.DownloadData(AppContext.AppConfig.serverIp + pictureServiceFilePath);
                                this.pbPicture.Image = Bitmap.FromStream(new MemoryStream(bytes));
                                return(bytes);
                            }
                            catch (Exception ex)
                            {
                                Xr.Log4net.LogHelper.Error(ex.Message);
                            }
                        }
                        return(null);
                    }, null, (data3) => //显示结果(此处用于对上面结果的处理,比如显示到界面上)
                    {
                        if (data3 != null)
                        {
                            this.pbPicture.Image = Bitmap.FromStream(new MemoryStream(data3 as byte[]));
                        }
                    });
                    groupBox1.Enabled = true;
                }
                else
                {
                    MessageBoxUtils.Show(objT["message"].ToString(), MessageBoxButtons.OK,
                                         MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MainForm);
                }
            });
        }