private void BuildDataFormat(out RptViewGridDataFormat gridDataFormat, out RptViewDataFormat dataFormat, string formatType, string columnName, string groupSeq, string styleValue) { gridDataFormat = new RptViewGridDataFormat(); dataFormat = new RptViewDataFormat(); string strId = System.Guid.NewGuid().ToString(); dataFormat.FormatID = strId; gridDataFormat.FormatID = strId; if (formatType == "header") { gridDataFormat.StyleType = ReportStyleType.Header; gridDataFormat.ColumnName = columnName; } else if (formatType == "groupdata") { gridDataFormat.StyleType = ReportStyleType.SubTotal; gridDataFormat.ColumnName = columnName; gridDataFormat.GroupSequence = decimal.Parse(groupSeq); } else if (formatType == "itemdata") { gridDataFormat.StyleType = ReportStyleType.Item; gridDataFormat.ColumnName = columnName; } dataFormat = (new ReportViewFacade(this.DataProvider)).BuildDataFormatByStyle(styleValue); dataFormat.FormatID = strId; dataFormat.MaintainUser = this.GetUserCode(); }
private string BuildExtendText(ReportDesignView designView, XmlDocument formatXml) { dRptExtendTextHeight = 0; if (designView.ExtendText == null || designView.ExtendText.Length == 0 || designView.DataFormats == null || designView.DataFormats.Length == 0) { return(""); } decimal dRptWidth = 0; foreach (decimal dWidthTmp in dicColumnWidth.Values) { dRptWidth += dWidthTmp; } decimal dTop = 0; StringBuilder sbText = new StringBuilder(); string strTextFormat = formatXml.SelectSingleNode("//ExtendText").FirstChild.Value; for (int i = 0; i < designView.ExtendText.Length; i++) { RptViewDataFormat dataFormat = null; for (int n = 0; n < designView.DataFormats.Length; n++) { if (designView.DataFormats[n].FormatID == designView.ExtendText[i].FormatID) { dataFormat = designView.DataFormats[n]; break; } } if (dataFormat == null) { continue; } decimal dHeight = 0.6M + 0.1M * (dataFormat.FontSize - 10); decimal dLeft = 0; if (dataFormat.TextAlign == "Center") { dLeft = (dRptWidth - dataFormat.ColumnWidth) / 2; } else if (dataFormat.TextAlign == "Right") { dLeft = dRptWidth - dataFormat.ColumnWidth; } string strTextTmp = strTextFormat; strTextTmp = strTextTmp.Replace("<%TextBoxName%>", "RptExtText_" + designView.ExtendText[i].Sequence.ToString()); strTextTmp = strTextTmp.Replace("<%Left%>", dLeft.ToString()); strTextTmp = strTextTmp.Replace("<%Top%>", dTop.ToString()); strTextTmp = strTextTmp.Replace("<%Height%>", dHeight.ToString()); strTextTmp = strTextTmp.Replace("<%Width%>", dataFormat.ColumnWidth.ToString()); strTextTmp = this.ApplyFontStyle(strTextTmp, designView, dataFormat.FormatID, formatXml, out dataFormat); strTextTmp = strTextTmp.Replace("<%TextValue%>", dataFormat.TextExpress); sbText.Append(strTextTmp); dTop += dHeight; } dRptExtendTextHeight = dTop; return(sbText.ToString()); }
/// <summary> /// 将字体格式设置应用到内容 /// </summary> private string ApplyFontStyle(string content, ReportDesignView designView, string formatId, XmlDocument formatXml, out RptViewDataFormat outDataFormat) { RptViewDataFormat format = null; for (int i = 0; designView.DataFormats != null && i < designView.DataFormats.Length; i++) { if (designView.DataFormats[i].FormatID == formatId) { format = designView.DataFormats[i]; break; } } if (format == null) { for (int i = 0; designView.ChartDataFormats != null && i < designView.ChartDataFormats.Length; i++) { if (designView.ChartDataFormats[i].FormatID == formatId) { format = designView.ChartDataFormats[i]; break; } } } outDataFormat = format; if (format == null || formatId == null) { string strBorderTemp = formatXml.SelectSingleNode("//CellBorderStyle").FirstChild.Value; strBorderTemp = strBorderTemp.Replace("<%BorderStyle%>", "Solid"); content = content.Replace("<%TableCellStyle%>", strBorderTemp); return(content); } string strStyle = formatXml.SelectSingleNode("//TableCellStyle").FirstChild.Value; strStyle = strStyle.Replace("<%FontFamily%>", format.FontFamily); strStyle = strStyle.Replace("<%FontSize%>", Convert.ToInt32(format.FontSize).ToString() + "pt"); strStyle = strStyle.Replace("<%FontWeight%>", format.FontWeight == "Bold" ? "700" : "400"); strStyle = strStyle.Replace("<%TextDecoration%>", format.TextDecoration); strStyle = strStyle.Replace("<%FontStyle%>", format.FontStyle); strStyle = strStyle.Replace("<%BackgroundColor%>", format.BackgroundColor); strStyle = strStyle.Replace("<%Color%>", format.Color); strStyle = strStyle.Replace("<%Format%>", format.TextFormat); string strBorderStyle = ""; if (format.BorderStyle != "0") { strBorderStyle = formatXml.SelectSingleNode("//CellBorderStyle").FirstChild.Value; strBorderStyle = strBorderStyle.Replace("<%BorderStyle%>", "Solid"); } strStyle = strStyle.Replace("<%BorderStyle%>", strBorderStyle); strStyle = strStyle.Replace("<%TextAlign%>", format.TextAlign); strStyle = strStyle.Replace("<%VerticalAlign%>", format.VerticalAlign); content = content.Replace("<%TableCellStyle%>", strStyle); return(content); }
void cmdSave_ServerClick(object sender, EventArgs e) { _facade = new ReportViewFacade(this.DataProvider); this.DataProvider.BeginTransaction(); try { if (this.hidHeaderRow.Value != "") { RptViewDataFormat format = _facade.BuildDataFormatByStyle(this.hidHeaderRow.Value); format.MaintainUser = this.GetUserCode(); _facade.UpdateRptViewReportStyleDetail(decimal.Parse(this.GetRequestParam("styleid")), ReportStyleType.Header, format); } if (this.hidGroup_0.Value != "") { RptViewDataFormat format = _facade.BuildDataFormatByStyle(this.hidGroup_0.Value); format.MaintainUser = this.GetUserCode(); _facade.UpdateRptViewReportStyleDetail(decimal.Parse(this.GetRequestParam("styleid")), ReportStyleType.SubTotal, format); } if (this.hidItemHeader.Value != "") { RptViewDataFormat format = _facade.BuildDataFormatByStyle(this.hidItemHeader.Value); format.MaintainUser = this.GetUserCode(); _facade.UpdateRptViewReportStyleDetail(decimal.Parse(this.GetRequestParam("styleid")), ReportStyleType.Item, format); } if (this.hidGroupData_0_0.Value != "") { RptViewDataFormat format = _facade.BuildDataFormatByStyle(this.hidGroupData_0_0.Value); format.MaintainUser = this.GetUserCode(); _facade.UpdateRptViewReportStyleDetail(decimal.Parse(this.GetRequestParam("styleid")), ReportStyleType.SubTotalGroupField, format); } if (this.hidGroupData_0_1.Value != "") { RptViewDataFormat format = _facade.BuildDataFormatByStyle(this.hidGroupData_0_1.Value); format.MaintainUser = this.GetUserCode(); _facade.UpdateRptViewReportStyleDetail(decimal.Parse(this.GetRequestParam("styleid")), ReportStyleType.SubTotalNonCalField, format); } if (this.hidGroupData_0_2.Value != "") { RptViewDataFormat format = _facade.BuildDataFormatByStyle(this.hidGroupData_0_2.Value); format.MaintainUser = this.GetUserCode(); _facade.UpdateRptViewReportStyleDetail(decimal.Parse(this.GetRequestParam("styleid")), ReportStyleType.SubTotalCalField, format); } this.DataProvider.CommitTransaction(); } catch (Exception ex) { this.DataProvider.RollbackTransaction(); throw ex; } finally { } }
private void BuildExtendTextObject(out RptViewExtendText extendText, out RptViewDataFormat dataFormat, string styleValue) { extendText = new RptViewExtendText(); dataFormat = new RptViewDataFormat(); string strId = System.Guid.NewGuid().ToString(); extendText.FormatID = strId; extendText.MaintainUser = this.GetUserCode(); dataFormat = (new ReportViewFacade(this.DataProvider)).BuildDataFormatByStyle(styleValue); dataFormat.FormatID = strId; dataFormat.MaintainUser = this.GetUserCode(); }
private void SaveColumnWidth(string columnName, RptViewDataFormat dataFormat) { if (dataFormat != null) { decimal dWidth = dataFormat.ColumnWidth; if (this.dicColumnWidth.ContainsKey(columnName) == false) { this.dicColumnWidth.Add(columnName, dWidth); } else if (this.dicColumnWidth[columnName] < dWidth) { this.dicColumnWidth[columnName] = dWidth; } } }
/// <summary> /// 构建Chart Data /// </summary> private string BuildChartData(ReportDesignView designView, RptViewChartMain chartMain, XmlDocument formatXml) { StringBuilder sbData = new StringBuilder(); string strDataFormat = formatXml.SelectSingleNode("//ChartData").FirstChild.Value; for (int i = 0; designView.ChartDatas != null && i < designView.ChartDatas.Length; i++) { if (designView.ChartDatas[i].ChartSequence == chartMain.ChartSequence) { RptViewChartData chartData = designView.ChartDatas[i]; string strColumnName = designView.ChartDatas[i].ColumnName; string strTmp = strDataFormat; string strValue = ""; if (chartData.TotalType == ReportTotalType.Sum) { strValue = "=Sum(Fields!" + strColumnName + ".Value)"; } else if (chartData.TotalType == ReportTotalType.Avg) { strValue = "=Avg(Fields!" + strColumnName + ".Value)"; } else if (chartData.TotalType == ReportTotalType.Count) { strValue = "=Count(Fields!" + strColumnName + ".Value)"; } strTmp = strTmp.Replace("<%Value%>", strValue); string strLabel = ""; if (FormatHelper.StringToBoolean(chartMain.ShowLabel) == true) { strLabel = formatXml.SelectSingleNode("//ChartDataLabelStyle").FirstChild.Value; RptViewDataFormat dataFormat = null; strLabel = this.ApplyFontStyle(strLabel, designView, chartMain.LabelFormatID, formatXml, out dataFormat); } strTmp = strTmp.Replace("<%DataLabelStyle%>", strLabel); string strMarker = ""; if (FormatHelper.StringToBoolean(chartMain.ShowMarker) == true) { strMarker = formatXml.SelectSingleNode("//ChartDataMarkerType").FirstChild.Value; strMarker = strMarker.Replace("<%MarkerType%>", chartMain.MarkerType); } strTmp = strTmp.Replace("<%MarkerType%>", strMarker); sbData.Append(strTmp); } } return(sbData.ToString()); }
/// <summary> /// 构建Header部分 /// </summary> private string BuildHeader(ReportDesignView designView, XmlDocument formatXml) { string strHeaderCells = ""; string strHeaderCell = formatXml.SelectSingleNode("//HeaderCell").FirstChild.Value; for (int i = 0; designView.GridColumns != null && i < designView.GridColumns.Length; i++) { string strColumnName = designView.GridColumns[i].ColumnName; string strTmp = strHeaderCell.Replace("<%TextBoxName%>", "table_header_field_" + strColumnName); string strGridDataFormatId = ""; for (int n = 0; designView.GridDataFormats != null && n < designView.GridDataFormats.Length; n++) { if (designView.GridDataFormats[n].StyleType == ReportStyleType.Header && designView.GridDataFormats[n].ColumnName == strColumnName) { strGridDataFormatId = designView.GridDataFormats[n].FormatID; break; } } RptViewDataFormat dataFormat = null; strTmp = this.ApplyFontStyle(strTmp, designView, strGridDataFormatId, formatXml, out dataFormat); SaveColumnWidth(strColumnName, dataFormat); string strHeaderText = ""; if (dataFormat == null || dataFormat.TextExpress == null || dataFormat.TextExpress == "") { strHeaderText = (designView.DataSourceColumns[strColumnName] != null ? designView.DataSourceColumns[strColumnName].Description : strColumnName); } else { strHeaderText = this.BuildCellTextExpression(designView, dataFormat.TextExpress); } strTmp = strTmp.Replace("<%HeaderText%>", strHeaderText); strTmp = strTmp.Replace("<%SortColumnName%>", "=Fields!" + strColumnName + ".Value"); strHeaderCells = strHeaderCells + strTmp; } return(strHeaderCells); }
private void BuildDataFormat(out RptViewDataFormat dataFormat, string styleValue) { dataFormat = new RptViewDataFormat(); string strId = System.Guid.NewGuid().ToString(); dataFormat.FormatID = strId; dataFormat.FontFamily = "Arial"; dataFormat.FontSize = 12; dataFormat.FontWeight = "Normal"; dataFormat.FontStyle = "Normal"; dataFormat.TextDecoration = "None"; dataFormat.Color = "Black"; dataFormat.BackgroundColor = "White"; dataFormat.TextAlign = "Left"; dataFormat.VerticalAlign = "Middle"; string[] styleList = styleValue.Split(';'); if (styleList.Length >= 10) { dataFormat.FontFamily = styleList[0]; // Font Family if (styleList[1] != "") // Font Size { dataFormat.FontSize = decimal.Parse(styleList[1]); } if (styleList[2] == "true") // Font Weight { dataFormat.FontWeight = "Bold"; } if (styleList[3] == "true") // Font Style { dataFormat.FontStyle = "Italic"; } if (styleList[4] == "true") // Font Decoration { dataFormat.TextDecoration = "Underline"; } if (styleList[5] != "") // Fore Color { dataFormat.Color = styleList[5]; } if (styleList[6] != "") // Back Color { dataFormat.BackgroundColor = styleList[6]; } if (styleList[7] == BenQGuru.eMES.Web.Helper.TextAlign.Center) // Text Align { dataFormat.TextAlign = "Center"; } else if (styleList[7] == BenQGuru.eMES.Web.Helper.TextAlign.Right) { dataFormat.TextAlign = "Right"; } else { dataFormat.TextAlign = "Left"; } if (styleList[8] == BenQGuru.eMES.Web.Helper.VerticalAlign.Top) // Vertical Align { dataFormat.VerticalAlign = "Top"; } else if (styleList[8] == BenQGuru.eMES.Web.Helper.VerticalAlign.Bottom) { dataFormat.VerticalAlign = "Bottom"; } else { dataFormat.VerticalAlign = "Middle"; } dataFormat.TextFormat = styleList[9]; // Text Format } }
protected override void UpdateReportDesignView() { RptViewChartMain chartMain = null; if (this.designView.ChartMains != null && this.designView.ChartMains.Length > 0) { chartMain = this.designView.ChartMains[0]; } else { chartMain = new RptViewChartMain(); } chartMain.ChartSequence = 1; chartMain.DataSourceID = this.designView.DesignMain.DataSourceID; chartMain.ChartType = this.hidChartType.Value; chartMain.ChartSubType = this.hidChartSubType.Value; chartMain.ShowLegend = FormatHelper.BooleanToString(this.chkIsShowLegend.Checked); chartMain.ShowMarker = FormatHelper.BooleanToString(this.chkIsShowMarker.Checked); if (this.chkIsShowMarker.Checked == false) { chartMain.MarkerType = ""; } else { chartMain.MarkerType = this.rdoListMarkerType.SelectedValue; } chartMain.ShowLabel = FormatHelper.BooleanToString(this.chkIsShowLabel.Checked); if (this.chkIsShowLabel.Checked == false) { chartMain.LabelFormatID = ""; this.designView.ChartDataFormats = null; } else { RptViewDataFormat dataFormat = null; this.BuildDataFormat(out dataFormat, this.hidLabelFormat.Value); chartMain.LabelFormatID = dataFormat.FormatID; this.designView.ChartDataFormats = new RptViewDataFormat[] { dataFormat }; } this.designView.ChartMains = new RptViewChartMain[] { chartMain }; ArrayList list = new ArrayList(); string[] strArrTmp = this.hidSelectedSeriesValue.Value.Split(';'); for (int i = 0; i < strArrTmp.Length; i++) { if (strArrTmp[i] == "") { continue; } RptViewChartSeries series = new RptViewChartSeries(); series.ChartSequence = 1; series.SeriesSequence = i + 1; series.DataSourceID = this.designView.DesignMain.DataSourceID; series.ColumnName = strArrTmp[i]; series.Description = this.lstSelectedSeries.Items.FindByValue(series.ColumnName).Text; list.Add(series); } this.designView.ChartSeries = new RptViewChartSeries[list.Count]; list.CopyTo(this.designView.ChartSeries); list = new ArrayList(); strArrTmp = this.hidSelectedCategoryValue.Value.Split(';'); for (int i = 0; i < strArrTmp.Length; i++) { if (strArrTmp[i] == "") { continue; } RptViewChartCategory cate = new RptViewChartCategory(); cate.ChartSequence = 1; cate.CategorySequence = i + 1; cate.DataSourceID = this.designView.DesignMain.DataSourceID; cate.ColumnName = strArrTmp[i]; list.Add(cate); } this.designView.ChartCategories = new RptViewChartCategory[list.Count]; list.CopyTo(this.designView.ChartCategories); list = new ArrayList(); for (int i = 0; i < this.gridWebGrid.Rows.Count; i++) { RptViewChartData data = new RptViewChartData(); data.ChartSequence = 1; data.DataSequence = i + 1; data.DataSourceID = this.designView.DesignMain.DataSourceID; data.ColumnName = this.gridWebGrid.Rows[i].Items.FindItemByKey("ColumnName").Value.ToString(); data.Description = this.gridWebGrid.Rows[i].Items.FindItemByKey("DisplayDesc").Value.ToString(); data.TotalType = this.gridWebGrid.Rows[i].Items.FindItemByKey("TotalType").Value.ToString(); list.Add(data); } this.designView.ChartDatas = new RptViewChartData[list.Count]; list.CopyTo(this.designView.ChartDatas); }
protected override void DisplayDesignData() { if (this.designView.ChartMains != null && this.designView.ChartMains.Length > 0) { this.hidChartType.Value = this.designView.ChartMains[0].ChartType; this.hidChartSubType.Value = this.designView.ChartMains[0].ChartSubType; } if (this.designView.ChartSeries != null) { string strVal = ""; for (int i = 0; i < this.designView.ChartSeries.Length; i++) { System.Web.UI.WebControls.ListItem item = this.lstUnSelectedSeries.Items.FindByValue(this.designView.ChartSeries[i].ColumnName); if (item == null) { continue; } this.lstSelectedSeries.Items.Add(new System.Web.UI.WebControls.ListItem(item.Text, item.Value)); strVal += item.Value + ";"; this.lstUnSelectedSeries.Items.Remove(item); } this.hidSelectedSeriesValue.Value = strVal; } if (this.designView.ChartCategories != null) { string strVal = ""; for (int i = 0; i < this.designView.ChartCategories.Length; i++) { System.Web.UI.WebControls.ListItem item = this.lstUnSelectedCategory.Items.FindByValue(this.designView.ChartCategories[i].ColumnName); if (item == null) { continue; } this.lstSelectedCategory.Items.Add(new System.Web.UI.WebControls.ListItem(item.Text, item.Value)); strVal += item.Value + ";"; this.lstUnSelectedCategory.Items.Remove(item); } this.hidSelectedCategoryValue.Value = strVal; } if (this.designView.ChartDatas != null) { for (int i = 0; i < this.designView.ChartDatas.Length; i++) { System.Web.UI.WebControls.ListItem item = this.lstUnSelectColumn.Items.FindByValue(this.designView.ChartDatas[i].ColumnName); if (item == null) { continue; } DataRow row = DtSource.NewRow(); row["GUID"] = Guid.NewGuid().ToString(); row["Sequence"] = this.designView.ChartDatas[i].DataSequence; row["ColumnName"] = item.Value; row["DisplayDesc"] = this.designView.ChartDatas[i].Description; row["TotalType"] = this.designView.ChartDatas[i].TotalType; this.DtSource.Rows.Add(row); this.gridWebGrid.DataSource = DtSource; this.gridWebGrid.DataBind(); this.lstUnSelectColumn.Items.Remove(item); } } if (this.designView.ChartMains != null) { this.chkIsShowLegend.Checked = FormatHelper.StringToBoolean(this.designView.ChartMains[0].ShowLegend); this.chkIsShowMarker.Checked = FormatHelper.StringToBoolean(this.designView.ChartMains[0].ShowMarker); if (this.chkIsShowMarker.Checked == true) { this.rdoListMarkerType.SelectedValue = this.designView.ChartMains[0].MarkerType; } this.chkIsShowLabel.Checked = FormatHelper.StringToBoolean(this.designView.ChartMains[0].ShowLabel); if (this.chkIsShowLabel.Checked == true) { string strFormatId = this.designView.ChartMains[0].LabelFormatID; ReportViewFacade rptFacade = new ReportViewFacade(this.DataProvider); RptViewDataFormat dataFormat = (RptViewDataFormat)rptFacade.GetRptViewDataFormat(strFormatId); string strVal = ""; if (dataFormat != null) { strVal += dataFormat.FontFamily + ";"; strVal += dataFormat.FontSize.ToString() + ";"; strVal += (dataFormat.FontWeight == "Bold" ? "true" : "false") + ";"; strVal += (dataFormat.FontStyle == "Italic" ? "true" : "false") + ";"; strVal += (dataFormat.TextDecoration == "Underline" ? "true" : "false") + ";"; strVal += dataFormat.Color + ";"; strVal += dataFormat.BackgroundColor + ";"; if (dataFormat.TextAlign == "Center") { strVal += BenQGuru.eMES.Web.Helper.TextAlign.Center + ";"; } else if (dataFormat.TextAlign == "Right") { strVal += BenQGuru.eMES.Web.Helper.TextAlign.Right + ";"; } else { strVal += BenQGuru.eMES.Web.Helper.TextAlign.Left + ";"; } if (dataFormat.VerticalAlign == "Top") { strVal += BenQGuru.eMES.Web.Helper.VerticalAlign.Top + ";"; } else if (dataFormat.VerticalAlign == "Bottom") { strVal += BenQGuru.eMES.Web.Helper.VerticalAlign.Bottom + ";"; } else { strVal += BenQGuru.eMES.Web.Helper.VerticalAlign.Middle + ";"; } strVal += dataFormat.TextFormat; } this.hidLabelFormat.Value = strVal; } } }
private void ApplyDefinedStyle(decimal styleId) { ReportViewFacade facade = new ReportViewFacade(this.DataProvider); RptViewReportStyleDetail[] styleDtls = facade.GetRptViewReportStyleDetailByStyleID(styleId); if (styleDtls == null || styleDtls.Length == 0) { ClearExistStyle(); return; } for (int i = 1; i < this.tbFormat.Rows.Count; i++) { for (int n = 0; n < this.tbFormat.Rows[i].Cells.Count; n++) { HtmlInputHidden hidVal = this.GetFormatInputField(this.tbFormat.Rows[i].Cells[n]); if (hidVal == null) { continue; } string strFormatType = hidVal.Attributes["FormatType"]; string strStyleType = ""; if (strFormatType == "header" || strFormatType == "headerrow") { strStyleType = ReportStyleType.Header; } else if (strFormatType == "group") { strStyleType = ReportStyleType.SubTotal; } else if (strFormatType == "groupdata") { strStyleType = ""; for (int j = 0; this.designView.GridGroups != null && j < this.designView.GridGroups.Length; j++) { if (this.designView.GridGroups[j].ColumnName == hidVal.Attributes["ColumnName"]) { strStyleType = ReportStyleType.SubTotalGroupField; break; } } if (strStyleType == "") { for (int j = 0; this.designView.GridGroupTotals != null && j < this.designView.GridGroupTotals.Length; j++) { if (this.designView.GridGroupTotals[j].GroupSequence == decimal.Parse(hidVal.Attributes["GroupSeq"]) && this.designView.GridGroupTotals[j].ColumnName == hidVal.Attributes["ColumnName"]) { if (this.designView.GridGroupTotals[j].TotalType == ReportTotalType.Empty) { strStyleType = ReportStyleType.SubTotalNonCalField; } else { strStyleType = ReportStyleType.SubTotalCalField; } } } } } else if (strFormatType == "itemdata" || strFormatType == "item") { strStyleType = ReportStyleType.Item; } hidVal.Value = ""; RptViewReportStyleDetail styleDtl = this.GetRptStyleDetailByType(styleDtls, strStyleType); if (styleDtl != null) { RptViewDataFormat dataFormat = (RptViewDataFormat)facade.GetRptViewDataFormat(styleDtl.FormatID); if (dataFormat != null) { hidVal.Value = facade.BuildStyleValueFromDataFormat(dataFormat); } } } } }
protected override void DisplayDesignData() { if (this.designView.DefinedReportStyle != null) { this.drpDefinedStyle.SelectedValue = this.designView.DefinedReportStyle.StyleID.ToString(); this.ApplyDefinedStyle(this.designView.DefinedReportStyle.StyleID); } if (this.designView.GridDataFormats != null) { Dictionary <string, RptViewDataFormat> formatList = new Dictionary <string, RptViewDataFormat>(); for (int i = 0; i < this.designView.GridDataFormats.Length; i++) { RptViewGridDataFormat dataFormat = this.designView.GridDataFormats[i]; string strKey = dataFormat.StyleType + ":" + dataFormat.ColumnName + ":" + dataFormat.GroupSequence.ToString(); for (int n = 0; this.designView.DataFormats != null && n < this.designView.DataFormats.Length; n++) { if (this.designView.DataFormats[n].FormatID == dataFormat.FormatID) { formatList.Add(strKey, this.designView.DataFormats[n]); break; } } } for (int i = 1; i < this.tbFormat.Rows.Count; i++) { for (int n = 1; n < this.tbFormat.Rows[i].Cells.Count; n++) { HtmlInputHidden hidVal = this.GetFormatInputField(this.tbFormat.Rows[i].Cells[n]); if (hidVal == null) { continue; } string strFormatType = hidVal.Attributes["FormatType"]; if (strFormatType == "header") { strFormatType = ReportStyleType.Header; } else if (strFormatType == "groupdata") { strFormatType = ReportStyleType.SubTotal; } else if (strFormatType == "itemdata") { strFormatType = ReportStyleType.Item; } string strColumnName = hidVal.Attributes["ColumnName"]; string strGroupSeq = hidVal.Attributes["GroupSeq"]; if (strGroupSeq == null || strGroupSeq == "") { strGroupSeq = "0"; } string strKey = strFormatType + ":" + strColumnName + ":" + strGroupSeq; if (formatList.ContainsKey(strKey) == false) { continue; } RptViewDataFormat dataFormat = formatList[strKey]; string strVal = (new ReportViewFacade(this.DataProvider)).BuildStyleValueFromDataFormat(dataFormat); hidVal.Value = strVal; } } } }
/// <summary> /// 构建明细数据部分 /// </summary> private string BuildTableCells(ReportDesignView designView, XmlDocument formatXml) { StringBuilder sbCells = new StringBuilder(); string strTableCellFormat = formatXml.SelectSingleNode("//TableCell").FirstChild.Value; for (int i = 0; designView.GridColumns != null && i < designView.GridColumns.Length; i++) { string strColumnName = designView.GridColumns[i].ColumnName; string strTmp = strTableCellFormat; strTmp = strTmp.Replace("<%TextBoxName%>", "table_cell_" + strColumnName); bool bIsGroupField = false; for (int n = 0; designView.GridGroups != null && n < designView.GridGroups.Length; n++) { if (designView.GridGroups[n].ColumnName == strColumnName) { bIsGroupField = true; break; } } if (bIsGroupField == false) { string strGridDataFormatId = ""; for (int n = 0; designView.GridDataFormats != null && n < designView.GridDataFormats.Length; n++) { if (designView.GridDataFormats[n].StyleType == ReportStyleType.Item && designView.GridDataFormats[n].ColumnName == strColumnName) { strGridDataFormatId = designView.GridDataFormats[n].FormatID; break; } } RptViewDataFormat dataFormat = null; strTmp = this.ApplyFontStyle(strTmp, designView, strGridDataFormatId, formatXml, out dataFormat); SaveColumnWidth(strColumnName, dataFormat); if (dataFormat == null || dataFormat.TextExpress == null || dataFormat.TextExpress == "") { if (strColumnName.ToLower().Equals("rownum")) { strTmp = strTmp.Replace("<%TextBoxValue%>", "=RowNumber(Nothing)"); } else { strTmp = strTmp.Replace("<%TextBoxValue%>", "=Fields!" + strColumnName + ".Value"); } } else { strTmp = strTmp.Replace("<%TextBoxValue%>", this.BuildCellTextExpression(designView, dataFormat.TextExpress)); } } else { strTmp = strTmp.Replace("<%TextBoxValue%>", ""); RptViewDataFormat dataFormat = null; strTmp = this.ApplyFontStyle(strTmp, designView, null, formatXml, out dataFormat); SaveColumnWidth(strColumnName, dataFormat); } sbCells.Append(strTmp); } return(sbCells.ToString()); }
/// <summary> /// 构建单个TableGroup部分 /// </summary> private string BuildTableGroup(ReportDesignView designView, int groupIndex, XmlDocument formatXml) { RptViewGridGroup group = designView.GridGroups[groupIndex]; Dictionary <string, RptViewGridGroupTotal> subTotal = designView.GetSubTotalByGroup(group); string strGroup = formatXml.SelectSingleNode("//TableGroup").FirstChild.Value; StringBuilder sbGroupCells = new StringBuilder(); string strGroupCell = formatXml.SelectSingleNode("//GroupCell").FirstChild.Value; for (int i = 0; designView.GridColumns != null && i < designView.GridColumns.Length; i++) { string strColumnName = designView.GridColumns[i].ColumnName; string strTmp = strGroupCell.Replace("<%TextBoxName%>", "group_field_" + group.ColumnName + "_" + strColumnName); string strGridDataFormatId = ""; for (int n = 0; designView.GridDataFormats != null && n < designView.GridDataFormats.Length; n++) { if (designView.GridDataFormats[n].StyleType == ReportStyleType.SubTotal && designView.GridDataFormats[n].ColumnName == strColumnName && Convert.ToInt32(designView.GridDataFormats[n].GroupSequence) == group.GroupSequence) { strGridDataFormatId = designView.GridDataFormats[n].FormatID; break; } } RptViewDataFormat dataFormat = null; strTmp = this.ApplyFontStyle(strTmp, designView, strGridDataFormatId, formatXml, out dataFormat); SaveColumnWidth(strColumnName, dataFormat); if (dataFormat == null || dataFormat.TextExpress == null || dataFormat.TextExpress == "") { if (strColumnName == group.ColumnName) { strTmp = strTmp.Replace("<%CellText%>", "=Fields!" + strColumnName + ".Value"); } else { string strTotalType = ReportTotalType.Empty; if (subTotal.ContainsKey(strColumnName) == true) { strTotalType = subTotal[strColumnName].TotalType; } if (strTotalType == ReportTotalType.Sum) { strTmp = strTmp.Replace("<%CellText%>", "=Sum(Fields!" + strColumnName + ".Value)"); } else if (strTotalType == ReportTotalType.Avg) { strTmp = strTmp.Replace("<%CellText%>", "=Avg(Fields!" + strColumnName + ".Value)"); } else if (strTotalType == ReportTotalType.Count) { strTmp = strTmp.Replace("<%CellText%>", "=Count(Fields!" + strColumnName + ".Value)"); } else if (strTotalType == ReportTotalType.Empty) { strTmp = strTmp.Replace("<%CellText%>", ""); } else if (strTotalType == ReportTotalType.Max) { strTmp = strTmp.Replace("<%CellText%>", "=Max(Fields!" + strColumnName + ".Value)"); } } } else { string strCellText = this.BuildCellTextExpression(designView, dataFormat.TextExpress); strTmp = strTmp.Replace("<%CellText%>", strCellText); } sbGroupCells.Append(strTmp); } strGroup = strGroup.Replace("<%GroupCellList%>", sbGroupCells.ToString()); strGroup = strGroup.Replace("<%GroupSortExpression%>", "=Fields!" + group.ColumnName + ".Value"); strGroup = strGroup.Replace("<%GroupName%>", "group_" + group.ColumnName); strGroup = strGroup.Replace("<%GroupExpression%>", "=Fields!" + group.ColumnName + ".Value"); if (groupIndex == 0) { strGroup = strGroup.Replace("<%Visibility%>", ""); } else { string strVisible = formatXml.SelectSingleNode("//Visibility").FirstChild.Value; strVisible = strVisible.Replace("<%ToggleItem%>", "group_field_" + designView.GridGroups[groupIndex - 1].ColumnName + "_" + designView.GridGroups[groupIndex - 1].ColumnName); strGroup = strGroup.Replace("<%Visibility%>", strVisible); } return(strGroup); }
private void InitStyleValue() { string styleId = this.GetRequestParam("styleid"); _facade = new ReportViewFacade(this.DataProvider); RptViewReportStyleDetail[] styleDtls = _facade.GetRptViewReportStyleDetailByStyleID(decimal.Parse(styleId)); if (styleDtls == null || styleDtls.Length == 0) { return; } for (int i = 0; i < styleDtls.Length; i++) { if (styleDtls[i].StyleType == ReportStyleType.Header) { RptViewDataFormat format = (RptViewDataFormat)_facade.GetRptViewDataFormat(styleDtls[i].FormatID); if (format != null) { this.hidHeaderRow.Value = _facade.BuildStyleValueFromDataFormat(format); this.hidHeader_0.Value = this.hidHeaderRow.Value; this.hidHeader_1.Value = this.hidHeaderRow.Value; this.hidHeader_2.Value = this.hidHeaderRow.Value; } } else if (styleDtls[i].StyleType == ReportStyleType.SubTotal) { RptViewDataFormat format = (RptViewDataFormat)_facade.GetRptViewDataFormat(styleDtls[i].FormatID); if (format != null) { this.hidGroup_0.Value = _facade.BuildStyleValueFromDataFormat(format); this.hidGroupData_0_0.Value = this.hidGroup_0.Value; this.hidGroupData_0_1.Value = this.hidGroup_0.Value; this.hidGroupData_0_2.Value = this.hidGroup_0.Value; } } else if (styleDtls[i].StyleType == ReportStyleType.Item) { RptViewDataFormat format = (RptViewDataFormat)_facade.GetRptViewDataFormat(styleDtls[i].FormatID); if (format != null) { this.hidItemHeader.Value = _facade.BuildStyleValueFromDataFormat(format); this.hidItemData_0.Value = this.hidItemHeader.Value; this.hidItemData_1.Value = this.hidItemHeader.Value; this.hidItemData_2.Value = this.hidItemHeader.Value; } } } for (int i = 0; i < styleDtls.Length; i++) { if (styleDtls[i].StyleType == ReportStyleType.SubTotalGroupField) { RptViewDataFormat format = (RptViewDataFormat)_facade.GetRptViewDataFormat(styleDtls[i].FormatID); if (format != null) { this.hidGroupData_0_0.Value = _facade.BuildStyleValueFromDataFormat(format); } } else if (styleDtls[i].StyleType == ReportStyleType.SubTotalNonCalField) { RptViewDataFormat format = (RptViewDataFormat)_facade.GetRptViewDataFormat(styleDtls[i].FormatID); if (format != null) { this.hidGroupData_0_1.Value = _facade.BuildStyleValueFromDataFormat(format); } } else if (styleDtls[i].StyleType == ReportStyleType.SubTotalCalField) { RptViewDataFormat format = (RptViewDataFormat)_facade.GetRptViewDataFormat(styleDtls[i].FormatID); if (format != null) { this.hidGroupData_0_2.Value = _facade.BuildStyleValueFromDataFormat(format); } } } }
protected override void UpdateReportDesignView() { ArrayList listGridFormat = new ArrayList(); ArrayList listDataFormat = new ArrayList(); for (int i = 1; i < this.tbFormat.Rows.Count; i++) { for (int n = 1; n < this.tbFormat.Rows[i].Cells.Count; n++) { HtmlInputHidden hidVal = this.GetFormatInputField(this.tbFormat.Rows[i].Cells[n]); if (hidVal == null) { continue; } string strFormatType = hidVal.Attributes["FormatType"]; string strColumnName = hidVal.Attributes["ColumnName"]; string strGroupSeq = hidVal.Attributes["GroupSeq"]; RptViewGridDataFormat gridFormat = null; RptViewDataFormat dataFormat = null; this.BuildDataFormat(out gridFormat, out dataFormat, strFormatType, strColumnName, strGroupSeq, hidVal.Value); listGridFormat.Add(gridFormat); listDataFormat.Add(dataFormat); } } ArrayList listExtText = new ArrayList(); SortedList <int, int> listRptTitleList = new SortedList <int, int>(); for (int i = 0; i < Request.Form.AllKeys.Length; i++) { if (Request.Form.AllKeys[i].StartsWith("hidRptTitle") == true) { int iTmp = int.Parse(Request.Form.AllKeys[i].Substring(11)); listRptTitleList.Add(iTmp, iTmp); } } decimal iAdjExtId = 0; foreach (int iIdx in listRptTitleList.Keys) { string strVal = Request.Form["hidRptTitle" + iIdx.ToString()]; iAdjExtId++; RptViewExtendText extendText = null; RptViewDataFormat dataFormat = null; this.BuildExtendTextObject(out extendText, out dataFormat, strVal); extendText.Sequence = iAdjExtId; listDataFormat.Add(dataFormat); listExtText.Add(extendText); } RptViewGridDataFormat[] gridFormats = new RptViewGridDataFormat[listGridFormat.Count]; listGridFormat.CopyTo(gridFormats); RptViewDataFormat[] dataFormats = new RptViewDataFormat[listDataFormat.Count]; listDataFormat.CopyTo(dataFormats); RptViewExtendText[] extendTexts = new RptViewExtendText[listExtText.Count]; listExtText.CopyTo(extendTexts); this.designView.GridDataFormats = gridFormats; this.designView.DataFormats = dataFormats; this.designView.ExtendText = extendTexts; }