forked from siteserver/cms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEAdvLevelType.cs
More file actions
91 lines (80 loc) · 2.34 KB
/
EAdvLevelType.cs
File metadata and controls
91 lines (80 loc) · 2.34 KB
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
using System;
using System.Web.UI.WebControls;
namespace SiteServer.CMS.Model.Enumerations
{
public enum EAdvLevelType
{
Hold, //独占
Standard //标准
}
public class EAdvLevelTypeUtils
{
public static string GetValue(EAdvLevelType type)
{
if (type == EAdvLevelType.Hold)
{
return "Hold";
}
if (type == EAdvLevelType.Standard)
{
return "Standard";
}
throw new Exception();
}
public static string GetText(EAdvLevelType type)
{
if (type == EAdvLevelType.Hold )
{
return "独占";
}
if (type == EAdvLevelType.Standard)
{
return "标准";
}
throw new Exception();
}
public static EAdvLevelType GetEnumType(string typeStr)
{
var retval = EAdvLevelType.Hold;
if (Equals(EAdvLevelType.Hold, typeStr))
{
retval = EAdvLevelType.Hold;
}
else if (Equals(EAdvLevelType.Standard, typeStr))
{
retval = EAdvLevelType.Standard;
}
return retval;
}
public static bool Equals(EAdvLevelType type, string typeStr)
{
if (string.IsNullOrEmpty(typeStr)) return false;
if (string.Equals(GetValue(type).ToLower(), typeStr.ToLower()))
{
return true;
}
return false;
}
public static bool Equals(string typeStr, EAdvType type)
{
return Equals(type, typeStr);
}
public static ListItem GetListItem(EAdvLevelType type, bool selected)
{
var item = new ListItem(GetText(type), GetValue(type));
if (selected)
{
item.Selected = true;
}
return item;
}
public static void AddListItems(ListControl listControl)
{
if (listControl != null)
{
listControl.Items.Add(GetListItem(EAdvLevelType.Hold, false));
listControl.Items.Add(GetListItem(EAdvLevelType.Standard, false));
}
}
}
}