コード例 #1
0
ファイル: FormStudent.cs プロジェクト: koorise/zsharedcode
 void IDataWindow <PagerSetting> .SetIsPagerControlEnabled(TableSetting <PagerSetting> tableSetting, PagerActionType actionType, bool isEnabled)
 {
 }
コード例 #2
0
        protected void bindPagerEvent <A> (object target, Type type, string eventName, EventHandlerType eventType, string tableName, PagerActionType actionType) where A : EventArgs
        {
#if V3_5 || V4
            this.BindEvent <A> (target, type, eventName, eventType,
                                delegate(object sender, A e)
            {
                if (!string.IsNullOrEmpty(tableName) && this.tableSettings.ContainsKey(tableName))
                {
                    this.setPager(this.tableSettings[tableName], actionType, this.window.GetPagerIndex(this.tableSettings[tableName]));
                }
            }
                                );
#else
            this.BindEvent <A> (target, type, eventName, eventType, null);
#endif
        }
コード例 #3
0
 /// <summary>
 /// 绑定可以触发分页相关操作的事件, 比如: Button 的 Click 事件.
 /// </summary>
 /// <typeparam name="A">事件的参数类型, 必须从 EventArgs 派生.</typeparam>
 /// <param name="target">目标实例, 比如: 窗口上的 Button.</param>
 /// <param name="eventName">事件名称, 比如: "Click".</param>
 /// <param name="eventType">事件的类型, 比如: EventHandler.</param>
 /// <param name="tableName">表格的名称, 与 TableSetting 的 Name 一致.</param>
 /// <param name="actionType">分页操作类型.</param>
 public void BindPagerEvent <A> (object target, string eventName, EventHandlerType eventType, string tableName, PagerActionType actionType) where A : EventArgs
 {
     this.bindPagerEvent <A> (target, null, eventName, eventType, tableName, actionType);
 }
コード例 #4
0
        protected virtual void setPager(TableSetting <P> tableSetting, PagerActionType actionType, int pagerIndex)
        {
            if (null == tableSetting || null == tableSetting.PagerSetting)
            {
                return;
            }

            P pagerSetting = tableSetting.PagerSetting;

            switch (actionType)
            {
            case PagerActionType.First:
                pagerSetting.Index = 1;
                break;

            case PagerActionType.Next:

                if (!pagerSetting.IsLast)
                {
                    pagerSetting.Index += 1;
                }

                break;

            case PagerActionType.Prev:

                if (!pagerSetting.IsFirst)
                {
                    pagerSetting.Index -= 1;
                }

                break;

            case PagerActionType.Last:

                if (pagerSetting.Count > 0)
                {
                    pagerSetting.Index = pagerSetting.Count;
                }

                break;

            case PagerActionType.GoTo:

                if (pagerIndex <= 0 || (pagerSetting.Count > 0 && pagerIndex > pagerSetting.Count))
                {
                    return;
                }

                pagerSetting.Index = pagerIndex;
                break;
            }

            this.window.SetIsPagerControlEnabled(tableSetting, PagerActionType.First, !pagerSetting.IsEmpty && !pagerSetting.IsFirst);
            this.window.SetIsPagerControlEnabled(tableSetting, PagerActionType.Last, !pagerSetting.IsEmpty && !pagerSetting.IsLast);
            this.window.SetIsPagerControlEnabled(tableSetting, PagerActionType.Next, !pagerSetting.IsEmpty && !pagerSetting.IsLast);
            this.window.SetIsPagerControlEnabled(tableSetting, PagerActionType.Prev, !pagerSetting.IsEmpty && !pagerSetting.IsFirst);
            this.window.SetIsPagerControlEnabled(tableSetting, PagerActionType.GoTo, !pagerSetting.IsEmpty && !(pagerSetting.IsFirst && pagerSetting.IsLast));

            this.window.SetPager(tableSetting);
        }
コード例 #5
0
        protected override void setPager(TableSetting <P> tableSetting, PagerActionType actionType, int pagerIndex)
        {
            base.setPager(tableSetting, actionType, pagerIndex);

            PagerBuilder.SetPagerSetting(tableSetting.PagerSetting);
        }
コード例 #6
0
        /// <summary>
        /// 为 StoreType 属性为 Query 的 PagerSetting 生成分页的 HTML 代码.
        /// </summary>
        /// <param name="htmlTemplate">HTML 模板.</param>
        /// <param name="pagerSetting">分页设置.</param>
        /// <param name="actionType">分页操作的类型.</param>
        /// <param name="querySettings">查询条件设置列表.</param>
        /// <returns>分页 HTML 代码.</returns>
        public static string MakePagerHTML(string htmlTemplate, PagerSetting pagerSetting, PagerActionType actionType, IList <QuerySetting> querySettings)
        {
            if (string.IsNullOrEmpty(htmlTemplate) || null == pagerSetting || pagerSetting.StoreType != PagerStoreType.Query)
            {
                return(string.Empty);
            }

            string query = string.Empty;

            switch (actionType)
            {
            case PagerActionType.First:
                query = string.Format("{0}=1&{1}={2}", makeIndexStoreKey(pagerSetting.StoreKey), makeItemCountStoreKey(pagerSetting.StoreKey), pagerSetting.ItemCount);
                break;

            case PagerActionType.Last:
                query = string.Format("{0}={1}&{2}={3}", makeIndexStoreKey(pagerSetting.StoreKey), pagerSetting.Count, makeItemCountStoreKey(pagerSetting.StoreKey), pagerSetting.ItemCount);
                break;

            case PagerActionType.Next:
                query = string.Format("{0}={1}&{2}={3}", makeIndexStoreKey(pagerSetting.StoreKey), pagerSetting.Index + 1, makeItemCountStoreKey(pagerSetting.StoreKey), pagerSetting.ItemCount);
                break;

            case PagerActionType.Prev:
                query = string.Format("{0}={1}&{2}={3}", makeIndexStoreKey(pagerSetting.StoreKey), pagerSetting.Index - 1, makeItemCountStoreKey(pagerSetting.StoreKey), pagerSetting.ItemCount);
                break;
            }

            query += QueryBuilder.MakeQueryString(querySettings);

            return(string.Format(htmlTemplate, query));
        }