Copy codeThe Code is as follows: public class AppEnum
{
Public enum PointLogType: int
{
/// <Summary>
/// Confirm by Email
/// </Summary>
[Description ("Email confirmation")]
Recruit = 1, // new customer activation +
/// <Summary>
// Old customer feedback
/// </Summary>
[Description ("old customer feedback")]
Veteran = 2, // old customer shopping history reply
/// <Summary>
/// Generate the order
/// </Summary>
[Description ("generate order")]
CreateOrder = 3, // place an order-
/// <Summary>
/// Cancel the order
/// </Summary>
[Description ("Void order")]
AbandonSO = 5, // cancel the order
/// <Summary>
/// Cancel the void order
/// </Summary>
[Description ("canceled order")]
CancelAbandonSO = 6, // cancel review-
/// <Summary>
/// Return
/// </Summary>
[Description ("return")]
ReturnProduct = 7, // return-
/// <Summary>
/// Cancel return
/// </Summary>
[Description ("cancel return")]
CancelReturn = 8,
/// <Summary>
/// Cancel warehouse picking
/// </Summary>
[Description ("cancel warehouse picking")]
CancelOutstock = 9, // cancel shipment
/// <Summary>
/// Point transfer
/// </Summary>
[Description ("point transfer")]
TransferPoint = 10, // point transfer
/// <Summary>
/// Shopping score
/// </Summary>
[Description ("shopping score")]
AddPointLater = 11, // lag + points
/// <Summary>
/// Order modification
/// </Summary>
[Description ("order modification")]
UpdateSO = 12, // modify SaleOrder
/// <Summary>
/// Wholesale deduction
/// </Summary>
[Description ("wholesale deduction")]
WholeSale = 13, // cut the WholeSale score-as if it was not used.
/// <Summary>
/// Buy a card
/// </Summary>
[Description ("buy card")]
InfoProduct = 14, // card purchase minus-
/// <Summary>
/// Others
/// </Summary>
[Description ("other")]
BizRequest = 15, // Request
/// <Summary>
/// Points for product comments
/// </Summary>
[Description ("Product comments and points")]
Remark = 16, // Remark
/// <Summary>
/// Register and send points
/// </Summary>
[Description ("register and send points")]
NewRegister = 17, // register and send points
/// <Summary>
/// Increase or decrease the DIY Activity points
/// </Summary>
[Description ("increase or decrease DIY Activity points")]
DIY = 18, // increase or decrease the DIY Activity points. The DIY System in Chengdu is useless.
/// <Summary>
/// System transfer points
/// </Summary>
[Description ("system transfer points")]
SysTransferPoint = 19, // The system account neweggcs transfers points to the customer
/// <Summary>
/// Add points to the system account
/// </Summary>
[Description ("Adding points to a system account")]
AddPointToSysAccounts = 20, // Add credits to the system account
/// <Summary>
/// Participate in the quiz
/// </Summary>
[Description ("participate in Quiz")]
Betequalctpoint = 21, // use points for betting
/// <Summary>
/// The result of the quiz
/// </Summary>
[Description ("Quiz income")]
BetAddPoint = 22, // earned points
/// <Summary>
/// Points for the first purchase of a new user
/// </Summary>
[Description ("New users' first shopping credit points")]
NewCustomerFirstBuy = 23, // newly registered user, points for the first shopping
/// <Summary>
/// Automatically raise the credit for the essence
/// </Summary>
[Description ("automatically raise the essence to give points")]
SetScoreAuto = 24, // automatically raise the credit points
/// <Summary>
/// Add credits for marketing promotions
/// </Summary>
[Description ("add points to promotions")]
MKTCampaign = 25,
/// <Summary>
/// Reclaim points upon expiration
/// </Summary>
[Description ("reclaim points upon expiration")]
DisusePoint =-1
}
}
The above is an enumeration list. How can I read it? What about binding with a DDR?Copy codeThe Code is as follows: ddlType. DisplayMember = "Value ";
DdlType. ValueMember = "Key ";
DdlType. DataSource = CommonFunctions. GetEnumItems (typeof (AppEnum. PointLogType), false );
DdlType. SelectedValue = 25; // Default Value
The GetEnumItems method in CommonFunctions is as follows:Copy codeThe Code is as follows: // <summary>
/// Obtain the list of all items contained in the enumerated type.
/// </Summary>
/// <Param name = "enumType"> Enumeration type </param>
/// <Param name = "withAll"> include "All" </param>
/// <Returns> </returns>
Public static List <EnumItem> GetEnumItems (Type enumType, bool withAll)
{
List <EnumItem> list = new List <EnumItem> ();
If (enumType. IsEnum! = True)
{
// Not an enumeration type
Throw new InvalidOperationException ();
}
// Contains the All option
If (withAll = true)
List. Add (new EnumItem (AppConst. IntNull, "All "));
// Obtain the type information of the feature Description
Type typeDescription = typeof (DescriptionAttribute );
// Obtain the enumerated field information (because the enumerated value is actually a static field value)
System. Reflection. FieldInfo [] fields = enumType. GetFields ();
// Retrieve all fields
Foreach (FieldInfo field in fields)
{
// Filter out one that is not an enumeration value and records the enumerated source type.
If (field. FieldType. IsEnum = false)
Continue;
// Obtain the enumerated value through the field name
Int value = (int) enumType. InvokeMember (field. Name, BindingFlags. GetField, null, null );
String text = string. Empty;
// Obtain all the custom features of this field. Only the Description feature is available here.
Object [] arr = field. GetCustomAttributes (typeDescription, true );
If (arr. Length> 0)
{
// Because the custom Description feature cannot be repeated, only the first one is used.
DescriptionAttribute aa = (DescriptionAttribute) arr [0];
// Obtain the description of the feature
Text = aa. Description;
}
Else
{
// If there is no feature description, the field name in English is displayed.
Text = field. Name;
}
List. Add (new EnumItem (value, text ));
}
Return list;
}
Public class EnumItem
{
Private object m_key;
Private object m_value;
Public object Key
{
Get {return m_key ;}
Set {m_key = value ;}
}
Public object Value
{
Get {return m_value ;}
Set {m_value = value ;}
}
Public EnumItem (object _ key, object _ value)
{
M_key = _ key;
M_value = _ value;
}
}