Beispiel #1
0
        public DataSetListModel(DataSet dataSet)
            : base(dataSet)
        {
            PageStyle      = dataSet.GetFieldValue <string>("Info", "Style");
            HasListButtons = CalcHasListButtons(dataSet);
            DecoderSelfUrl = dataSet.GetFieldValue <string>("URL", "DSelfURL");

            DataRow countRow = dataSet.GetRow("Count");

            if (countRow != null)
            {
                PageInfo = new CountInfo(1, 1, 1);
                PageInfo.ReadFromDataRow(countRow);
            }
            DataRow sortRow = dataSet.GetRow("Sort");

            if (sortRow != null)
            {
                SortInfo = new ListSortInfo(null);
                SortInfo.ReadFromDataRow(sortRow);
            }

            DataTable table = dataSet.Tables["ListOperator"];

            ListOperators = Operator.ReadFromDataTable(table);
            table         = dataSet.Tables["RowOperator"];
            RowOperators  = Operator.ReadFromDataTable(table);

            fEmptyProvider = new DataRowFieldValueProvider(null, dataSet);
        }
Beispiel #2
0
        private CountInfo CreatePageInfo(IInputData input, int pageNumber,
                                         int pageSize, ParamBuilderContainer condition)
        {
            CountInfo pageInfo;
            int       totalCount = input.QueryString["TotalCount"].Value <int>();

            if (totalCount <= 0 || input.IsPost)
            {
                int count = DbUtil.ExecuteScalar("SELECT COUNT(*) FROM " + GetTableName(Context),
                                                 Context, condition).Value <int>();
                pageInfo = new CountInfo(count, pageNumber, pageSize);
            }
            else
            {
                pageInfo = new CountInfo(totalCount,
                                         input.QueryString["TotalPage"].Value <int>(), pageNumber, pageSize);
            }
            return(pageInfo);
        }
Beispiel #3
0
        protected void FillListDataSet(IInputData input, int pageNumber, int pageSize, int start)
        {
            ParamBuilderContainer condition = CreateListCondition(input);

            IOperateRight operateRight = null;

            if (TabSheets != null && TabSheets.Count > 0)
            {
                var selectedTab = GetSelectTabSheet(input);
                selectedTab.Selected = true;
                condition.Add(selectedTab.ParamBuilder);
                DataSet.Tables.Add(TabSheets.CreateTable("TabSheet"));
            }

            if (input.QueryString["GetData"] != "Page" && !input.IsPost)
            {
                MainResolver.FillCodeTable(input.Style);
                CreateListOperators(input, ref operateRight);
            }

            ListSortInfo listInfo = new ListSortInfo(input);
            string       orderby  = null;

            if (input.IsPost)
            {
                orderby = SetPostListInfo(input, condition, listInfo);
            }
            else
            {
                orderby = SetGetListInfo(input, condition, listInfo);
            }

            CountInfo pageInfo = CreatePageInfo(input, pageNumber, pageSize, condition);

            DataSet.Tables.Add(EnumUtil.Convert(pageInfo).CreateTable("Count"));
            DataSet.Tables.Add(EnumUtil.Convert(listInfo).CreateTable("Sort"));

            if (pageInfo.TotalCount <= 0)
            {
                OnFilledListTables(new FilledListEventArgs(input.IsPost, pageNumber, pageSize,
                                                           pageInfo.TotalCount, orderby, MainResolver, input.PostObject, condition));
                return;
            }

            int    recCount    = pageSize * pageNumber + start;
            string whereSql    = condition.IsEmpty ? string.Empty : "WHERE " + condition.Sql;
            var    listContext = FillListTable(MainResolver.ListFields, GetTableName(Context),
                                               MainResolver.GetKeyFieldArray(), whereSql, orderby, recCount, pageSize);

            SqlSelector selector = new SqlSelector(Context, DataSet);

            using (selector)
            {
                ISimpleAdapter adapter = selector;
                adapter.SetSql(listContext.ListSql, condition);
                Context.ContextConfig.SetListData(listContext, adapter, DataSet, recCount,
                                                  pageSize, FillTableName);

                MainResolver.AddVirtualFields();

                if (Operators != null)
                {
                    if (operateRight == null)
                    {
                        operateRight = Operators.Right.CreateObject();
                    }
                    var allOperators = Operators.Operators;
                    if (allOperators != null)
                    {
                        CreateRowOperators(input, operateRight, allOperators);
                    }
                }
                MainResolver.Decode(input.Style);

                OnFilledListTables(new FilledListEventArgs(input.IsPost, pageNumber, pageSize,
                                                           pageInfo.TotalCount, orderby, MainResolver, input.PostObject, condition));
            }
        }