<%@ page language="C#" autoeventwireup="true" inherits="Cstype, LebiMall" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title><%=model.Title %>-类别管理</title>
    <meta name="description" content=<%=model.Description %> />
    <meta name="keywords" content=<%=model.Keywords %> />
    <meta name="generator" content="LBMall 3.0.0" />
    <link href="images/css/css3.css" rel="stylesheet" type="text/css" />
    <link href="images/css/css.css" rel="stylesheet" type="text/css" />
    <link href="images/css/shopcss.css" rel="stylesheet" type="text/css" />
    <link href="images/css/css2.css" rel="stylesheet" type="text/css" />
    <!--[if lte IE 6]><style type="text/css" media="screen">/* <![CDATA[ */ @import url(images/css/ie6.css); /* ]]> */</style><![endif]-->
    <!--[if gte IE 7]><STYLE type=text/css media=screen>@import url(images/css/ie7.css);</STYLE><![endif]-->
    <script type="text/javascript" src="images/js/shopjs.js"></script>
    <script type="text/javascript">
        //鼠标移动
        chColor=function(obj,color){obj.style.background=color;obj.style.cursor="pointer";};
        var tt=<%=tlength %>;
        //添加大类
        function addgg(){
              var ta1=document.createElement("table"); 
              ta1.id="table"+tt;
              ta1.className="kind-list";
              var rowz = ta1.insertRow(0);
              rowz.className="kind-list-list";
              rowz.onmouseover=function(){chColor(this,"#CDD9EC");};
              rowz.onmouseout=function(){chColor(this,"#EFF3F9");};
              rowz.id = "Tr" + tt;
              //类别名称 
              var cell1 = rowz.insertCell(0);
              cell1.className="kind-list-padding-left";
              cell1.innerHTML = "<input class='kind-form' name='label1_"+tt+"' id='label1_"+tt+"' type='text' size=9>";
              //添加hidden customid custompid
              cell1.innerHTML+="<input type='hidden' name='hidden_id"+tt+"' id='hidden_id"+tt+"' value="+tt+">";
              cell1.innerHTML+="<input type='hidden' name='hidden_pid"+tt+"' id='hidden_pid"+tt+"' value='-1'>";
              //h_sid添加时为0; 修改时为类的id
              cell1.innerHTML+="<input type='hidden' name='h_sid"+tt+"' id='h_sid"+tt+"' value=0>";
              //添加子类按钮
              var cell2 = rowz.insertCell(1);
              cell2.innerHTML = "<img src='images/kind-acc.gif' id='btn"+tt+"' onclick=addchlid('table"+tt+"',"+tt+")>";
              //排序----------
              var cell3 = rowz.insertCell(2);
              cell3.innerHTML = "<input class='kind-form' name='label2_"+tt+"' value='0'  id='label2_"+tt+"' type='text' size=9>";
              //删除按钮
              var cell4 = rowz.insertCell(3);
              cell4.innerHTML = "<img src='images/kind-del.gif' onclick='delRow(table"+tt+");'  type='button' value='删除' size=9>";
              //查看
              var cell5 = rowz.insertCell(4);
              cell5.style.width="120px";
              cell5.innerHTML = "&nbsp";
              //上传
              var cell6 = rowz.insertCell(5);
              cell6.innerHTML = "<input name='file"+tt+"'class='kind-form' id='file"+tt+"' type='file'>";
              var cell7 = rowz.insertCell(6);
              cell7.className="kind-list-padding-right";
              cell7.innerHTML = "&nbsp;";
              document.getElementById("ty_div").appendChild(ta1); 
              tt++;
        }
        //添加子类
        function addchlid(tname,custompid){
            var table=document.getElementById(tname);
            var vt=table.rows.length-1;
            var rows=table.insertRow(vt+1);
            rows.id = "Trc" + table.id;
            rows.onmouseover=function(){chColor(this,"#CDD9EC");};
            rows.onmouseout=function(){chColor(this,"#ffffff");};
            //为空
            var cell1 = rows.insertCell(0);
            cell1.className = "kind-son";
            cell1.innerHTML = "&nbsp;";
            //类别名称
            var cell2 = rows.insertCell(1);
            cell2.innerHTML = "<input  name='clabel1_"+custompid+vt+"' id='clabel1_"+custompid+vt+"' class='kind-form-list' type='text' size=9>";
            //添加hidden customid custompid
            cell2.innerHTML+="<input type='hidden' name='chidden_id"+custompid+vt+"' id='chidden_id"+custompid+vt+"' value="+vt+">";
            cell2.innerHTML+="<input type='hidden' name='chidden_pid"+custompid+vt+"' id='chidden_pid"+custompid+vt+"' value="+custompid+">";
            //h_sid添加时为0; 修改时为类的id
            cell2.innerHTML+="<input type='hidden' name='ch_sid"+custompid+vt+"' id='ch_sid"+vt+"' value=0>";
            //排序
            var cell3 = rows.insertCell(2);
            cell3.innerHTML = "<input class='kind-form-list' name='clabel2_"+custompid+vt+"'value=0  id='clabel2_"+custompid+vt+"' type='text' size=9>";
            //删除按钮
            var cell4 = rows.insertCell(3);
            cell4.innerHTML = "<img src='images/kind-del.gif' onclick='delRowchild("+tname.id+");'>";
            //查看
            var cell5 = rows.insertCell(4);
            cell5.style.width="120px";
            cell5.innerHTML = "&nbsp;";
            //cell5.innerHTML = "<img src='images/kind-par.gif'>";
            //上传
            var cell6 = rows.insertCell(5);
            cell6.innerHTML = "<input name='cfile"+custompid+vt+"' id='cfile"+custompid+vt+"' class='kind-form-list' type='file'>";
            var cell7 = rows.insertCell(6);
            cell7.className="kind-list-padding-right";
            cell7.innerHTML = "&nbsp;";
            vt++;
        }
        //删除行
        function delRow(table)   
        {   
            try   
            {   
                if( typeof(table) != "undefined" )        
                setTable(table); 
                var Elm  =  event.srcElement; 
                while(Elm  &&  Elm.tagName  !=  "TR")   
                {   
                    Elm  =  Elm.parentElement;   
                } 
                var intThisIndex = Elm.rowIndex; 
                if(table.rows.length==1){
                    Elm.parentElement.deleteRow(intThisIndex);  
                }else{
                    alert('有子类不能删除');
                }
            }   
            catch(ex)   
            {   
                alert("delRow() Err  5001:\r\n"  +  ex);   
                m_strError += "delRow() Error" + ex; 
            }   
        }
        //删除子行
        function delRowchild(table)   
        {   
            try   
            {   
                if( typeof(table) != "undefined" )        
                setTable(table); 
                 
                var Elm  =  event.srcElement; 
                while(Elm  &&  Elm.tagName  !=  "TR")   
                {   
                    Elm  =  Elm.parentElement;   
                } 
                var intThisIndex = Elm.rowIndex; 
                
                    Elm.parentElement.deleteRow(intThisIndex);  
            }   
            catch(ex)   
            {   
                alert("delRow() Err  5001:\r\n"  +  ex);   
                m_strError += "delRow() Error" + ex; 
            }   
        }
        function setTable(table)           
        { 
            if(typeof(table) == "string") 
                this.m_objTable = getObjTableByID(table); 
            else if(typeof(table) == "object") 
                this.m_objTable = table; 
        }
        function deletectype(delid,delimg){
            
            document.getElementById("delete_id").value=delid;
            document.getElementById("delete_img").value=delimg;
            document.getElementById("del_form").submit();
        }
        function deleteType(table,delid,delimg){
            
            try   
            {   
                if( typeof(table) != "undefined" )        
                setTable(table); 
                var Elm  =  event.srcElement; 
                while(Elm  &&  Elm.tagName  !=  "TR")   
                {   
                    Elm  =  Elm.parentElement;   
                } 
                var intThisIndex = Elm.rowIndex; 
                if(table.rows.length==1){
                    document.getElementById("delete_id").value=delid;
                    document.getElementById("delete_img").value=delimg;
                    document.getElementById("del_form").submit();      
                }else{
                    alert('有子类不能删除');
                }
            }   
            catch(ex)   
            {   
                alert("delRow() Err  5001:\r\n"  +  ex);   
                m_strError += "delRow() Error" + ex; 
            }   
            
        }
        function val(){
            var flag=true;
            var dd=document.getElementById("form1");
            var count_ssr=dd.getElementsByTagName("input");
            
            for(var s=0;s<count_ssr.length;s++){
                if(count_ssr[s].type=="text"){ 
                    if(count_ssr[s].value==""){
                        flag=false;
                    }
                }
            }
            if(flag){
                document.form1.submit();
            }
            else{
                document.getElementById("message_error").style.display="block";
            }
        }
        
         function search2(){
            var texts2=document.getElementById("ser2").value;
            var select_v2=document.getElementById("Select3").value;
            window.location="list.aspx?tid="+select_v2+"&titlec="+escape(texts2);
        }
    </script>

