protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { #region 获取页面参数 ViewState["Report"] = Request.QueryString["Report"] != null ? new Guid(Request.QueryString["Report"]) : Guid.Empty; ViewState["LoadCache"] = Request.QueryString["LoadCache"] != null ? Request.QueryString["LoadCache"] != "false" : true; #endregion if ((Guid)ViewState["Report"] == Guid.Empty) { Response.Redirect("Rpt_ReportList.aspx"); } #region 判断有无浏览权限 //Rpt_Report rpt = new Rpt_ReportBLL((Guid)ViewState["Report"]).Model; //if (rpt == null) Response.Redirect("Rpt_ReportList.aspx"); //IList<Rpt_FolderRight> rights = Rpt_FolderRightBLL.GetAssignedRightByUser(Session["UserName"].ToString()).Where(p => p.Folder == rpt.Folder).ToList(); //if (rights.Count == 0) //{ // MessageBox.ShowAndRedirect(this, "对不起,您没有权限浏览该报表", "Rpt_ReportList.aspx"); // return; //} #endregion //增加浏览记录 Rpt_ReportBLL.AddViewTimes(new Guid(ViewState["Report"].ToString()), (int)Session["UserID"]); bt_Refresh_Click(null, null); } }
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 BindData() { Rpt_ReportCharts m = new Rpt_ReportChartsBLL((Guid)ViewState["ID"]).Model; if (m != null) { pl_detail.BindData(m); ViewState["Report"] = m.Report; Rpt_ReportBLL report = new Rpt_ReportBLL(m.Report); //设置轴字段下拉框的值 if (m.AxisColumns != "" && ddl_AxisColumns.Items.FindByValue(m.AxisColumns) != null) { ddl_AxisColumns.SelectedValue = m.AxisColumns; } //设置系列字段列复选框的打勾选项 foreach (string s in m.SeriesColumns.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)) { ListItem item = cbxl_Fields.Items.FindByValue(s); if (item != null) { item.Selected = true; } } } }
protected void gv_ReportList_RowDeleting(object sender, GridViewDeleteEventArgs e) { Guid reportid = new Guid(gv_ReportList.DataKeys[e.RowIndex]["ReportID"].ToString()); Rpt_ReportBLL.DeleteViewTimes(reportid, (int)Session["UserID"]); BindRports(); }
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(); }
protected void bt_Add_Click(object sender, EventArgs e) { SaveGrid(); Rpt_ReportBLL report = new Rpt_ReportBLL((Guid)ViewState["ID"]); IList <Rpt_ReportGridColumns> columns = report.GetGridColumns(); int maxsortid = 0; if (columns.Count > 0) { maxsortid = columns.Max(p => p.ColumnSortID); } foreach (ListItem item in cbxl_Fields.Items) { if (item.Selected && columns.FirstOrDefault(p => p.DataSetField == new Guid(item.Value)) == null) { maxsortid++; Rpt_ReportGridColumnsBLL column = new Rpt_ReportGridColumnsBLL(); column.Model.Report = (Guid)ViewState["ID"]; column.Model.DataSetField = new Guid(item.Value); column.Model.DisplayName = item.Text; column.Model.ColumnSortID = maxsortid; column.Model.AddSummary = "N"; column.Model.Visible = "Y"; column.Add(); } } BindDataSetFields(); BindGrid(); }
protected void Page_Load(object sender, EventArgs e) { #region 获取页面参数 ViewState["ID"] = Request.QueryString["ID"] != null ? new Guid(Request.QueryString["ID"]) : Guid.Empty; #endregion if ((Guid)ViewState["ID"] == Guid.Empty) Response.Redirect("Rpt_ReportList.aspx"); Rpt_Report m = new Rpt_ReportBLL((Guid)ViewState["ID"]).Model; if (m != null) { #region 根据报表类型控制Tab可见 switch (m.ReportType) { case 1: MCSTabControl1.Items[2].Visible = false; break; case 2: MCSTabControl1.Items[1].Visible = false; break; } #endregion } BindGrid(); }
protected void Page_Load(object sender, EventArgs e) { #region 获取页面参数 ViewState["ID"] = Request.QueryString["ID"] != null ? new Guid(Request.QueryString["ID"]) : Guid.Empty; #endregion if ((Guid)ViewState["ID"] == Guid.Empty) { Response.Redirect("Rpt_ReportList.aspx"); } Rpt_Report m = new Rpt_ReportBLL((Guid)ViewState["ID"]).Model; if (m != null) { #region 根据报表类型控制Tab可见 switch (m.ReportType) { case 1: MCSTabControl1.Items[2].Visible = false; break; case 2: MCSTabControl1.Items[1].Visible = false; break; } #endregion } BindGrid(); }
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 } }
protected void bt_OK_Click(object sender, EventArgs e) { Rpt_ReportBLL _bll; if ((Guid)ViewState["ID"] != Guid.Empty) { //修改 _bll = new Rpt_ReportBLL((Guid)ViewState["ID"]); } else { //新增 _bll = new Rpt_ReportBLL(); } pl_detail.GetData(_bll.Model); #region 判断必填项 if (_bll.Model.DataSet == Guid.Empty) { MessageBox.Show(this, "请正确选择报表使用的数据集!"); return; } #endregion if (_bll.Model.Title == "") { _bll.Model.Title = _bll.Model.Name; } if (_bll.Model.ReportType == 1 && _bll.Model.AddColumnTotal != "N") { _bll.Model.AddColumnTotal = "N"; } if ((Guid)ViewState["ID"] != Guid.Empty) { //修改 _bll.Model.UpdateStaff = (int)Session["UserID"]; if (_bll.Update() == 0) { MessageBox.ShowAndRedirect(this, "修改成功!", "Rpt_ReportDetail.aspx?ID=" + _bll.Model.ID.ToString()); } } else { //新增 _bll.Model.InsertStaff = (int)Session["UserID"]; if (_bll.Add() == 0) { MessageBox.ShowAndRedirect(this, "新增成功!", "Rpt_ReportDetail.aspx?ID=" + _bll.Model.ID.ToString()); } } }
private void BindData() { IList <Rpt_Folder> _folder_list = Rpt_FolderBLL.GetModelList(" superid=" + (string)ViewState["FolderID"]); rp_1.DataSource = _folder_list; rp_1.DataBind(); IList <Rpt_Report> _file_list = Rpt_ReportBLL.GetModelList(" folder=" + (string)ViewState["FolderID"]); rp_2.DataSource = _file_list; rp_2.DataBind(); }
protected void bt_SaveDataCacache_Click(object sender, EventArgs e) { Dictionary <string, object> param; if (!pl_Param.GetParamsValue(out param)) { MessageBox.Show(this, "请正确设定必填参数!"); return; } Guid reportid = new Guid(ViewState["Report"].ToString()); Rpt_ReportBLL report = new Rpt_ReportBLL(reportid); report.SaveForever(param); MessageBox.Show(this, "保存成功"); }
public void OptimizaToExcel(GridView gv) { IWorkbook hssfworkbook = GvToWorkBook(gv); MemoryStream memory = new MemoryStream(); try { hssfworkbook.Write(memory); memory.Close(); } catch (Exception e1) { MessageBox.Show(Page, "errorMessage=" + e1.Message); } Guid reportGuid = Request.QueryString["Report"] != null ? new Guid(Request.QueryString["Report"]) : Guid.Empty; //增加浏览记录 string fileName = new Rpt_ReportBLL(reportGuid).Model.Name; this.DownLoadFile(memory, fileName); }
protected void bt_ExprotList_Click(object sender, EventArgs e) { string filename = HttpUtility.UrlEncode(Encoding.UTF8.GetBytes(lb_ReportTitle.Text.Trim() == "" ? "Export" : lb_ReportTitle.Text.Trim())); 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, true)) { CreateExcel(report.GetReportData(), filename); } }
private void BindData() { Rpt_Report m = new Rpt_ReportBLL((Guid)ViewState["ID"]).Model; if (m != null) { pl_detail.BindData(m); #region 根据报表类型控制Tab可见 switch (m.ReportType) { case 1: MCSTabControl1.Items[2].Visible = false; break; case 2: MCSTabControl1.Items[1].Visible = false; break; } #endregion } }
protected void bt_ExprotList_Click(object sender, EventArgs e) { string filename = HttpUtility.UrlEncode(Encoding.UTF8.GetBytes(lb_ReportTitle.Text.Trim() == "" ? "Export" : lb_ReportTitle.Text.Trim())); 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, true)) { CreateExcel(report.GetReportData(), filename); } }
private void BindGrid() { Rpt_ReportBLL report = new Rpt_ReportBLL((Guid)ViewState["ID"]); gv_List.BindGrid(report.GetGridColumns()); }
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, "未能检索到数据!"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { #region 获取页面参数 ViewState["Report"] = Request.QueryString["Report"] != null ? new Guid(Request.QueryString["Report"]) : Guid.Empty; ViewState["LoadCache"] = Request.QueryString["LoadCache"] != null ? Request.QueryString["LoadCache"] != "false" : true; #endregion if ((Guid)ViewState["Report"] == Guid.Empty) { Response.Redirect("Rpt_ReportList.aspx"); } #region 判断有无浏览权限 Rpt_Report rpt = new Rpt_ReportBLL((Guid)ViewState["Report"]).Model; if (rpt == null) Response.Redirect("Rpt_ReportList.aspx"); IList<Rpt_FolderRight> rights = Rpt_FolderRightBLL.GetAssignedRightByUser(Session["UserName"].ToString()).Where(p => p.Folder == rpt.Folder).ToList(); if (rights.Count == 0) { MessageBox.ShowAndRedirect(this, "对不起,您没有权限浏览该报表", "Rpt_ReportList.aspx"); return; } #endregion //增加浏览记录 Rpt_ReportBLL.AddViewTimes(new Guid(ViewState["Report"].ToString()), (int)Session["UserID"]); } }
protected void BindRports() { gv_ReportList.DataSource = Rpt_ReportBLL.GetFrequentByStaff((int)Session["UserID"]); gv_ReportList.DataBind(); }
protected void bt_SaveDataCacache_Click(object sender, EventArgs e) { Dictionary<string, object> param; if (!pl_Param.GetParamsValue(out param)) { MessageBox.Show(this, "请正确设定必填参数!"); return; } Guid reportid = new Guid(ViewState["Report"].ToString()); Rpt_ReportBLL report = new Rpt_ReportBLL(reportid); report.SaveForever(param); MessageBox.Show(this, "保存成功"); }
public void OptimizaToExcel(GridView gv) { IWorkbook hssfworkbook = GvToWorkBook(gv); MemoryStream memory = new MemoryStream(); try { hssfworkbook.Write(memory); memory.Close(); } catch (Exception e1) { MessageBox.Show(Page, "errorMessage=" + e1.Message); } Guid reportGuid = Request.QueryString["Report"] != null ? new Guid(Request.QueryString["Report"]) : Guid.Empty; //增加浏览记录 string fileName = new Rpt_ReportBLL(reportGuid).Model.Name; this.DownLoadFile(memory,fileName); }
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 BindData() { Rpt_ReportCharts m = new Rpt_ReportChartsBLL((Guid)ViewState["ID"]).Model; if (m != null) { pl_detail.BindData(m); ViewState["Report"] = m.Report; Rpt_ReportBLL report = new Rpt_ReportBLL(m.Report); //设置轴字段下拉框的值 if (m.AxisColumns != "" && ddl_AxisColumns.Items.FindByValue(m.AxisColumns) != null) { ddl_AxisColumns.SelectedValue = m.AxisColumns; } //设置系列字段列复选框的打勾选项 foreach (string s in m.SeriesColumns.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries)) { ListItem item = cbxl_Fields.Items.FindByValue(s); if (item != null) item.Selected = true; } } }
private void BindDataSetFields() { Rpt_ReportBLL report = new Rpt_ReportBLL((Guid)ViewState["ID"]); IList<Rpt_ReportGridColumns> columns = report.GetGridColumns(); IList<Rpt_DataSetFields> fields = new Rpt_DataSetBLL((Guid)ViewState["DataSet"]).GetFields(); foreach (Rpt_ReportGridColumns col in columns) { 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, "未能检索到数据!"); } }
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 } }