/// <summary> /// 根据某个枚举项的描述文本,得到枚举的值(ID) /// </summary> /// <param name="enumType"></param> /// <param name="DisplayText"></param> /// <returns> /// 找到则返回枚举的值(ID) /// 没找到返回enumDisplayText</returns> public static string GetEnumValueByDBText(Type enumType, string DisplayText) { ALEnumDescription[] descriptions = ALEnumDescription.GetFieldTexts(enumType); foreach (ALEnumDescription ed in descriptions) { if (ed.FieldName == DisplayText) { return(ed.enumDisplayText); } } return("未知"); }
/// <summary> /// 根据某个枚举项的描述文本,得到枚举的值(ID) /// </summary> /// <param name="enumType"></param> /// <param name="DisplayText"></param> /// <returns> /// 找到则返回枚举的值(ID) /// 没找到返回int.MinValue</returns> public static int GetEnumValueByDisplayText(Type enumType, string DisplayText) { ALEnumDescription[] descriptions = ALEnumDescription.GetFieldTexts(enumType); foreach (ALEnumDescription ed in descriptions) { if (ed.EnumDisplayText == DisplayText) { return(ed.EnumValue); } } return(int.MinValue); }