asp.net lodop单个打印

1、首先在列表页面增加以下代码

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CertificateSearch.aspx.cs" Inherits="DTMIS.Web.StudentMG.CertificateSearch" %>









    StudentSearch

    
    
    
	


    
   学员管理 -- 学员信息

<%-- --%> <%-- --%> <%-- --%> <%-- --%> <%-- --%>
学员信息查询
所属驾校 学员姓名
证件号 报名日期  至 
打印状态 全部记录 已打印 未打印    
学员编号 学员姓名
审批状态 通过 未通过 未审核 批量编号
证件类型
学员状态 学车类型
<%--  --%>  
<%--
审批操作: 通过 未通过  
--%>
<%# Container.ItemIndex + 1%> <%-- --%> <%-- --%> <%-- --%> <%----%> <%----%> <%----%> <%----%> <%----%> <%-- 学习进度 --%> 结业证打印
首页 上一页 下一页 末页   第 1/1 页   共有个记录   每页个记录

 2、打印页面(前台)

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CertificatePrint.aspx.cs" Inherits="DTMIS.Web.StudentMG.CertificatePrint" %>





    
    
    
    
    
    
        
    
    


    

 3、后台代码

using AjaxPro;
using DTMIS.BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DTMIS.Web.StudentMG
{
    public partial class CertificatePrint : System.Web.UI.Page
    {
       
        private string ModuleDir = "StudentMG/";
        private string ModulePage = "CertificatePrint.aspx";
        public static int iStudentID;//学员编号
        public string S_GraduateNo;//资格证号
        public string S_Name;//姓名
        public string S_Sex;//性别
        public DateTime S_RegisterDate;//报名日期
        public string S_Pic;//照片
        public string S_StudyVehicleType;//准驾车型
        public string D_Name;//驾校
        protected string sRegYear;
        protected string sRegMonth;
        protected string sRegDay;

        protected string gRYear;
        protected string gRMonth;
        protected string gRDay;

        protected string sPrintYear;
        protected string sPrintMonth;
        protected string sPrintDay;
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!Common.canAccess(this.ModuleDir + this.ModulePage))
            //{
            //    base.Response.Redirect("../NoPower.html");
            //} 
            if (!IsPostBack)
            {
                Utility.RegisterTypeForAjax(typeof(CertificatePrint));
                iStudentID = Convert.ToInt32(base.Request.QueryString["ID"]);

                DataSet set = BLL.T_Student_Base.getStudentData(iStudentID);

                if (set.Tables.Count > 0)
                {
                    foreach (DataRow item in set.Tables[0].Rows)
                    {
                        DateTime time;
                        DateTime time1;
                        S_GraduateNo = item["S_GraduateNo"].ToString().Trim();
                        S_Name = item["S_Name"].ToString().Trim();
                        S_Sex = item["S_Sex"].ToString().Trim();
                        S_Pic = ConvertUrl(item["S_Pic"].ToString().Trim());
                        S_StudyVehicleType = item["S_StudyVehicleType"].ToString().Trim();
                        D_Name = item["D_Name"].ToString().Trim();
                        //报名日期
                        if (item["S_RegisterDate"].ToString() != "")
                        {
                            time = Convert.ToDateTime(item["S_RegisterDate"].ToString());
                            sRegYear = time.Year.ToString();
                            sRegMonth = time.Month.ToString();
                            sRegDay = time.Day.ToString();
                        }
                        //结业日期
                        if (item["A_AddTime"].ToString() != "")
                        {
                            time1 = Convert.ToDateTime(item["A_AddTime"].ToString());
                            gRYear = time1.Year.ToString();
                            gRMonth = time1.Month.ToString();
                            gRDay = time1.Day.ToString();
                        }
                        //打印时间
                        DateTime now = DateTime.Now;
                        sPrintYear = now.Year.ToString();
                        sPrintMonth = now.Month.ToString();
                        sPrintDay = now.Day.ToString();
                    }


                }

            }
        }
        //[AjaxMethod]
        [WebMethod]
        public static string UpdatePrintStatus(string stuid)
        {
            string msg = string.Empty;
            int result = Common.Update("T_Student_Base", "IsGraducatePrint=1", "ID=" + stuid);
            if (result > 0)
            {
                msg = "ok";
            }
            else
            {
                msg = "error";
            }
            return msg;

        }
        private string ConvertUrl(string imgUrl)
        {
            if (!string.IsNullOrEmpty(imgUrl))
            {
                imgUrl = imgUrl.Substring(1, imgUrl.Length - 1);
                string strDomain = "http://" + HttpContext.Current.Request.Url.Host;
                int iPort = HttpContext.Current.Request.Url.Port;
                string imgPath = strDomain + ":" + iPort.ToString() + "/" +
                                 imgUrl.Replace(Server.MapPath("/"), "").Replace(@"\", "/");

                return imgPath;
            }
            else
            {
                return "";
            }
        }
    }
}

 以上三步即可实现lodop打印

转载于:https://www.cnblogs.com/Blog-Yang/p/4517312.html

你可能感兴趣的:(javascript,json,ui)