61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.IO;
|
|
using DevExpress.XtraReports.UI;
|
|
using CommonLib;
|
|
|
|
namespace Lskj.MyControl.PrintMoude
|
|
{
|
|
public class PrintUtil
|
|
{
|
|
/// <summary>
|
|
/// 打印模版后缀
|
|
/// </summary>
|
|
public static string TemplateFlag = ".repx";
|
|
/// <summary>
|
|
/// 打印完成后事件
|
|
/// </summary>
|
|
public static EventHandler OnAfterPrint;
|
|
/// <summary>
|
|
/// <para>说明:模版打印</para>
|
|
/// <para>创建人:姜棚</para>
|
|
/// <para>创建日期:2018-06-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="userId">The user identifier.</param>
|
|
/// <param name="sqls">The SQLS.</param>
|
|
/// <param name="printFile">The print file.</param>
|
|
public static void TemplatePrint(List<string> sqls, string printFile, bool isPrint)
|
|
{
|
|
string path = PubUtil.PrintModePath + printFile.Replace("\\r\\n", "");
|
|
XtraReport report = new XtraReport();
|
|
if (File.Exists(path) && !string.IsNullOrEmpty(path))
|
|
report = XtraReport.FromFile(path, true);
|
|
FrmPrintDesign design = new FrmPrintDesign();
|
|
design.Report = report;
|
|
design.SetDataSource(sqls);
|
|
if (isPrint)
|
|
{
|
|
//直接调用打印
|
|
report.PrintDialog();
|
|
return;
|
|
}
|
|
design.OpenReport(path);
|
|
if (ERPInfo.Instance.EmployeeName != "管理员")
|
|
{
|
|
design.SetPreviewForm();
|
|
design.Show();
|
|
}
|
|
else
|
|
{
|
|
design.Show();
|
|
}
|
|
}
|
|
}
|
|
}
|