列表数据统计

前台代码:

 <style>

        .td_total, .td_count

        {

            text-align: center;

            font-size: 16px;

            font-weight: bold;

            color: Red;

        }

        .SupCount

        {

            font-size: 14px;

            color: blue;

            font-weight: bold;

        }

    </style>

<script>

        $(function () {

            sumCount();

        })

 

        // 计算类型总数

        function sumCount() {

            var count = 0;

            $.each($(".SupCount"), function () {

                count += parseInt($(this).text());

            });

            $("#ProcessedSum").text(count);

            count = 0;

 

            $.each($(".ProcessedCount"), function () {

                count += parseInt($(this).text());

            });

            $("#ProcessingSum").text(count);

            count = 0;

 

            $.each($(".UnderwayCount"), function () {

                count += parseInt($(this).text());

            });

            $("#TimeoutingSum").text(count);

            count = 0;

        }

    </script>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="server">

    <div class="search" style="margin-top: 2px;">

        <web:search ID="GridSearch" GridViewId="gvList" ShowRestButton="false" runat="server">

            <SearchConditionTemplate>

                <table cellspacing="0" cellpadding="0" width="100%">

                    <tr>

                        <th>

                            月份:

                        </th>

                        <td>

                            <web:DatePicker ID="dpApplyDate" Name="ApplyDate" runat="server" enablecontrol="(0.*)"

                                SkinID="calender" DateTimeFormat="yyyy-MM" class="com_textbox com_datepicker"></web:DatePicker>

                        </td>

                    </tr>

                </table>

            </SearchConditionTemplate>

        </web:search>

    </div>

    <div class="datalist">

        <!-- 标题头 -->

        <h2 style="height: 30px;">

            类型统计</h2>

        <!-- 工具栏 -->

        <div class="toolbar" style="height: 30px;">

        </div>

        <web:SmartGridView ID="gvList" runat="server" AllowPaging="True" AllowSorting="True" PageSize="200"      //这里的PageSize需要设的大一点,因为这里默认是10条

            AutoGenerateColumns="False" EnableModelValidation="True" ClientIDMode="Static"

            DataSourceID="SmartDataSource1">

            <FixRowColumnSettings MarginLeft="" MarginRight=""></FixRowColumnSettings>

            <Columns>

                <web:DataDictonaryBoundField DictionaryCode="WorkOrder" DataField="Code" HeaderText="处理类型"

                    ItemStyle-HorizontalAlign="Center" SortExpression="Code" />

                <asp:TemplateField HeaderText="已处理" SortExpression="Processed">

                    <ItemStyle HorizontalAlign="Center" CssClass="ProcessedCount" />

                    <ItemTemplate>

                        <%# Convert.ToInt32(Eval("Processed"))%>

                    </ItemTemplate>

                </asp:TemplateField>

                <asp:TemplateField HeaderText="处理中" SortExpression="">

                    <ItemStyle HorizontalAlign="Center" CssClass="UnderwayCount" />

                    <ItemTemplate>

                        <%# Convert.ToInt32(Eval("Underway"))%>

                    </ItemTemplate>

                </asp:TemplateField>

                <asp:TemplateField HeaderText="总处理数" SortExpression="">

                    <ItemStyle HorizontalAlign="Center" CssClass="SupCount" />

                    <ItemTemplate>

                        <%# Convert.ToInt32(Eval("Processed")) + Convert.ToInt32(Eval("Underway"))%>

                    </ItemTemplate>

                </asp:TemplateField>

            </Columns>

            <PagerTemplate>                                                        // 这里是重新定义了PagerTemplate属性,替换了原来的分页

                <tr class="dg_itemstyle_s">

                    <td class="td_total">

                        合计

                    </td>

                    <td id="ProcessingSum" class="td_count">

                        0

                    </td>

                    <td id="TimeoutingSum" class="td_count">

                        0

                    </td>

                    <td id="ProcessedSum" class="td_count">

                        0

                    </td>

                </tr>

            </PagerTemplate>

        </web:SmartGridView>

    </div>

    <web:SmartSqlDataSource ID="SmartDataSource1" runat="server" SelectCommand="biz_sysmaintain.countlist"

        DefaultSortExpression="Code">

    </web:SmartSqlDataSource>

</asp:Content>

 

后台代码:

public partial class CarInfoTotalList : System.Web.UI.Page

{

        Car_ReportsBLL repBLL = new Car_ReportsBLL();

protected void Page_Load(object sender, EventArgs e)

{

            if (!IsPostBack)

            {

                this.SmartDataSource1.SelectParameters.Add(new Parameter("AddDateMonth", DbType.String, DateTime.Now.ToString("yyyy-MM")));

            }

}

 

        protected void DeleteApplication(object sender, EventArgs e)

        {

            ImageButton ctr = sender as ImageButton;

            string delId = ctr.Attributes["_KeyID"];

            repBLL.DelByID(delId);

            this.gvList.DataBind();

        }

 

        protected void Refresh(object sender, EventArgs e)

        {

            this.gvList.DataBind();

        }

 

 

}

posted @ 2013-11-26 23:09  weifb  阅读(170)  评论(0)    收藏  举报