/// <summary>
        /// 响应请求分页数据
        /// </summary>
        // @SuppressWarnings({ "rawtypes", "unchecked" })
        protected TableDataInfo <T> getDataTable <T>(List <T> list, long total)
        {
            //to do 这个方式可能不好,全部移植完毕后优化这个分页的
            TableDataInfo <T> rspData = new TableDataInfo <T>();

            rspData.code  = HttpStatusConst.SUCCESS;
            rspData.msg   = "查询成功";
            rspData.rows  = list;
            rspData.total = total;
            return(rspData);
        }
Beispiel #2
0
        public TableDataInfo GetTableData(int tabId)
        {
            DataTable dt      = new DataTable();
            var       tabInfo = this.GetTableInfo(tabId);

            if (tabInfo != null)
            {
                string tabName = tabInfo.Name;
                string cols    = tabInfo.GetColumnSql();
                dt = SqlHelper.GetTableData(string.Format("select {0} from {1}", cols, tabName));
            }

            TableDataInfo dataInfo = new TableDataInfo();

            dataInfo.TableInfo = tabInfo;
            dataInfo.TableData = dt;
            return(dataInfo);
        }
Beispiel #3
0
        public static string ConvertDataTableToHTML(TableDataInfo tableDataInfo, string orderBy, string sort)
        {
            DataTable dt = tableDataInfo.TableData;
            TableInfo t  = tableDataInfo.TableInfo;

            string html = "<table border=\"1\">";

            //add header row
            html += "<tr>";
            for (int i = 0; i < dt.Columns.Count; i++)
            {
                string colName = dt.Columns[i].ColumnName;
                if (orderBy.ToLower().Equals(colName.ToLower()))
                {
                    if (sort.ToLower().Equals("asc"))
                    {
                        html += string.Format("<td><a href=\"?orderby={1}&sort={2}\">{0}</a></td>", t.GetColumnDesc(colName), colName, "DESC");
                    }
                    else
                    {
                        html += string.Format("<td><a href=\"?orderby={1}&sort={2}\">{0}</a></td>", t.GetColumnDesc(colName), colName, "ASC");
                    }
                }
                else
                {
                    html += string.Format("<td><a href=\"?orderby={1}&sort={2}\">{0}</a></td>", t.GetColumnDesc(colName), colName, "DESC");
                }
            }
            html += "</tr>";
            //add rows
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                html += "<tr>";
                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    html += "<td>" + dt.Rows[i][j].ToString() + "</td>";
                }
                html += "</tr>";
            }
            html += "</table>";
            return(html);
        }
Beispiel #4
0
        //
        // GET: /Home/Details/5

        public ActionResult Detail(int id, string orderBy = "ID", string sort = "DESC", int pageIndex = 1)
        {
            int pageSize = 20;
            var tabInfo  = repository.GetTableInfo(id);

            string orderInfo = "";

            if (string.IsNullOrEmpty(orderBy) || string.IsNullOrEmpty(sort))
            {
                orderInfo = "ID DESC";
            }
            else
            {
                orderInfo = string.Format("{0} {1}", orderBy, sort);
            }

            var           pagerInfo = ERP.DAL.SqlHelper.GetPagerData(tabInfo.Name, tabInfo.GetColumnSql(), null, orderInfo, pageIndex, pageSize);
            TableDataInfo info      = new TableDataInfo();

            info.TableData = pagerInfo.PagerData;
            info.TableInfo = tabInfo;


            PagedList <DataRow> arts = new PagedList <DataRow>(pagerInfo.PagerData.Select(), pageIndex, pageSize, pagerInfo.RecordCount);

            Models.TableModel model = new Models.TableModel();

            var requestInfo = new Models.RequestInfo();

            requestInfo.OrderBy   = orderBy;
            requestInfo.Sort      = sort;
            requestInfo.PageIndex = pageIndex;

            model.PagedList   = arts;
            model.TableInfo   = info;
            model.RequestInfo = requestInfo;

            return(View(model));
        }
        public static void FillRecords(Worksheet sheet, Title title, TableDataInfo tableDataInfo)
        {
            int usedRowNum        = sheet.UsedRange.Rows.Count;
            int firstDataRowIndex = GetTitleRowCount(sheet) + 1;

            if (usedRowNum >= firstDataRowIndex)
            {
                Range allDataRange = sheet.Range[sheet.Cells[firstDataRowIndex, 1], sheet.Cells[usedRowNum, sheet.UsedRange.Columns.Count]];
                allDataRange.ClearContents();
            }

            //int nextRowIndex = titleRowNum + 2;

            var records = DefAssembly.ToSortByKeyDataList(tableDataInfo.Table, tableDataInfo.MainRecords);

            int totalRowCount  = 0;
            var dataRangeArray = new List <object[]>();

            foreach (var rec in records)
            {
                var fillVisitor = new FillSheetVisitor(dataRangeArray, title.ToIndex + 1, totalRowCount);
                totalRowCount += rec.Data.Apply(fillVisitor, TBean.Create(false, rec.Data.Type, null), title);
            }

            object[,] resultDataRangeArray = new object[dataRangeArray.Count, title.ToIndex + 1];
            for (int i = 0; i < dataRangeArray.Count; i++)
            {
                object[] row = dataRangeArray[i];
                for (int j = 0; j < row.Length; j++)
                {
                    resultDataRangeArray[i, j] = row[j];
                }
            }

            Range recordFillRange = sheet.Range[sheet.Cells[firstDataRowIndex, 1], sheet.Cells[firstDataRowIndex + dataRangeArray.Count - 1, title.ToIndex + 1]];

            recordFillRange.Value = resultDataRangeArray;
        }