<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/whir_system/master/SystemMasterPage.master"
    CodeFile="gatherlist.aspx.cs" Inherits="whir_system_module_extension_gatherlist" %>

<%@ Import Namespace="Whir.Language" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript">
        $(function () {

            var isAdd = '<%=IsAdd %>'.toLowerCase() == 'true' ? true : false;
            var isStartGather = '<%=IsStartGather %>'.toLocaleLowerCase() == 'true' ? true : false;
            var isGatherResult = '<%=IsGatherResult %>'.toLocaleLowerCase() == 'true' ? true : false;
            var isDelete = '<%=IsDelete %>'.toLocaleLowerCase() == 'true' ? true : false;
            var isEdit = '<%=IsEdit %>'.toLocaleLowerCase() == 'true' ? true : false;

            //是否具有添加采集点功能
            if (isAdd)
                $("#aAdd").css("display", "");
            else
                $("#aAdd").css("display", "none");

            //是否具有开始采集功能
            if (isStartGather)
                whir.control.getAllControlByNameToEnabled("a", "name", "lbStart");
            else
                whir.control.getAllControlByNameToDisabled("a", "name", "lbStart");

            //是否具有采集结果功能
            if (isGatherResult)
                whir.control.getAllControlByNameToEnabled("a", "name", "aGatherResult");
            else
                whir.control.getAllControlByNameToDisabled("a", "name", "aGatherResult");

            //是否具有修改功能
            if (isEdit)
                whir.control.getAllControlByNameToEnabled("a", "name", "aEdit");
            else
                whir.control.getAllControlByNameToDisabled("a", "name", "aEdit");


            //是否具有删除和批量删除功能 lbDel
            if (isDelete) {
                whir.control.getAllControlByNameToEnabled("a", "name", "lbDelete");  //行删除
                $("#<%=lbChooseDelete.ClientID %>").css("display", "");  //批量删除
            }
            else {
                whir.control.getAllControlByNameToDisabled("a", "name", "lbDelete");
                $("#<%=lbChooseDelete.ClientID %>").css("display", "none"); //批量删除
            }

        });

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="mainbox">
        <dl class="title_column">
            <a href="gatherlist.aspx" class="aSelect"><b>
                <%="采集管理".ToLang() %></b></a><span id="aAdd"><em class="line"></em><a href="gather_edit.aspx">
                    <b>
                        <%="添加采集点".ToLang() %></b></a></span>
        </dl>
        <div class="All_list">
            <table id="ta_list" width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <th width="20"> <div class="th-inner ">
                        <input id="chkAll" type="checkbox" title="全选/全不选" name="cb_Top" onclick="whir.checkbox.selectAll(this,'cb_Position');" />  </div>
                    </th>
                    <th width="110px">
                        <%="排序".ToLang() %>
                    </th>
                    <th>
                        <%="项目名称".ToLang()%>
                    </th>
                    <th>
                        <%="采集地址".ToLang()%>
                    </th>
                    <th>
                        <%="入库栏目".ToLang() %>
                    </th>
                    <th width="230">
                        <%="操作".ToLang() %>
                    </th>
                </tr>
                <tbody id="tbdList">
                    <asp:Repeater ID="rpGather" runat="server" OnItemCommand="rpGather_ItemCommand" OnItemDataBound="rpGather_ItemDataBound">
                        <ItemTemplate>
                            <tr>
                                <td>
                                    <input type="checkbox" name="cb_Position" value='<%# Eval("GatherId")%>' onclick="choose_file();" />
                                </td>
                                <td>
                                    <whir:textbox id="txtSort" runat="server" width="95px" errorcss="form_error" tipcss="form_tip"
                                        required="True" requirederrormessage="" errormessage=" " regular="Intege" apid='<%# Eval("GatherId")%>'
                                        text='<%# Eval("Sort")  %>' cssclass="text_common apid_sort" />
                                </td>
                                <td>
                                    <%# Eval("ItemName")%>
                                </td>
                                <td>
                                    <%# Eval("WebUrl")%>
                                </td>
                                <td>
                                    <%# Eval("ColumnName")%>
                                </td>
                                <td>
                                    <asp:LinkButton ID="lbStart" runat="server" CommandName="Start" CommandArgument='<%# Eval("GatherId") %>'>[<%="开始采集".ToLang() %>]</asp:LinkButton>
                                    <a name="aGatherResult" href="gathertablelist.aspx?id=<%# Eval("GatherId") %>">[<%="采集结果".ToLang() %>]</a>
                                    <a name="aEdit" href="gather_edit.aspx?id=<%# Eval("GatherId") %>"><%="编辑".ToLang() %></a>
                                    <asp:LinkButton ID="lbDelete" name="lbDelete" runat="server" CommandName="Delete"
                                        CommandArgument='<%# Eval("GatherId") %>'><%="删除".ToLang() %></asp:LinkButton>
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                </tbody>
            </table>
            <asp:Literal ID="ltNoRecord" runat="server"></asp:Literal>
        </div>
        <div class="pages">
            <whir:WhirPager ID="AspNetPager1" runat="server" OnPageChanged="PageChanged" 
                NumericButtonCount="5" PageSize="10"
                UrlPaging="True" AlwaysShow="True" 
                LayoutType="Div" CssClass="btn-group pageNumA"
                CustomInfoClass="page_total" ShowCustomInfoSection="Left" 
                PagingButtonsClass="btn btn-white" CurrentPageButtonClass="btn btn-primary"
                FirstLastButtonsClass="btn btn-white first-last" PrevNextButtonsClass="btn btn-white prev-next"
                >
            </whir:WhirPager>
        </div>
        <div class="operate_foot">
            <asp:HiddenField ID="hidChoose" runat="server" />
            <asp:HiddenField ID="hidSort" runat="server" />
            <a href="javascript:whir.checkbox.selectAll(null,'cb_Position');">
                <%="全选".ToLang() %></a>/<a href="javascript:whir.checkbox.cancelSelectAll(null,'cb_Position');"><%="取消".ToLang() %></a>
            <asp:LinkButton ID="lbSort" runat="server" CommandName="sort" CssClass="aLink" OnCommand="Operate_Command">
                <b>
                    <%="排序".ToLang() %></b></asp:LinkButton>
            <asp:LinkButton ID="lbChooseDelete" runat="server" OnCommand="Operate_Command" CommandName="ChooseDelete"
                CssClass="aLink"><b><%="批量删除".ToLang()%></b></asp:LinkButton>
        </div>
    </div>
    <script type="text/javascript">
        //获取主键Id
        function collectApid_Sort() {
            var apidsort = "";
            $(".apid_sort").each(function (i) {
                if (i == 0) {
                    apidsort += $(this).attr("apid") + "|" + $(this).val();
                } else {
                    apidsort += "," + $(this).attr("apid") + "|" + $(this).val();
                }
            });
            $("#<%=hidSort.ClientID %>").val(apidsort);
        }
        //点击选中文件列表中的多选框
        function choose_file() {
            var choose = "";
            var flag_count = 0;
            var $checkbox = $("#tbdList input[type='checkbox']");
            $checkbox.each(function (i) {
                if ($(this).attr("checked") == true) {
                    if (i == 0) {
                        choose += $(this).val();
                    } else {
                        choose += "," + $(this).val();
                    }
                    flag_count += 1;
                }
            });
            $("#chkAll").attr("checked", $checkbox.length == flag_count ? true : false);
            $("#<%= hidChoose.ClientID %>").val(choose);
        }
    </script>
</asp:Content>
