基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,206 @@
|
||||
/***********************
|
||||
* 说明:打印设置模版
|
||||
* 创建人:龚宇超
|
||||
* 创建日期:2018-06-21
|
||||
* 修改人:
|
||||
* 修改日期:
|
||||
* 修改备注:
|
||||
* 版本:1.0.0.0
|
||||
***********************/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using DevExpress.XtraReports.UI;
|
||||
using Lskj.Business.Impl;
|
||||
using Lskj.Control.Model;
|
||||
using DevExpress.XtraReports.UserDesigner;
|
||||
using DevExpress.XtraReports.Localization;
|
||||
using DevExpress.XtraPrinting;
|
||||
|
||||
namespace Lskj.Control
|
||||
{
|
||||
public partial class FrmPrintDesign : Form
|
||||
{
|
||||
public FrmPrintDesign()
|
||||
{
|
||||
InitializeComponent();
|
||||
Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前报表
|
||||
/// </summary>
|
||||
public XtraReport Report;
|
||||
/// <summary>
|
||||
/// 地址记录
|
||||
/// </summary>
|
||||
private string _filePath;
|
||||
/// <summary>
|
||||
/// 数据源
|
||||
/// </summary>
|
||||
private DataSet myDataSet;
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:打开报表</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-06-21 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
public void OpenReport(string filePath)
|
||||
{
|
||||
this.reportDesigner1.OpenReport(this.Report);
|
||||
this._filePath = this.reportDesigner1.ActiveDesignPanel.FileName = filePath;
|
||||
this.ribbonControl1.SelectedPage = this.ribbonPage4;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:预览</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-06-21 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
public void SetPreviewForm()
|
||||
{
|
||||
//隐藏编辑窗口
|
||||
this.ribbonPage3.Visible = this.ribbonPage1.Visible = false;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:设置数据源</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-06-21 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
public void SetDataSource(List<string> sqls)
|
||||
{
|
||||
myDataSet = new DataSet();
|
||||
myDataSet.DataSetName = "myDataSet";
|
||||
int i = 0;
|
||||
string tabName = "tab";
|
||||
//这里集合反转下,保证主Sql执行的Table位置(预览数据条数依赖于主sql查询得到条数)
|
||||
sqls.Reverse(0, sqls.Count);
|
||||
foreach (string sql in sqls)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sql)) continue;
|
||||
DataTable dt = BaseImpl.GetDataTableResult(sql);
|
||||
myDataSet.Merge(SetDataSource(sql, tabName + i), true, MissingSchemaAction.AddWithKey);
|
||||
i++;
|
||||
}
|
||||
this.Report.DataMember = "myDataSet";
|
||||
this.Report.DataSource = myDataSet;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:设置数据源</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-06-21 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="sql">The SQL.</param>
|
||||
/// <returns>DataSet.</returns>
|
||||
public DataSet SetDataSource(string sql, string tabName)
|
||||
{
|
||||
DataTable table = BaseImpl.GetDataTableResult(sql);
|
||||
table.TableName = tabName;
|
||||
return table.DataSet;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:打印完成回调</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-07-17 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
||||
private void PrintingSystem_EndPrint(object sender, EventArgs e)
|
||||
{
|
||||
if (PrintUtil.OnAfterPrint != null)
|
||||
PrintUtil.OnAfterPrint(sender, e);
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:注册打印完成后事件</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-07-17 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
private void RegisterPrintEnd(bool mode)
|
||||
{
|
||||
XtraReport xr = XtraReport.FromFile(_filePath, true);
|
||||
xr.DataSource = myDataSet;
|
||||
xr.PrintingSystem.EndPrint += new EventHandler(PrintingSystem_EndPrint);
|
||||
if (mode)
|
||||
xr.Print();
|
||||
else
|
||||
xr.PrintDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:快速打印事件</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-07-17 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e">The <see cref="DevExpress.XtraBars.ItemClickEventArgs"/> instance containing the event data.</param>
|
||||
private void OnFastPrintClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
RegisterPrintEnd(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message,ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:普通设置打印事件</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-07-17 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e">The <see cref="DevExpress.XtraBars.ItemClickEventArgs"/> instance containing the event data.</param>
|
||||
private void OnCommonPrint(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
RegisterPrintEnd(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message,ex.Message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user