Пример #1
0
        public DataTable GetPagedData(Pagination pagination)
        {
            if (pagination.Total.HasValue == false)
            {
                var countCmdText = _pagingTranslater.GetTotalCommad();
                using (var cmd = _dbHelper.GetSqlStringCommond(countCmdText))
                {
                    pagination.Total = (int)_dbHelper.ExecuteScalar(cmd);
                }
            }

            var getDataCmdText = _pagingTranslater.GetDataCommand();

            using (var cmd = _dbHelper.GetSqlStringCommond(getDataCmdText))
            {
                return(_dbHelper.ExecuteDataTable(cmd));
            }
        }
Пример #2
0
        public virtual DataTable GetPagedData(Pagination pagination)
        {
            PagingTranslater.TableName    = TableName;
            PagingTranslater.InnerJoin    = InnerJoin;
            PagingTranslater.SelectFields = SelectFields;
            PagingTranslater.Pagination   = pagination;
            PagingTranslater.Filter       = Filter;
            PagingTranslater.Sort         = Sort;
            PagingTranslater.Parms.Clear();
            if (pagination.Total.HasValue == false)
            {
                var countCmdText = PagingTranslater.GetTotalCommad();
                using (var cmd = DbHelper.GetSqlStringCommond(countCmdText))
                {
                    if (PagingTranslater.Parms.Count > 0)
                    {
                        foreach (var parameter in PagingTranslater.Parms)
                        {
                            DbHelper.AddInParameter(cmd, parameter.Name, parameter.Value);
                        }
                    }
                    pagination.Total = (int)DbHelper.ExecuteScalar(cmd);
                }
            }
            PagingTranslater.Parms.Clear();

            var getDataCmdText = PagingTranslater.GetDataCommand();

            using (var cmd = DbHelper.GetSqlStringCommond(getDataCmdText))
            {
                if (PagingTranslater.Parms.Count > 0)
                {
                    foreach (var parameter in PagingTranslater.Parms)
                    {
                        DbHelper.AddInParameter(cmd, parameter.Name, parameter.Value);
                    }
                }
                return(DbHelper.ExecuteDataTable(cmd));
            }
        }