private bool AccountTypesAreValid() { var result = !string.IsNullOrEmpty(ReportPage.GetSelectedAccountTypes(cblAccountType)); phAccountTypeMessage.Visible = !result; return(result); }
private void AddImages(ReportPage template) { template.AddImage("logo", Configuration.LogoImagePath); template.AddImage("website", Configuration.WorldImagePath); template.AddImage("phone", Configuration.PhoneImagePath); template.AddImage("email", Configuration.EmailImagePath); }
/// <inheritdoc/> protected override void ExportPageEnd(ReportPage page) { // export top watermark if (page.Watermark.Enabled && page.Watermark.ShowImageOnTop) { AddImageWatermark(page); } if (page.Watermark.Enabled && page.Watermark.ShowTextOnTop) { AddTextWatermark(page); } g.Restore(state); if (g != bigGraphics) { g.Dispose(); } if (SeparateFiles || IsMultiFrameTiff) { SaveImage(image, fileSuffix); } else { curOriginY += height + paddingNonSeparatePages * 2; } firstPage = false; pageNumber++; }
public bool NumberMoreThan(string value, string column) { var _reportPage = new ReportPage(_driver); if (_reportPage.NoData.Displayed) { return(false); } var headers = _driver.FindElements(By.TagName("th")); int colNumber = 0; for (int i = 1; i <= headers.Count; i++) { if (headers[i - 1].Text == column) { colNumber = i; break; } } Console.WriteLine("*//table/tbody/tr/th[contains(., '{0}')]/../../td[{1}]", column, colNumber); IList <IWebElement> list = _driver.FindElements( By.XPath(String.Format("*//table/tbody/tr/th[contains(., '{0}')]/../../tr/td[{1}]", column, colNumber))); IList <string> dates = list.Select(el => el.Text).ToList(); return(dates.All(el => int.Parse(el) >= int.Parse(value))); }
private void RunReportPages() { #if TIMETRIAL if (new DateTime($YEAR, $MONTH, $DAY) < System.DateTime.Now) { throw new Exception("The trial version is now expired!"); } #endif for (int i = 0; i < Report.Pages.Count; i++) { ReportPage page = Report.Pages[i] as ReportPage; // Calc and apply visible expression if needed. if (!String.IsNullOrEmpty(page.VisibleExpression)) { page.Visible = CalcVisibleExpression(page.VisibleExpression); } if (page != null && page.Visible && page.Subreport == null) { RunReportPage(page); } if (Report.Aborted) { break; } } }
private bool ColumnIsEmpty(string val, string column) { var _reportPage = new ReportPage(_driver); if (_reportPage.NoData.Displayed) { return(false); } var headers = _driver.FindElements(By.TagName("th")); int colNumber = 0; for (int i = 1; i <= headers.Count; i++) { if (headers[i - 1].Text == column) { colNumber = i; break; } } Console.WriteLine("*//table/tbody/tr/th[contains(., '{0}')]/../../td[{1}]", column, colNumber); IList <IWebElement> list = _driver.FindElements( By.XPath(String.Format("*//table/tbody/tr/th[contains(., '{0}')]/../../tr/td[{1}]", column, colNumber))); IList <string> names = new List <string>(); foreach (var el in list.AsParallel()) { Console.WriteLine(el.Text); names.Add(el.Text); } return(names.AsParallel().All(el => (String.IsNullOrEmpty(el) || String.IsNullOrWhiteSpace(el)))); }
public void TestExportPdfInfo() { Report r = new Report(); ReportPage page = new ReportPage(); PageHeaderBand pageHeaderBand = new PageHeaderBand(); pageHeaderBand.CreateUniqueName(); pageHeaderBand.Height = 300; page.Bands.Add(pageHeaderBand); r.Pages.Add(page); r.Prepare(); PDFSimpleExport export = new PDFSimpleExport(); export.Title = "FastReport OpenSource Test Title dad5dd69-4c07-4789-ab4d-f03d0ba68c9c"; export.Subject = "FastReport OpenSource Test Subject 7cf3d3d9-716f-4c51-a397-c6389c3100ca"; export.Keywords = "FastReport OpenSource Test Keywors 2fbbf8b9-2daf-40b5-b216-a4c3130aac56"; export.Author = "FastReport OpenSource Test Author a1e57c3e-1e0e-4b94-a472-07b5f05fa515"; string pdf; using (MemoryStream ms = new MemoryStream()) { r.Export(export, ms); pdf = Encoding.UTF8.GetString(ms.ToArray()); } #pragma warning disable xUnit2009 // Do not use boolean check to check for substrings Assert.True(pdf.Contains("/Title (" + StringToPdfUnicode(export.Title) + ")")); Assert.True(pdf.Contains("/Subject (" + StringToPdfUnicode(export.Subject) + ")")); Assert.True(pdf.Contains("/Keywords (" + StringToPdfUnicode(export.Keywords) + ")")); Assert.True(pdf.Contains("/Author (" + StringToPdfUnicode(export.Author) + ")")); #pragma warning restore xUnit2009 // Do not use boolean check to check for substrings }
/// <inheritdoc/> protected override void ExportPageEnd(ReportPage page) { if (!WebMode) { if (singlePage) { if (navigator) { if (saveStreams) { ExportHTMLPageEnd(d); GeneratedUpdate(singlePageFileName, d.PagesStream); } else { ExportHTMLPageEnd(d); d.PagesStream.Close(); d.PagesStream.Dispose(); } } else { ExportHTMLPageEnd(d); } } else { ProcessPageEnd(pagesCount - 1, pagesCount); } } else { ProcessPageEnd(pagesCount - 1, pagesCount); } }
public ReportPage Get(int index) { int i = ItemIndex(index); if (i != -1) { // page exists. Put it on the top of list. CacheItem item = FPages[i]; FPages.RemoveAt(i); FPages.Insert(0, item); return(item.Page); } // add new page on the top of list. ReportPage page = FPreparedPages.GetPage(index); FPages.Insert(0, new CacheItem(index, page)); // remove least used pages. while (FPages.Count > Config.PreviewSettings.PagesInCache) { RemoveAt(FPages.Count - 1); } return(page); }
static Report GetTableReport() { Report report = new Report(); ReportPage page = new ReportPage(); page.Name = "Page1"; report.Pages.Add(page); DataBand dataBand = new DataBand(); dataBand.Name = "DataBand"; page.Bands.Add(dataBand); TableObject table = new TableObject(); table.Name = "Table1"; table.RowCount = 10; table.ColumnCount = 10; for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { table[j, i].Text = (10 * i + j + 1).ToString(); table[j, i].Border.Lines = BorderLines.All; } } dataBand.Objects.Add(table); table.CreateUniqueNames(); return(report); }
public void ExcludeApprovedInitiatives() { var reportPage = new ReportPage(Driver); reportPage.SelectInitiativeInclusionOption(ReportPage.ExcludeApprovedInitiatives); CheckWindow("Exclude approved initiatives"); }
public void ExcludePreliminaryInitiatives() { var reportPage = new ReportPage(Driver); reportPage.SelectInitiativeInclusionOption(ReportPage.ExcludePreliminaryInitiatives); CheckWindow("Exclude preliminary initiatives"); }
/// <inheritdoc/> protected override void ExportPage(int pageNo) { using (ReportPage page = GetPage(pageNo)) { FMatrix.AddPage(page); } }
public void Postprocess(ReportPage page) { page.ExtractMacros(); ObjectCollection allObjects = page.AllObjects; for (int i = 0; i < allObjects.Count; i++) { Base c = allObjects[i]; if (c.Report == null) { c.SetReport(page.Report); } c.ExtractMacros(); if (c is BandBase) { (c as BandBase).UpdateWidth(); } if (c is TextObjectBase && (c as TextObjectBase).Duplicates != Duplicates.Show) { ProcessDuplicates(c as TextObjectBase); } } CloseDuplicates(); }
private void Watermark(FastString Page, ReportPage page, bool drawText) { using (PictureObject pictureWatermark = new PictureObject()) { pictureWatermark.Left = 0; pictureWatermark.Top = 0; pictureWatermark.Width = (ExportUtils.GetPageWidth(page) - page.LeftMargin - page.RightMargin) * Units.Millimeters; pictureWatermark.Height = (ExportUtils.GetPageHeight(page) - page.TopMargin - page.BottomMargin) * Units.Millimeters; pictureWatermark.SizeMode = PictureBoxSizeMode.Normal; pictureWatermark.Image = new Bitmap((int)pictureWatermark.Width, (int)pictureWatermark.Height); using (Graphics g = Graphics.FromImage(pictureWatermark.Image)) { g.Clear(Color.Transparent); if (drawText) { page.Watermark.DrawText(new FRPaintEventArgs(g, 1f, 1f, Report.GraphicCache), new RectangleF(0, 0, pictureWatermark.Width, pictureWatermark.Height), Report, true); } else { page.Watermark.DrawImage(new FRPaintEventArgs(g, 1f, 1f, Report.GraphicCache), new RectangleF(0, 0, pictureWatermark.Width, pictureWatermark.Height), Report, true); } pictureWatermark.Transparency = page.Watermark.ImageTransparency; LayerBack(Page, pictureWatermark, null); LayerPicture(Page, pictureWatermark, null); } } }
protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; if (FReport != null && FReport.Pages.Count > 0 && FReport.Pages[0] is ReportPage) { ReportPage page = FReport.Pages[0] as ReportPage; float zoom = FZoom; if (FullPagePreview) { float pageWidth = page.PaperWidth * Units.Millimeters; float pageHeight = page.PaperHeight * Units.Millimeters; zoom = Math.Min((Width - 20) / pageWidth, (Height - 20) / pageHeight); } FRPaintEventArgs args = new FRPaintEventArgs(g, zoom, zoom, FReport.GraphicCache); g.TranslateTransform(10, 10); page.Draw(args); g.TranslateTransform(-10, -10); } // draw control frame using (Pen p = new Pen(Color.FromArgb(127, 157, 185))) { g.DrawRectangle(p, 0, 0, Width - 1, Height - 1); } }
public void InitReport() { // check if report has a reportpage bool reportPageExists = false; foreach (PageBase page in Report.Pages) { if (page is ReportPage) { reportPageExists = true; } } // if it has not, create the page if (!reportPageExists) { ReportPage reportPage = new ReportPage(); Report.Pages.Add(reportPage); reportPage.CreateUniqueName(); reportPage.SetDefaults(); } InitPages(1); Script = Report.ScriptText; UpdateCaption(); ResetModified(); FPlugins.Unlock(); }
private void UpdatePreview() { if (previewExport != null) { TextExport textExport = Export as TextExport; ReportPage page = textExport.Report.PreparedPages.GetPage(int.Parse(tbPage.Text) - 1); previewExport.PageBreaks = cbPageBreaks.Checked; previewExport.DataOnly = cbDataOnly.Checked; previewExport.Frames = cbbFrames.SelectedIndex != 0; previewExport.TextFrames = cbbFrames.SelectedIndex == 1; previewExport.EmptyLines = cbEmptyLines.Checked; if (cbbCodepage.SelectedIndex == 0) { previewExport.Encoding = Encoding.Default; } else if (cbbCodepage.SelectedIndex == 1) { previewExport.Encoding = Encoding.UTF8; } else if (cbbCodepage.SelectedIndex == 2) { previewExport.Encoding = Encoding.GetEncoding(CultureInfo.CurrentCulture.TextInfo.OEMCodePage); } previewExport.ScaleX = (float)udX.Value; previewExport.ScaleY = (float)udY.Value; tbPreview.Text = previewExport.ExportPage(page); lblPageWidthValue.Text = previewExport.PageWidth.ToString(); lblPageHeightValue.Text = previewExport.PageHeight.ToString(); lblLoss.Visible = !previewExport.DataSaved; } }
public void EditWatermark() { if (Disabled) { return; } ReportPage page = FPreparedPages.GetPage(PageNo - 1); using (WatermarkEditorForm editor = new WatermarkEditorForm()) { editor.Watermark = page.Watermark; if (editor.ShowDialog() == DialogResult.OK) { if (editor.ApplyToAll) { FPreparedPages.ApplyWatermark(editor.Watermark); } else { page.Watermark = editor.Watermark; FPreparedPages.ModifyPage(PageNo - 1, page); } Refresh(); } } }
void OnKeyboardShow(object sender, UIKeyboardEventArgs args) { ReportPage page = Element as ReportPage; if (page == null) { return; } NSValue result = (NSValue)args.Notification.UserInfo.ObjectForKey(new NSString(UIKeyboard.FrameEndUserInfoKey)); Console.WriteLine("Show Keyboard ReportPage " + result); CGSize keyboardSize = result.RectangleFValue.Size; Console.WriteLine(keyboardSize); if (savedBounds == false) { savedBounds = true; bounds = Element.Bounds; } page.KeyboardChangeHandler(true); var newBounds = new Rectangle(bounds.Left, bounds.Top, bounds.Width, App.Current.MainPage.Height - keyboardSize.Height - 100); Element.Layout(newBounds); }
public void SetReport(FastReport.Report fastReport) { ReportPage page = (ReportPage)fastReport.Pages[0]; //page.PageHeader //page.Bands[0].ChildObjects //page.Bands[0].Objects }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object Value) { Hyperlink hyperlink = context.Instance is Hyperlink ? context.Instance as Hyperlink : ((object[])context.Instance)[0] as Hyperlink; if (hyperlink != null) { edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); ComponentRefListBox lb = new ComponentRefListBox(); lb.PopulateList(hyperlink.Report, typeof(ReportPage), hyperlink.Parent.Page); if (Value != null) { lb.SelectedIndex = lb.Items.IndexOf(Value); } lb.Click += new EventHandler(lb_Click); if (FSize.Width > 0) { lb.Size = FSize; } edSvc.DropDownControl(lb); FSize = lb.Size; ReportPage page = lb.SelectedObject as ReportPage; if (page != null) { page.Visible = false; } return(page == null ? "" : page.Name); } return(Value); }
/// <summary> /// /// </summary> /// <param name="page1"></param> private void ReportTile(ReportPage page1) { page1.ReportTitle = new ReportTitleBand() { Name = "ReportTitle1", Width = 718.2F, Height = 75.6F }; page1.ReportTitle.Objects.Add( new TextObject() { Name = "Truck", Text = informacion.Truck, Left = 548.1F, Top = 37.8F, Width = 141.75F, Height = 18.8F, FillColor = Color.White, HorzAlign = HorzAlign.Right, VertAlign = VertAlign.Bottom, Font = new System.Drawing.Font("Calibri", 11, FontStyle.Bold) }); page1.ReportTitle.Objects.Add( new PictureObject() { Name = "Picture1", Top = 9.45F, Width = 160.65F, Height = 56.7F, FillColor = Color.White, Image = System.Drawing.Image.FromFile(@"C:\Users\mario.chan\Documents\GitHub\Benchmark\Library_benchmark\Content\images\CemexPDF.PNG") }); }
private int PageNByBookmark(string bookmark) { int pageN = -1; if (Report.PreparedPages != null) { for (int i = 0; i < Report.PreparedPages.Count; i++) { ReportPage page = Report.PreparedPages.GetPage(i); if (page != null) { ObjectCollection allObjects = page.AllObjects; for (int j = 0; j < allObjects.Count; j++) { ReportComponentBase c = allObjects[j] as ReportComponentBase; if (c.Bookmark == bookmark) { pageN = i; break; } } page.Dispose(); if (pageN != -1) { break; } } } } return(pageN); }
private void miReport_PopupOpen(object sender, PopupOpenEventArgs e) { bool bandsEnabled = Designer.cmdInsertBand.Enabled; miReportBands.Enabled = bandsEnabled; miReportGroupExpert.Enabled = bandsEnabled; ReportPage page = Page as ReportPage; bool isSubreport = page.Subreport != null; miReportTitle.Enabled = bandsEnabled && !isSubreport; miReportSummary.Enabled = bandsEnabled && !isSubreport; miPageHeader.Enabled = bandsEnabled && !isSubreport; miPageFooter.Enabled = bandsEnabled && !isSubreport; miColumnHeader.Enabled = bandsEnabled && !isSubreport; miColumnFooter.Enabled = bandsEnabled && !isSubreport; miOverlay.Enabled = bandsEnabled && !isSubreport; miReportTitle.Checked = page.ReportTitle != null; miReportSummary.Checked = page.ReportSummary != null; miPageHeader.Checked = page.PageHeader != null; miPageFooter.Checked = page.PageFooter != null; miColumnHeader.Checked = page.ColumnHeader != null; miColumnFooter.Checked = page.ColumnFooter != null; miOverlay.Checked = page.Overlay != null; }
private void RunReportPage(ReportPage page) { FPage = page; InitReprint(); FPage.OnStartPage(EventArgs.Empty); StartFirstPage(); OnStateChanged(FPage, EngineState.ReportPageStarted); OnStateChanged(FPage, EngineState.PageStarted); DataBand keepSummaryBand = FindDeepmostDataBand(page); if (keepSummaryBand != null) { keepSummaryBand.KeepSummary = true; } if (FPage.IsManualBuild) { FPage.OnManualBuild(EventArgs.Empty); } else { RunBands(page.Bands); } OnStateChanged(FPage, EngineState.PageFinished); OnStateChanged(FPage, EngineState.ReportPageFinished); EndLastPage(); FPage.OnFinishPage(EventArgs.Empty); }
public void PostprocessUnlimited(PreparedPage preparedPage, ReportPage page) { bool flag = false; int i = 0; foreach (Base b in preparedPage.GetPageItems(page, true)) { foreach (Base c in b.AllObjects) { if (c is TextObjectBase && (c as TextObjectBase).Duplicates != Duplicates.Show) { ProcessDuplicates(c as TextObjectBase); flag = true;//flag for keep in dictionary } } i++; if (flag) { b.ExtractMacros(); bands[i - 1] = b; } else { b.Dispose(); } } CloseDuplicates(); }
public bool FindNext() { Visible = true; for (; PageNo <= FPreviewTab.PageCount; PageNo++) { ReportPage page = FPreviewTab.PreparedPages.GetPage(PageNo - 1); ObjectCollection pageObjects = page.AllObjects; for (; ObjNo < pageObjects.Count; ObjNo++) { ISearchable obj = pageObjects[ObjNo] as ISearchable; if (obj != null) { Ranges = obj.SearchText(FText, FMatchCase, FWholeWord); if (Ranges != null) { RangeNo++; if (RangeNo < Ranges.Length) { FPreviewTab.PositionTo(PageNo, (obj as ComponentBase).AbsBounds.Location); FPreviewTab.Refresh(); return(true); } } } RangeNo = -1; } ObjNo = 0; } PageNo = 1; Visible = false; return(false); }
public void Preview() { try { Report report = rpt.PrepareReport(); report.Preview = this.previewControl1; if (!String.IsNullOrEmpty(rpt.Watermark))//有水印 { if (report.Pages.Count > 0 && report.Pages[0] is ReportPage) { ReportPage page = report.Pages[0] as ReportPage; Watermark watermark = new Watermark(); watermark.Enabled = true; watermark.Font = new Font(watermark.Font.FontFamily, (float)40, FontStyle.Bold); watermark.Text = rpt.Watermark; page.Watermark = watermark; } } //if (!isPrepared) report.Prepare(false);//准备工作,显示报表预览窗体 report.Prepare(false);//准备工作,显示报表预览窗体 report.ShowPrepared(true); } catch (Exception ex) { MessageBox.Show(ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public ReportPage Get(int index) { int i = ItemIndex(index); if (i != -1) { // page exists. Put it on the top of list. CacheItem item = pages[i]; if (i != 0) { pages.RemoveAt(i); pages.Insert(0, item); } return(item.page); } // add new page on the top of list. ReportPage page = preparedPages.GetPage(index); if (preparedPages.Count > pages.Count) { pages.Insert(0, new CacheItem(index, page)); // remove least used pages. while (pages.Count > GetPageLimit()) { RemoveAt(pages.Count - 1); } } return(page); }
/// <summary> /// 生成默认报表 /// </summary> /// <returns></returns> public FastReport.Report DefaultReport() { FastReport.Report report = new FastReport.Report(); //判断有报表数据,则注册数据 if (dt != null && dt.Rows.Count > 0) { report.RegisterData(dt, styleObject); } else { return null; } //查询报表设置 DataTable dtReportSet = DBHelper.GetTable("", "tb_report_set", "*", string.Format("set_object='{0}' and set_user='******'", styleObject, GlobalStaticObj.UserID), "", "order by set_num"); if (dtReportSet == null || dtReportSet.Rows.Count == 0) { return null; } // enable the "Employees" table to use it in the report report.GetDataSource(styleObject).Enabled = true; // add report page ReportPage page = new ReportPage(); if (paperSize != null) { page.PaperWidth = paperSize.Width; page.PaperHeight = paperSize.Height; } report.Pages.Add(page); // always give names to objects you create. You can use CreateUniqueName method to do this; // call it after the object is added to a report. page.CreateUniqueName(); // create title band page.ReportTitle = new ReportTitleBand(); // native FastReport unit is screen pixel, use conversion page.ReportTitle.Height = Units.Centimeters * 1; page.ReportTitle.CreateUniqueName(); // create title text TextObject titleText = new TextObject(); titleText.Parent = page.ReportTitle; titleText.CreateUniqueName(); //titleText.Bounds = new RectangleF(Units.Centimeters * 5, 0, Units.Centimeters * 10, Units.Centimeters * 1); titleText.Bounds = new RectangleF(0, 0, Units.Millimeters * page.PaperWidth, Units.Centimeters * 1); titleText.Font = new Font("Arial", 14, FontStyle.Bold); titleText.Text = styleTitle; titleText.HorzAlign = HorzAlign.Center; titleText.VertAlign = VertAlign.Center; //内容行高 float rowHeight = Units.Centimeters * 1F; //标题行高,如果有合并列,怎行高价高 float rowHeaderHeight = rowHeight; if (dicSpanRows != null && dicSpanRows.Count > 0) { rowHeaderHeight = Units.Centimeters * 1.5f; } page.PageHeader = new PageHeaderBand(); page.PageHeader.Height = rowHeaderHeight; page.PageHeader.CreateUniqueName(); #region 生成报表内容 // create data band DataBand dataBand = new DataBand(); page.Bands.Add(dataBand); dataBand.CreateUniqueName(); dataBand.DataSource = report.GetDataSource(styleObject); dataBand.Height = rowHeight; float x = 0F;//x坐标 foreach (DataRow dr in dtReportSet.Rows) { //判断是否要打印 if (CommonCtrl.IsNullToString(dr["is_print"]) != "1") { continue; } //列宽 float columnWidth = Units.Centimeters * 2; //标题 string headerName = string.Empty; //获取设置的列宽和标题 float.TryParse(dr["set_width"].ToString(), out columnWidth); //columnWidth = columnWidth * 0.9f; headerName = dr["set_name"].ToString(); //生成标题 TextObject txtHeader = new TextObject(); txtHeader.Parent = page.PageHeader; txtHeader.CreateUniqueName(); txtHeader.Text = headerName; txtHeader.HorzAlign = HorzAlign.Center; txtHeader.VertAlign = VertAlign.Center; //生成标题竖线 LineObject lineHeaderVer = new LineObject(); lineHeaderVer.Parent = page.PageHeader; //生成标题横线 LineObject lineHeaderHor = new LineObject(); lineHeaderHor.Parent = page.PageHeader; lineHeaderHor.Bounds = new RectangleF(x, 0, columnWidth, 1f); //数据源列名称 string dataName = dr["set_data_name"].ToString(); string spanName = IsContainDataColumn(dataName); //判断列是否是合并列 if (spanName.Length > 0) { #region 合并列标题 txtHeader.Bounds = new RectangleF(x, rowHeaderHeight / 2, columnWidth, rowHeaderHeight / 2); lineHeaderVer.Bounds = new RectangleF(x, rowHeaderHeight / 2, 1F, rowHeaderHeight / 2); //生成合并列的短竖线 LineObject lineHeaderHorSpan = new LineObject(); lineHeaderHorSpan.Parent = page.PageHeader; lineHeaderHorSpan.Bounds = new RectangleF(x, rowHeaderHeight / 2, columnWidth, 1F); //判断是否包含合并列头 if (dicSpanWidth.ContainsKey(spanName)) { //增加合并列头的列宽 RectangleF rf = dicSpanWidth[spanName]; rf.Width += columnWidth; dicSpanWidth[spanName] = rf; } else { //记录合并列头 RectangleF rf = new RectangleF(); rf.X = x; rf.Y = 0; rf.Width = columnWidth; rf.Height = rowHeaderHeight / 2; dicSpanWidth.Add(spanName, rf); } #endregion } else { lineHeaderVer.Bounds = new RectangleF(x, 0, 1F, rowHeaderHeight); txtHeader.Bounds = new RectangleF(x, 0, columnWidth, rowHeaderHeight); } // create two text objects with employee's name and birth date //生成内容 TextObject empNameText = new TextObject(); empNameText.Parent = dataBand; empNameText.CreateUniqueName(); empNameText.Bounds = new RectangleF(x, 0, columnWidth, rowHeight); DataColumn dc = dt.Columns[dataName]; empNameText.Text = string.Format("[{0}.{1}]", styleObject, dataName); //empNameText.HideZeros = true; if (dc != null && dc.DataType != typeof(string)) { empNameText.HorzAlign = HorzAlign.Right; } else { empNameText.HorzAlign = HorzAlign.Center; } empNameText.VertAlign = VertAlign.Center; //生成内容列的竖线 LineObject lineVertical = new LineObject(); lineVertical.Parent = dataBand; lineVertical.Bounds = new RectangleF(x, 0, 1F, rowHeight); //生成内容列顶部的横线 LineObject lineHorizontal = new LineObject(); lineHorizontal.Parent = dataBand; lineHorizontal.Bounds = new RectangleF(x, 0, columnWidth, 1f); //生成内荣列底部的横线 LineObject lineHorizontalD = new LineObject(); lineHorizontalD.Parent = dataBand; lineHorizontalD.Bounds = new RectangleF(x, rowHeight, columnWidth, 1f); //x坐标增加当前列 x += columnWidth; } //生成标题右边的竖线 LineObject lineHeaderRightVer = new LineObject(); lineHeaderRightVer.Parent = page.PageHeader; lineHeaderRightVer.Bounds = new RectangleF(x, 0, 1f, rowHeight); //生成内容右边的竖线 LineObject lineRightVer = new LineObject(); lineRightVer.Parent = dataBand; lineRightVer.Bounds = new RectangleF(x, 0, 1f, rowHeight); //生成合并列头 foreach (string span in dicSpanWidth.Keys) { //合并列头 TextObject txtSpan = new TextObject(); txtSpan.Parent = page.PageHeader; txtSpan.CreateUniqueName(); txtSpan.Bounds = dicSpanWidth[span]; txtSpan.Text = span; txtSpan.HorzAlign = HorzAlign.Center; txtSpan.VertAlign = VertAlign.Center; //合并列头的竖线 LineObject lineHeaderVer = new LineObject(); lineHeaderVer.Parent = page.PageHeader; lineHeaderVer.Bounds = new RectangleF(txtSpan.Bounds.X, txtSpan.Bounds.Y, 1f, txtSpan.Bounds.Height); } #endregion #region 生成页脚 page.PageFooter = new PageFooterBand(); page.PageFooter.Height = rowHeaderHeight; page.PageHeader.CreateUniqueName(); TextObject txtPageN = new TextObject(); txtPageN.Parent = page.PageFooter; txtPageN.CreateUniqueName(); txtPageN.Text = "[PageNofM]"; txtPageN.Bounds = new RectangleF(100, 0, 200, rowHeaderHeight); //TextObject txtTotalPages = new TextObject(); //txtTotalPages.Parent = page.PageFooter; //txtTotalPages.CreateUniqueName(); //txtTotalPages.Text = "[TotalPages]"; //txtTotalPages.Bounds = new RectangleF(350, 0, 200, rowHeaderHeight); #endregion return report; }
private void reportShow() { this.Invoke(new setStatusDelegate1(setStatus)); int i = 0, j = 0; dbHepler db = new dbHepler(); string sql = this.Invoke(new getsql(generatesql)) as string; MessageBox.Show(sql); // string sql = "select * from [20028] where XH='128590'"; DataSet Student = db.LoadData(sql); report.Pages.Clear(); //report.Load("Untitled.frx"); ; //DataBand data = (DataBand)report.FindObject("data1"); for (i = 0; i < Student.Tables[0].Rows.Count / 10; i++) { ReportPage page1 = new ReportPage(); report.Pages.Add(page1); DataBand data = new DataBand(); page1.Bands.Add(data); for (j = 0; j < 10; j++) { TextObject text1 = new TextObject(); if (j % 2 == 0) { text1.Bounds = new RectangleF(Units.Centimeters * 4, Units.Centimeters * 3 * j, Units.Centimeters * 5, Units.Centimeters * 0.6f); } else { text1.Bounds = new RectangleF(Units.Centimeters * 9 + Units.Centimeters * 4, Units.Centimeters * 3 * (j - 1), Units.Centimeters * 5, Units.Centimeters * 0.6f); } text1.Text = Student.Tables[0].Rows[10 * i + j]["name"].ToString(); data.Objects.Add(text1); PictureObject pic = new PictureObject(); if (j % 2 == 0) { pic.Bounds = new RectangleF(0, Units.Centimeters * 3 * j, Units.Centimeters * 2, Units.Centimeters * 2); } else { pic.Bounds = new RectangleF(Units.Centimeters * 9 + Units.Centimeters * 0, Units.Centimeters * 3 * (j - 1), Units.Centimeters * 2, Units.Centimeters * 2); } if (File.Exists("./" + "20"+Student.Tables[0].Rows[10 * i + j]["XH"].ToString().Substring(0,2) + "/" + Student.Tables[0].Rows[10 * i + j]["XH"].ToString()+ ".jpg")) pic.Image = Image.FromFile("./" +"20"+ Student.Tables[0].Rows[10 * i + j]["XH"].ToString().Substring(0,2) + "/" + Student.Tables[0].Rows[10 * i + j]["XH"].ToString() + ".jpg"); data.Objects.Add(pic); BarcodeObject bar = new BarcodeObject(); if (j % 2 == 0) { bar.Bounds = new RectangleF(0, Units.Centimeters * 3 * j + Units.Centimeters * 2.5f, Units.Centimeters * 8, Units.Centimeters * 2); } else { bar.Bounds = new RectangleF(Units.Centimeters * 9 + Units.Centimeters * 0, Units.Centimeters * 3 * (j - 1) + Units.Centimeters * 2.5f, Units.Centimeters * 8, Units.Centimeters * 2); } //pic.Image = Image.FromFile("100001.jpg"); bar.Text = Student.Tables[0].Rows[10 * i + j]["ZKZH"].ToString(); data.Objects.Add(bar); } } if (Student.Tables[0].Rows.Count % 10 != 0) { Console.WriteLine((10 * i + j).ToString()); ReportPage page2 = new ReportPage(); report.Pages.Add(page2); DataBand data2 = new DataBand(); page2.Bands.Add(data2); for (int k = 10 * (i - 1) + j; k < Student.Tables[0].Rows.Count; k++) { TextObject text1 = new TextObject(); if (k % 2 == 0) { text1.Bounds = new RectangleF(Units.Centimeters * 4, Units.Centimeters * 3 * (k % 10), Units.Centimeters * 5, Units.Centimeters * 0.6f); } else { text1.Bounds = new RectangleF(Units.Centimeters * 9 + Units.Centimeters * 4, Units.Centimeters * 3 * (k % 10 - 1), Units.Centimeters * 5, Units.Centimeters * 0.6f); } text1.Text = Student.Tables[0].Rows[k]["name"].ToString(); data2.Objects.Add(text1); PictureObject pic = new PictureObject(); if (k % 2 == 0) { pic.Bounds = new RectangleF(0, Units.Centimeters * 3 * k % 10, Units.Centimeters * 2, Units.Centimeters * 2); } else { pic.Bounds = new RectangleF(Units.Centimeters * 9 + Units.Centimeters * 0, Units.Centimeters * 3 * (k % 10 - 1), Units.Centimeters * 2, Units.Centimeters * 2); } if (File.Exists("./" + "20" + Student.Tables[0].Rows[k]["XH"].ToString().Substring(0,2) + "/" + Student.Tables[0].Rows[k]["XH"].ToString() + ".jpg")) pic.Image = Image.FromFile("./" + "20"+Student.Tables[0].Rows[k]["XH"].ToString().Substring(0,2) + "/" + Student.Tables[0].Rows[k]["XH"].ToString()+ ".jpg"); data2.Objects.Add(pic); BarcodeObject bar = new BarcodeObject(); if (k % 2 == 0) { bar.Bounds = new RectangleF(0, Units.Centimeters * 3 * (k % 10) + Units.Centimeters * 2.5f, Units.Centimeters * 8, Units.Centimeters * 2); } else { bar.Bounds = new RectangleF(Units.Centimeters * 9 + Units.Centimeters * 0, Units.Centimeters * 3 * (k % 10 - 1) + Units.Centimeters * 2.5f, Units.Centimeters * 8, Units.Centimeters * 2); } //pic.Image = Image.FromFile("100001.jpg"); bar.Text = Student.Tables[0].Rows[k]["ZKZH"].ToString(); data2.Objects.Add(bar); } } this.Invoke(new setStatusDelegate1(setStatus2)); this.Invoke(new setStatusDelegate1(reportShow1)); }
private void GenerateReportPage(XtraTabPage pTabPage) { /** * if from send email, we will need to use the private var -> m_TabPage. * so we can be able to call the public methods preview report and create pdf via the send email. * we create the pool handle on the tab page itself. * * Important Note: we dont need threading when send email since we only load one tab. * * will be utilized also when called from web portal. */ #region Code Logic if (CallingEnvironment == eCallingEnvironment.BrightSales_SendEmail || m_IsWebPortalCall) { //m_TabPage = pTabPage.Tag as ReportPage; m_TabPage = pTabPage as ReportPage; if (m_TabPage != null) { try { view_configuration _eftConfig = null; using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(m_DatabaseConnection)) { _eftConfig = _efDbContext.view_configuration.FirstOrDefault(i => i.id == m_TabPage.ConfigData.id); _efDbContext.Detach(_eftConfig); int _CampaignId = (int)_efDbContext.subcampaigns.FirstOrDefault(i => i.id == _eftConfig.subcampaign_id).campaign_id; int _CustomerId = (int)_efDbContext.campaigns.FirstOrDefault(i => i.id == _CampaignId).customers.id; m_TabPage.CustomerId = _CustomerId; } m_TabPage.VerifyPoolHandler(); if (string.IsNullOrEmpty(_eftConfig.xml_config) || _eftConfig.xml_config.Equals("<view />")) return; /** * [jeff 05.14.2012]: https://brightvision.jira.com/browse/PLATFORM-1381 * add second parameter to determine the selected display mode of the export view. * if no 2nd parameter defined, default will be loaded. */ m_TabPage.ViewType = DisplayMode; Dictionary<string, string> _drConfigData = new Dictionary<string,string>(); if (DisplayMode == eDisplayMode.AccountsContacts_WithDialogData) _drConfigData = DatabaseUtility.GetViews(m_TabPage.ConfigData.id, ExportView.eExportViewDisplayMode.Default, m_DatabaseConnection, AccountId); else if (DisplayMode == eDisplayMode.AccountsContacts_WithCallAttempts) _drConfigData = DatabaseUtility.GetViews(m_TabPage.ConfigData.id, ExportView.eExportViewDisplayMode.AccountsAndContactsHavingSubCampaignCallAttemps, m_DatabaseConnection, AccountId); if (_drConfigData == null) throw new Exception("No data was found."); string _XmlData = string.Empty; var datasource = this.GetXmlData(_eftConfig.xml_config, _drConfigData, ref _XmlData); System.Threading.Thread.Sleep(1500); if (m_TabPage != null) { m_TabPage.ViewType = DisplayMode; m_TabPage.DataSource = datasource; m_TabPage.XmlConfig = _eftConfig.xml_config; m_TabPage.XmlConfigData = _XmlData; if (m_IsWebPortalCall) { if (!string.IsNullOrEmpty(m_GridFilterString)) m_TabPage.GridFilterString = m_GridFilterString; if (!string.IsNullOrEmpty(m_GridSortInfo)) m_TabPage.GridSortInfo = m_GridSortInfo; if (!string.IsNullOrEmpty(m_GridColumnsInfo)) m_TabPage.GridColumnsInfo = m_GridColumnsInfo; } } if (datasource != null && datasource.Rows.Count > 0) { m_TabPage.ViewConfigName = _eftConfig.name; m_TabPage.ViewConfigId = _eftConfig.id; m_TabPage.SubCampaignId = _eftConfig.subcampaign_id; m_TabPage.CampaignInfo = CampaignInfo; } } catch (Exception e) { if (m_IsWebPortalCall) throw e; NotificationDialog.Error("Reports", string.Format("{0}{1}{2}", e.Message, Environment.NewLine, e.InnerException.Message)); } if (OnReportPageCompleted != null) OnReportPageCompleted(this, new EventArgs()); } } #endregion /** * if not send email, just use method level report page var, so we can be able to display * multiple tab pages on a tab control calling this module. * we create the pool handle right on this method. */ #region Code Logic else { ReportPage _TabPage = pTabPage.Tag as ReportPage; if (_TabPage != null) { Action _action = delegate() { try { view_configuration _eftConfig = null; using (BrightPlatformEntities _efDbContext = new BrightPlatformEntities(m_DatabaseConnection)) { _eftConfig = _efDbContext.view_configuration.FirstOrDefault(i => i.id == _TabPage.ConfigData.id); _efDbContext.Detach(_eftConfig); int _CampaignId = (int)_efDbContext.subcampaigns.FirstOrDefault(i => i.id == _eftConfig.subcampaign_id).campaign_id; int _CustomerId = (int)_efDbContext.campaigns.FirstOrDefault(i => i.id == _CampaignId).customers.id; _TabPage.CustomerId = _CustomerId; } if (!IsHandleCreated) this.CreateHandle(); _TabPage.Invoke(new MethodInvoker(delegate { _TabPage.SetButtonState(false); _TabPage.InitRecordCount(); })); if (string.IsNullOrEmpty(_eftConfig.xml_config) || _eftConfig.xml_config.Equals("<view />")) { _TabPage.Invoke(new MethodInvoker(delegate { _TabPage.HideLoadingInfo(); })); return; } /** * [jeff 05.14.2012]: https://brightvision.jira.com/browse/PLATFORM-1381 * add second parameter to determine the selected display mode of the export view. * if no 2nd parameter defined, default will be loaded. */ _TabPage.ViewType = DisplayMode; Dictionary<string, string> _drConfigData = new Dictionary<string, string>(); if (DisplayMode == eDisplayMode.AccountsContacts_WithDialogData) _drConfigData = DatabaseUtility.GetViews(_TabPage.ConfigData.id, ExportView.eExportViewDisplayMode.Default); else if (DisplayMode == eDisplayMode.AccountsContacts_WithCallAttempts) _drConfigData = DatabaseUtility.GetViews(_TabPage.ConfigData.id, ExportView.eExportViewDisplayMode.AccountsAndContactsHavingSubCampaignCallAttemps); if (_drConfigData == null) throw new Exception("No data was found."); string _XmlData = string.Empty; var datasource = this.GetXmlData(_eftConfig.xml_config, _drConfigData, ref _XmlData); System.Threading.Thread.Sleep(1500); if (_TabPage != null) { _TabPage.ViewType = DisplayMode; _TabPage.DataSource = datasource; _TabPage.XmlConfig = _eftConfig.xml_config; _TabPage.XmlConfigData = _XmlData; if (m_IsWebPortalCall) { if (!string.IsNullOrEmpty(m_GridFilterString)) _TabPage.GridFilterString = m_GridFilterString; if (!string.IsNullOrEmpty(m_GridSortInfo)) _TabPage.GridSortInfo = m_GridSortInfo; if (!string.IsNullOrEmpty(m_GridColumnsInfo)) _TabPage.GridColumnsInfo = m_GridColumnsInfo; } } if (datasource != null && datasource.Rows.Count > 0) { _TabPage.ViewConfigName = _eftConfig.name; _TabPage.ViewConfigId = _eftConfig.id; _TabPage.SubCampaignId = _eftConfig.subcampaign_id; _TabPage.Invoke(new MethodInvoker(delegate { _TabPage.SetButtonState(true); _TabPage.SetRecordCount(datasource.Rows.Count); })); } } catch (Exception e) { _TabPage.Invoke(new MethodInvoker(delegate { NotificationDialog.Error("Reports", string.Format("{0}{1}", e.Message, Environment.NewLine)); })); } }; bw = new BackgroundWorker(); bw.DoWork += (sender, e) => { _action(); }; bw.RunWorkerCompleted += (sender, e) => { _TabPage.ImageIndex = -1; }; bw.RunWorkerAsync(); } } #endregion }
public void GenerateReportPages(ref XtraTabControl pTabControl, int[] pSubcampaignIds, int pViewConfigId = 0) { List<XtraTabPage> _lstGroup = new List<XtraTabPage>(); ReportPage _ReportPage = null; int _DefaultTab = 0; int _SubcampaignId = 0; string _SubCampaignTitle = string.Empty; SubcampaignData _SubCampaignData = null; m_lstViewConfigData = this.GetConfigurationInfos(pSubcampaignIds); for (int x = 0; x < m_lstViewConfigData.Count; ++x) { /** * if specific view is specified (pViewConfigId > 0), we will only need to use that view. * so we can save process. */ if (pViewConfigId > 0 && m_lstViewConfigData[x].id != pViewConfigId) continue; if (m_lstViewConfigData[x].id == pViewConfigId) _DefaultTab = x; _SubcampaignId = m_lstViewConfigData[x].subcampaign_id; if (pSubcampaignIds.Length > 1) { _SubCampaignData = LSubCampaignData.FirstOrDefault(f => f.id == _SubcampaignId); if (_SubCampaignData != null) _SubCampaignTitle = _SubCampaignData.title + ">"; } _ReportPage = new ReportPage(ref this.gcReport, ref this.gvReport, string.Format("{0}{1}", _SubCampaignTitle, m_lstViewConfigData[x].name), CallingEnvironment, m_IsWebPortalCall) { ConfigData = m_lstViewConfigData[x], DatabaseConnection = m_DatabaseConnection, WebPortalRequester = m_WebPortalRequester, ReportsPath = m_ReportsPath, CallingApplication = CallingApplication }; _lstGroup.Add(_ReportPage); } /** * if its a web portal call, no need to thread tab loading. * since we only get one tab to process when called from web portal. */ if (CallingEnvironment == eCallingEnvironment.BrightSales_SendEmail || m_IsWebPortalCall) { this.GenerateReportPage(_lstGroup[0]); return; } pTabControl.BeginUpdate(); pTabControl.TabPages.AddRange(_lstGroup.ToArray()); pTabControl.EndUpdate(); pTabControl.SelectedTabPageIndex = _DefaultTab; this.StartPoolingReportPages(ref pTabControl); }
public override void PageAdded(Report report, ReportPages pages, ReportPage page) { // このメソッドはページが追加されるたびに呼ばれます // 直前のページで"group_example"という識別子を持ったグループが終了しているかを調べます Group g = page.FindFinishedGroup("group_example"); if (g != null) { // 直前に終了したグループのデータを用いて集計ページを作成し、挿入します Report _report = new Report(this.reportDesign); _report.Fill(g.Data); pages.AddRange(_report.GetPages()); } }