<%@ Page Title="类别管理" Language="C#" StylesheetTheme="AdminSkin" MasterPageFile="~/Others/AdminMasterPage.Master" AutoEventWireup="true" CodeBehind="CategoryManage.aspx.cs" Inherits="Solution.Admin.Contents.CategoryManage" %>

<%@ Register Assembly="BX.Common" Namespace="Common" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="AdminContentHead" runat="server">
    <script type="text/javascript">
        var ofolderimg = "../Images/List/folderopen.gif", cfolderimg = "../Images/List/folderclose.gif";
        function GetListSytle(nodePath, nodeName) {
            var node = nodePath.split('/'); var newnode = nodePath.replace(/\//g, "_");
            var depth = node.length; var style = "", imgtxt = "";
            if (depth > 1) {
                style = "padding-left: " + (depth - 1) * 15 + "px;"; imgtxt = "<img src=\"../Images/List/t.gif\"/>" + "<img class=\"folderimg\" src=\"" + ofolderimg + "\" id=\"" + newnode + "\" onclick=\"closeFolder(this);\" status=\"open\"/>";;
            }
            else {
                imgtxt = "<img class=\"folderimg\" src=\"" + ofolderimg + "\" id=\"" + newnode + "\" onclick=\"closeFolder(this);\" status=\"open\"/>";
                var parentPath = nodePath.replace(/\/\d+$/, ""); nodeName = "<span style=\"cursor:pointer;\" title=\"点击查看子项\" onclick=\"window.location.href='CategoryManage.aspx?conditional=rightlike&category=NodePath&keywords=" + parentPath + "'\">" + nodeName + "</span>";
            }
            var nodetxt = "<div id=\"" + newnode + "\" class=\"ListIndustryName\" style=\"" + style + "\">" + imgtxt + nodeName + "</div>";
            return nodetxt;
        }
        function closeFolder(obj) {
            var divlist = document.getElementById("CategoryList").getElementsByTagName("div");
            var display = ""; var childquantity = 0;
            if (obj.attributes["status"].value == "close") { display = ""; } else { display = "none"; }
            for (var i = 0; i < divlist.length; i++) {
                if (divlist[i].id.indexOf(obj.id + "_") != -1 && divlist[i].id != obj.id) { var tr = divlist[i].parentNode.parentNode; tr.style.display = display; childquantity++; }
            }
            if (childquantity > 0) {
                if (obj.attributes["status"].value == "close") { obj.setAttribute("status", "open"); obj.src = ofolderimg; }
                else { obj.setAttribute("status", "close"); obj.src = cfolderimg; }
            }
        }
    </script>
    <style type="text/css">
        .ListIndustryName
        {
            text-align: left;
            margin-left: 20px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="AdminContentCenter" runat="server">
    <form id="Form1" runat="server">
        <asp:ObjectDataSource ID="ObjectDataSourceCategoryList" runat="server" EnablePaging="False"
            SelectMethod="List" TypeName="Logic.Category"
            OldValuesParameterFormatString="original_{0}">
            <SelectParameters>
                <asp:QueryStringParameter DefaultValue="0" Name="categroy" QueryStringField="category"
                    Type="String" />
                <asp:QueryStringParameter DefaultValue="0" Name="keywords" QueryStringField="keywords"
                    Type="String" />
                <asp:QueryStringParameter DefaultValue="0" Name="conditional" QueryStringField="conditional"
                    Type="string" />
            </SelectParameters>
        </asp:ObjectDataSource>
        <div class="DivRightCenter">
            <div class="listdiv">
                <div class="grid-title">
                    <div class="grid-title-text">
                        <h4>
                            <span>类别管理</span>
                        </h4>
                    </div>
                    <div class="grid-title-menu">
                        <ul>
                            <li><a href="CategoryManage.aspx"><span>所有行业</span></a></li>
                            <li><a href="CategoryManage.aspx?conditional=equals&category=ParentNode&keywords=0"><span>一级行业</span></a></li>
                            <li><a href="CategoryManage.aspx?conditional=equals&category=CategoryStatus&keywords=1"><span>有效状态</span></a></li>
                            <li><a href="CategoryManage.aspx?conditional=equals&category=CategoryStatus&keywords=0"><span>禁用状态</span></a></li>
                        </ul>
                    </div>
                </div>
                <div class="grid-list">
                    <cc1:ExtendedGridView ID="ExtendedGridViewIndustryList" runat="server" PageSize="1000" AutoGenerateColumns="False" CheckBox="False" CssClass="grid" DataSourceID="ObjectDataSourceCategoryList" ItemName="行业列表管理" AllowPaging="True">
                        <Columns>
                            <asp:BoundField DataField="CategoryID" HeaderText="ID" SortExpression="IndustryID">
                                <ItemStyle Width="50px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="CategoryAliasName" HeaderText="类别别名">
                                <ItemStyle Width="100px" Wrap="False" HorizontalAlign="Left" />
                            </asp:BoundField>
                            <asp:TemplateField HeaderText="类别名称">
                                <ItemTemplate>
                                    <script type="text/javascript">
                                        document.write(GetListSytle('<%#Eval("NodePath")%>', '<%#Eval("CategoryName")%>'));
                                    </script>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="排序">
                                <ItemStyle Width="50px" Wrap="False" />
                                <ItemTemplate>
                                    <input id='txtIndustryOrder<%#Eval("CategoryID") %>' style="width: 55px; border: 1px #D7D7D7 solid;" type="text" readonly="readonly" value="<%#Eval("CategoryOrder") %>" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="状态">
                                <ItemStyle Width="100px" Wrap="False" />
                                <ItemTemplate>
                                    <%#Eval("CategoryStatus").ToString().Equals("1")?"有效":"禁用"%>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="操作">
                                <ItemStyle Width="100px" Wrap="False" />
                                <ItemTemplate>
                                    <a href="CategoryEdit.aspx?cmd=modify&id=<%#Eval("CategoryID") %>">修改</a>&nbsp;<a href="CategoryManage.aspx?cmd=delete&id=<%#Eval("CategoryID") %>" onclick="return confirm('确定删除?')">删除</a>
                                    &nbsp;<a href="CategoryEdit.aspx?cmd=add&parentnode=<%#Eval("CategoryID") %>">添加子项</a>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </cc1:ExtendedGridView>
                </div>
            </div>
            <br />
            <div class="FormButtonArea">
                <asp:Button ID="Button2" runat="server" Text="添加类别" OnClientClick="window.location.href='CategoryEdit.aspx';return false;" />&nbsp;&nbsp;
                        &nbsp;&nbsp;
            </div>
        </div>
    </form>
</asp:Content>
