/// <summary> /// 动态绑定字段 /// </summary> /// <param name="dataSource">报表的数据源</param> /// <param name="bindableControls">对应字段的报表控件集体</param> private void BindingFields(DataSet dataSource, XRControlCollection bindableControls) { foreach (XRControl C in bindableControls) { if ((C.Tag != null) && (C.Tag.ToString() == "DATA")) //注意!只处理Tag=DATA的控件 { C.DataBindings.Add("Text", dataSource, C.Text.Replace("[", "").Replace("]", "")); } } }
private void ProcessControls(XRControlCollection controls, StiContainer parent) { foreach (XRControl control in controls) { if (control is XRLabel) { ReadLabel(control as XRLabel, parent); } else if (control is XRPageInfo) { ReadPageInfo(control as XRPageInfo, parent); } else if (control is XRCheckBox) { ReadCheckBox(control as XRCheckBox, parent); } else if (control is XRPictureBox) { ReadPictureBox(control as XRPictureBox, parent); } else if (control is XRRichText) { ReadRichText(control as XRRichText, parent); } else if (control is XRPanel) { ReadPanel(control as XRPanel, parent); } else if (control is XRLine) { ReadLine(control as XRLine, parent); } else if (control is XRShape) { ReadShape(control as XRShape, parent); } else if (control is XRBarCode) { ReadBarCode(control as XRBarCode, parent); } else if (control is XRTable) { ReadTable(control as XRTable, parent); } else if (control is XRTableRow) { ReadTableRow(control as XRTableRow, parent); } } }
private void ProcessBands(XtraReportBase xtraReport, XRControlCollection controls, StiPage page) { foreach (XRControl band in controls) { if (band is GroupHeaderBand) { ReadGroupHeaderBand(xtraReport, band as GroupHeaderBand, page); } else if (band is GroupFooterBand) { ReadGroupFooterBand(xtraReport, band as GroupFooterBand, page); } else if (band is DetailBand) { ReadDetailBand(xtraReport, band as DetailBand, page); } else if (band is ReportHeaderBand) { ReadReportHeaderBand(xtraReport, band as ReportHeaderBand, page); } else if (band is ReportFooterBand) { ReadReportFooterBand(xtraReport, band as ReportFooterBand, page); } else if (band is PageHeaderBand) { ReadPageHeaderBand(xtraReport, band as PageHeaderBand, page); } else if (band is PageFooterBand) { ReadPageFooterBand(xtraReport, band as PageFooterBand, page); } else if (band is TopMarginBand) { ReadTopMarginBand(xtraReport, band as TopMarginBand, page); } else if (band is BottomMarginBand) { ReadBottomMarginBand(xtraReport, band as BottomMarginBand, page); } else if (band is DetailReportBand) { ReadDetailReportBand(xtraReport, band as DetailReportBand, page); } } }
private void TranslateLabels(Translation translate, XRControlCollection Controls, string lang) { for (int i = 0; i < Controls.Count; i++) { XRControl item = Controls[i]; if (item is XRSubreport) { XRSubreport control = (XRSubreport)item; if (control.ReportSource is BaseReport) { BaseReport report = (BaseReport)control.ReportSource; report.TranslateLabels(translate, lang); } } else if (item is XRTable) { XRTableRowCollection control = (XRTableRowCollection)item.Controls; foreach (XRTableRow row in control) { TranslateLabels(translate, row.Controls, lang); } } else if (item is XRTableCell) { XRTableCell label = (XRTableCell)item; if (label.Name.ToLower() == "programid") { string reportName = GetType().Name.Replace("Report", ""); label.Text = translate.GetProgramName(lang, reportName) + " (" + reportName + ")"; } else { string caption = GetControlLabel(translate, label.Name, lang); if (caption.Length > 0 && !caption.StartsWith("[")) { label.Text = caption; } } foreach (XRBinding binding in label.DataBindings) { if (binding.FormatString != null) { if (binding.FormatString.Contains("$")) { binding.FormatString = "{0:c}"; } else if (binding.FormatString.Contains("%")) { binding.FormatString = "{0:p}"; } } } if (item.Controls.Count > 0) { TranslateLabels(translate, item.Controls, lang); } } else if (item is XRLabel) { XRLabel label = (XRLabel)item; if (label.Name.ToLower() == "programid") { string reportName = GetType().Name.Replace("Report", ""); label.Text = translate.GetProgramName(lang, reportName) + " (" + reportName + ")"; } else { string caption = GetControlLabel(translate, label.Name, lang); if (caption.Length > 0 && !caption.StartsWith("[")) { label.Text = caption; } } foreach (XRBinding binding in label.DataBindings) { if (binding.FormatString != null) { if (binding.FormatString.Contains("$")) { binding.FormatString = "{0:c}"; } else if (binding.FormatString.Contains("%")) { binding.FormatString = "{0:p}"; } } } } else if (item is XRPivotGrid) { XRPivotGrid grid = (XRPivotGrid)item; foreach (XRPivotGridField field in grid.Fields) { string caption = GetControlLabel(translate, field.Name, lang); if (caption.Length > 0 && !caption.StartsWith("[")) { field.Caption = caption; } if (field.CellFormat.FormatType == DevExpress.Utils.FormatType.Numeric) { String sFormatString = field.CellFormat.FormatString.ToLower(); if (!sFormatString.Contains("c") && !sFormatString.Contains("n") && !sFormatString.Contains("p")) { if (sFormatString.Contains("$")) { field.CellFormat.FormatString = "c"; } else if (sFormatString.Contains("%")) { field.CellFormat.FormatString = "p"; } else { field.CellFormat.FormatString = "n"; } } } if (field.ValueFormat.FormatType == DevExpress.Utils.FormatType.Numeric) { String sFormatString = field.ValueFormat.FormatString.ToLower(); if (!sFormatString.Contains("c") && !sFormatString.Contains("n") && !sFormatString.Contains("p")) { if (sFormatString.Contains("$")) { field.ValueFormat.FormatString = "c"; } else if (sFormatString.Contains("%")) { field.ValueFormat.FormatString = "p"; } else { field.ValueFormat.FormatString = "n"; } } field.CellFormat.FormatType = field.ValueFormat.FormatType; field.CellFormat.FormatString = field.ValueFormat.FormatString; } } } } }
/// <summary> /// Binda todos os campos do relatório /// </summary> /// <param name="controle">coleção de controles</param> private void Bind_Control_Report(XRControlCollection controle) { foreach (XRControl ctrl in controle) { if (ctrl.Controls.Count > 0) { this.Bind_Control_Report(ctrl.Controls); } else { switch (ctrl.GetType().Name) { case "cf_Report_Label": if (!string.IsNullOrEmpty(((cf_Report_Label)ctrl).ControlSource)) { cf_Report_Label Label = ((cf_Report_Label)ctrl); //-- Monta o data member do relatório. string sDataMember; if (string.IsNullOrEmpty(Label.Tabela)) { sDataMember = Label.ControlSource; } else { sDataMember = string.Format("{0}.{1}" , Label.Tabela , Label.ControlSource); } //-- Binda o relatório... if (string.IsNullOrEmpty(Label.FormatString)) { Label.DataBindings.Add( "Text" , this.dt_DataSet , sDataMember); } else { Label.DataBindings.Add( "Text" , this.dt_DataSet , sDataMember , Label.FormatString); } } break; case "cf_Report_CheckBox": if (!string.IsNullOrEmpty(((CompSoft.cf_Bases.cf_Report_CheckBox)ctrl).ControlSource)) { //-- Monta o data member do relatório. string sDataMember; if (string.IsNullOrEmpty(((CompSoft.cf_Bases.cf_Report_CheckBox)ctrl).Tabela)) { sDataMember = ((CompSoft.cf_Bases.cf_Report_CheckBox)ctrl).ControlSource; } else { sDataMember = string.Format("{0}.{1}", ((CompSoft.cf_Bases.cf_Report_CheckBox)ctrl).Tabela, ((CompSoft.cf_Bases.cf_Report_CheckBox)ctrl).ControlSource); } ((CompSoft.cf_Bases.cf_Report_CheckBox)ctrl).DataBindings.Add( "CheckState" , this.dt_DataSet , sDataMember); } break; } } } }