protected void bt_Add_ValueGroup_Click(object sender, EventArgs e) { SaveGrid_ValueGroup(); Rpt_ReportBLL report = new Rpt_ReportBLL((Guid)ViewState["ID"]); IList<Rpt_ReportValueGroups> columns = report.GetValueGroups(); int maxsortid = 0; if (columns.Count > 0) maxsortid = columns.Max(p => p.ValueSortID); foreach (ListItem item in cbxl_Fields.Items) { if (item.Selected && columns.FirstOrDefault(p => p.DataSetField == new Guid(item.Value)) == null) { maxsortid++; Rpt_ReportValueGroupsBLL column = new Rpt_ReportValueGroupsBLL(); column.Model.Report = (Guid)ViewState["ID"]; column.Model.DataSetField = new Guid(item.Value); column.Model.DisplayName = item.Text; column.Model.ValueSortID = maxsortid; column.Model.StatisticMode = 1; column.Add(); } } BindDataSetFields(); BindGrid_ValueGroup(); }
private void BindDataSetFields() { Rpt_ReportBLL report = new Rpt_ReportBLL((Guid)ViewState["ID"]); IList <Rpt_DataSetFields> fields = new Rpt_DataSetBLL((Guid)ViewState["DataSet"]).GetFields(); foreach (Rpt_ReportColumnGroups col in report.GetColumnGroups()) { Rpt_DataSetFields f = fields.FirstOrDefault(p => p.ID == col.DataSetField); if (f != null) { fields.Remove(f); } } foreach (Rpt_ReportRowGroups col in report.GetRowGroups()) { Rpt_DataSetFields f = fields.FirstOrDefault(p => p.ID == col.DataSetField); if (f != null) { fields.Remove(f); } } foreach (Rpt_ReportValueGroups col in report.GetValueGroups()) { Rpt_DataSetFields f = fields.FirstOrDefault(p => p.ID == col.DataSetField); if (f != null) { fields.Remove(f); } } cbxl_Fields.DataSource = fields; cbxl_Fields.DataBind(); }
protected void bt_Add_ValueGroup_Click(object sender, EventArgs e) { SaveGrid_ValueGroup(); Rpt_ReportBLL report = new Rpt_ReportBLL((Guid)ViewState["ID"]); IList <Rpt_ReportValueGroups> columns = report.GetValueGroups(); int maxsortid = 0; if (columns.Count > 0) { maxsortid = columns.Max(p => p.ValueSortID); } foreach (ListItem item in cbxl_Fields.Items) { if (item.Selected && columns.FirstOrDefault(p => p.DataSetField == new Guid(item.Value)) == null) { maxsortid++; Rpt_ReportValueGroupsBLL column = new Rpt_ReportValueGroupsBLL(); column.Model.Report = (Guid)ViewState["ID"]; column.Model.DataSetField = new Guid(item.Value); column.Model.DisplayName = item.Text; column.Model.ValueSortID = maxsortid; column.Model.StatisticMode = 1; column.Add(); } } BindDataSetFields(); BindGrid_ValueGroup(); }
private void BindDropDown() { if ((Guid)ViewState["ID"] != Guid.Empty) { Rpt_ReportCharts m = new Rpt_ReportChartsBLL((Guid)ViewState["ID"]).Model; if (m != null) { pl_detail.BindData(m); ViewState["Report"] = m.Report; } } if ((Guid)ViewState["Report"] != Guid.Empty) { Rpt_ReportBLL report = new Rpt_ReportBLL((Guid)ViewState["Report"]); #region 绑定可选的轴下拉框 IList <Rpt_ReportRowGroups> rowgroups = report.GetRowGroups(); if (rowgroups.Count > 0) { //报表有行分组时,则从行分组中取最后一列作为轴,且不可变更 ddl_AxisColumns.Items.Add(rowgroups[rowgroups.Count - 1].DisplayName); ddl_AxisColumns.Enabled = false; } else { //报表无行分组时,从数据集中取一列 foreach (Rpt_DataSetFields f in new Rpt_DataSetBLL(report.Model.DataSet).GetFields()) { ddl_AxisColumns.Items.Add(f.DisplayName); } } #endregion #region 绑定可选的系列 if (report.Model.ReportType == 1) { foreach (Rpt_DataSetFields f in new Rpt_DataSetBLL(report.Model.DataSet).GetFields()) { if (f.DataType == 1 || f.DataType == 2) { cbxl_Fields.Items.Add(f.DisplayName); } } } else if (report.Model.ReportType == 2) { foreach (Rpt_ReportValueGroups f in report.GetValueGroups()) { cbxl_Fields.Items.Add(f.DisplayName); } } #endregion } }
private void BindDropDown() { if ((Guid)ViewState["ID"] != Guid.Empty) { Rpt_ReportCharts m = new Rpt_ReportChartsBLL((Guid)ViewState["ID"]).Model; if (m != null) { pl_detail.BindData(m); ViewState["Report"] = m.Report; } } if ((Guid)ViewState["Report"] != Guid.Empty) { Rpt_ReportBLL report = new Rpt_ReportBLL((Guid)ViewState["Report"]); #region 绑定可选的轴下拉框 IList<Rpt_ReportRowGroups> rowgroups = report.GetRowGroups(); if (rowgroups.Count > 0) { //报表有行分组时,则从行分组中取最后一列作为轴,且不可变更 ddl_AxisColumns.Items.Add(rowgroups[rowgroups.Count - 1].DisplayName); ddl_AxisColumns.Enabled = false; } else { //报表无行分组时,从数据集中取一列 foreach (Rpt_DataSetFields f in new Rpt_DataSetBLL(report.Model.DataSet).GetFields()) { ddl_AxisColumns.Items.Add(f.DisplayName); } } #endregion #region 绑定可选的系列 if (report.Model.ReportType == 1) { foreach (Rpt_DataSetFields f in new Rpt_DataSetBLL(report.Model.DataSet).GetFields()) { if (f.DataType == 1 || f.DataType == 2) { cbxl_Fields.Items.Add(f.DisplayName); } } } else if (report.Model.ReportType == 2) { foreach (Rpt_ReportValueGroups f in report.GetValueGroups()) { cbxl_Fields.Items.Add(f.DisplayName); } } #endregion } }
private void BindGrid(bool IsExport, bool LoadFromCache) { Guid reportid = new Guid(ViewState["Report"].ToString()); Rpt_ReportBLL report = new Rpt_ReportBLL(reportid); lb_ReportTitle.Text = report.Model.Title; Dictionary<string, object> param; if (!pl_Param.GetParamsValue(out param)) { MessageBox.Show(this, "请正确设定必填参数!"); return; } if (report.LoadData(param, LoadFromCache)) { if (!IsExport) { #region 绑定图表 Chart1.Series.Clear(); Chart1.ChartAreas.Clear(); DataTable dt_chart = report.GetReportData(); if (report.GetCharts().Count == 0) Chart1.Visible = false; else { Chart1.Legends.Clear(); Chart1.Series.Clear(); Chart1.ChartAreas.Clear(); int chartindex = 0; foreach (Rpt_ReportCharts chart in report.GetCharts()) { chartindex++; ChartArea chartarea = new ChartArea("ChartArea" + chartindex.ToString()); Chart1.ChartAreas.Add(chartarea); chartarea.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dot; chartarea.AxisX.MajorGrid.Interval = 1; chartarea.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dot; chartarea.AxisX.MajorGrid.LineColor = Color.LightGray; chartarea.AxisY.MajorGrid.LineColor = Color.LightGray; chartarea.AxisX.LabelStyle.Angle = 0; chartarea.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.IncreaseFont; chartarea.AxisX.IsLabelAutoFit = true; //chartarea.AxisX.LabelStyle.ForeColor = System.Drawing.Color.Blue; chartarea.AxisX.LabelAutoFitMaxFontSize = 8; chartarea.AxisX.LabelAutoFitMinFontSize = 5; chartarea.AxisY.LabelAutoFitMaxFontSize = 8; chartarea.AxisY.LabelAutoFitMinFontSize = 5; //3D显示 if (chart["Enable3D"] == "Y") chartarea.Area3DStyle.Enable3D = true; #region 第二轴坐标 if (chart["AxisX2Enabled"] == "Y") { chartarea.AxisX2.Enabled = AxisEnabled.True; chartarea.AxisX2.LabelAutoFitStyle = LabelAutoFitStyles.IncreaseFont; chartarea.AxisX2.LabelAutoFitMaxFontSize = 8; chartarea.AxisX2.LabelAutoFitMinFontSize = 5; } if (chart["AxisY2Enabled"] == "Y") { chartarea.AxisY2.Enabled = AxisEnabled.True; chartarea.AxisY2.LabelAutoFitStyle = LabelAutoFitStyles.IncreaseFont; chartarea.AxisY2.LabelAutoFitMaxFontSize = 8; chartarea.AxisY2.LabelAutoFitMinFontSize = 5; } #endregion #region 处理图表系列 IList<string> list_series = new List<string>(); string[] series_array = chart.SeriesColumns.Split(new char[] { ',', '|' }, StringSplitOptions.RemoveEmptyEntries); if (report.Model.ReportType == 1) { //普通列表 for (int i = 0; i < series_array.Length; i++) { if (dt_chart.Columns.Contains(series_array[i])) list_series.Add(series_array[i]); } } if (report.Model.ReportType == 2) { //矩阵表 IList<Rpt_ReportRowGroups> rowgroups = report.GetRowGroups(); IList<Rpt_ReportValueGroups> valuegroups = report.GetValueGroups(); for (int i = 0; i < series_array.Length; i++) { foreach (DataColumn column in dt_chart.Columns) { if (rowgroups.FirstOrDefault(p => p.DisplayName == column.ColumnName) != null) { continue; } if (valuegroups.Count == 1) list_series.Add(column.ColumnName); else { if (column.ColumnName.EndsWith(series_array[i])) list_series.Add(column.ColumnName); } } chartarea.AxisY.Title += series_array[i] + " "; chartarea.AxisY.TitleFont = new Font("宋体", 9); chartarea.AxisY.TitleForeColor = Color.Blue; } } Legend legend = new Legend("Legend" + chartindex.ToString()); legend.Docking = Docking.Bottom; legend.Alignment = StringAlignment.Center; legend.Title = chartarea.AxisY.Title; Chart1.Legends.Add(legend); foreach (string seriesname in list_series) { Series series = new Series(seriesname); string charttypedesc = DictionaryBLL.GetDicCollections("RPT_ReportChartType")[chart.ChartType.ToString()].Description; series.ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), charttypedesc, true); series.ChartArea = chartarea.Name; series.Legend = legend.Name; series.YValueMembers = seriesname; series.XValueMember = chart.AxisColumns; series.ToolTip = seriesname; if (series.ChartType == SeriesChartType.Spline || series.ChartType == SeriesChartType.Line) { series.BorderWidth = 3; chartarea.AxisX.IsMarginVisible = false; } if (chart["IsValueShownAsLabel"] == "Y") series.IsValueShownAsLabel = true; //显示值标签 if (DictionaryBLL.GetDicCollections("PRT_ChartDrawingStyle").ContainsKey(chart["DrawingStyle"])) { Dictionary_Data dic = DictionaryBLL.GetDicCollections("PRT_ChartDrawingStyle")[chart["DrawingStyle"]]; series.CustomProperties = "DrawingStyle=" + dic.Description; } Chart1.Series.Add(series); } #endregion #region 设置横向轴分组式Label IList<Rpt_ReportRowGroups> RowGroups = report.GetRowGroups(); for (int rowgroupindex = 0; rowgroupindex < RowGroups.Count; rowgroupindex++) { int startposition = 0; for (int i = 0; i < dt_chart.Rows.Count; i++) { if (i == dt_chart.Rows.Count - 1 || dt_chart.Rows[i][RowGroups[rowgroupindex].DisplayName].ToString() != dt_chart.Rows[i + 1][RowGroups[rowgroupindex].DisplayName].ToString()) { chartarea.AxisX.CustomLabels.Add(startposition + 0.5, i + 1.4, dt_chart.Rows[i][RowGroups[rowgroupindex].DisplayName].ToString(), RowGroups.Count - rowgroupindex - 1, LabelMarkStyle.LineSideMark); startposition = i + 1; } } } #endregion } Chart1.Height = new Unit(500 * Chart1.ChartAreas.Count); Chart1.DataSource = dt_chart; Chart1.DataBind(); } #endregion } #region 绑定GridView DataTable dt_gridview = report.GetReportDataWithSummary(); if (report.Model.ReportType == 1) { GridView1.AllowPaging = !IsExport; GridView1.PageSize = 50; GridView1.DataSource = dt_gridview; GridView1.DataBind(); } else if (report.Model.ReportType == 2) { GridView1.AllowPaging = !IsExport; GridView1.PageSize = 100; GridView1.DataSource = dt_gridview; GridView1.DataBind(); GridViewMatric(GridView1); } lb_PageInfo.Visible = false; bt_PrePage.Visible = false; bt_NextPage.Visible = false; if (GridView1.AllowPaging) { lb_PageInfo.Text = string.Format("每页<b><font color=red>{0}</font></b>条/共<b><font color=red>{1}</font></b>条 第<b><font color=red>{2}</font></b>页/共<b><font color=red>{3}</font></b>页", GridView1.PageSize > dt_gridview.Rows.Count ? dt_gridview.Rows.Count : GridView1.PageSize, dt_gridview.Rows.Count, GridView1.PageIndex + 1, GridView1.PageCount); lb_PageInfo.Visible = true; if (GridView1.PageIndex > 0) bt_PrePage.Visible = true; if (GridView1.PageIndex < GridView1.PageCount - 1) bt_NextPage.Visible = true; } if (dt_gridview.Columns.Count >= 22) GridView1.Width = new Unit(dt_gridview.Columns.Count * 65); else GridView1.Width = new Unit(100, UnitType.Percentage); if (!IsExport) { int rowindex = 0; foreach (Rpt_ReportRowGroups rowgroup in report.GetRowGroups()) { if (dt_gridview.Columns.Contains(rowgroup.DisplayName)) { GridViewMergSampeValueRow(GridView1, rowindex); rowindex++; } } } #endregion if (report.DataCacheTime <= DateTime.Now.AddMinutes(-1)) { bt_ClearDataCache.Visible = true; lb_DataSetCacheTime.Visible = true; lb_DataSetCacheTime.Text = " 数据源来自历史快照,获取时间:" + report.DataCacheTime.ToString("yyyy-MM-dd HH:mm"); } else { bt_ClearDataCache.Visible = false; lb_DataSetCacheTime.Visible = false; } } else { MessageBox.Show(this, "未能检索到数据!"); } }
private void BindGrid_ValueGroup() { Rpt_ReportBLL report = new Rpt_ReportBLL((Guid)ViewState["ID"]); gv_List_ValueGroup.BindGrid(report.GetValueGroups()); }
private void BindDataSetFields() { Rpt_ReportBLL report = new Rpt_ReportBLL((Guid)ViewState["ID"]); IList<Rpt_DataSetFields> fields = new Rpt_DataSetBLL((Guid)ViewState["DataSet"]).GetFields(); foreach (Rpt_ReportColumnGroups col in report.GetColumnGroups()) { Rpt_DataSetFields f = fields.FirstOrDefault(p => p.ID == col.DataSetField); if (f != null) fields.Remove(f); } foreach (Rpt_ReportRowGroups col in report.GetRowGroups()) { Rpt_DataSetFields f = fields.FirstOrDefault(p => p.ID == col.DataSetField); if (f != null) fields.Remove(f); } foreach (Rpt_ReportValueGroups col in report.GetValueGroups()) { Rpt_DataSetFields f = fields.FirstOrDefault(p => p.ID == col.DataSetField); if (f != null) fields.Remove(f); } cbxl_Fields.DataSource = fields; cbxl_Fields.DataBind(); }
private void BindGrid(bool IsExport, bool LoadFromCache) { Guid reportid = new Guid(ViewState["Report"].ToString()); Rpt_ReportBLL report = new Rpt_ReportBLL(reportid); lb_ReportTitle.Text = report.Model.Title; Dictionary <string, object> param; if (!pl_Param.GetParamsValue(out param)) { MessageBox.Show(this, "请正确设定必填参数!"); return; } if (report.LoadData(param, LoadFromCache)) { if (!IsExport) { #region 绑定图表 Chart1.Series.Clear(); Chart1.ChartAreas.Clear(); DataTable dt_chart = report.GetReportData(); if (report.GetCharts().Count == 0) { Chart1.Visible = false; } else { Chart1.Legends.Clear(); Chart1.Series.Clear(); Chart1.ChartAreas.Clear(); int chartindex = 0; foreach (Rpt_ReportCharts chart in report.GetCharts()) { chartindex++; ChartArea chartarea = new ChartArea("ChartArea" + chartindex.ToString()); Chart1.ChartAreas.Add(chartarea); chartarea.AxisX.MajorGrid.LineDashStyle = ChartDashStyle.Dot; chartarea.AxisX.MajorGrid.Interval = 1; chartarea.AxisY.MajorGrid.LineDashStyle = ChartDashStyle.Dot; chartarea.AxisX.MajorGrid.LineColor = Color.LightGray; chartarea.AxisY.MajorGrid.LineColor = Color.LightGray; chartarea.AxisX.LabelStyle.Angle = 0; chartarea.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.IncreaseFont; chartarea.AxisX.IsLabelAutoFit = true; //chartarea.AxisX.LabelStyle.ForeColor = System.Drawing.Color.Blue; chartarea.AxisX.LabelAutoFitMaxFontSize = 8; chartarea.AxisX.LabelAutoFitMinFontSize = 5; chartarea.AxisY.LabelAutoFitMaxFontSize = 8; chartarea.AxisY.LabelAutoFitMinFontSize = 5; //3D显示 if (chart["Enable3D"] == "Y") { chartarea.Area3DStyle.Enable3D = true; } #region 第二轴坐标 if (chart["AxisX2Enabled"] == "Y") { chartarea.AxisX2.Enabled = AxisEnabled.True; chartarea.AxisX2.LabelAutoFitStyle = LabelAutoFitStyles.IncreaseFont; chartarea.AxisX2.LabelAutoFitMaxFontSize = 8; chartarea.AxisX2.LabelAutoFitMinFontSize = 5; } if (chart["AxisY2Enabled"] == "Y") { chartarea.AxisY2.Enabled = AxisEnabled.True; chartarea.AxisY2.LabelAutoFitStyle = LabelAutoFitStyles.IncreaseFont; chartarea.AxisY2.LabelAutoFitMaxFontSize = 8; chartarea.AxisY2.LabelAutoFitMinFontSize = 5; } #endregion #region 处理图表系列 IList <string> list_series = new List <string>(); string[] series_array = chart.SeriesColumns.Split(new char[] { ',', '|' }, StringSplitOptions.RemoveEmptyEntries); if (report.Model.ReportType == 1) { //普通列表 for (int i = 0; i < series_array.Length; i++) { if (dt_chart.Columns.Contains(series_array[i])) { list_series.Add(series_array[i]); } } } if (report.Model.ReportType == 2) { //矩阵表 IList <Rpt_ReportRowGroups> rowgroups = report.GetRowGroups(); IList <Rpt_ReportValueGroups> valuegroups = report.GetValueGroups(); for (int i = 0; i < series_array.Length; i++) { foreach (DataColumn column in dt_chart.Columns) { if (rowgroups.FirstOrDefault(p => p.DisplayName == column.ColumnName) != null) { continue; } if (valuegroups.Count == 1) { list_series.Add(column.ColumnName); } else { if (column.ColumnName.EndsWith(series_array[i])) { list_series.Add(column.ColumnName); } } } chartarea.AxisY.Title += series_array[i] + " "; chartarea.AxisY.TitleFont = new Font("宋体", 9); chartarea.AxisY.TitleForeColor = Color.Blue; } } Legend legend = new Legend("Legend" + chartindex.ToString()); legend.Docking = Docking.Bottom; legend.Alignment = StringAlignment.Center; legend.Title = chartarea.AxisY.Title; Chart1.Legends.Add(legend); foreach (string seriesname in list_series) { Series series = new Series(seriesname); string charttypedesc = DictionaryBLL.GetDicCollections("RPT_ReportChartType")[chart.ChartType.ToString()].Description; series.ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), charttypedesc, true); series.ChartArea = chartarea.Name; series.Legend = legend.Name; series.YValueMembers = seriesname; series.XValueMember = chart.AxisColumns; series.ToolTip = seriesname; if (series.ChartType == SeriesChartType.Spline || series.ChartType == SeriesChartType.Line) { series.BorderWidth = 3; chartarea.AxisX.IsMarginVisible = false; } if (chart["IsValueShownAsLabel"] == "Y") { series.IsValueShownAsLabel = true; //显示值标签 } if (DictionaryBLL.GetDicCollections("PRT_ChartDrawingStyle").ContainsKey(chart["DrawingStyle"])) { Dictionary_Data dic = DictionaryBLL.GetDicCollections("PRT_ChartDrawingStyle")[chart["DrawingStyle"]]; series.CustomProperties = "DrawingStyle=" + dic.Description; } Chart1.Series.Add(series); } #endregion #region 设置横向轴分组式Label IList <Rpt_ReportRowGroups> RowGroups = report.GetRowGroups(); for (int rowgroupindex = 0; rowgroupindex < RowGroups.Count; rowgroupindex++) { int startposition = 0; for (int i = 0; i < dt_chart.Rows.Count; i++) { if (i == dt_chart.Rows.Count - 1 || dt_chart.Rows[i][RowGroups[rowgroupindex].DisplayName].ToString() != dt_chart.Rows[i + 1][RowGroups[rowgroupindex].DisplayName].ToString()) { chartarea.AxisX.CustomLabels.Add(startposition + 0.5, i + 1.4, dt_chart.Rows[i][RowGroups[rowgroupindex].DisplayName].ToString(), RowGroups.Count - rowgroupindex - 1, LabelMarkStyle.LineSideMark); startposition = i + 1; } } } #endregion } Chart1.Height = new Unit(500 * Chart1.ChartAreas.Count); Chart1.DataSource = dt_chart; Chart1.DataBind(); } #endregion } #region 绑定GridView DataTable dt_gridview = report.GetReportDataWithSummary(); if (report.Model.ReportType == 1) { GridView1.AllowPaging = !IsExport; GridView1.PageSize = 50; GridView1.DataSource = dt_gridview; GridView1.DataBind(); } else if (report.Model.ReportType == 2) { GridView1.AllowPaging = !IsExport; GridView1.PageSize = 100; GridView1.DataSource = dt_gridview; GridView1.DataBind(); GridViewMatric(GridView1); } lb_PageInfo.Visible = false; bt_PrePage.Visible = false; bt_NextPage.Visible = false; if (GridView1.AllowPaging) { lb_PageInfo.Text = string.Format("每页<b><font color=red>{0}</font></b>条/共<b><font color=red>{1}</font></b>条 第<b><font color=red>{2}</font></b>页/共<b><font color=red>{3}</font></b>页", GridView1.PageSize > dt_gridview.Rows.Count ? dt_gridview.Rows.Count : GridView1.PageSize, dt_gridview.Rows.Count, GridView1.PageIndex + 1, GridView1.PageCount); lb_PageInfo.Visible = true; if (GridView1.PageIndex > 0) { bt_PrePage.Visible = true; } if (GridView1.PageIndex < GridView1.PageCount - 1) { bt_NextPage.Visible = true; } } if (dt_gridview.Columns.Count >= 22) { GridView1.Width = new Unit(dt_gridview.Columns.Count * 65); } else { GridView1.Width = new Unit(100, UnitType.Percentage); } if (!IsExport) { int rowindex = 0; foreach (Rpt_ReportRowGroups rowgroup in report.GetRowGroups()) { if (dt_gridview.Columns.Contains(rowgroup.DisplayName)) { GridViewMergSampeValueRow(GridView1, rowindex); rowindex++; } } } #endregion if (report.DataCacheTime <= DateTime.Now.AddMinutes(-1)) { bt_ClearDataCache.Visible = true; lb_DataSetCacheTime.Visible = true; lb_DataSetCacheTime.Text = " 数据源来自历史快照,获取时间:" + report.DataCacheTime.ToString("yyyy-MM-dd HH:mm"); } else { bt_ClearDataCache.Visible = false; lb_DataSetCacheTime.Visible = false; } } else { MessageBox.Show(this, "未能检索到数据!"); } }