95 lines
3.6 KiB
C#
95 lines
3.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using WeiSha.Common;
|
|
using Song.ServiceInterfaces;
|
|
using VTemplate.Engine;
|
|
using Song.Entities;
|
|
|
|
namespace Song.Site
|
|
{
|
|
/// <summary>
|
|
/// pxbg1 的摘要说明
|
|
/// </summary>
|
|
public class pxbg1 : BasePage
|
|
{
|
|
|
|
public void ProcessRequest(HttpContext context)
|
|
{
|
|
context.Response.ContentType = "text/plain";
|
|
context.Response.Write("Hello World");
|
|
}
|
|
|
|
protected override void InitPageTemplate(HttpContext context)
|
|
{
|
|
//如果未登录
|
|
if (!Extend.LoginState.Accounts.IsLogin || this.Account == null)
|
|
{
|
|
string url = WeiSha.Common.Login.Get["Accounts"].NoLoginPath.String ?? "/";
|
|
context.Response.Write("<script>top.location.href='"+url.Replace("~/","") +"'</script>");
|
|
context.Response.End();
|
|
//context.Response.Redirect(url);
|
|
}
|
|
Song.Entities.Accounts student = this.Account;
|
|
FastReport.Report webReport = new FastReport.Report(); // 创建报表对象
|
|
System.IO.MemoryStream ms = new System.IO.MemoryStream();
|
|
FastReport.Export.Image.ImageExport pdf = new FastReport.Export.Image.ImageExport();
|
|
DataTable dt = new DataTable(); //JsonConvert.DeserializeObject<DataTable>(JsonConvert.SerializeObject(new xgDal().getJYSQD(int.Parse(id))));
|
|
dt.Columns.Add("name");
|
|
dt.Columns.Add("rq");
|
|
dt.Columns.Add("date_year");
|
|
dt.Columns.Add("sfzh");
|
|
dt.Columns.Add("zsbh");
|
|
dt.Columns.Add("jg");
|
|
dt.Columns.Add("type");
|
|
|
|
|
|
string id = context.Request.QueryString.Get("id");
|
|
Song.Entities.ExamResults exr = Business.Do<IExamination>().ResultSingle(int.Parse(id));
|
|
|
|
DataRow dr = dt.NewRow();
|
|
dt.Rows.Add(dr);
|
|
dr["name"] = student.Ac_Name;
|
|
dr["rq"] = exr.Exr_CalcTime.ToString("yyyy年MM月dd日");
|
|
dr["date_year"] = DateTime.Now.Year;
|
|
dr["sfzh"] = student.Ac_IDCardNumber;
|
|
dr["zsbh"] = "DZZYJKPXPT" + exr.Exr_CalcTime.ToString("yyyyMMdd") + exr.Exr_ID.ToString("000000");
|
|
dr["jg"] = student.Ac_QyName;
|
|
if (student.Ac_Type == "main")
|
|
{
|
|
dr["type"] = "用人单位主要负责人";
|
|
webReport.Load(this.Server.MapPath("~/Download/") + "manager.frx");//调用报表
|
|
}
|
|
else if (student.Ac_Type == "manager")
|
|
{
|
|
dr["type"] = "职业卫生管理人员";
|
|
webReport.Load(this.Server.MapPath("~/Download/") + "manager.frx");//调用报表
|
|
}
|
|
else
|
|
{
|
|
webReport.Load(this.Server.MapPath("~/Download/") + "worker.frx");//调用报表
|
|
}
|
|
webReport.RegisterData(dt, "bg"); //传递数据
|
|
webReport.Prepare();
|
|
webReport.Export(pdf, ms);
|
|
webReport.Dispose();
|
|
Response.ContentType = "image/JPEG";
|
|
//Response.ContentType = "application/octet-stream";
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=" + student.Ac_Name + "证书.jpg");
|
|
Response.BinaryWrite(ms.ToArray());
|
|
Response.Flush();
|
|
Response.End();
|
|
//return File(ms, "image/jpeg");
|
|
}
|
|
|
|
public bool IsReusable
|
|
{
|
|
get
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
} |