209 lines
9.5 KiB
C#
209 lines
9.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using FastReport;
|
|
using FastReport.Export.Pdf;
|
|
namespace Epost.Common
|
|
{
|
|
public class FastReportHelper
|
|
{
|
|
#region 打印方法(winform)
|
|
public static void Report_SKU(string filename, string batchid, string goodsname, string sku, string z_quantity, string quantity, string barcode, string z_unit, string unit, string block, string senddate, out Report reps/*,out MemoryStream strm1*/)
|
|
{
|
|
Report rep = null;
|
|
try
|
|
{
|
|
if (block != "总分")
|
|
{
|
|
block = block + "通道";
|
|
}
|
|
rep = new Report();
|
|
rep.Load(filename);//读取配置文件
|
|
rep.SetParameterValue("batchid", batchid); // p1参数名
|
|
rep.SetParameterValue("goodsname", goodsname); // p1参数名
|
|
rep.SetParameterValue("sku", sku); // p1参数名
|
|
rep.SetParameterValue("barcode", barcode); // p1参数名
|
|
rep.SetParameterValue("z_quantity", z_quantity); // p1参数名
|
|
rep.SetParameterValue("quantity", quantity); // p1参数名
|
|
rep.SetParameterValue("z_unit", z_unit); // p1参数名
|
|
rep.SetParameterValue("unit", unit); // p1参数名
|
|
rep.SetParameterValue("block", block); // p1参数名
|
|
rep.SetParameterValue("senddate", senddate); // p1参数名
|
|
LogHelper.WriteLogInfo(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss开始打印\r\n"));
|
|
rep.Prepare();
|
|
rep.PrintSettings.ShowDialog = false;
|
|
rep.Print();
|
|
reps = rep;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
reps = null;
|
|
LogHelper.WriteLogInfo(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ex.ToString());
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 打印方法(winform)
|
|
public static void Report_Box(string filename, string boxno, string shopid, string shopname, string barcode, string orderid, string city, string orderway, string totalcount, string printstate, string senddate, string loc, out Report reps/*,out MemoryStream strm1*/)
|
|
{
|
|
Report rep = null;
|
|
try
|
|
{
|
|
rep = new Report();
|
|
rep.Load(filename);//读取配置文件
|
|
rep.SetParameterValue("boxno", boxno); // p1参数名
|
|
rep.SetParameterValue("shopid", shopid); // p1参数名
|
|
rep.SetParameterValue("shopname", shopname); // p1参数名
|
|
rep.SetParameterValue("barcode", barcode); // p1参数名
|
|
rep.SetParameterValue("orderid", orderid); // p1参数名
|
|
rep.SetParameterValue("city", city); // p1参数名
|
|
rep.SetParameterValue("orderway", orderway); // p1参数名
|
|
rep.SetParameterValue("totalcount", totalcount); // p1参数名
|
|
rep.SetParameterValue("printstate", printstate); // p1参数名
|
|
rep.SetParameterValue("senddate", senddate); // p1参数名
|
|
rep.SetParameterValue("loc", loc); // p1参数名
|
|
LogHelper.WriteLogInfo(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss开始打印\r\n"));
|
|
rep.Prepare();
|
|
rep.PrintSettings.ShowDialog = false;
|
|
rep.Print();
|
|
reps = rep;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
reps = null;
|
|
LogHelper.WriteLogInfo(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ex.ToString());
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 打印方法(winform)
|
|
public static void ReportSkuList(string filename, DataTable table, string boxcode, string boxno, string shopid, string shopname, string senddate, out Report reps/*,out MemoryStream strm1*/)
|
|
{
|
|
Report rep = null;
|
|
try
|
|
{
|
|
rep = new Report();
|
|
rep.Load(filename);//读取配置文件
|
|
// DataTable table = new DataTable();//设置DataTable
|
|
table.TableName = "RepList";//设置表名
|
|
rep.SetParameterValue("boxcode", boxcode); // p1参数名
|
|
rep.SetParameterValue("boxno", boxno); // p1参数名
|
|
rep.SetParameterValue("shopid", shopid); // p1参数名
|
|
rep.SetParameterValue("shopname", shopname); // p1参数名
|
|
|
|
rep.SetParameterValue("senddate", senddate); // p1参数名
|
|
LogHelper.WriteLogInfo(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss开始打印\r\n"));
|
|
rep.RegisterData(table, "RepList");
|
|
rep.Prepare();
|
|
rep.PrintSettings.ShowDialog = false;
|
|
rep.Print();
|
|
|
|
reps = rep;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
reps = null;
|
|
LogHelper.WriteLogInfo(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ex.ToString());
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 打印方法DN(winform)
|
|
public static void ReportDNList(string filename, DataTable table, string orderwayname, string boxcount, string shopid, string shopname, string address, string city, string readtime, string senddate, string orderid, out Report reps/*,out MemoryStream strm1*/)
|
|
{
|
|
Report rep = null;
|
|
try
|
|
{
|
|
rep = new Report();
|
|
rep.Load(filename);//读取配置文件
|
|
// DataTable table = new DataTable();//设置DataTable
|
|
|
|
rep.SetParameterValue("shopid", shopid); // p1参数名
|
|
rep.SetParameterValue("shopname", shopname); // p1参数名
|
|
rep.SetParameterValue("orderwayname", orderwayname); // p1参数名
|
|
rep.SetParameterValue("boxcount", boxcount); // p1参数名
|
|
rep.SetParameterValue("address", address); // p1参数名
|
|
rep.SetParameterValue("lighttime", readtime); // p1参数名
|
|
rep.SetParameterValue("city", city); // p1参数名
|
|
rep.SetParameterValue("partcode", address); // p1参数名
|
|
rep.SetParameterValue("orderid", orderid); // p1参数名
|
|
var time = Convert.ToDateTime(senddate).ToString("yyyy/MM/dd");
|
|
|
|
|
|
rep.SetParameterValue("senddate", time.Replace("-", "/")); // p1参数名
|
|
table.TableName = "DNList";//设置表名
|
|
LogHelper.WriteLogInfo(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss开始打印\r\n"));
|
|
rep.RegisterData(table, "DNList");
|
|
rep.Prepare();
|
|
rep.PrintSettings.ShowDialog = false;
|
|
rep.Print();
|
|
reps = rep;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
reps = null;
|
|
LogHelper.WriteLogInfo(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ex.ToString());
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 打印方法DN(winform)
|
|
public static void ReportDNList_PDF(string filename, DataTable table, string orderwayname, string boxcount, string shopid, string shopname, string address, string city, string readtime, string senddate, string orderid, out Report reps/*,out MemoryStream strm1*/)
|
|
{
|
|
Report rep = null;
|
|
try
|
|
{
|
|
string PDF_File = ConfigurationManager.AppSettings["PDF_File"] + "\\" + DateTime.Now.ToString("yyyyMMdd");
|
|
rep = new Report();
|
|
rep.Load(filename);//读取配置文件
|
|
// DataTable table = new DataTable();//设置DataTable
|
|
|
|
rep.SetParameterValue("shopid", shopid); // p1参数名
|
|
rep.SetParameterValue("shopname", shopname); // p1参数名
|
|
rep.SetParameterValue("orderwayname", orderwayname); // p1参数名
|
|
rep.SetParameterValue("boxcount", boxcount); // p1参数名
|
|
rep.SetParameterValue("address", address); // p1参数名
|
|
rep.SetParameterValue("lighttime", readtime); // p1参数名
|
|
rep.SetParameterValue("city", city); // p1参数名
|
|
rep.SetParameterValue("partcode", address); // p1参数名
|
|
rep.SetParameterValue("orderid", orderid); // p1参数名
|
|
|
|
rep.SetParameterValue("senddate", senddate); // p1参数名
|
|
table.TableName = "DNList";//设置表名
|
|
LogHelper.WriteLogInfo(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss开始打印\r\n"));
|
|
rep.RegisterData(table, "DNList");
|
|
rep.Prepare();
|
|
//rep.PrintSettings.ShowDialog = false;
|
|
//rep.Print();
|
|
if (!Directory.Exists(PDF_File))
|
|
{
|
|
DirectoryInfo f = System.IO.Directory.CreateDirectory(PDF_File);
|
|
|
|
}
|
|
PDFExport expPdf = new PDFExport();
|
|
rep.Export(expPdf, PDF_File + "\\" + shopid + "_" + DateTime.Now.ToString("yyyyMMdd") + ".pdf");
|
|
reps = rep;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
reps = null;
|
|
LogHelper.WriteLogInfo(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ex.ToString());
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
}
|