zoukankan      html  css  js  c++  java
  • asp.net Lodop实现批量打印

    1、列表(前台)

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="w_studentTrainResultSearch.aspx.cs" Inherits="DTMIS.Web.StudentMG.w_studentTrainResultSearch" %>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script src="../js/jquery-1.4.4.min.js" type="text/javascript"></script>
        <script src="../js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
        <%--  <script src="../js/WebCalendar.js" type="text/javascript"></script>--%>
        <link href="../Include/StyleFile.css" type="text/css" rel="stylesheet" />
        <script type="text/javascript">
            var tr;
            var _bgColor;
            $(function () {
                $("#DataGrid1 tr:gt(0)").hover(
                function () {
                    tr = $(this);
                    if (tr.rowIndex != 0) {
                        _bgColor = tr.css("backgroundColor");
                        tr.css("backgroundColor", "#ffc051");
                    }
                },
                function () {
                    tr.css("backgroundColor", _bgColor);
                }
                );
            });
    
            //批量打印
            function PrintUrl()
            {
                var canshu = "<%= canshu%>";
                var canshuUrl = "";
                var canshus = canshu.split('|');
                var IfBlankPrint = ($("#ChbIfBlankPrint").attr("checked") == true) ? 0 : 1;
                var chks = document.getElementsByName("DataGrid1_CheckSingle");
                if (chks != null && chks.length != 0) {
                    var len = chks.length;
                    for (var i = 0; i < len; i++) {
                        var chk = chks[i]
                        if (chk.checked) {
                            canshuUrl += canshus[i] + "," + IfBlankPrint + "|";
                        }
                    }
                }
                if (canshuUrl!= "") {
                    var canshusub = canshuUrl.substr(0, canshuUrl.length - 1);
                    window.open("w_studentTrainResultNew.aspx?canshu=" + canshusub);
                }
                else {
                    alert("请选择需打印学员!");
                }            
            }
            function printStuTrainResult(ID, km, dno)
            {
                var TypeState = document.getElementById("hidTypeState").value;
                var IfBlankPrint = ($("#ChbIfBlankPrint").attr("checked") == true) ? 0 : 1;
                var href = "w_studentTrainResult.aspx?ID=" + ID + "&km=" + km + "&dno=" + dno + "&IfBlankPrint=" + IfBlankPrint + "&fun=0";
                if (TypeState == "0")
                {
                    //if (km != "1") {
                        window.open(href);
                        //window.location.href = "w_studentTrainResult.aspx?ID=" + ID + "&km=" + km + "&dno=" + dno + "&IfBlankPrint=" + IfBlankPrint + "&fun=0";
                    //} else
                    //{
                    //    //alert("驾校用户没有打印科目一的权限!");
                    //}
                }
                else if (TypeState == "1") {
                    if (km == "1") {
                        window.open(href);
                        //window.location.href = "w_studentTrainResult.aspx?ID=" + ID + "&km=" + km + "&dno=" + dno + "&IfBlankPrint=" + IfBlankPrint + "&fun=0";
                    } else
                    {
                        if(km == "2")
                        {
                            alert("培训中心用户没有打印科目二的权限!");
                        }else
                        {
                            alert("培训中心用户没有打印科目三的权限!");
                        }
                    }
                }
                else
                {
                    var R_Class = document.getElementById("hidR_Class").value;
                    if (R_Class != 0) {
                        alert("交管局用户没有打印权限!");
                    } else
                    {
                        window.open(href);
                        //window.location.href = "w_studentTrainResult.aspx?ID=" + ID + "&km=" + km + "&dno=" + dno + "&IfBlankPrint=" + IfBlankPrint + "&fun=0";
                    }
                }
            }
        </script>
        <script type="text/javascript">
            function SelectAll(tempControl) {
                var theBox = tempControl;
                xState = theBox.checked;
                elem = theBox.form.elements;
                for (i = 0; i < elem.length; i++) {
                    if (elem[i].type == "checkbox" && elem[i].id != theBox.id) {
                        if (elem[i].checked != xState) {
                            elem[i].click();
                        }
                    }
                }
                $("#ChbIfBlankPrint").removeAttr("checked");
            }
        </script>
    </head>
    <body class="background_all">
        <form id="Form1" method="post" runat="server">
            <table height="100%" cellspacing="0" cellpadding="0" width="100%" border="0">
                <tr>
                    <td valign="top" width="100%">
                        <table cellspacing="1" cellpadding="0" width="98%" align="center" border="0">
                            <tr>
                                <td bgcolor="#cccccc" height="23" width="70%">   学员管理 -- 证书记录打印 -- 学员培训记录
                                </td>
                                <td bgcolor="#cccccc" align="center" width="30%"> </td>
                            </tr>
                            <tr>
                                <td valign="top" colspan="2">
                                    <asp:Panel ID="SearchPanel" runat="server" Width="100%" />
                                    <table cellspacing="0" cellpadding="0" width="100%" align="center" border="0">
                                        <tr>
                                            <td class="td_border_all">
                                                <table cellspacing="1" cellpadding="1" width="100%" align="center" border="0">
                                                    <tr>
                                                        <td class="td_bgcolor_all" align="center" colspan="4" height="22">学员查询</td>
                                                    </tr>
                                                    <tr>
                                                        <td class="BDTD">
                                                            <asp:Label runat="server" ID="lblTitle" Text="所属机构"></asp:Label>
                                                        </td>
                                                        <td class="WHITETD" colspan="3">
                                                            <asp:DropDownList ID="ddlDistrict" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlDistrict_SelectedIndexChanged">
                                                            </asp:DropDownList>
                                                            <asp:DropDownList ID="ddlTrainCenter" runat="server" AutoPostBack="True" Visible="false">
                                                            </asp:DropDownList>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="BDTD">所属驾校</td>
                                                        <td class="WHITETD">
                                                            <asp:DropDownList ID="ddlDrvNo" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlDrvNo_SelectedIndexChanged">
                                                            </asp:DropDownList>
                                                        </td>
                                                        <td class="BDTD">申请日期</td>
                                                        <td class="WHITETD">
                                                            <%--<asp:TextBox ID="BeginDate" runat="server" onclick="new Calendar().show(this);" Width="100px"></asp:TextBox>--%>
                                                            <input runat="server" readonly="readonly" id="BeginDate" onfocus="WdatePicker({Date:'%y-%M-{%d}'})" />
                                                             至 
                                                            <input runat="server" readonly="readonly" id="EndDate" onfocus="WdatePicker({Date:'%y-%M-{%d}'})" />
                                                            <%--<asp:TextBox ID="EndDate" runat="server" onclick="new Calendar().show(this);" Width="100px"></asp:TextBox>--%>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="BDTD" width="15%">学员编号</td>
                                                        <td class="WHITETD" width="35%">
                                                            <asp:TextBox ID="txtS_No" runat="server" Width="160px"></asp:TextBox>
                                                        </td>
                                                        <td class="BDTD" width="15%">学员姓名</td>
                                                        <td class="WHITETD" width="35%">
                                                            <asp:TextBox ID="txtS_Name" runat="server" Width="100px"></asp:TextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="BDTD">学员状态</td>
                                                        <td class="WHITETD">
                                                            <asp:DropDownList ID="ddlS_Status" runat="server">
                                                            </asp:DropDownList>
                                                        </td>
                                                        <td class="BDTD">学车类型</td>
                                                        <td class="WHITETD">
                                                            <asp:DropDownList ID="ddlS_StudyVehicleType" runat="server">
                                                                <asp:ListItem Value=" "></asp:ListItem>
                                                            </asp:DropDownList>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="BDTD">证件类型</td>
                                                        <td class="WHITETD">
                                                            <asp:DropDownList ID="ddlS_PaType" runat="server">
                                                            </asp:DropDownList>
                                                        </td>
                                                        <td class="BDTD">证件号</td>
                                                        <td class="WHITETD">
                                                            <asp:TextBox ID="txtS_IDCardNo" runat="server" Width="160px"></asp:TextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="BDTD">科目</td>
                                                        <td class="WHITETD">
                                                            <asp:DropDownList ID="ddlSubject" runat="server">
                                                                <%--<asp:ListItem Value="0">所有</asp:ListItem>
                                                            <asp:ListItem Value="科目一">科目一</asp:ListItem>
                                                            <asp:ListItem Value="科目二">科目二</asp:ListItem>
                                                            <asp:ListItem Value="科目三">科目三</asp:ListItem>--%>
                                                            </asp:DropDownList>
                                                        </td>
                                                        <td class="BDTD">打印状态</td>
                                                        <td class="WHITETD">
                                                            <asp:DropDownList ID="ddlPrint" runat="server">
                                                                <asp:ListItem Value="0">未打印</asp:ListItem>
                                                                <asp:ListItem Value="1">已打印</asp:ListItem>
                                                            </asp:DropDownList>
                                                        </td>
                                                    </tr>
                                                    <tr bgcolor="#cccccc">
                                                        <td align="center" colspan="4" height="30">
                                                            <asp:Button ID="Button1" runat="server" Width="60PX" Text="搜索" Height="22px" Font-Size="12px" OnClick="Button1_Click"></asp:Button>
                                                             <asp:Button ID="Button2" runat="server" Width="60px" Text="返回" Height="22px" Font-Size="12px" OnClick="Button2_Click"></asp:Button>
                                                            <asp:HiddenField ID="hidTypeState" runat="server" />
                                                            <asp:HiddenField ID="hidR_Class" runat="server" />
                                                            <%--<br />
                                                                <br />
                                                                培训单位签名(科目一):<asp:TextBox ID="txtTrainSign0" runat="server" Width="150px"></asp:TextBox>
                                                                  培训单位签名(科目二):<asp:TextBox ID="txtTrainSign1" runat="server" Width="150px"></asp:TextBox>
                                                                  培训单位签名(科目三):<asp:TextBox ID="txtTrainSign2" runat="server" Width="150px"></asp:TextBox>
                                                                 <br /> 
    <%--                                                        管理机构签名(科目一):<asp:TextBox ID="txtGOVSign0" runat="server" Width="150px"></asp:TextBox>
                                                                  管理机构签名(科目二):<asp:TextBox ID="txtGOVSign1" runat="server" Width="150px"></asp:TextBox>
                                                                  管理机构签名(科目三):<asp:TextBox ID="txtGOVSign2" runat="server" Width="150px"></asp:TextBox>
                                                                 <br /> --%>
                                                            <%--签名日期(科目一):<asp:TextBox ID="txtSignDate0" runat="server" onclick="new Calendar().show(this);" Width="100px"></asp:TextBox>
                                                                  签名日期(科目二):<asp:TextBox ID="txtSignDate1" runat="server" onclick="new Calendar().show(this);" Width="100px"></asp:TextBox>
                                                                  签名日期(科目三):<asp:TextBox ID="txtSignDate2" runat="server" onclick="new Calendar().show(this);" Width="100px"></asp:TextBox>
                                                                 
                                                                <asp:Button ID="btnSaveDate" runat="server" Font-Size="12px" Height="22px" 
                                                                    onclick="btnSaveDate_Click" Text="保存" Width="60PX" />--%>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </table>
                                    </asp:Panel>
                                    <asp:Panel ID="pBlankPrint" runat="server">
                                        <table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
                                            <tr bgcolor="#cccccc">
                                                <td align="right" height="25px">
                                                    <%--<asp:CheckBox ID="ChbIfBlankPrint"  AutoPostBack="true" runat="server" Text="全打" />--%>
                                                    <input id="ChbIfBlankPrint" type="checkbox" /><label for="ChbIfBlankPrint">全打</label>
                                                    <input id="btnPrint" runat="server" type="button" onclick="PrintUrl();" value="批量打印" />
                                                    <%--<asp:Button ID="btnPrint" runat="server" OnClick="btnPrint_Click" Text="批量打印" />--%>
                                                         
                                                </td>
                                            </tr>
                                        </table>
                                    </asp:Panel>
                                    <asp:Panel ID="ResultPanel" runat="server" Width="100%">
                                        <table cellspacing="1" cellpadding="1" width="100%" align="center" border="0">
                                            <tr>
                                                <td align="center">
                                                    <asp:DataGrid ID="DataGrid1" runat="Server" Width="100%" CssClass="grid_border_all" BorderWidth="1px"
                                                        PageSize="15" AutoGenerateColumns="False" BackColor="White" OnItemDataBound="DataGrid1_ItemDataBound">
                                                        <AlternatingItemStyle BackColor="#F7F7F7"></AlternatingItemStyle>
                                                        <ItemStyle HorizontalAlign="Center" Height="20px"></ItemStyle>
                                                        <HeaderStyle HorizontalAlign="Center" Height="22px" ForeColor="White" VerticalAlign="Middle"
                                                            CssClass="gird_bgcolor_all"></HeaderStyle>
                                                        <Columns>
                                                            <asp:TemplateColumn HeaderText="序号">
                                                                <ItemTemplate>
                                                                    <%# Container.ItemIndex + 1%>
                                                                </ItemTemplate>
                                                            </asp:TemplateColumn>
                                                            <asp:BoundColumn DataField="D_Name" HeaderText="驾校简称"></asp:BoundColumn>
                                                            <asp:BoundColumn DataField="Subject" HeaderText="科目"></asp:BoundColumn>
                                                            <asp:BoundColumn DataField="S_No" HeaderText="学员编号"></asp:BoundColumn>
                                                            <asp:BoundColumn DataField="S_Name" HeaderText="学员姓名"></asp:BoundColumn>
                                                            <%--<asp:BoundColumn DataField="S_Type" HeaderText="学员类型"></asp:BoundColumn>--%>
                                                            <asp:BoundColumn DataField="S_Sex" HeaderText="性别"></asp:BoundColumn>
                                                            <asp:BoundColumn DataField="S_Tel" HeaderText="联系电话"></asp:BoundColumn>
                                                            <asp:BoundColumn DataField="S_PaType" HeaderText="证件类型"></asp:BoundColumn>
                                                            <asp:BoundColumn DataField="S_IDCardNo" HeaderText="证件号"></asp:BoundColumn>
                                                            <asp:BoundColumn DataField="S_StudyVehicleType" HeaderText="学车类型"></asp:BoundColumn>
                                                            <asp:BoundColumn DataField="AddTime" DataFormatString="{0:d}" HeaderText="申请日期"></asp:BoundColumn>
                                                            <asp:BoundColumn DataField="S_Teacher" HeaderText="所属教练"></asp:BoundColumn>
                                                            <asp:BoundColumn DataField="S_Status" HeaderText="学员状态"></asp:BoundColumn>
                                                            <asp:BoundColumn HeaderText="打印次数" DataField="PrintCount"></asp:BoundColumn>
                                                            <%--  <asp:TemplateColumn HeaderText="查看">
                                                            <ItemTemplate>
                                                                <a target="_blank" style="color: Blue;" href='w_studentTrainResult.aspx?ID=<%# (DataBinder.Eval(Container,"DataItem.ID"))%>&km=<%# (DataBinder.Eval(Container,"DataItem.subjectid"))%>&dno=<%# (DataBinder.Eval(Container,"DataItem.d_no"))%>&IfBlankPrint=<%=IfBlankPrint.ToString()%>&fun=0'>
                                                                    培训记录</a>
                                                            </ItemTemplate>
                                                        </asp:TemplateColumn>--%>
                                                            <asp:TemplateColumn HeaderText="查看">
                                                                <ItemTemplate>
                                                                    <a style="color: Blue; cursor: pointer;" onclick="printStuTrainResult(<%# (DataBinder.Eval(Container,"DataItem.ID"))%>,<%# (DataBinder.Eval(Container,"DataItem.subjectid"))%>,'<%# (DataBinder.Eval(Container,"DataItem.d_no"))%>')">培训记录</a>
                                                                </ItemTemplate>
                                                            </asp:TemplateColumn>
                                                            <asp:TemplateColumn HeaderText="选择">
                                                                <HeaderTemplate>
                                                                    <asp:CheckBox ID="check1" runat="server"
                                                                        onclick="javascript:SelectAll(this);" />
                                                                </HeaderTemplate>
                                                                <ItemTemplate>
                                                                    <asp:Label ID="lbid" runat="server"
                                                                        Text='<%# DataBinder.Eval(Container,"DataItem.ID")%>' Visible="False"></asp:Label>
                                                                    <asp:Label ID="lbSubject" runat="server"
                                                                        Text='<%# DataBinder.Eval(Container,"DataItem.subjectid")%>' Visible="False"></asp:Label>
                                                                    <asp:Label ID="lbD_No" runat="server"
                                                                        Text='<%# DataBinder.Eval(Container,"DataItem.d_no")%>' Visible="False"></asp:Label>
                                                                    <input id="CheckSingle" type="checkbox" name="<%#DataGrid1.ClientID%>_CheckSingle" />
                                                                    <%--<asp:CheckBox ID="CheckSingle" Runat="server" />--%>
                                                                </ItemTemplate>
                                                            </asp:TemplateColumn>
                                                        </Columns>
                                                    </asp:DataGrid>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td bgcolor="#CCCCCC" align="right">
                                                    <asp:LinkButton ID="lbFirst" runat="server" OnClick="lbFirst_Click" Enabled="false">首页</asp:LinkButton>
                                                    <asp:LinkButton ID="lbBack" runat="server" OnClick="lbBack_Click" Enabled="false">上一页</asp:LinkButton>
                                                    <asp:LinkButton ID="lbNext" runat="server" OnClick="lbNext_Click" Enabled="false">下一页</asp:LinkButton>
                                                    <asp:LinkButton ID="lbLast" runat="server" OnClick="lbLast_Click" Enabled="false">末页</asp:LinkButton>  
                                                第<asp:DropDownList ID="ddlPageSelect" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlPageSelect_SelectedIndexChanged">
                                                    <asp:ListItem Value="1">1/1</asp:ListItem>
                                                </asp:DropDownList>
                                                    页   共有<asp:Label ID="lbTotal" runat="server"></asp:Label>个记录  
                                                每页<input id="tbPageSize" runat="server" style=" 35px;" value="15" />个记录
                                                </td>
                                            </tr>
                                        </table>
                                    </asp:Panel>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <!--td width="13" background="../Images/Default_20.gif"></td-->
                </tr>
            </table>
        </form>
    </body>
    </html>
    

     2、打印页面(前台)

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="w_studentTrainResultNew.aspx.cs" Inherits="DTMIS.Web.StudentMG.w_studentTrainResultNew" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <style type="text/css">
            .btnStyle {
                display: none;
            }
        </style>
        <script type="text/javascript" src="../js/LodopFuncs.js"></script>
        <object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width="0"
            height="0">
            <embed id="LODOP_EM" type="application/x-print-lodop" width="0" height="0" pluginspage="../js/install_lodop.exe"></embed>
        </object>
        <title></title>
        <script type="text/javascript">
    
            var LODOP; //声明为全局变量
            function myShow4() {
                
                LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
                LODOP.PRINT_INITA(0, 0, 1123, 756, "重庆驾培学员培训记录打印");
                LODOP.SET_PRINT_PAGESIZE(2, 2100, 2970, "A4");
    
                LODOP.SET_SHOW_MODE("HIDE_PAPER_BOARD", 1);   //隐藏背景条文
                LODOP.SET_SHOW_MODE("HIDE_SBUTTIN_PREVIEW", 1);
                //LODOP.SET_SHOW_MODE("LANDSCAPE_DEFROTATED", 1); //注:"BKIMG_IN_PREVIEW"-预览包含背景图 "BKIMG_IN_FIRSTPAGE"- 仅首页包含背景图		
    
                var count = <%= prinCount%> ;
                for (var i = 1; i <= count; i++) {
                    if(i!=count)
                    {
                        LODOP.ADD_PRINT_HTM(0, -10, 1000, 900, document.getElementById("div"+i).innerHTML);
                        LODOP.NewPage();
                    }
                    else {
                        LODOP.ADD_PRINT_HTM(0, -10, 1000, 900, document.getElementById("div"+i).innerHTML);
                    }
                }
                    
                var result = LODOP.PREVIEW();
                if (result > 0) {
                    DTMIS.Web.StudentMG.w_studentTrainResultNew.UpdatePrintStatus();
                    window.close();
                }
                else {
                    if (window.confirm("未检测到打印信号,如果你已经打印,请点确认更新打印状态")) {
                        DTMIS.Web.StudentMG.w_studentTrainResultNew.UpdatePrintStatus();
                       
                    }
                    window.close();
                }
            };
    
            
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <div style="100%; height:100%; text-align:center;">
             <div id="div_PrintDown"> 
                 <input id="btn_Print" type="button" value="打印预览" name="B3"  onclick="myShow4()" />
           </br> <a href="../js/print.rar">打印插件包下载</a>
                 </div>
           </div>
            <div style="display: none;"><%= div_data.ToString() %></div>
    
        </form>
    </body>
    </html>
    

     3、后台(套打、全打)

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="w_studentTrainResultNew.aspx.cs" Inherits="DTMIS.Web.StudentMG.w_studentTrainResultNew" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <style type="text/css">
            .btnStyle {
                display: none;
            }
        </style>
        <script type="text/javascript" src="../js/LodopFuncs.js"></script>
        <object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width="0"
            height="0">
            <embed id="LODOP_EM" type="application/x-print-lodop" width="0" height="0" pluginspage="../js/install_lodop.exe"></embed>
        </object>
        <title></title>
        <script type="text/javascript">
    
            var LODOP; //声明为全局变量
            function myShow4() {
                
                LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
                LODOP.PRINT_INITA(0, 0, 1123, 756, "重庆驾培学员培训记录打印");
                LODOP.SET_PRINT_PAGESIZE(2, 2100, 2970, "A4");
    
                LODOP.SET_SHOW_MODE("HIDE_PAPER_BOARD", 1);   //隐藏背景条文
                LODOP.SET_SHOW_MODE("HIDE_SBUTTIN_PREVIEW", 1);
                //LODOP.SET_SHOW_MODE("LANDSCAPE_DEFROTATED", 1); //注:"BKIMG_IN_PREVIEW"-预览包含背景图 "BKIMG_IN_FIRSTPAGE"- 仅首页包含背景图		
    
                var count = <%= prinCount%> ;
                for (var i = 1; i <= count; i++) {
                    if(i!=count)
                    {
                        LODOP.ADD_PRINT_HTM(0, -10, 1000, 900, document.getElementById("div"+i).innerHTML);
                        LODOP.NewPage();
                    }
                    else {
                        LODOP.ADD_PRINT_HTM(0, -10, 1000, 900, document.getElementById("div"+i).innerHTML);
                    }
                }
                    
                var result = LODOP.PREVIEW();
                if (result > 0) {
                    DTMIS.Web.StudentMG.w_studentTrainResultNew.UpdatePrintStatus();
                    window.close();
                }
                else {
                    if (window.confirm("未检测到打印信号,如果你已经打印,请点确认更新打印状态")) {
                        DTMIS.Web.StudentMG.w_studentTrainResultNew.UpdatePrintStatus();
                       
                    }
                    window.close();
                }
            };
    
            
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <div style="100%; height:100%; text-align:center;">
             <div id="div_PrintDown"> 
                 <input id="btn_Print" type="button" value="打印预览" name="B3"  onclick="myShow4()" />
           </br> <a href="../js/print.rar">打印插件包下载</a>
                 </div>
           </div>
            <div style="display: none;"><%= div_data.ToString() %></div>
    
        </form>
    </body>
    </html>
    

     (不使用全打、套打)

    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 = "<img border='0' src='../Images/001.jpg' />";
                    //div_data.Append("<div id="div" + (i + 1) + "" style="position:relative;">" + bgpath);       //背景图片
                    div_data.Append("<div id="div" + (i + 1) + "" style="position:relative;">");       //背景图片
                    div_data.Append("<span style="position:absolute; top:85px; left:80px;280px;height:50px; font-family:楷体;font-weight:bold; font-size:18px;">" + S_GraduateNo + "</span>"); //证件编号
                    //div_data.Append("<img style="position:absolute; top:100px; left:400px;" border='0' src='" + S_Pic + "' width='114' height='149' />");        //照片
                    div_data.Append("<span style="position:absolute; top:165px; left:60px;height:50px; font-family:楷体;font-weight:bold; font-size:18px;">" + S_Name + "</span>"); //学员名称
                    div_data.Append("<span style="position:absolute; top:165px; left:170px;height:50px; font-family:楷体;font-weight:bold; font-size:18px;">" + S_Sex + "</span>"); //性别
                    div_data.Append("<span style="position:absolute; top:190px; left:250px;height:50px; font-family:楷体;font-weight:bold; font-size:18px;">" + S_StudyVehicleType + "</span>"); //准驾车型
    
                    div_data.Append("<span style="position:absolute; top:165px; left: 235px;height:50px; font-family:楷体;font-weight:bold; font-size:18px;">" + sRegYear + "</span>"); //报名时间(年)
                    div_data.Append("<span style="position:absolute; top:165px; left:315px;height:50px; font-family:楷体;font-weight:bold; font-size:18px;">" + sRegMonth + "</span>"); //报报名时间(月)
                    div_data.Append("<span style="position:absolute; top:165px; left:355px;height:50px; font-family:楷体;font-weight:bold; font-size:18px;">" + sRegDay + "</span>"); //报名时间(日)
    
                    div_data.Append("<span style="position:absolute; top:190px; left:30px;height:50px; font-family:楷体;font-weight:bold; font-size:18px;">" + gRYear + "</span>"); //结业时间(年)
                    div_data.Append("<span style="position:absolute; top:190px; left:98px;height:50px; font-family:楷体;font-weight:bold; font-size:18px;">" + gRMonth + "</span>"); //结业时间(月)
                    div_data.Append("<span style="position:absolute; top:190px; left:140px;height:50px; font-family:楷体;font-weight:bold; font-size:18px;">" + gRDay + "</span>"); //结业时间(日)
    
    
                    div_data.Append("<span style="position:absolute; top:265px; left:220px;height:50px; font-family:楷体;font-weight:bold; font-size:18px;">" + sPrintYear + "</span>"); //打印时间(年)
                    div_data.Append("<span style="position:absolute; top:265px; left: 300px;height:50px; font-family:楷体;font-weight:bold; font-size:18px;">" + sPrintMonth + "</span>"); //打印时间(月)
                    div_data.Append("<span style="position:absolute; top:265px; left: 353px;height:50px; font-family:楷体;font-weight:bold; font-size:18px;">" + sPrintDay + "</span>"); //打印时间(日)
    
                    div_data.Append("<span style="position:absolute; top:240px; left:250px; 400px;height:50px; font-family:楷体;font-weight:bold; font-size:18px;">" + D_Name + "</span>"); //培训机构
    
                    div_data.Append(" </div>");
                    #endregion
                    if (prinCount == (i + 1))      //全部打印完成后,移除Session保存的值
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "print", "<script>myShow4();</script>");
                        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 "";
                }
            }
        }
    }
    
  • 相关阅读:
    很长的下拉框菜单
    Pure CSS Buttons – Good Button Style and No Images
    ssh 配置
    php大量session存储到内存中,散列及过期回收
    array_append_distinct, array_erase函数
    关于C# 中的Attribute 特性(转载)
    Jquery如何操作Table的某一个td
    ASP.NET应用程序生命周期趣谈(四) HttpHandler和页面生命周期
    ASP.NET应用程序生命周期趣谈(五) IIS7瞎说
    ASP.NET应用程序生命周期趣谈(三)
  • 原文地址:https://www.cnblogs.com/Blog-Yang/p/4517325.html
Copyright © 2011-2022 走看看