BLL:
//得到查验信息推送状态
public string GetEnumStationPushState(EnumStationPushState en) { FieldInfo fi = en.GetType().GetField(en.ToString());object[] attrs = fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
if (attrs != null && attrs.Length > 0) { return ((DescriptionAttribute)attrs[0]).Description; } else { return en.ToString(); } }一般处理程序:
//查验信息推送状态
public void GetChaYanstate(HttpContext context) { List<CommonModel> list = new List<CommonModel>(); int index = 1; foreach (int i in Enum.GetValues(typeof(EnumStationPushState))) { CommonModel model = new CommonModel(); model.Id = index; model.Name = _dsmb.GetEnumStationPushState((EnumStationPushState)i); model.Value = i.ToString(); list.Add(model); index++; } jsonstring = JsonConvert.SerializeObject(list);if (!string.IsNullOrEmpty(jsonstring))
{ HttpContext.Current.Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1); HttpContext.Current.Response.Expires = -1; HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ContentType = "application/json"; HttpContext.Current.Response.Write(jsonstring); HttpContext.Current.Response.End(); } }注:EnumStationPushState 枚举名
/// <summary>
/// 公共的使用类 /// </summary> public class CommonModel { public int Id { get; set; } public string Name { get; set; } public string Value { get; set; } }
前台:
//单据状态
var GetBillStatusEnum = new Ext.data.JsonStore({ root: '', idProperty: 'Value', remoteSort: true, baseParams: { Type: "GetChaYanstate" }, fields: ['Value', 'Name'], proxy: new Ext.data.HttpProxy({ url: '../../DAC/Data/GetEnum.ashx', method: 'GET' }) });
//单据状态
var danjuState = new Ext.form.ComboBox({ xtype: 'combo', fieldLabel: '单据状态', name: 'planstate', id: 'planstate', lazyRender: true, mode: 'local', width: 130, triggerAction: 'all', valueField: 'Value', displayField: 'Name', emptyText: '--单据状态--', blankText: '--单据状态--', store: GetBillStatusEnum, });