/// <summary> /// 动态添加Table /// </summary> /// <param name="table"></param> /// <returns></returns> public Table AddTable(TableAddEntity TableAdd) { Table table = new Table(); if (TableAdd.TableWidth != null) { table.Width = TableAdd.TableWidth; } if (TableAdd.TableHeight != null) { table.Height = TableAdd.TableHeight; } if (TableAdd.TableID != null) { table.ID = TableAdd.TableID; } if (TableAdd.TableCssCalss != null) { table.CssClass = TableAdd.TableCssCalss; } if (TableAdd.TableAddRows != null) { foreach (TableAddRowEntity TableAddRow in TableAdd.TableAddRows) { table = AddRow(table, TableAddRow); } } return(table); }
/// <summary> /// 创建问卷报告表 /// </summary> /// <param name="div"></param> /// <param name="SID">问卷ID</param> /// <returns></returns> public HtmlGenericControl ShowItemTableValue(HtmlGenericControl div, string SID) { DataTable dtGetSurveyTableInfo = new SurveyReport_Layer().GetSurveyTableInfo(SID); //获取SurveyTable表的信息 DataTable dtGetAnswerInfoStatistics = new SurveyReport_Layer().GetAnswerInfoStatistics(SID); //获取AnswerInfoStatistics的统计信息 DataTable dtGetPageTable = new SurveyReport_Layer().GetPageTable(SID); //获取PageTable统计信息 DataTable dtGetItemTable = new SurveyReport_Layer().GetItemTable(SID); //获取ItemTable统计信息 string startDate = null; string endDate = null; string surveyPeriod = null; //调研周期 string surveyProgress = null; //调研进度 long maxAnswerAmount = 0; int itemNum = 0; int pageNum = 0; long maxTime = 0; long minTime = 0; long sumTime = 0; long avgTime = 0; if (dtGetSurveyTableInfo.Rows.Count > 0) { startDate = ConvertHelper.ConvertString(dtGetSurveyTableInfo.Rows[0]["CreateDate"]); endDate = ConvertHelper.ConvertString(dtGetSurveyTableInfo.Rows[0]["EndDate"]); maxAnswerAmount = ConvertHelper.ConvertLong(dtGetSurveyTableInfo.Rows[0]["MaxAnswerAmount"]); if (!string.IsNullOrEmpty(endDate)) { surveyPeriod = (ConvertHelper.ConvertDateTime(dtGetSurveyTableInfo.Rows[0]["CreateDate"]) - ConvertHelper.ConvertDateTime(dtGetSurveyTableInfo.Rows[0]["EndDate"])).Days + " 天"; } else { endDate = "未设置"; surveyPeriod = "天"; } if (maxAnswerAmount <= 0) { surveyProgress = ConvertHelper.ConvertString(dtGetSurveyTableInfo.Rows[0]["AnswerAmount"]) + "/不限制"; } else { surveyProgress = ConvertHelper.ConvertString(dtGetSurveyTableInfo.Rows[0]["AnswerAmount"]) + "/" + maxAnswerAmount; } } itemNum = dtGetItemTable.Rows.Count; pageNum = dtGetPageTable.Rows.Count; if (dtGetAnswerInfoStatistics.Rows.Count > 0) { maxTime = ConvertHelper.ConvertLong(dtGetAnswerInfoStatistics.Rows[0]["MaxSecondTime"]); minTime = ConvertHelper.ConvertLong(dtGetAnswerInfoStatistics.Rows[0]["MinSecondTime"]); sumTime = ConvertHelper.ConvertLong(dtGetAnswerInfoStatistics.Rows[0]["SumSecondTime"]); avgTime = ConvertHelper.ConvertLong(dtGetAnswerInfoStatistics.Rows[0]["AvgSecondTime"]); } #region 创建表 TableAddEntity TableAdd = new TableAddEntity(); TableAdd.TableCssCalss = "surveyReportTable"; List <TableAddRowEntity> TableAddRows = new List <TableAddRowEntity>(); //创建开始日期 TableAddRowEntity TableAddRowStartDate = new TableAddRowEntity(); List <TableAddCellEntity> TableAddCellsStartDate = new List <TableAddCellEntity>(); TableAddCellEntity TableAddCellStartDate = new TableAddCellEntity(); TableAddCellStartDate.TableCellWidth = Unit.Point(280); TableAddCellStartDate.TableCellHorizontalAlign = HorizontalAlign.Left; TableAddCellStartDate.TableCellContent = "开始日期:"; TableAddCellEntity TableAddCellStartDateValue = new TableAddCellEntity(); TableAddCellStartDateValue.TableCellWidth = Unit.Point(420); TableAddCellStartDateValue.TableCellHorizontalAlign = HorizontalAlign.Left; TableAddCellStartDateValue.TableCellContent = startDate; TableAddCellsStartDate.Add(TableAddCellStartDate); TableAddCellsStartDate.Add(TableAddCellStartDateValue); TableAddRowStartDate.TableAddCells = TableAddCellsStartDate; //创建结束日期 TableAddRowEntity TableAddRowEndDate = new TableAddRowEntity(); List <TableAddCellEntity> TableAddCellsEndDate = new List <TableAddCellEntity>(); TableAddCellEntity TableAddCellEndDate = new TableAddCellEntity(); TableAddCellEndDate.TableCellContent = "结束日期:"; TableAddCellEntity TableAddCellEndDateValue = new TableAddCellEntity(); TableAddCellEndDateValue.TableCellContent = endDate; TableAddCellsEndDate.Add(TableAddCellEndDate); TableAddCellsEndDate.Add(TableAddCellEndDateValue); TableAddRowEndDate.TableAddCells = TableAddCellsEndDate; //创建调研周期 TableAddRowEntity TableAddRowSurveyPeriod = new TableAddRowEntity(); List <TableAddCellEntity> TableAddCellsSurveyPeriod = new List <TableAddCellEntity>(); TableAddCellEntity TableAddCellSurveyPeriod = new TableAddCellEntity(); TableAddCellSurveyPeriod.TableCellContent = "调研周期:"; TableAddCellEntity TableAddCellSurveyPeriodValue = new TableAddCellEntity(); TableAddCellSurveyPeriodValue.TableCellContent = surveyPeriod; TableAddCellsSurveyPeriod.Add(TableAddCellSurveyPeriod); TableAddCellsSurveyPeriod.Add(TableAddCellSurveyPeriodValue); TableAddRowSurveyPeriod.TableAddCells = TableAddCellsSurveyPeriod; //创建调研进度 TableAddRowEntity TableAddRowSurveyProgress = new TableAddRowEntity(); List <TableAddCellEntity> TableAddCellsSurveyProgress = new List <TableAddCellEntity>(); TableAddCellEntity TableAddCellSurveyProgress = new TableAddCellEntity(); TableAddCellSurveyProgress.TableCellContent = "调研进度:"; TableAddCellEntity TableAddCellSurveyProgressValue = new TableAddCellEntity(); TableAddCellSurveyProgressValue.TableCellContent = surveyProgress; TableAddCellsSurveyProgress.Add(TableAddCellSurveyProgress); TableAddCellsSurveyProgress.Add(TableAddCellSurveyProgressValue); TableAddRowSurveyProgress.TableAddCells = TableAddCellsSurveyProgress; //创建题目数 TableAddRowEntity TableAddRowItemNum = new TableAddRowEntity(); List <TableAddCellEntity> TableAddCellsItemNum = new List <TableAddCellEntity>(); TableAddCellEntity TableAddCellItemNum = new TableAddCellEntity(); TableAddCellItemNum.TableCellContent = "题目数/页数:"; TableAddCellEntity TableAddCellItemNumValue = new TableAddCellEntity(); TableAddCellItemNumValue.TableCellContent = itemNum + "/" + pageNum; TableAddCellsItemNum.Add(TableAddCellItemNum); TableAddCellsItemNum.Add(TableAddCellItemNumValue); TableAddRowItemNum.TableAddCells = TableAddCellsItemNum; //创建答卷用时 TableAddRowEntity TableAddRowAnswerTime = new TableAddRowEntity(); List <TableAddCellEntity> TableAddCellsAnswerTime = new List <TableAddCellEntity>(); TableAddCellEntity TableAddCellAnswerTime = new TableAddCellEntity(); TableAddCellAnswerTime.TableCellContent = "答卷用时(秒):"; TableAddCellEntity TableAddCellAnswerTimeValue = new TableAddCellEntity(); TableAddCellAnswerTimeValue.TableCellContent = "最多用时:" + maxTime + " 最少用时:" + minTime + " 用时总计:" + sumTime + " 平均用时:" + avgTime; TableAddCellsAnswerTime.Add(TableAddCellAnswerTime); TableAddCellsAnswerTime.Add(TableAddCellAnswerTimeValue); TableAddRowAnswerTime.TableAddCells = TableAddCellsAnswerTime; TableAddRows.Add(TableAddRowStartDate); TableAddRows.Add(TableAddRowEndDate); TableAddRows.Add(TableAddRowSurveyPeriod); TableAddRows.Add(TableAddRowSurveyProgress); TableAddRows.Add(TableAddRowItemNum); TableAddRows.Add(TableAddRowAnswerTime); TableAdd.TableAddRows = TableAddRows; Table table1 = new PublicClass().AddTable(TableAdd); div.Controls.Add(table1); #endregion return(div); }