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

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<!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_t.Title%>-类别管理</title>
    <meta name="description" content=<%=model_t.Description %> />
    <meta name="keywords" content=<%=model_t.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"> 
    //选择下拉框搜索
        var typeid='<%=type_%>';
        var txt_='<%=tname%>';
        function chtype(type_id){
            var cname=document.getElementById("txt_search").value;
            window.location.href="update_type.aspx?type_id="+type_id+'&cname='+escape(cname)+'&page=1';
        }
        //显示右侧的类别
        var currentShowCmpt = null;
        function hideDiv(){
        if(currentShowCmpt != null){
            currentShowCmpt.innerHTML = "";
            currentShowCmpt.style.display="none";
            }
        }
        var update_id="";
        function show_back(d,id){
            if(currentShowCmpt != null){
                currentShowCmpt.innerHTML = "";
                currentShowCmpt.style.display="none";
                }
            var dd=document.getElementById('div_select');
            currentShowCmpt = d;
            d.innerHTML=dd.innerHTML;
            d.style.display="block";
            update_id=id;
           
        }
        function submit_id(typeid){
            document.getElementById("update_id").value=update_id;
            document.getElementById("type_id").value=typeid;
            document.getElementById("upt_form").submit();
        }
        //删除
        function det(type_id,c_id){
            document.getElementById("del_id").value=c_id;
            document.getElementById("type_id2").value=type_id;
            document.getElementById("del_form").submit();
        }
        //全选
        function SelectAllCheckBox()
        {
            var form =document.forms[0];
            for(i=0;i<form.elements.length;i++)
            {
                if(form.elements[i].type=="checkbox")
                {
                    form.elements[i].checked=true;
                }
            }
        }
        //反选
        function ReSelectCheckBox()
        {
            var form =document.forms[0];
            for(i=0;i<form.elements.length;i++)
            {
                if(form.elements[i].type=="checkbox")
                {
                    if(form.elements[i].checked)
                        form.elements[i].checked=false;
                    else
                        form.elements[i].checked=true;
                }
             }
        }
        function onselect(cvalue){
            if(cvalue=="0"){
               
                document.getElementById("Select3").setAttribute("disabled",true);
                
            }else{
                document.getElementById("Select3").removeAttribute("disabled");
            }
            var slist=document.getElementById("Select1");
            for(var i=0;i<slist.length;i++){
                if(typeid==slist[i].value){
                    slist[i].selected='selected';
                }
            }
            document.getElementById("txt_search").value=txt_;
        }
        function listid(){
            var blist=document.getElementsByName("box");
            var idlist="";
            for(var i=0;i<blist.length;i++){
                if(blist[i].checked==true){
                    idlist+=blist[i].value+",";
                }
            }
            if(idlist==""){
                return false;
                
            }
            else{
                document.getElementById("id_list").value=idlist;
                var select2=document.getElementById("Select2").value;
                if(select2=="0"){
                    return false;
                }
                document.getElementById("select2_").value=select2;
                var select3=document.getElementById("Select3").value;
                document.getElementById("select3_").value=select3;
                
                return true;
            }
        }
        function search2(){
            var texts2=document.getElementById("ser2").value;
            var select_v2=document.getElementById("Select4").value;
            window.location="list.aspx?tid="+select_v2+"&titlec="+escape(texts2);
        }
    </script>

