DevExpress GridControl控件绑定ID显示别的内容

 /// <summary>
        /// 未安排列表赋值
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GVBeforeSchedule_CustomUnboundColumnData(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDataEventArgs e)
        {
            if (e.RowHandle < 0)
                return;
            ScheduleInfo si = (ScheduleInfo)GVBeforeSchedule.GetRow(e.RowHandle);

            if (si == null)
                return;
            string strName = string.Empty;
            if (e.Column.FieldName == "SPECIAL_Name")
            {
                //绿色通道
                if (si.IS_SPECIAL == 0)
                    strName = "";
                if (si.IS_SPECIAL == 1)
                    strName = "";
                e.Value = strName;
            }
            else if (e.Column.FieldName == "AnesMethodsField")
            {
                if (si.AnesMethodList != null)
                {
                    ANESTHESIA Anes = null;
                    foreach (JHOIS.Entity.ANESTHESIA_INFO AnesInfo in si.AnesMethodList)
                    {
                        Anes = JHOIS.Local.DataCache.GetAnesMethodListByID(AnesInfo.ANESTHESIA_ID);
                        strName += Anes == null ? string.Empty : Anes.ANESTHESIA_NAME + " ";
                    }
                }
                e.Value = strName;
            }
            else if (e.Column.FieldName == "DiagField")
            {
                if (si.DiagnosisList != null)
                {
                    foreach (JHOIS.Entity.DIAGNOSIS_INFO DiagInfo in si.DiagnosisList)
                    {
                        strName += DiagInfo.NOTE + " ";
                    }
                }
                e.Value = strName;
            }
            else if (e.Column.FieldName == "OpeField")
            {
                if (si.OperationList != null)
                {
                    foreach (JHOIS.Entity.OPERATION_NAME OpeInfo in si.OperationList)
                    {
                        strName += OpeInfo.NOTE + " ";
                    }
                }
                e.Value = strName;
            }
            else if (e.Column.FieldName == "OpeDocField")
            {
                if (si.PersonInfoList != null)
                {
                    List<MEDICAL_PERSON_INFO> DoctorList = si.PersonInfoList.FindAll(pDoc => pDoc.ROLE_ID == (int)ScheduleRole.OperDoctor);
                    if (DoctorList != null)
                    {
                        USERS user = null;
                        foreach (JHOIS.Entity.MEDICAL_PERSON_INFO DocInfo in DoctorList)
                        {
                            user = JHOIS.Local.DataCache.GetUserByID(DocInfo.USER_ID, ConfigService.CurrentUser.HOSPITAL_NO);
                          //  strName += user == null ? string.Empty : user.USER_NAME + " ";
                            if (user != null && user.USER_NAME != null)
                            {
                                strName += user == null ? string.Empty : user.USER_NAME;
                            }
                            else
                            {
                                strName += DocInfo.USER_ID;
                            }
                        }
                    }
                }
                e.Value = strName;
            }
            else if (e.Column.FieldName == "OpeAssField")
            {
                strName = string.Empty;
                if (si.PersonInfoList != null)
                {
                    List<MEDICAL_PERSON_INFO> DoctorList = si.PersonInfoList.FindAll(pDoc => pDoc.ROLE_ID == (int)ScheduleRole.OperAssDoctor);
                    if (DoctorList != null)
                    {
                        USERS user = null;
                        foreach (JHOIS.Entity.MEDICAL_PERSON_INFO DocInfo in DoctorList)
                        {
                            user = JHOIS.Local.DataCache.GetUserByID(DocInfo.USER_ID, ConfigService.CurrentUser.HOSPITAL_NO);
                            if (strName != string.Empty)
                                strName += "
";
                            //strName += user == null ? string.Empty : user.USER_NAME;
                            if (user != null && user.USER_NAME != null)
                            {
                                strName += user == null ? string.Empty : user.USER_NAME;
                            }
                            else
                            {
                                strName += DocInfo.USER_ID;
                            }
                        }
                    }
                }
                e.Value = strName;
            }
            else if (e.Column.FieldName == "AppField")//ASgcOpeAssField
            {
                //if (si.ApparatusList != null)
                //{
                //    APPARATUS app = null;
                //    foreach (JHOIS.Entity.APPARATUS_INFO AppInfo in si.ApparatusList.FindAll(pMatch=>pMatch.STATE==(int)State.Effective))
                //    {
                //        app = DataCache.GetApparrtusByID(AppInfo.APPARATUS_ID);
                //        strName += app == null ? string.Empty : app.APPARATUS_NAME + " ";
                //    }
                //}
                //e.Value = strName;
            }
            else if (e.Column.FieldName == "ASEPTICField")
            {
                e.Value = si.IS_ISOLATION == 0 ? false : true;
            }
            else if (e.Column.FieldName == "ImageIndex")
            {
                //if (ConsultList != null)
                //{
                //    if (ConsultList.Exists(p => p.PatientID == si.PATIENT_ID && p.INPNO == si.INP_NO && p.bIsExist == true))
                //        e.Value = 1;
                //    else
                //        e.Value = -1;
                //}
            }
            else if (e.Column.FieldName == "AreaName")
            {

                JHOIS.Entity.AREA area = JHOIS.Local.DataCache.GetAreaPaibanListById(si.AREA_ID);
                if (area != null)
                {
                    e.Value = area.AREA_NAME;
                }
            }
            else if (e.Column.FieldName == "InfectDetailInfo")
            {
                string infectDetailInfo = "";
                if (si.InfectDetailList != null)
                {
                    if (infectDetailList == null)
                    infectDetailList = DataCache.GetSysTypeDetailListBySysTypeID(JHOIS.Entity.SYS_TYPE_ID.INFECT_ID);

                    foreach (INFECT_DETAIL detail in si.InfectDetailList)
                    {
                        SYSTYPE_DETAIL tmpInfectInfo = infectDetailList.Find(p => p.DICT_ID == detail.INFECT_ID);
                        if (tmpInfectInfo != null)
                        {
                            if (!string.IsNullOrEmpty(infectDetailInfo))
                            {
                                infectDetailInfo += ";";
                            }
                            infectDetailInfo += tmpInfectInfo.DICT_NAME;
                        }
                    }
                }
                e.Value = infectDetailInfo;
            }
            else if (e.Column.FieldName == "VisitPersonInfo")//参观人员
            {
                string tmp = "";
                if (si.PersonInfoList != null)
                {
                    var tmpPersonVisit = si.PersonInfoList.FindAll(s => s.ROLE_ID == (int)Entity.ScheduleRole.VisitDoctor);
                    if (tmpPersonVisit.Count > 0)
                    {
                        foreach (var item in tmpPersonVisit)
                        {
                           // tmp+=item.
                            //var tmpUser = JHOIS.Local.DataCache.GetUserByID(item.USER_ID, si.HOSPITAL_NO);
                            //if (tmpUser != null && tmpUser.USER_ID != null)
                            //{
                                if (!string.IsNullOrEmpty(tmp))
                                {
                                    tmp += ";";
                                }
                                tmp += item.USER_ID;
                            //}
                        }
                    }
                }
                e.Value = tmp;
            }
            else if (e.Column.FieldName.ToUpper() == "OPERATIONTYPE")
            {
                string tmp = "";
                if (si.OPERATION_TYPE == 1)
                {
                    tmp = "";
                }
                e.Value = tmp;
            }
            else if (e.Column.FieldName.ToUpper() == "INCI_TYPE_DETAIL")
            {
                string tmpInciDetail="";
                //si.InciTypeList
                if (si.InciTypeList != null && si.InciTypeList.Count > 0)
                {
                   
                    if (lstInciTypeDetailList == null)
                    {
                        lstInciTypeDetailList = JHOIS.Local.DataCache.GetSysTypeDetailListBySysTypeID(SYS_TYPE_ID.INCI_TYPE_ID);
                    }
                    foreach (var item in si.InciTypeList)
                    {
                        
                        var tmpInci=lstInciTypeDetailList.Find(f=>f.DICT_ID==item.INCI_TYPE_ID);
                        if(tmpInci!=null)
                        {
                            if (!string.IsNullOrEmpty(tmpInciDetail))
                            {
                                tmpInciDetail += ";";
                            }
                            tmpInciDetail += tmpInci.DICT_NAME;
                        }
                    }
                }
                e.Value = tmpInciDetail;
            }
            else
            {
                object[] param = new object[2];
                param[0] = si.CASE_ID;
                param[1] = e.Column.FieldName;
                var tmp = JHOIS.Common.OCService.CallReflectMethod("JHOIS.FormTemplateBLL.dll", false, "JHOIS.FormTemplateBLL.Unitils", "CustomUnboundColumnValue", param);
                if (tmp != null)
                {
                    strName = tmp.ToString();
                    e.Value = strName;
                }
                else
                {
                    param = new object[4];
                    param[0] = si.CASE_ID;
                    param[1] = e.Column.FieldName;
                    param[2] = si;
                    param[3] = "手术排班-未排班";
                    tmp = JHOIS.Common.OCService.CallReflectMethod("JHOIS.FormTemplateBLL.dll", false, "JHOIS.FormTemplateBLL.Unitils", "CustomUnboundColumnValue", param);
                    if (tmp != null)
                    {
                        strName = tmp.ToString();
                        e.Value = strName;
                    }
                }
            }
            //else if (e.Column.FieldName == "InfectDetailInfo")//传染病
            //{
            //    string tmp = "";
            //    if (si.InfectDetailList != null)
            //    {
            //        foreach (var item in si.InfectDetailList)
            //        {
            //            var tmpInfect=JHOIS.Local.DataCache.GetSysTypeDetailByID((int)Entity.SYS_TYPE_ID.INFECT_ID, item.INFECT_ID);
            //            if (tmpInfect != null)
            //            {
            //                tmp += tmpInfect.DICT_NAME;
            //            }
            //        }
            //    }
            //    e.Value = tmp;
            //}
        }
原文地址:https://www.cnblogs.com/yuanshuo/p/14841740.html