首页 技术 正文
技术 2022年11月14日
0 收藏 959 点赞 3,234 浏览 8522 个字

打印
若此页有一个打印按钮:
<input type=”button” id=”btnPrint” class=”button_sm7″ value=”打印” onclick=”PrintDep();” />
JS连接到打印页问号后边是传参数,是在此页的查询条件:
function PrintDep() {
            window.open(‘Print.aspx?txtUName=’ + escape($(“#txtUName”).val()) + ‘&ddlDep=’ + escape($(“#ddlDep”).val()) + ‘&ddlClass=’ + escape($(“#ddlClass”).val()) + ‘&ddlIYear=’ + escape($(“#ddlIYear”).val()), ‘_blank’)
        }
Print.aspx(显示的是要打印的数据):

<head id=”Head1″ runat=”server”>
    <title>。。。。打印</title>
    <script type=”text/javascript” src=”../Page/js/jquery-1.7.2.min.js”></script>
    <script type=”text/javascript” src=”../Page/js/hide_show.js”></script>
    <link href=”../Page/css/layout.css” rel=”stylesheet” type=”text/css” />
    <link href=”../Page/css/Dialog.css” rel=”stylesheet” type=”text/css” />
    <script type=”text/javascript” src=”../Page/js/jQuery_Dialog.js”></script>
    <script type=”text/javascript” src=”../Page/js/function.js”></script>
    <script type=”text/javascript” src=”../Page/js/jquery.easydrag.js”></script>
    <link href=”../Page/css/style01.css” rel=”stylesheet” type=”text/css” />
</head>
<body>
    <form id=”form1″ runat=”server”>

<div class=”div_page_bottom_operation” style=”text-align: center; display: ”;”>
        <input type=”button” class=”button_sm7″ value=”打印” onclick=”PrintSalary();” />
    </div>
    <div style=”width: 96%; margin: 0 auto;font-size:24px;” align=”center” >
        。。查询
    </div>

<div style=”overflow: auto; width: 96%; margin: 0 auto;”>
      <table class=”table”>
            <thead>
                <tr>
                    <th style=”width: 60px” rowspan=”2″>
                        序号
                    </th>
                    <th rowspan=”2″>
                        。。
                    </th>
                    <th rowspan=”2″>
                        。。
                    </th>
                    <th rowspan=”2″>
                        。。
                    </th>
                    <th rowspan=”2″>
                        。。
                    </th>
                    <th rowspan=”2″>
                        。。
                    </th>
                    <th rowspan=”2″>
                        。。
                    </th>
                    <th rowspan=”2″>
                        。。
                    </th>
                    <th colspan=”4″ style=”text-align: center;”>
                        。。
                    </th>
                </tr>
                <tr>
                    <th>
                        。。
                    </th>
                    <th>
                        。。
                    </th>
                    <th>
                        。。
                    </th>
                    <th>
                        。。
                    </th>
                </tr>
            </thead>
            <tbody>
                <asp:Repeater ID=”rptStudentFee” runat=”server”>
                    <ItemTemplate>
                        <tr>
                            <td>
                                <%#Eval(“r_n”) %>
                            </td>
                            <td>
                                <%#Eval(“Department”) %>
                            </td>
                            <td>
                                <%#Eval(“CName”) %>
                            </td>
                            <td>
                                <%#Eval(“TTCard”) %>
                            </td>
                            <td>
                                <%#Eval(“UName”) %>
                            </td>
                            <td>
                                <%#DigitalCampus.Web.Common.pfunction.getPBCName(DigitalCampus.Web.Common.clsDictionaryData.Gender.ToString(),Eval(“Gender”).ToString()) %>
                            </td>
                            <td>
                                <%#DigitalCampus.Web.Common.pfunction.GetStrToShortDate(Eval(“AdmissionDate”).ToString())%>
                            </td>
                            <td>
                                <%#Eval(“UName”) %>
                            </td>
                            <td>
                                <%#Eval(“SubYear”)%>
                            </td>
                            <td>
                                <%#Eval(“ShouldPayment”)%>
                            </td>
                            <td>
                                <%#Eval(“ActualPayment”)%>
                            </td>
                            <td>
                                <%#Decimal.Parse(Eval(“ShouldPayment”).ToString()) – Decimal.Parse(Eval(“ActualPayment”).ToString())%>
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
                <asp:Repeater runat=”server” ID=”rptCount”>
                    <ItemTemplate>
                        <tr style=”font-weight: bold;”>
                            <td>
                                合计
                            </td>
                            <td>
                                &nbsp;
                            </td>
                            <td>
                                &nbsp;
                            </td>
                            <td>
                                &nbsp;
                            </td>
                            <td>
                                &nbsp;
                            </td>
                            <td>
                                &nbsp;
                            </td>
                            <td>
                                &nbsp;
                            </td>
                            <td>
                                &nbsp;
                            </td>
                            <td>
                                &nbsp;
                            </td>
                            <td>
                               ¥ <%#Eval(“ShouldPayment”) %>
                            </td>
                            <td>
                               ¥ <%#Eval(“ActualPayment”)%>
                            </td>
                            <td>
                               ¥ <%#Decimal.Parse(Eval(“ShouldPayment”).ToString()) – Decimal.Parse(Eval(“ActualPayment”).ToString())%>
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </tbody>
        </table>
    </div>
     <script type=”text/javascript” language=”javascript”>
         function PrintSalary() {
             $(“.div_page_bottom_operation”).hide();
             window.print();
         }
    </script>
    </form>
</body>
</html>

Print.aspx.cs(后台查询出数据):
       
        //查询参数
        public string txtUName = string.Empty;
        public string ddlDep = string.Empty;
        public string ddlClass = string.Empty;
        public string ddlIYear = string.Empty;

protected void Page_Load(object sender, EventArgs e)
        {
            txtUName = Request.QueryString[“txtUName”];
            ddlDep = Request.QueryString[“ddlDep”];
            ddlClass = Request.QueryString[“ddlClass”];
            ddlIYear = Request.QueryString[“ddlIYear”];

if (!IsPostBack)
            {
                GetFilesList();
            }
        }

private void GetFilesList()
        {
            string sort = “”;
            string strWhere = ” where 1=1 “;
            if (!string.IsNullOrEmpty(txtUName) && txtUName != “。。”)
            {
                strWhere += ” and (vw.UName like ‘%” + txtUName+ “%’ or vw.IdentityCard like ‘%” + txtUName + “%’ or vw.TTCard like ‘%” + txtUName + “%’)”;
            }
            if (ddlDep != “-1”)
            {
                strWhere += ” and vw.DepName='” + ddlDep + “‘”;
            }
            if (ddlClass != “-1”)
            {
                strWhere += ” and vw.ClassName='” + ddlClass + “‘”;
            }
            if (ddlIYear != “-1”)
            {
                strWhere += ” and sp.SubYear='” + ddlIYear + “‘”;
            }

string strSql = @”select row_number() over(order by sp.SubYear,vw.DepName,vw.ClassName,vw.UName) as r_n,sp.*,vw.*
                             from (select StuID,SubYear,isnull(sum(ShouldPayment),0) ShouldPayment,isnull(sum(ActualPayment),0)
                             ActualPayment from StudentShouldpay group by StuID,SubYear) sp inner join dbo.vw_StudentInfo vw on sp.StuID=vw.ID ” + strWhere;
            DataTable dt = sys.GetRecordByPage(strSql, pNum, pSize, sort, out rCount, out pCount).Tables[0];
            rptStudentFee.DataSource = dt;
            rptStudentFee.DataBind();
            if (dt.Rows.Count > 0)
            {
                DataTable dt2 = new DataTable();
                dt2 = DbHelperSQL.Query(@”select isnull(sum(ShouldPayment),0) ShouldPayment,isnull(sum(ActualPayment),0) ActualPayment from (select StuID,SubYear,isnull(sum(ShouldPayment),0) ShouldPayment,isnull(sum(ActualPayment),0) ActualPayment from StudentShouldpay group by StuID,SubYear) sp inner join dbo.vw_StudentInfo vw on sp.StuID=vw.ID ” + strWhere).Tables[0];
                rptCount.DataSource = dt2;
                rptCount.DataBind();
            }

}

点击Print.aspx页的打印就可打印出

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,497
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,910
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,744
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,498
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,136
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,301