1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CY.IDAL;
using AbstractFactory;
using CY.Model;
 
namespace CY.BLL.Sys
{
    /// <summary>
    /// 字典表业务逻辑操作类
    /// </summary>
    public class Sys_DictionaryBLL
    {
 
        private ISys_DictionaryDAL _DicDal;//字典表数据访问服务接口
 
        /// <summary>
        /// 初始化
        /// </summary>
        public Sys_DictionaryBLL()
        {
            _DicDal = Factory.GetDALByInterfaceName(DALInterface.ISys_DictionaryDAL) as ISys_DictionaryDAL;//获取数据访问接口实现对象
        }
 
        /// <summary>
        /// 添加数据
        /// </summary>
        /// <param name="dicInfo"></param>
        /// <returns></returns>
        public bool AddData(Sys_Dictionary dicInfo)
        {
            return _DicDal.InserModel(dicInfo);
        }
 
        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="dicInfo"></param>
        /// <returns></returns>
        public bool UpdataData(Sys_Dictionary dicInfo)
        {
            return _DicDal.UpdateModel(dicInfo);
        }
 
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="dicInfo"></param>
        /// <returns></returns>
        public bool DeleteData(Sys_Dictionary dicInfo)
        {
            return _DicDal.DeleteModel(dicInfo);
        }
 
        /// <summary>
        /// 根据类型获取字典表数据
        /// </summary>
        /// <param name="dataType"></param>
        /// <returns></returns>
        public IEnumerable<Sys_Dictionary> GetDataByType(string dataType)
        {
            return _DicDal.SelectModlesByType(dataType);
        }
        /// <summary>
        /// 获取全部类型
        /// </summary>
        /// <returns></returns>
        public IEnumerable<string> GetDataTypes()
        {
            return _DicDal.SelectDicTypes();
        }
 
        /// <summary>
        /// 根据Keyid获得名称
        /// </summary>
        /// <param name="Keyid">数据id</param>
        /// <returns></returns>
        public string GetModelByKeyid(int? Keyid)
        {
            return _DicDal.SelectModelByKeyid(Keyid);
        }
 
        /// <summary>
        /// 根据代表值和类型获得KeyId
        /// </summary>
        /// <param name="MeanValue">数据id</param>
        /// <param name="DicType">数据id</param>
        /// <returns></returns>
        public int? GetKeyIdByKeyid(int? MeanValue, string DicType)
        {
            return _DicDal.GetNameByKeyid(MeanValue, DicType);
        }
 
        /// <summary>
        /// 根据代表值和类型获得Name
        /// </summary>
        /// <param name="MeanValue">数据id</param>
        /// <param name="DicType">数据id</param>
        /// <returns></returns>
        public string GetNameByMeanValue(int? MeanValue, string DicType)
        {
            return _DicDal.GetNameByMeanValue(MeanValue, DicType);
        }
    }
}