public void Preview() { if (rptTmp == null) { return; } SetVariables(rptTmp); rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" }; rptTmp.DataSource = db; rptTmp.ShowPreview(); }
public static void XemVaIn(this DevExpress.XtraGrid.GridControl grid, DevExpress.XtraReports.UI.XtraReport rpt, System.Drawing.Printing.PaperKind PageKind, bool Landscape) { #region Thiết kế trước khi in if (grid != null) { DevExpress.XtraGrid.Views.Grid.GridView view = grid.MainView as DevExpress.XtraGrid.Views.Grid.GridView; if (view != null) { view.AppearancePrint.EvenRow.Font = new System.Drawing.Font("Times New Roman", 11F); view.AppearancePrint.EvenRow.Options.UseFont = true; view.AppearancePrint.FilterPanel.Font = new System.Drawing.Font("Times New Roman", 11F); view.AppearancePrint.FilterPanel.Options.UseFont = true; view.AppearancePrint.FooterPanel.BorderColor = System.Drawing.Color.Black; view.AppearancePrint.FooterPanel.Font = new System.Drawing.Font("Times New Roman", 11F); view.AppearancePrint.FooterPanel.Options.UseBorderColor = true; view.AppearancePrint.FooterPanel.Options.UseFont = true; view.AppearancePrint.GroupFooter.BorderColor = System.Drawing.Color.Black; view.AppearancePrint.GroupFooter.Font = new System.Drawing.Font("Times New Roman", 11F); view.AppearancePrint.GroupFooter.Options.UseBorderColor = true; view.AppearancePrint.GroupFooter.Options.UseFont = true; view.AppearancePrint.GroupRow.BorderColor = System.Drawing.Color.Black; view.AppearancePrint.GroupRow.Font = new System.Drawing.Font("Times New Roman", 11F, System.Drawing.FontStyle.Bold); view.AppearancePrint.GroupRow.Options.UseBorderColor = true; view.AppearancePrint.GroupRow.Options.UseFont = true; view.AppearancePrint.HeaderPanel.BorderColor = System.Drawing.Color.Black; view.AppearancePrint.HeaderPanel.Font = new System.Drawing.Font("Times New Roman", 11F, System.Drawing.FontStyle.Bold); view.AppearancePrint.HeaderPanel.Options.UseBorderColor = true; view.AppearancePrint.HeaderPanel.Options.UseFont = true; view.AppearancePrint.HeaderPanel.Options.UseTextOptions = true; view.AppearancePrint.HeaderPanel.Options.UseBackColor = true; view.AppearancePrint.HeaderPanel.BackColor = System.Drawing.Color.FromArgb(192, 255, 255); view.AppearancePrint.HeaderPanel.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center; view.AppearancePrint.HeaderPanel.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center; view.AppearancePrint.Lines.BackColor = System.Drawing.Color.Black; view.AppearancePrint.Lines.Font = new System.Drawing.Font("Times New Roman", 11F); view.AppearancePrint.Lines.Options.UseBackColor = true; view.AppearancePrint.Lines.Options.UseFont = true; view.AppearancePrint.OddRow.Font = new System.Drawing.Font("Times New Roman", 11F); view.AppearancePrint.OddRow.Options.UseFont = true; view.AppearancePrint.Preview.Font = new System.Drawing.Font("Times New Roman", 11F); view.AppearancePrint.Preview.Options.UseFont = true; view.AppearancePrint.Row.BorderColor = System.Drawing.Color.Black; view.AppearancePrint.Row.Font = new System.Drawing.Font("Times New Roman", 11F); view.AppearancePrint.Row.Options.UseBorderColor = true; view.AppearancePrint.Row.Options.UseFont = true; view.AppearancePrint.EvenRow.BackColor = System.Drawing.Color.MintCream; view.OptionsPrint.EnableAppearanceEvenRow = true; } } #endregion Thiết kế trước khi in rpt.PaperKind = PageKind; rpt.Landscape = Landscape; rpt.Bands[DevExpress.XtraReports.UI.BandKind.Detail].Controls.Add(CopyGridControl(grid)); rpt.ShowPreview(); }
/// <param name="rptTmp">DevReport file.</param> /// <param name="_Script">Script get data for report.</param> /// <param name="index">Index Row which get data</param> /// <param name="isPrint">Print or Preview</param> /// <param name="j">Liên Parameter</param> private void PrintPreview(DevExpress.XtraReports.UI.XtraReport rptTmp, string _Script, int index, int isPrint, int j) { DataTable dtReport = new DataTable(); try { if (_Script == string.Empty) { dtReport = _data.GetDataForPrint(index); DataMasterDetail dta = (_data as DataMasterDetail); if (dta != null) { richTextBox1.Text = dta.PrintSQL; } } else { dtReport = _data.GetDataForPrint(index, _Script); DataMasterDetail dta = (_data as DataMasterDetail); if (dta != null) { richTextBox1.Text = dta.PrintSQL; } } } catch { } dtReport = AddRecordToData(dtReport); DevExpress.XtraReports.UI.XRControl xrcTitle = rptTmp.FindControl("title", true); if (xrcTitle != null) { xrcTitle.Text = textEditTitle.Text.ToUpper(); } DevExpress.XtraReports.UI.XRControl xrcSoCTGoc = rptTmp.FindControl("SoCTGoc", true); if (xrcSoCTGoc != null) { xrcSoCTGoc.Text = textEditSoCTGoc.Text; } //SetVariables(rptTmp); if (dtReport == null) { return; } rptTmp.DataSource = dtReport; rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" }; SetVariables(rptTmp); if (Config.GetValue("Language").ToString() == "1") { Translate(rptTmp); } SetVariables(rptTmp, j); rptTmp.ShowPrintMarginsWarning = false; if (isPrint == 0) { rptTmp.Print(); //Update LanIn } else if (isPrint == 1) { rptTmp.ShowPreview(); } else if (isPrint == 2) { SaveFileDialog fd = new SaveFileDialog(); fd.Filter = "(*.xls)|*.xls"; fd.AddExtension = true; fd.ShowDialog(); if (fd.FileName != string.Empty) { rptTmp.ExportToXls(fd.FileName); } } }
private void PrintOrPreview(bool isPrint, int j) { DevExpress.XtraReports.UI.XtraReport rptTmp = null; string path; if (Config.GetValue("DuongDanBaoCao") != null) { path = Config.GetValue("DuongDanBaoCao").ToString() + "\\" + Config.GetValue("Package").ToString() + "\\" + _reportFile + ".repx"; } else { path = Application.StartupPath + "\\Reports\\" + Config.GetValue("Package").ToString() + "\\" + _reportFile + ".repx"; } if (System.IO.File.Exists(path)) { for (int i = 0; i < _arrIndex.Length; i++) { int index = _arrIndex[i]; DataTable dtReport = _data.GetDataForPrint(index); if (_data.mt.Columns.Contains("PrintIndex")) { _reportFile = tbMau.Rows[int.Parse(_data.mt.Rows[index]["PrintIndex"].ToString())]["RFile"].ToString(); } if (Config.GetValue("DuongDanBaoCao") != null) { path = Config.GetValue("DuongDanBaoCao").ToString() + "\\" + Config.GetValue("Package").ToString() + "\\" + _reportFile + ".repx"; } else { path = Application.StartupPath + "\\Reports\\" + Config.GetValue("Package").ToString() + "\\" + _reportFile + ".repx"; } rptTmp = DevExpress.XtraReports.UI.XtraReport.FromFile(path, true); DevExpress.XtraReports.UI.XRControl xrcTitle = rptTmp.FindControl("title", true); if (xrcTitle != null) { xrcTitle.Text = textEditTitle.Text.ToUpper(); } DevExpress.XtraReports.UI.XRControl xrcSoCTGoc = rptTmp.FindControl("SoCTGoc", true); if (xrcSoCTGoc != null) { xrcSoCTGoc.Text = textEditSoCTGoc.Text; } //SetVariables(rptTmp); if (dtReport == null) { continue; } rptTmp.DataSource = dtReport; rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" }; SetVariables(rptTmp); if (Config.GetValue("Language").ToString() == "1") { Translate(rptTmp); } SetVariables(rptTmp, j); if (isPrint) { rptTmp.Print(); } else { rptTmp.ShowPreview(); } } } else { XtraMessageBox.Show("Không tìm thấy file báo cáo " + _reportFile); } }
/// <param name="rptTmp">DevReport file.</param> /// <param name="_Script">Script get data for report.</param> /// <param name="index">Index Row which get data</param> /// <param name="isPrint">Print or Preview</param> /// <param name="j">Liên Parameter</param> private void PrintPreview(DevExpress.XtraReports.UI.XtraReport rptTmp, string _Script, int index, bool isPrint, int j) { DataTable dtReport = new DataTable(); try { if (_Script == string.Empty) { dtReport = _data.GetDataForPrint(index); DataMasterDetail dta = (_data as DataMasterDetail); if (dta != null) { richTextBox1.Text = dta.PrintSQL; } } else { dtReport = _data.GetDataForPrint(index, _Script); DataMasterDetail dta = (_data as DataMasterDetail); if (dta != null) { richTextBox1.Text = dta.PrintSQL; } } } catch { } dtReport = AddRecordToData(dtReport); DevExpress.XtraReports.UI.XRControl xrcTitle = rptTmp.FindControl("title", true); if (xrcTitle != null) { xrcTitle.Text = textEditTitle.Text.ToUpper(); } DevExpress.XtraReports.UI.XRControl xrcSoCTGoc = rptTmp.FindControl("SoCTGoc", true); if (xrcSoCTGoc != null) { xrcSoCTGoc.Text = textEditSoCTGoc.Text; } //SetVariables(rptTmp); if (dtReport == null) { return; } rptTmp.DataSource = dtReport; rptTmp.ScriptReferences = new string[] { Application.StartupPath + "\\CDTLib.dll" }; SetVariables(rptTmp); if (Config.GetValue("Language").ToString() == "1") { Translate(rptTmp); } SetVariables(rptTmp, j); if (isPrint) { rptTmp.Print(); } else { rptTmp.ShowPreview(); } }