123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using MySystem.BsModels;
- namespace MySystem
- {
- public sealed class DictionaryClass
- {
- static BsModels.WebCMSEntities bsdb = new BsModels.WebCMSEntities();
- #region Col字典
- public Dictionary<string, string> getColDic(string ColId = "")
- {
- List<BsModels.Col> ColList = bsdb.Col.Where(m => m.ColId.StartsWith(ColId)).OrderBy(m => m.ColId).ToList();
- Dictionary<string, string> ColDic = new Dictionary<string, string>();
- foreach (BsModels.Col subCol in ColList)
- {
- ColDic.Add(subCol.ColId.ToString(), subCol.ColName.ToString());
- }
- return ColDic;
- }
- public Dictionary<int, string> getColDicForInt(string ColId = "")
- {
- List<BsModels.Col> ColList = bsdb.Col.Where(m => m.ColId.StartsWith(ColId)).OrderBy(m => m.ColId).ToList();
- Dictionary<int, string> ColDic = new Dictionary<int, string>();
- foreach (BsModels.Col subCol in ColList)
- {
- ColDic.Add(subCol.Id, subCol.ColName.ToString());
- }
- return ColDic;
- }
- #endregion
- #region 角色字典
- public Dictionary<string, string> getRoleDic()
- {
- List<BsModels.SysAdminRole> List = bsdb.SysAdminRole.ToList();
- Dictionary<string, string> ColDic = new Dictionary<string, string>();
- foreach (BsModels.SysAdminRole sub in List)
- {
- ColDic.Add(sub.Id.ToString(), sub.Name.ToString());
- }
- return ColDic;
- }
- #endregion
- #region 后台管理员角色字典
- public Dictionary<string, string> getSysAdminRoleDic()
- {
- List<BsModels.SysAdminRole> SysAdminRoleList = bsdb.SysAdminRole.ToList();
- Dictionary<string, string> SysAdminRoleDic = new Dictionary<string, string>();
- foreach (BsModels.SysAdminRole subSysAdminRole in SysAdminRoleList)
- {
- SysAdminRoleDic.Add(subSysAdminRole.Id.ToString(), subSysAdminRole.Name.ToString());
- }
- return SysAdminRoleDic;
- }
- public Dictionary<string, string> getSysAdminRoleNewDic()
- {
- List<BsModels.SysAdminRoleNew> SysAdminRoleNewList = bsdb.SysAdminRoleNew.ToList();
- Dictionary<string, string> SysAdminRoleNewDic = new Dictionary<string, string>();
- foreach (BsModels.SysAdminRoleNew subSysAdminRoleNew in SysAdminRoleNewList)
- {
- SysAdminRoleNewDic.Add(subSysAdminRoleNew.Id.ToString(), subSysAdminRoleNew.Name.ToString());
- }
- return SysAdminRoleNewDic;
- }
- #endregion
- #region 后台管理员字典
- public Dictionary<string, string> getSysAdminDic()
- {
- List<SysAdmin> SysAdminList = bsdb.SysAdmin.ToList();
- Dictionary<string, string> SysAdminDic = new Dictionary<string, string>();
- foreach (SysAdmin subSysAdmin in SysAdminList)
- {
- SysAdminDic.Add(subSysAdmin.Id.ToString(), subSysAdmin.AdminName.ToString());
- }
- return SysAdminDic;
- }
- #endregion
- #region 根据字典key获取字典值
- public string getDictionaryNameByKey(Dictionary<string, string> data, string key)
- {
- if (data.ContainsKey(key))
- {
- return data[key];
- }
- return "";
- }
- public string getDictionaryNameById(Dictionary<int, string> data, int key)
- {
- if (data.ContainsKey(key))
- {
- return data[key];
- }
- return "";
- }
- public string getDictionaryNamesByKeys(Dictionary<string, string> data, string keys)
- {
- string result = "";
- string[] keylist = keys.Split(',');
- foreach (string subkey in keylist)
- {
- if (data.ContainsKey(subkey))
- {
- result += data[subkey] + ",";
- }
- }
- return result.TrimEnd(',');
- }
- #endregion
- }
- }
|