<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/ExhibitorMaster.Master" Inherits="System.Web.Mvc.ViewPage<List<FamousFurnitureExpo.Models.TypeInfo>>" %>

<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript">
        $(function () {
            $("#CurrentPosition").html("产品分类信息");
            $("#menu22").css("visibility", "visible");

            var selectID = $("#SelectTypeID").val();
            var IDList = selectID.split(",");
            for (var i = 0; i < IDList.length; i++) {
                var id = IDList[i];
                if (id != "") {
                    $("#TypID" + id).attr("checked", true);
                }
            }
        });

        function Save() {
            var checkItem = $("input[type=checkbox][name=TypID]:checked");
            if (checkItem.length <= 0) {
                MsgTip.show({ msg: "请选择产品分类！", ico: "warning", top: 340 });
            } else {
                $("#f1").submit();
            }
        }
    </script>
    <style type="text/css">
        .checktype
        {
             width:170px;
             height:23px; 
             padding:5px;
             line-height:13px;
             display:inline;
             float:left;
        }
        .checktypeword
        {
            width:140px;
            height:22px;
            line-height:13px;   
            display:inline;
            padding-top:5px;
            padding-bottom:5px;
        }
        .childcontainer
        {
             margin-left:30px;
             width:550px;
        }
    </style>
</asp:Content>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <div>
        <center>
            <form id="f1" action="" method="post">
            <table width="100%" border="0" style="text-align: left" cellpadding="0" cellspacing="0" id="main">
                <tr>
                    <td align="left">
                        <span>产品关键字（填写产品关键字能让您的潜在客户更方便的通过产品关键字查询到您的信息）</span>
                    </td>
                </tr>
                <tr>
                    <td align="left">
                        <input type="text" class="text" style="width:300px;" id="Key" name="Key" value="<%=ViewData["Key"] %>" />
                    </td>
                </tr>
                <tr><td>&nbsp;</td></tr>
                <tr>
                    <td align="left">
                        <span>产品分类（必选，认真填写产品分类能让您的潜在客户更方便的通过产品分类查询到您的信息）</span>
                    </td>
                </tr>
                <tr>
                    <td align="left" style="border:1px solid #bfefff;">
                        <%
                            List<FamousFurnitureExpo.Models.TypeInfo> liAll = Model;
                            if (liAll.Count > 0)
                            {
                                int i = 0;
                                List<FamousFurnitureExpo.Models.TypeInfo> liType1 = liAll.FindAll(main => main.TypParentID.Trim() == "");
                                foreach (FamousFurnitureExpo.Models.TypeInfo ti1 in liType1)
                                {
                                    List<FamousFurnitureExpo.Models.TypeInfo> liType2 = liAll.FindAll(child => child.TypParentID.Trim() == ti1.TypID.ToString());
                                    bool type1HaveChild = false;
                                    if (liType2.Count > 0)
                                    {
                                        type1HaveChild = true;
                                    }
                        %>
                            <%if (type1HaveChild&&i!=0) { %><%} %>
                            <div id="Type1-<%=ti1.TypID %>" class="checktype" style="font-weight:bolder;">
                            <%if (!type1HaveChild){ %>
                                <input type="checkbox" id="TypID<%=ti1.TypID %>" name="TypID" value="<%=ti1.TypID %>" style="vertical-align:top;" />
                            <%}%>
                                <div class="checktypeword">
                                <label for="TypID<%=ti1.TypID %>"><%=ti1.TypName%></label>
                                </div>
                            </div>
                            <%if (type1HaveChild){ %>
                            <table id="Child-Type1-<%=ti1.TypID %>" class="childcontainer"><tr><td>
                            <%} %>
                        <%
                                    foreach (FamousFurnitureExpo.Models.TypeInfo ti2 in liType2)
                                    {
                                        List<FamousFurnitureExpo.Models.TypeInfo> liType3 = liAll.FindAll(child => child.TypParentID.Trim() == ti2.TypID.ToString());
                                        bool type2HaveChild = false;
                                        if (liType3.Count > 0)
                                        {
                                            type2HaveChild = true;
                                        }  
                        %>
                                <%if (type2HaveChild) { %><%} %>
                                <div id="Type2-<%=ti2.TypID %>" class="checktype" style="font-weight:normal;">
                                <%if (!type2HaveChild){ %>
                                    <input type="checkbox" id="TypID<%=ti2.TypID %>" name="TypID" value="<%=ti2.TypID %>" style="vertical-align:top;" />
                                <%}%>
                                    <div class="checktypeword">
                                    <label for="TypID<%=ti2.TypID %>"><%=ti2.TypName%></label>
                                    </div>
                                </div>
                                <%if (type2HaveChild){ %>
                                <table id="Child-Type2-<%=ti2.TypID %>" class="childcontainer"><tr><td>
                                <%} %>
                        <% 
                                        foreach (FamousFurnitureExpo.Models.TypeInfo ti3 in liType3)
                                        {
                        %>
                                    <div id="Type3-<%=ti3.TypID %>" class="checktype" style="font-weight:lighter;">
                                        <input type="checkbox" id="TypID<%=ti3.TypID %>" name="TypID" value="<%=ti3.TypID %>" style="vertical-align:top;" />
                                        <div class="checktypeword">
                                        <label for="TypID<%=ti3.TypID %>"><%=ti3.TypName%></label>
                                        </div>
                                    </div>
                        <%                    
                                        }    
                        %>
                                <%if (type2HaveChild){ %>
                                </td></tr></table>
                                <%} %>
                        <%                
                                    }  
                        %>
                            <%if (type1HaveChild){ %>
                            </td></tr></table>
                            <%} %>
                        <%
                                    i++;
                                }
                        %>
                            
                            <br />
                            <br />
                        <%
                            }
                        %>
                    </td>
                </tr>
                <tr><td>&nbsp;</td></tr>
                <tr>
                    <td>
                        <div class="button" onclick="Save()">保存</div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="hidden" id="SelectTypeID" name="SelectTypeID" value="<%=ViewData["Type"] %>" /> 
                        <%=ViewData["Message"] %>
                    </td>
                </tr>
            </table>
            </form>
        </center>
    </div>
</asp:Content>