private void lueHospital_EditValueChanged(object sender, EventArgs e) { if (lueHospital.EditValue == null || lueHospital.EditValue.ToString().Length == 0) { treeParentId.Properties.DataSource = null; return; } HospitalInfoEntity hospitalInfo = lueHospital.GetSelectedDataRow() as HospitalInfoEntity; //查询上级科室下拉框数据 String url = AppContext.AppConfig.serverUrl + "cms/dept/findAll?hospital.code=" + hospitalInfo.code;// +"&deptIds=" + AppContext.Session.deptIds; String data = HttpClass.httpPost(url); JObject objT = JObject.Parse(data); if (string.Compare(objT["state"].ToString(), "true", true) == 0) { List <DeptEntity> deptLsit = objT["result"].ToObject <List <DeptEntity> >(); DeptEntity dept = new DeptEntity(); dept.id = "0"; dept.name = "无"; deptLsit.Insert(0, dept); treeParentId.Properties.DataSource = deptLsit; treeParentId.Properties.TreeList.KeyFieldName = "id"; treeParentId.Properties.TreeList.ParentFieldName = "parentId"; treeParentId.Properties.DisplayMember = "name"; treeParentId.Properties.ValueMember = "id"; } else { MessageBoxUtils.Show(objT["message"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MainForm); return; } }
private void btnAdd_Click(object sender, EventArgs e) { //清除值 dcHospitalInfo.ClearValue(); pbLogo.Image = null; pbLogo.Refresh(); logoServiceFilePath = null; pbPicture.Image = null; pbPicture.Refresh(); pictureServiceFilePath = null; logoFilePath = ""; pictureFilePath = ""; groupBox1.Enabled = true; hospitalInfo = new HospitalInfoEntity(); List <DictEntity> isUseList = lueIsUse.Properties.DataSource as List <DictEntity>; if (isUseList.Count > 0) { lueIsUse.EditValue = isUseList[0].value; } List <DictEntity> hospitalTypeList = lueHospitalType.Properties.DataSource as List <DictEntity>; if (hospitalTypeList.Count > 0) { lueHospitalType.EditValue = hospitalTypeList[0].value; } }
private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e) { var selectedRow = gridView1.GetFocusedRow() as HospitalInfoEntity; if (selectedRow == null) { return; } //清除值 dcHospitalInfo.ClearValue(); pbLogo.Image = null; pbLogo.Refresh(); logoServiceFilePath = null; pbPicture.Image = null; pbPicture.Refresh(); pictureServiceFilePath = null; logoFilePath = null; pictureFilePath = null; logoFilePath = null; pictureFilePath = null; hospitalInfo = new HospitalInfoEntity(); cmd.ShowOpaqueLayer(); String url = AppContext.AppConfig.serverUrl + "cms/hospital/findById?id=" + selectedRow.id; this.DoWorkAsync(500, (o) => //耗时逻辑处理(此处不能操作UI控件,因为是在异步中) { String data = HttpClass.httpPost(url); return(data); }, null, (r) => //显示结果(此处用于对上面结果的处理,比如显示到界面上) { cmd.HideOpaqueLayer(); JObject objT = JObject.Parse(r.ToString()); if (string.Compare(objT["state"].ToString(), "true", true) == 0) { hospitalInfo = objT["result"].ToObject <HospitalInfoEntity>(); dcHospitalInfo.SetValue(hospitalInfo); //显示图片 logoServiceFilePath = hospitalInfo.logoUrl; pictureServiceFilePath = hospitalInfo.pictureUrl; //医院的机子有些请求不到路径的时候,会卡的1分钟左右,所以下载图片用异步 this.DoWorkAsync(0, (o) => //耗时逻辑处理(此处不能操作UI控件,因为是在异步中) { if (logoServiceFilePath != null && logoServiceFilePath.Length > 0) { try { WebClient web = new WebClient(); Log4net.LogHelper.Info("1"); var bytes = web.DownloadData(logoServiceFilePath); return(bytes); } catch (Exception ex) { Log4net.LogHelper.Info("2"); Xr.Log4net.LogHelper.Error(ex.Message); } } return(null); }, null, (data) => //显示结果(此处用于对上面结果的处理,比如显示到界面上) { if (data != null) { this.pbLogo.Image = Bitmap.FromStream(new MemoryStream(data as byte[])); } }); this.DoWorkAsync(0, (o) => //耗时逻辑处理(此处不能操作UI控件,因为是在异步中) { if (pictureServiceFilePath != null && pictureServiceFilePath.Length > 0) { try { WebClient web = new WebClient(); Log4net.LogHelper.Info("3"); var bytes = web.DownloadData(pictureServiceFilePath); this.pbPicture.Image = Bitmap.FromStream(new MemoryStream(bytes)); return(bytes); } catch (Exception ex) { Log4net.LogHelper.Info("4"); Xr.Log4net.LogHelper.Error(ex.Message); } } return(null); }, null, (data) => //显示结果(此处用于对上面结果的处理,比如显示到界面上) { if (data != null) { this.pbPicture.Image = Bitmap.FromStream(new MemoryStream(data as byte[])); } }); groupBox1.Enabled = true; } else { MessageBoxUtils.Show(objT["message"].ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MainForm); } }); }