We often need to set some of the flags: such as the module, we divide, review, modify, delete, freeze, etc.
Permissions, there may be no permissions and full permissions, which can be superimposed and may also be divided. We must set up for each module
Set the relevant permissions of the user on this module, so it is inevitably to bind, display, modify these flags. under
This class provides the corresponding operation as a color as an example, and everyone can discuss together. ----------------------- Public class colorType {// enumerate all the flags, the minimum item should be 0, // The biggest item is the sum of the previous values, Such a biggest item includes all combinations [Flags] public enumcolortype {Transparent = 0, Yellow = 1, Red = 2, Blue = 4, AllColor = 7} public const string transparent = "Transparent"; public const string Yellow = "Yellow"; public const string red = "red"; public const string blue = "blue"; public const string allColor = "full color";
Private static system.collections.specialized.listDictionary _lstdiCItem; // Display data and radical data source PUBLIC Static iDictionary DICSINGLORVIEWCOLOR {Get {if (_lstdiicItem == null) {// Due to less projects, Use listDictionary; // If the project is more and you need to sort, you can use sortedlist _lstdiCItem = new system.collections.Specialized.ListDictionary ();
Foreach (int32 nconstvalue in system.enum.getvalues)) {// uses String type as Key to reduce the disassembly box _LstdiCItem.com (NConstValue.toString (), Typeof (ColorType) .Getfield (enum. TOOBJECT (IPEOF (ENUMCOLORTYPE), NCONSTVALUE) .tostring (). TouPper ()). GetValue (null));}}}}}}}} // Check the data source used in the case, you can also declare another static Variables to store it public static idictionary DiCmultipleColor {Get {// does not include first and last items.
The CheckBoxList example, the user is not the first option, a Select is the last System.Collections.Specialized.ListDictionary _lstDicItemCopied = new System.Collections.Specialized.ListDictionary (); foreach (DictionaryEntry DicEntry in _lstDicItem) {if (DicEntry.Key .ToString () == enumColorType.AllColor.ToString () || DicEntry.Key.ToString () == enumColorType.Transparent.ToString ()) continue; _lstDicItemCopied.Add (DicEntry.Key, DicEntry.Value);} return _lstDicItemCopied }} // parsing Key or Value into the corresponding value PUBLIC Static INT32 PARSEVALUE (Int Nsumtotal = 0; if (CHAR.ISDIGIT (StrKeyorValue [0])) {ix (strkeyorvalue.indexof (" ) == -1) return Int32.Parse (strKeyOrValue); foreach (string strOneValue in strKeyOrValue.Split ( ',')) {nSumTotal = Int32.Parse (strOneValue);}} else {nSumTotal = Convert.ToInt32 (( Enumcolortype) (System.enum.Parse (TypeYorValue, true));} Return nsumtotal;} // Publish key or value to the corresponding Chinese characters Description Public Static String P arseValueWord (string strKeyOrValue, bool boolParsed) {if (strKeyOrValue.IndexOf ( ",")> -1) {if {int nParsedValue = ParseValue (strKeyOrValue) (boolParsed!); if (dicSingleOrViewColor.Contains (nParsedValue.ToString ()) ) {return dicSingleOrViewColor [nParsedValue.ToString ()] ToString ();.}} string strComboWords = ""; string [] strSepWords = strKeyOrValue.Split ( ','); foreach (string strOneWord in strSepWords) {if (strComboWords. Length> 0) {strcombowords = "&";