1、列表(前台)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="w_studentTrainResultSearch.aspx.cs" Inherits="DTMIS.Web.StudentMG.w_studentTrainResultSearch" %>
<%-- --%>
2、打印页面(前台)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="w_studentTrainResultNew.aspx.cs" Inherits="DTMIS.Web.StudentMG.w_studentTrainResultNew" %>
3、后台(套打、全打)
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="w_studentTrainResultNew.aspx.cs" Inherits="DTMIS.Web.StudentMG.w_studentTrainResultNew" %>
(不使用全打、套打)
using AjaxPro;
using DTMIS.BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace DTMIS.Web.StudentMG
{
public partial class CertificatePrintNew : System.Web.UI.Page
{
protected StringBuilder div_data = new StringBuilder();
protected int prinCount = 0;
public static string stuidStr = ""; //学员ID字符串,用于批量修改打印次数
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 string bgpath;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Utility.RegisterTypeForAjax(typeof(CertificatePrintNew));
}
#region 批量打印执行程序
MorePrin();
#endregion
}
private void MorePrin()
{
string canshu = Request.QueryString["canshu"];
stuidStr = canshu;
string[] allstudent = canshu.Split(',');
this.prinCount = allstudent.Length;
for (int i = 0; i < allstudent.Length; i++)
{
DataSet set = BLL.T_Student_Base.getStudentData(Convert.ToInt32(allstudent[i]));
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();
//报名日期
if (item["S_RegisterDate"].ToString() != "")
{
time = Convert.ToDateTime(item["S_RegisterDate"].ToString().Trim());
sRegYear = time.Year.ToString();
sRegMonth = time.Month.ToString();
sRegDay = time.Day.ToString();
}
//结业日期
if (item["A_AddTime"].ToString() != "")
{
time1 = Convert.ToDateTime(item["A_AddTime"].ToString().Trim());
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();
}
}
#region 构建div
bgpath = "";
//div_data.Append("" + bgpath); //背景图片
div_data.Append(""); //背景图片
div_data.Append("" + S_GraduateNo + ""); //证件编号
//div_data.Append(""); //照片
div_data.Append("" + S_Name + ""); //学员名称
div_data.Append("" + S_Sex + ""); //性别
div_data.Append("" + S_StudyVehicleType + ""); //准驾车型
div_data.Append("" + sRegYear + ""); //报名时间(年)
div_data.Append("" + sRegMonth + ""); //报报名时间(月)
div_data.Append("" + sRegDay + ""); //报名时间(日)
div_data.Append("" + gRYear + ""); //结业时间(年)
div_data.Append("" + gRMonth + ""); //结业时间(月)
div_data.Append("" + gRDay + ""); //结业时间(日)
div_data.Append("" + sPrintYear + ""); //打印时间(年)
div_data.Append("" + sPrintMonth + ""); //打印时间(月)
div_data.Append("" + sPrintDay + ""); //打印时间(日)
div_data.Append("" + D_Name + ""); //培训机构
div_data.Append(" ");
#endregion
if (prinCount == (i + 1)) //全部打印完成后,移除Session保存的值
{
ClientScript.RegisterStartupScript(this.GetType(), "print", "");
Session.Remove("canshu");
}
}
}
//[AjaxMethod]
[WebMethod]
public static string UpdatePrintStatus(string stulist)
{
string msg = string.Empty;
int result= Common.Update("T_Student_Base", "IsGraducatePrint=1", "ID in(" + stulist + ")");
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 "";
}
}
}
}
转载于:https://www.cnblogs.com/Blog-Yang/p/4517325.html