/// <summary> /// 根据显示值获取存储值,用到了缓存 /// </summary> /// <param name="typeId">大类名称</param> /// <param name="key">键</param> /// <returns>空字符串或者值</returns> public string GetCodeSValue(DatacodeTypeEnum typeId, string key) { string result = null; Dictionary <string, string> codeMap = null; codeMapDValue.TryGetValue(typeId.ToString(), out codeMap); if (codeMap == null) { codeMap = LoadDValueCodeMap(typeId); if (codeMap != null) { codeMapDValue.Add(typeId.ToString(), codeMap); codeMap.TryGetValue(key, out result); } } else { codeMap.TryGetValue(key, out result); } if (result == null) { result = ""; } return(result); }
/// <summary> /// 返回"DValue","SValue" /// </summary> /// <param name="typeId"></param> /// <returns></returns> private Dictionary <string, string> LoadDValueCodeMap(DatacodeTypeEnum typeId) { Dictionary <string, string> result = new Dictionary <string, string>(); List <DatacodeEntity> dataCodes = codeDAO.ListByTypeId(typeId.ToString()); foreach (var d in dataCodes) { result.Add(d.Code_d_value, d.Code_s_value); } return(result); }
/// <summary> /// 根据typeID返回列表,可直接绑定到下拉框 /// </summary> /// <param name="typeId"></param> /// <returns></returns> public List <DatacodeEntity> GetDateCodeList(DatacodeTypeEnum typeId) { return(codeDAO.ListByTypeId(typeId.ToString())); }