ab56a9bcf7
SVN-Revision: r240
107 lines
3.5 KiB
C#
107 lines
3.5 KiB
C#
/******************************
|
|
* 说明:FastReport打印
|
|
* 创建人:龚宇超
|
|
* 创建日期:2019-09-12
|
|
* 修改人:
|
|
* 修改日期:
|
|
* 修改备注:
|
|
* 版本: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 FastReport;
|
|
using FastReport.Data;
|
|
using FastReport.Preview;
|
|
using Lskj.Control;
|
|
using Lskj.Business.Impl;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Lskj.Control
|
|
{
|
|
/// <summary>
|
|
/// FastReport打印
|
|
/// </summary>
|
|
public partial class FrmFastReportDesign : BaseForm
|
|
{
|
|
public Report ReportObj;
|
|
public PreviewControl PreviewControlObj { get { return this.previewControl1; } }
|
|
|
|
public FrmFastReportDesign()
|
|
{
|
|
InitializeComponent();
|
|
Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:设置数据源</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-09-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="args">The arguments.</param>
|
|
public void SetDataSource(string[] args)
|
|
{
|
|
DataSet myDataSet = new DataSet();
|
|
myDataSet.DataSetName = "myDataSet";
|
|
for (int i = 0; i < args.Length; i++)
|
|
{
|
|
string sql = args[i];
|
|
if (string.IsNullOrEmpty(sql)) continue;
|
|
myDataSet.Merge(SetDataSource(sql, "temp" + i), true, MissingSchemaAction.Add);
|
|
}
|
|
|
|
this.ReportObj.RegisterData(myDataSet);
|
|
foreach (DataSourceBase source in this.ReportObj.Dictionary.DataSources)
|
|
source.Enabled = true;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置数据源</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-09-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="args">The arguments.</param>
|
|
public void SetDataSource(List<Task<DataTable>> dataTableTasks)
|
|
{
|
|
DataSet myDataSet = new DataSet();
|
|
myDataSet.DataSetName = "myDataSet";
|
|
foreach (Task<DataTable> dataTableTask in dataTableTasks)
|
|
{
|
|
myDataSet.Merge(dataTableTask.Result, true, MissingSchemaAction.Add);
|
|
}
|
|
this.ReportObj.RegisterData(myDataSet);
|
|
foreach (DataSourceBase source in this.ReportObj.Dictionary.DataSources)
|
|
source.Enabled = true;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置数据源</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sql">The SQL.</param>
|
|
/// <returns>DataSet.</returns>
|
|
public DataTable SetDataSource(string sql, string tableName)
|
|
{
|
|
DataTable table = BaseImpl.GetDataTableResult(sql);
|
|
table.TableName = tableName;
|
|
return table;
|
|
}
|
|
}
|
|
}
|