</head>
<body>
    <div id="dhtmltooltip">
        <img src=""></div>

    <script type="text/javascript" src="images/js/js_link.js"></script>

    <div id="top-menu02">
        <div id="top-menu">
            <div class="right">
                <script type="text/javascript">indexhead();</script>
            </div>
        </div>
    </div>
    <div id="top">
        <div id="logo">
            <a href="http://<%=Request.Url.Host %><%=model.WebPath %>/">
                <img src="Upload/WebAdminImages/<%=model.Logoimg %>" border="0" /></a></div>
    </div>
    <div id="sp-menu">
        <ul>
            <li><a href="http://<%=Request.Url.Host %><%=model.WebPath %>/">首页</a></li>
            <%for (int i = 0; i < ds_tab.Tables[0].Rows.Count; i++){ %>
            <li><%if (model.Tab == "1")
                  { %>
                <a href="<%= ds_tab.Tables[0].Rows[i]["tdirname"]%>/" target="_blank"><%= ds_tab.Tables[0].Rows[i]["tname"]%></a>
                <%}else{%>
                <a href="TopTab.aspx?type=<%= ds_tab.Tables[0].Rows[i]["tdirname"]%>" target="_blank"><%= ds_tab.Tables[0].Rows[i]["tname"]%></a>
                <%} %></li>
            <%} %>
            <li><a href="http://<%=Request.Url.Host %><%=model.WebPath %>/News/" target="_blank">资讯</a></li>
        </ul>
        <p>
            <span><a href="ShopCoupon.aspx">优惠券</a></span></p>
    </div>

    <div id="contenter2">
        <div id="contenter">

            <script type="text/javascript">
                shopLeft();
            </script>
            <div class="nav-tabs">
                <ul class="tabs">
                    <li><a href="Cstype.aspx">设置类别</a></li>
                </ul>
                <ul class="tabs">
                    <li><a href="update_type.aspx">修改类别</a></li>
                </ul>
            </div>
            <form id="form1" name="form1" method="post" action="addshoptype.aspx" enctype="multipart/form-data"
                onsubmit="return val();">
                <div id="right">
                    <div class="page-title">
                        <a class="back" href="#" onclick="javascript:window.history.back();"><span>返回上一页</span></a>
                        <h2 class="shop clearfix">
                            宝贝类别管理&nbsp;</h2>
                    </div>
                    <div class="contenter">
                        <div id="ty_div">
                            <table>
                                <tr>
                                    <td width="90px;" style="padding: 4px;">
                                        分类名称
                                    </td>
                                    <td width="86px;" style="padding: 4px;">
                                        添加子类
                                    </td>
                                    <td width="90px;" style="padding: 4px;">
                                        排序
                                    </td>
                                    <td width="54px;" style="padding: 4px;">
                                        删除
                                    </td>
                                    <td width="124px;" style="padding: 4px;">
                                        查看分类下的宝贝
                                    </td>
                                    <td width="220px;" style="padding: 4px;">
                                        图片
                                    </td>
                                    <td width="76px;" style="padding: 4px;">
                                        图片预览
                                    </td>
                                </tr>
                            </table>
                            <%for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                          { %>
                            <%if (ds.Tables[0].Rows[i]["custompid"].ToString() == "-1")
                          { %>
                            <table id="table<%=ds.Tables[0].Rows[i]["customid"]%>" class="kind-list">
                                <tr id="tr0" class="kind-list-list" onmouseover="this.className='kind_on'" onmouseout="this.className='kind_out'">
                                    <td class="kind-list-padding-left">
                                        <input name="label1_<%=ds.Tables[0].Rows[i]["customid"] %>" id="label1_<%=ds.Tables[0].Rows[i]["customid"] %>"
                                            value='<%=ds.Tables[0].Rows[i]["sctname"]%>' type="text" class="kind-form" size="9">
                                        <input type='hidden' name='hidden_id<%=ds.Tables[0].Rows[i]["customid"] %>' id='hidden_id<%=ds.Tables[0].Rows[i]["customid"] %>'
                                            value="<%=ds.Tables[0].Rows[i]["customid"] %>" class="kind-form" />
                                        <input type='hidden' name='hidden_pid<%=ds.Tables[0].Rows[i]["customid"] %>' id='hidden_pid<%=ds.Tables[0].Rows[i]["customid"] %>'
                                            value='-1' class="kind-form" />
                                        <input type="hidden" name="h_sid<%=ds.Tables[0].Rows[i]["customid"] %>" id="h_sid<%=ds.Tables[0].Rows[i]["customid"] %>"
                                            value='<%=ds.Tables[0].Rows[i]["id"] %>' class="kind-form" />
                                    </td>
                                    <td>
                                        <img src="images/kind-acc.gif" onclick="addchlid('table<%=ds.Tables[0].Rows[i]["customid"] %>',<%=ds.Tables[0].Rows[i]["customid"] %>)" />
                                    </td>
                                    <td>
                                        <input name="label2_<%=ds.Tables[0].Rows[i]["customid"] %>" id="label2_<%=ds.Tables[0].Rows[i]["customid"] %>"
                                            value='<%=ds.Tables[0].Rows[i]["sort"]%>' type="text" size="9" class="kind-form">
                                    </td>
                                    <td>
                                        <img id="Button3" src="images/kind-del.gif" onclick="deleteType(table<%=ds.Tables[0].Rows[i]["customid"] %>,'<%=ds.Tables[0].Rows[i]["id"] %>','<%=ds.Tables[0].Rows[i]["img_text"] %>')" />
                                    </td>
                                    <td width="120px;">
                                    </td>
                                    <td>
                                        <input name="file<%=ds.Tables[0].Rows[i]["customid"] %>" id="file<%=ds.Tables[0].Rows[i]["customid"] %>"
                                            type="file" class="kind-form" />
                                    </td>
                                    <td class="kind-list-padding-right" style="width: 60px">
                                        <%if (!ds.Tables[0].Rows[i]["img_text"].ToString().Equals(""))
                                      {%>
                                        <img src="images/kind-pic001.jpg" align='absmiddle' onmouseover="javascript:ddrivetip('<img src=Upload/imgtype/<%=ds.Tables[0].Rows[i]["img_text"] %>>', '#ffffff', '150')"
                                            onmouseout="hideddrivetip()">
                                        <% }%>
                                    </td>
                                </tr>
                                <%for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                              { %>
                                <%if (ds.Tables[0].Rows[i]["customid"].ToString() == ds.Tables[0].Rows[j]["custompid"].ToString())
                              {%>
                                <tr onmouseover="this.className='kind_on'" onmouseout="this.className='kind_out_son'">
                                    <td class="kind-son">
                                    </td>
                                    <td>
                                        <input name="clabel1_<%=ds.Tables[0].Rows[i]["customid"] %><%=ds.Tables[0].Rows[j]["customid"] %>"
                                            id="clabel1_<%=ds.Tables[0].Rows[i]["customid"] %><%=ds.Tables[0].Rows[j]["customid"] %>"
                                            value='<%=ds.Tables[0].Rows[j]["sctname"]%>' type="text" size="9" class="kind-form-list">
                                        <input type='hidden' name='chidden_id<%=ds.Tables[0].Rows[i]["customid"] %><%=ds.Tables[0].Rows[j]["customid"] %>'
                                            id='chidden_id<%=ds.Tables[0].Rows[i]["customid"] %><%=ds.Tables[0].Rows[j]["customid"] %>'
                                            value="<%=ds.Tables[0].Rows[j]["customid"] %>" class="kind-form-list" />
                                        <input type='hidden' name='chidden_pid<%=ds.Tables[0].Rows[i]["customid"] %><%=ds.Tables[0].Rows[j]["customid"] %>'
                                            id='chidden_pid<%=ds.Tables[0].Rows[i]["customid"] %><%=ds.Tables[0].Rows[j]["customid"] %>'
                                            value="<%=ds.Tables[0].Rows[j]["custompid"] %>" class="kind-form-list" />
                                        <input type="hidden" name="ch_sid<%=ds.Tables[0].Rows[i]["customid"] %><%=ds.Tables[0].Rows[j]["customid"] %>"
                                            id="ch_sid<%=ds.Tables[0].Rows[i]["customid"] %><%=ds.Tables[0].Rows[j]["customid"] %>"
                                            value='<%=ds.Tables[0].Rows[j]["id"] %>' class="kind-form-list" />
                                    </td>
                                    <td>
                                        <input name="clabel2_<%=ds.Tables[0].Rows[i]["customid"] %><%=ds.Tables[0].Rows[j]["customid"] %>"
                                            id="clabel2_<%=ds.Tables[0].Rows[i]["customid"] %><%=ds.Tables[0].Rows[j]["customid"] %>"
                                            value='<%=ds.Tables[0].Rows[j]["sort"]%>' type="text" size="9" class="kind-form-list">
                                    </td>
                                    <td>
                                        <input name="btn" id="Button4" type="image" src="images/kind-del.gif" value="删除"
                                            onclick="deletectype('<%=ds.Tables[0].Rows[j]["id"] %>','<%=ds.Tables[0].Rows[j]["img_text"] %>');"
                                            size="9">
                                    </td>
                                    <td width="120px;">
                                        <img src="images/kind-par.gif">
                                        <a href="update_type.aspx?type_id=<%=ds.Tables[0].Rows[j]["id"] %>">查看宝贝详情</a></td>
                                    <td>
                                        <input name="cfile<%=ds.Tables[0].Rows[i]["customid"] %><%=ds.Tables[0].Rows[j]["customid"] %>"
                                            id="cfile<%=ds.Tables[0].Rows[i]["customid"] %><%=ds.Tables[0].Rows[j]["customid"] %>"
                                            type="file" class="kind-form-list" />
                                    </td>
                                    <td class="kind-list-padding-right" style="width: 60px">
                                        <%if (!ds.Tables[0].Rows[j]["img_text"].ToString().Equals(""))
                                      {%>
                                        <img src="images/kind-pic001.jpg" align='absmiddle' onmouseover="javascript:ddrivetip('<img src=Upload/imgtype/<%=ds.Tables[0].Rows[j]["img_text"] %>>', '#ffffff', '150')"
                                            onmouseout="hideddrivetip()" />
                                        <% }%>
                                    </td>
                                </tr>
                                <%} %>
                                <%} %>
                            </table>
                            <%} %>
                            <%} %>
                        </div>
                        <br />
                        <input id="Button1" type="button" class="addbtnc" onclick="addgg()" />
                        <input id="Button2" type="button" class="addbtnc02" value="保存" onclick="val();" />
                    </div>
                    <div id="message_error" style="display: none;">
                        分类名称不可为空</div>
                </div>
            </form>
            <form id="del_form" action="delshoptype.aspx" method="post">
                <input type="hidden" value="" id="delete_id" name="delete_id" />
                <input type="hidden" value="" id="delete_img" name="delete_img" />
            </form>

            <div id="footer">
                <div id="copyright">
                    <div class="search">
                        <div class="search-left">
                            <div class="search-left-title">
                                搜索：</div>
                            <div class="search-left-form">
                                <input type="text" runat="server" id="ser2" size="30" /></div>
                            <div class="search-left-list">
                                <select id="Select3" runat="server">
                                </select>
                            </div>
                            <div class="search-left-button">
                                <img src="images/search-buttom.gif" width="60" height="20" onclick="search2()" /></div>
                        </div>
                        <div class="search-right">
                            <div runat=server id="div_s2"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="copyright" runat="server" id="copr"></div>
        </div>
    </div>
</body>
</html>
