• OA项目之打印


    打印
    若此页有一个打印按钮:
    <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=" 96%; margin: 0 auto;font-size:24px;" align="center" >
            。。查询
        </div>

        <div style="overflow: auto; 96%; margin: 0 auto;">
          <table class="table">
                <thead>
                    <tr>
                        <th style=" 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页的打印就可打印出

  • 相关阅读:
    小酌一下:pipenv 基本用法
    sql2008使用您对无法重新创建的表进行了更改或者启用了“阻止保存重新创建表的更改”
    Join操作基本:外连接、自然连接、内连接
    用dataReader获取datetime类型完整精度的时间字串
    c# MesageBox
    判断当前时间是否在一个时间段内
    c# 根据当前时间获取,本周,本月,本季度,月初,月末,各个时间段
    sql Convert函数
    c# MD5方法总结
    wml跳转
  • 原文地址:https://www.cnblogs.com/keanuyaoo/p/3290070.html
Copyright © 2020-2023  润新知