83 lines
3.0 KiB
C#
83 lines
3.0 KiB
C#
|
|
using BLL;
|
|||
|
|
using NPOI.POIFS.Crypt.Dsig;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.IO;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Web;
|
|||
|
|
using System.Web.UI;
|
|||
|
|
using System.Web.UI.WebControls;
|
|||
|
|
|
|||
|
|
namespace FineUIPro.Web.HJGL.TestPackage
|
|||
|
|
{
|
|||
|
|
public partial class TestPackageDatePrint : PageBase
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 试压包主键
|
|||
|
|
/// </summary>
|
|||
|
|
public string PTP_ID
|
|||
|
|
{
|
|||
|
|
get
|
|||
|
|
{
|
|||
|
|
return (string)ViewState["PTP_ID"];
|
|||
|
|
}
|
|||
|
|
set
|
|||
|
|
{
|
|||
|
|
ViewState["PTP_ID"] = value;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (!IsPostBack)
|
|||
|
|
{
|
|||
|
|
PTP_ID = Request.Params["PTP_ID"];
|
|||
|
|
if (!string.IsNullOrEmpty(PTP_ID))
|
|||
|
|
{
|
|||
|
|
BindGrid();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
private void BindGrid()
|
|||
|
|
{
|
|||
|
|
var list = BLL.TestPackagePrintService.GetListByPTP_ID(PTP_ID);
|
|||
|
|
//根据 BLL.TestPackagePrintService.TypeIntMap 和 list 进行左连接,确保所有类型都显示,获取对应的 PrintCount,没有的类型 PrintCount 为 0
|
|||
|
|
var result = from type in BLL.TestPackagePrintService.TypeIntMap
|
|||
|
|
join item in list on type.Key equals item.TypeInt into gj
|
|||
|
|
from subitem in gj.DefaultIfEmpty()
|
|||
|
|
select new
|
|||
|
|
{
|
|||
|
|
TypeInt = type.Key,
|
|||
|
|
TypeName = type.Value,
|
|||
|
|
PrintCount = subitem != null ? subitem.PrintCount : 0
|
|||
|
|
};
|
|||
|
|
Grid1.DataSource = result;
|
|||
|
|
Grid1.DataBind();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
protected void btnPrint_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
Model.PTP_TestPackage updateTestPackage = Funs.DB.PTP_TestPackage.FirstOrDefault(x => x.PTP_ID == PTP_ID);
|
|||
|
|
|
|||
|
|
var fastReportItem = BLL.TestPackagePrintService.GetFastReportItem(updateTestPackage,Grid1.SelectedRowID,PTP_ID,this.CurrUser.LoginProjectId);
|
|||
|
|
BLL.FastReportService.ResetData();
|
|||
|
|
BLL.FastReportService.AddFastreportParameter(fastReportItem.ParameterValues);
|
|||
|
|
if (fastReportItem.DataTables!=null)
|
|||
|
|
{
|
|||
|
|
foreach (var item in fastReportItem.DataTables)
|
|||
|
|
{
|
|||
|
|
BLL.FastReportService.AddFastreportTable(item);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
string initTemplatePath = "";
|
|||
|
|
string rootPath = Server.MapPath("~/");
|
|||
|
|
initTemplatePath = fastReportItem.ReportPath;
|
|||
|
|
|
|||
|
|
if (File.Exists(rootPath + initTemplatePath))
|
|||
|
|
{
|
|||
|
|
TestPackagePrintService.AddPrintCountByTypeInt(PTP_ID, int.Parse( Grid1.SelectedRowID));
|
|||
|
|
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("~/Controls/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|