罗敏贵 发表于 2013-1-3 15:37:43

OEA体验:查询面板

<div id="cnblogs_post_body">一、摘要

          在这里主要是写OEA设计方面的知识了。OEA 源码:OEA框架 2.9 Pre-Alpha 源码公布
    可以到BloodyAngel的博客和中可以下到。虽然现在应经知道使用了,但是还是 需要了解框架相关知识运行机制,让我们更好的使用OEA进行开发
            OEA提供了自定义模板机制。我们这里主要是 实现简单的 查询面板
二、本文大纲

          a、摘要 。
         b、远景 。
         c、项目结构 。
         d、OEA实现方法。
三、远景

      圈圈里的就是我们要实现查询条件,这个条件也是比较通用的,我们只要做一次就可以在多个页面上使用这个功能了,爽吧,减少的重复劳动了。
    http://images.cnblogs.com/cnblogs_com/luomingui/201204/201204261721132000.png
    这个我们这里只用到了一个表的数据。
四、项目结构

          http://images.cnblogs.com/cnblogs_com/luomingui/201204/201204261721145197.png
    用到的主要的类 如下:
    1:Charging.cs2:ChargingDateCriteria.cs   3:TimeSpanCriteria.cs五、OEA实现方法

<blockquote>         我们现在来看看他是如何实现的
       1:第一步查询条件基础TimeSpanCriteria.cs
<div style="border-bottom: #4f81bd 1px solid; text-align: left; border-left: #4f81bd 1px solid; line-height: 18px; background-color: white; margin: 0px; width: 100%; font-family: 'Courier New','Consolas','Fixedsys','BitStream Vera Sans Mono', courier,monospace,serif; color: black; font-size: 12px; overflow: auto; border-top: #4f81bd 1px solid; border-right: #4f81bd 1px solid">    1:[Serializable]    2:public abstract class TimeSpanCriteria : Criteria    3:{    4:    public TimeSpanCriteria()    5:    {    6:      this.TimeSpanType = TimeSpanType.LastMonth;    7:    }    8:   9:    public static readonly Property<TimeSpanType> TimeSpanTypeProperty = P<TimeSpanCriteria>.Register(e => e.TimeSpanType, new PropertyMetadata<TimeSpanType>    10:    {    11:      PropertyChangedCallBack = (o, e) => (o as TimeSpanCriteria).OnTimeSpanTypeChanged(e)    12:    });    13:    public TimeSpanType TimeSpanType    14:    {    15:      get { return this.GetProperty(TimeSpanTypeProperty); }    16:      set { this.SetProperty(TimeSpanTypeProperty, value); }    17:    }    18:    protected virtual void OnTimeSpanTypeChanged(ManagedPropertyChangedEventArgs<TimeSpanType> e)    19:    {    20:      var today = DateTime.Today;    21:      switch (e.NewValue)    22:      {    23:            case TimeSpanType.Today:    24:                this.From = this.To = today;    25:                break;    26:            case TimeSpanType.Week:    27:                var dayOfWeek = (int)today.DayOfWeek;    28:                if (dayOfWeek == 0) dayOfWeek = 7;    29:                dayOfWeek--;//0-6    30:    31:                var monday = today.AddDays(-dayOfWeek);    32:                this.From = monday;    33:                this.To = monday.AddDays(6);    34:                break;    35:            case TimeSpanType.Month:    36:                this.From = new DateTime(today.Year, today.Month, 1);    37:                this.To = new DateTime(today.Year, today.Month, DateTime.DaysInMonth(today.Year, today.Month));    38:                break;    39:            case TimeSpanType.LastMonth:    40:                this.From = today.AddDays(-30);    41:                this.To = today;    42:                break;    43:            case TimeSpanType.Year:    44:                this.From = new DateTime(today.Year, 1, 1);    45:                this.To = new DateTime(today.Year, 12, DateTime.DaysInMonth(today.Year, 12));    46:                break;    47:            case TimeSpanType.All:    48:                this.From = new DateTime(1800, 1, 1);    49:                this.To = new DateTime(9999, 12, 31);    50:                break;    51:            case TimeSpanType.Custom:    52:                break;    53:            default:    54:                break;    55:      }    56:      var to = this.To;    57:      this.To = to.Add(new TimeSpan(23, 59, 59));    58:    }    59:    60:    public static readonly Property<DateTime> FromProperty = P<TimeSpanCriteria>.Register(e => e.From);    61:    public DateTime From    62:    {    63:      get { return this.GetProperty(FromProperty); }    64:      set { this.SetProperty(FromProperty, value); }    65:    }    66:    67:    public static readonly Property<DateTime> ToProperty = P<TimeSpanCriteria>.Register(e => e.To);    68:    public DateTime To    69:    {    70:      get { return this.GetProperty(ToProperty); }    71:      set { this.SetProperty(ToProperty, value); }    72:    }    73:}    74:internal class TimeSpanCriteriaConfig : EntityConfig<TimeSpanCriteria>    75:{    76:    protected override void ConfigView()    77:    {    78:      View.DomainName("查é询ˉ条?件t");    79:    80:      //横á向ò显?示?查é询ˉ面?板?。£    81:      //View.DetailAsHorizontal = true;    82:    83:      using (View.OrderProperties())    84:      {    85:            View.Property(TimeSpanCriteria.TimeSpanTypeProperty)    86:                .HasLabel("入?库a日?期ú").ShowIn(ShowInWhere.Detail);    87:            View.Property(TimeSpanCriteria.FromProperty)    88:                .HasLabel("从ó").ShowInDetail(labelWidth: 30);    89:            View.Property(TimeSpanCriteria.ToProperty)    90:                .HasLabel("至á").ShowInDetail(labelWidth: 30);    91:      }    92:    }    93:}    94:public enum TimeSpanType    95:{    96:    [Label("自?定¨义?")]    97:    Custom,    98:    [Label("当±天ì")]    99:    Today,    100:    [Label("本?周ü")]    101:    Week,    102:    [Label("本?月?")]    103:    Month,    104:    [Label("最?近ü一?月?")]    105:    LastMonth,    106:    [Label("本?年ê")]    107:    Year,    108:    [Label("全?部?")]    109:    All    110:}    111:
页: [1]
查看完整版本: OEA体验:查询面板