Пример #1
0
        /// <summary>
        /// 获取所有的字典信息的方法
        /// </summary>
        /// <returns></returns>
        private Dictionary <string, object> GetDataItemList()
        {
            var dicts     = new DictBll().GetAllDict();
            var dictItems = new DictItemBll().GetAllDictItem();
            Dictionary <string, object> dictionaryList = new Dictionary <string, object>();

            foreach (DictModel item in dicts)
            {
                var dataItemList = dictItems.FindAll(t => t.F_DictId.Equals(item.F_Id));
                Dictionary <string, string> dictionaryItemList = new Dictionary <string, string>();
                foreach (var itemList in dataItemList)
                {
                    dictionaryItemList.Add(itemList.F_Code, itemList.F_Name);
                }
                if (!dictionaryList.ContainsKey(item.F_Code))
                {
                    dictionaryList.Add(item.F_Code, dictionaryItemList);
                }
            }
            return(dictionaryList);
        }
Пример #2
0
        /// <summary>
        /// 获取字典的字典项信息
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string GetDictItems(HttpContext context)
        {
            string dictCode = context.Request["dictCode"];

            DictItemBll          dictItemBll = new DictItemBll();
            List <DictItemModel> dictItems   = dictItemBll.GetDictItemByDict(dictCode);

            switch (dictCode)
            {
            case "menuTypeDict":        //这个只是预留作参考用,实际使用意义不大,可删除
                var menuTypeDic = dictItems.Select(t => new { text = t.F_Name, value = t.F_Code });
                return(JsonResult(menuTypeDic));

                break;

            default:
                var defaultDict = dictItems.Select(t => new { text = t.F_Name, value = t.F_Code });
                return(JsonResult(defaultDict));

                break;
            }
        }