lixiaojun
2024-12-02 f460fd2c628ab56db7450d70f3b7ad4b3524e6c8
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
namespace Yw.WinFrmUI
{
    /// <summary>
    /// 水力阀门状态辅助类
    /// </summary>
    public class HydroValveStatusHelper
    {
 
        //字典
        private static readonly Dictionary<string, string> _dict = new Dictionary<string, string>()
        {
            { Yw.Hydro.ValveStatus.None,"默认"},
            { Yw.Hydro.ValveStatus.Open,"开启"},
            { Yw.Hydro.ValveStatus.Closed,"关闭"}
        };
 
        /// <summary>
        /// 获取状态名称
        /// </summary>
        public static string GetStatusName(string code)
        {
            if (_dict.ContainsKey(code))
            {
                return _dict[code];
            }
            return string.Empty;
        }
 
        /// <summary>
        /// 获取状态编码
        /// </summary>
        public static string GetStatusCode(string name)
        {
            if (_dict.ContainsValue(name))
            {
                return _dict.First(x => x.Value == name).Key;
            }
            return string.Empty;
        }
 
 
    }
}