</head>
<body onload="onselect(0)">

    <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_t.WebPath %>/">
                <img src="Upload/WebAdminImages/<%=model_t.Logoimg %>" border="0" /></a></div>
    </div>
    <div id="sp-menu">
        <ul>
            <li><a href="http://<%=Request.Url.Host %><%=model_t.WebPath %>/">首页</a></li>
            <%for (int i = 0; i < ds_tab.Tables[0].Rows.Count; i++){ %>
            <li><%if (model_t.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_t.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>
            <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>
                <form id="form1" runat="server">
                    <div class="contenter">
                        <div class="div_top">
                            <div class="div_t_l">
                                <input type="hidden" id="typei" runat="server" />
                                选择分类<select id="Select1" onchange="chtype(this.value)">
                                    <option value="-1">未分类</option>
                                    <option value="0">全部</option>
                                    <%for (int i = 0; i < dst1.Tables[0].Rows.Count; i++)
                                  { %>
                                    <%if (dst1.Tables[0].Rows[i]["custompid"].ToString() == "-1")
                                  {
                                      if (dst1.Tables[0].Rows[i]["ct"].ToString() != "0")
                                      {%>
                                    <optgroup label="<%=dst1.Tables[0].Rows[i]["sctname"] %>">
                                    </optgroup>
                                    <%}
                                  else
                                  {%>
                                    <option value='<%=dst1.Tables[0].Rows[i]["id"]%>' onclick="chtype('<%=dst1.Tables[0].Rows[i]["id"]%>')">
                                        <%=dst1.Tables[0].Rows[i]["sctname"] %>
                                    </option>
                                    <% } %>
                                    <%for (int j = 0; j < dst1.Tables[0].Rows.Count; j++)
                                  { %>
                                    <%if (dst1.Tables[0].Rows[i]["customid"].ToString() == dst1.Tables[0].Rows[j]["custompid"].ToString())
                                  { %>
                                    <option value='<%=dst1.Tables[0].Rows[j]["id"]%>' onclick="chtype('<%=dst1.Tables[0].Rows[i]["id"]%>')">
                                        ┗<%=dst1.Tables[0].Rows[j]["sctname"] %></option>
                                    <%} %>
                                    <%} %>
                                    <%} %>
                                    <%} %>
                                </select></div>
                            <div class="div_t_r">
                                宝贝搜索<input type="text" id="txt_search" class="txt_se" runat="server" />
                                <input id="Button1" type="button" value="搜索" class="txt_btn_us" runat="server" onserverclick="Button1_ServerClick" />
                            </div>
                            <div style="clear: both;">
                            </div>
                        </div>
                        <div class="div_content">
                            <table class="utable">
                                <tr>
                                    <td class="utd1">
                                        宝贝描述
                                    </td>
                                    <td class="utd2">
                                    </td>
                                    <td class="utd3">
                                    </td>
                                    <td class="utd4">
                                        编辑宝贝
                                    </td>
                                    <td class="utd5">
                                        所属分类
                                    </td>
                                    <td class="utd6">
                                        添加所属分类
                                    </td>
                                </tr>
                            </table>
                            <table class="utable2">
                                <%for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                              { %>
                                <tr>
                                    <td class="utd11" valign="top">
                                        <input id="Checkbox<%=ds.Tables[0].Rows[i]["id"] %>" name="box" value="<%=ds.Tables[0].Rows[i]["id"] %>"
                                            type="checkbox" />
                                    </td>
                                    <td class="utd2" valign="top">
                                        <img src="Upload/commodity/<%=ds.Tables[0].Rows[i]["cmin_img"] %>" width="30px" />
                                    </td>
                                    <td class="utd33" valign="top">
                                        <%=ds.Tables[0].Rows[i]["cname"] %>
                                    </td>
                                    <td class="utd4" valign="top">
                                        <a href="Update_c.aspx?cid=<%=ds.Tables[0].Rows[i]["id"] %>">编辑</a>
                                    </td>
                                    <td class="utd55" onclick="hideDiv();" valign="top">
                                        <%=typebind(ds.Tables[0].Rows[i]["cstype_id"].ToString(), ds.Tables[0].Rows[i]["id"].ToString())%>
                                    </td>
                                    <td class="utd6" valign="top">
                                        <div id="l<%=i %>" style="display: none; background-color: White; position: absolute;
                                            margin-top: 20px; margin-left: -10px; float: left; z-index: 1; border: 1px solid #ccc;
                                            padding: 5px; width: 70px;">
                                        </div>
                                        <div style="float: left; position: absolute;">
                                            <input type="button" value="添加分类" onclick='show_back(document.getElementById("l<%=i %>"),<%=ds.Tables[0].Rows[i]["id"] %>)' /></div>
                                        <div style="float: right; width: 30px;" onclick="hideDiv();">
                                        </div>
                                    </td>
                                </tr>
                                <%} %>
                            </table>
                            <div style="clear: both;">
                            </div>
                            <div class="div_b">
                                <a onclick="SelectAllCheckBox()" href="javascript:;">全选</a>| <a onclick="ReSelectCheckBox()"
                                    href="javascript:;">反选</a>
                                <select id="Select2" onchange="onselect(this.value)">
                                    <option value="0">选择分类操作</option>
                                    <option value="1">批量添加</option>
                                    <option value="2">批量移动</option>
                                </select>
                                宝贝到
                                <select id="Select3">
                                    <%for (int i = 0; i < dst1.Tables[0].Rows.Count; i++)
                                  { %>
                                    <%if (dst1.Tables[0].Rows[i]["custompid"].ToString() == "-1")
                                  {
                                      if (dst1.Tables[0].Rows[i]["ct"].ToString() != "0")
                                      {%>
                                    <optgroup label="<%=dst1.Tables[0].Rows[i]["sctname"] %>">
                                    </optgroup>
                                    <%}
                                  else
                                  {%>
                                    <option value='<%=dst1.Tables[0].Rows[i]["id"]%>' onclick="chtype('<%=dst1.Tables[0].Rows[i]["id"]%>')">
                                        <%=dst1.Tables[0].Rows[i]["sctname"] %>
                                    </option>
                                    <% } %>
                                    <%for (int j = 0; j < dst1.Tables[0].Rows.Count; j++)
                                  { %>
                                    <%if (dst1.Tables[0].Rows[i]["customid"].ToString() == dst1.Tables[0].Rows[j]["custompid"].ToString())
                                  { %>
                                    <option value='<%=dst1.Tables[0].Rows[j]["id"]%>' onclick="chtype('<%=dst1.Tables[0].Rows[i]["id"]%>')">
                                        ┗<%=dst1.Tables[0].Rows[j]["sctname"] %></option>
                                    <%} %>
                                    <%} %>
                                    <%} %>
                                    <%} %>
                                </select>
                                <input type="hidden" id="id_list" runat="server" />
                                <input type="hidden" id="select2_" runat="server" />
                                <input type="hidden" id="select3_" runat="server" />
                                <asp:Button ID="Button2" runat="server" Text="确定" OnClientClick="return listid();"
                                    OnClick="Button3_ServerClick" />
                                <webdiyer:AspNetPager ID="AspNetPager1" runat="server" RecordCount="228" FirstPageText="首页"
                                    LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页" UrlPaging="True">
                                </webdiyer:AspNetPager>
                            </div>
                            <div id="div_select" style="display: none;">
                                <%for (int i = 0; i < dst1.Tables[0].Rows.Count; i++)
                              { %>
                                <%if (dst1.Tables[0].Rows[i]["custompid"].ToString() == "-1")
                              {
                                  if (dst1.Tables[0].Rows[i]["ct"].ToString() != "0")
                                  {%>
                                <%=dst1.Tables[0].Rows[i]["sctname"] %>
                                <br />
                                <%}
                              else
                              {%>
                                <a href="javascript:submit_id('<%=dst1.Tables[0].Rows[i]["id"] %>')">
                                    <%=dst1.Tables[0].Rows[i]["sctname"] %>
                                </a>
                                <br />
                                <% } %>
                                <%for (int j = 0; j < dst1.Tables[0].Rows.Count; j++)
                              { %>
                                <%if (dst1.Tables[0].Rows[i]["customid"].ToString() == dst1.Tables[0].Rows[j]["custompid"].ToString())
                              { %>
                                <a href="javascript:submit_id('<%=dst1.Tables[0].Rows[j]["id"] %>')">┗<%=dst1.Tables[0].Rows[j]["sctname"] %></a><br />
                                <%} %>
                                <%} %>
                                <%} %>
                                <%} %>
                            </div>
                        </div>
                    </div>
                </form>
                <form id="upt_form" action="update_type2.aspx" method="post">
                    <input type="hidden" value="" id="update_id" name="update_id" />
                    <input type="hidden" value="" id="type_id" name="type_id" />
                </form>
                <form id="del_form" action="del_type.aspx" method="post">
                    <input type="hidden" value="" id="del_id" name="del_id" />
                    <input type="hidden" value="" id="type_id2" name="type_id2" />
                </form>
            </div>

             <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="Select4" 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>
