<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="True" Inherits="Kesion.NET.WebSite.Admin_Book_BookClass" Codebehind="KS.SJTypeClass.aspx.cs" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.Publics" %>
<asp:Content ID="Content1" ContentPlaceHolderID="KSContent" Runat="Server">
<div id="manage_top" class="menu_top_fixed">
    
    <ul class="titleTab">
      <li><a href="KS.SJConfig.aspx">频道参数设置</a></li>
      <li><a href="KS.SJCategory.aspx">分类管理</a></li>
      <li><a href="KS.SJType.aspx">自定义类别</a></li>
      <li><a href="KS.SJZDYType.aspx">自定义题型</a></li>
       <%if (MyCache.GetSJCacheConfig(2).ToString() == "1"){ %>
      <li><a href="KS.SJKnowledge.aspx">知识点管理</a></li>
    <%} %>
      <li class="curr"><a href="KS.SjTypeClass.aspx">章节管理</a></li>
      <li><a href="KS.SJCJD.aspx">成绩等级管理</a></li>
      <li><a href="KS.ZGCard.aspx">准考证生成管理</a></li>
      <li><a href="KS.SJKM.aspx">会计科目管理</a></li>
   </ul>
</div>  
<div class="menu_top_fixed_height"></div>
<asp:Panel ID="ClassList" runat="server" Width="100%">
<div class="content-area">   
	<div class="myTitle"> 
    	<div class="fr headOperation ">
            <ul>
               	<li class="fl"><asp:LinkButton ID="rootButton" runat="server" OnClick="rootButton_Click" CssClass="button">一键修复排序</asp:LinkButton></li>
           		<li class="fl"><asp:LinkButton ID="updataTotal" runat="server" OnClick="updataTotal_Click" CssClass="button">一键统计题目</asp:LinkButton></li>
            </ul>
     	</div>
     	章节管理
    </div>  
    <script type="text/javascript">
         function ExtSub(ID,event) {//阻止冒泡调用parent
             var e = (event) ? event : window.event;
             if (window.event) {//IE
                 e.cancelBubble = true;
             } else { //FF
                 e.stopPropagation();
             }
             if (jQuery('#C'+ID).attr('class')=="tree_Close")
             {       
                 jQuery('#C'+ID).attr('class','tree_Open');
                 if ($(".CTable").find("tr[attr*=',"+ID+",']").length>0){
                     $(".CTable").find("tr[attr*=',"+ID+",']").show();
                 }else{
                     jQuery('#ajaxmsg',window.parent.document).toggle();
                     jQuery.ajax({
                         type: "POST",
                         url: "KS.SJtypeClass.aspx",
                         data: "parentid="+ID+"&action=ExtSub",
                         success: function (data) {
                             jQuery('#ajaxmsg',window.parent.document).toggle();
                             jQuery("#sub"+ID).after(data);
                             
                         }
                     });
                 }
             }
             else{
                 $(".CTable").find("tr[attr*=',"+ID+",']").hide();
                 jQuery('#C'+ID).attr('class','tree_Close');
             }
         }

         function SubKnowledge(ID,event) {//阻止冒泡调用parent            
            
             jQuery('#ajaxmsg',window.parent.document).toggle();
             jQuery.ajax({
                 type: "POST",
                 url: "KS.SJtypeClass.aspx",
                 data: "SJTypeId="+ID+"&action=SubKnowledge",
                 success: function (data) {
                     jQuery('#ajaxmsg',window.parent.document).toggle();                   
                     jQuery("#subKId"+ID).after(data);                       
                 }
             });   
         }

	</script>
 	<div class="quickSearch clearfix">   
        <asp:LinkButton ID="addbutton" runat="server" OnClick="lbtaddmodel_Click" CssClass="fr button button_on">添加试卷章节</asp:LinkButton>
        <div class="quickSelect">
             <asp:DropDownList ID="DropSJclassid1" runat="server" onchange="location.href='?TheSjclassId='+this.value;">
             <asp:ListItem Value="0">--按试卷分类查看--</asp:ListItem>
             </asp:DropDownList>
        </div>
    </div>
      <asp:Repeater ID="list" runat="server">
          <HeaderTemplate>
          <table width="99%" cellpadding="0" cellspacing="0" class="CTable">
           <tr class="CTitle">
				<th scope="col">选择</th>
                <th scope="col">章节ID</th>
                <th scope="col" style="text-align:left;">章节名称<a href="KS.SJTypeClass.aspx?action=showall" class="greenFont">（全部展开）</a></th>
				<th scope="col">序号</th>
                <th scope="col">操作</th>
			</tr>
          </HeaderTemplate>
          <ItemTemplate>
           
            <tr id='sub<%#Eval("classid") %>'  onmouseover="jQuery('#a<%# Eval("classid") %>').show();this.className='CtrMouseOver'" onmouseout="jQuery('#a<%# Eval("classid") %>').hide();this.className='CtrMouseOut'" onclick="chk(this)">
             <td class="Ctd" style="text-align:center;width:40px;"><input type="checkbox" name="ids" value='<%#Eval("classID")%>' /></td>
             <td class="Ctd" style="text-align:center;width:100px;"><%# Eval("classid") %></td>
             <td class="Ctd" style="height:30px;">
             <%if (KSCMS.S("Action") != "showall")
               { %>
                <a href="javascript:void(0)" onclick='ExtSub("<%# Eval("ClassID").ToString() %>",event);' style='text-decoration:none'><%# Utils.StrToInt(Eval("depth"))==1 ? GetParentClassName( Utils.StrToInt(Eval("SJClassId"))) :string.Empty %><%# getClassName(Convert.ToInt32(Eval("ClassID")),Eval("Classname", "{0}"), Convert.ToInt16(Eval("child")), Convert.ToInt16(Eval("NextID")), Convert.ToInt16(Eval("depth", "{0}")), 1)%></a><%}
               else
               { %> <%# Utils.StrToInt(Eval("depth"))==1 ? GetParentClassName( Utils.StrToInt(Eval("SJClassId")))  :string.Empty %><%# getClassName(Convert.ToInt32(Eval("ClassID")),Eval("Classname", "{0}"), Convert.ToInt16(Eval("child")), Convert.ToInt16(Eval("NextID")), Convert.ToInt16(Eval("depth", "{0}")), 1)%><%} %>
               
               <span id="a<%# Eval("classid") %>" style="display:none;padding-left:20px">
                    <%if (MyCache.GetSJCacheConfig(2).ToString() == "1"){ %>
                     <%#Utils.StrToInt( Eval("depth"))>=3 ? "<a style='color:#999' href='KS.SJKnowledge.aspx?action=add&SjclassId=" +Eval("SJClassId") + "&classId="+Eval("classid")+"'>添加知识点</a>&nbsp;<a href='javascript:void(0)' onclick='SubKnowledge(" + Eval("classid") + ",event)' >查看知识点</a>":"" %>          
                    <%} %>

                  <%# Utils.StrToInt( Eval("depth"))<3 ?"<a style='color:#999' href='KS.SJtypeClass.Aspx?action=add&parentid="+Eval("classid")+"'>添加子章节</a>":"" %>
               </span>

             </td>      
             <td class="Ctd" align="center" style="width:50px;"><%# Container.ItemIndex + 1 + (CurrPage - 1) * PageSize%></td>
             <td class="Ctd" style="text-align:center;width:200px">
              <a href="KS.SJtypeClass.aspx?action=edit&parentid=<%#Eval("classid")%>&classid=<%# Eval("classid") %>" class="greenFont">编辑</a>&nbsp;&nbsp;&nbsp;
              <a href="KS.SJtypeClass.aspx?Action=del&Ids=<%# Eval("classid") %>" onclick="return(confirm('删除章节，同时删除该章节下的问答，此操作不可逆，确定删除章节吗?'));" class="greenFont">删除</a>
             </td>
            </tr>     
        
          </ItemTemplate>
          <FooterTemplate>
               <tr style="display:<%# bool.Parse((list.Items.Count==0).ToString())?"":"none"%>">
                <td class="Ctd" style="text-align:center" colspan="5">
                 <asp:LinkButton ID="addbutton" runat="server" OnClick="lbtaddmodel_Click"> 还没有添加任何章节，点此添加章节&raquo;</asp:LinkButton>
                </td>
               </tr> 
          </table>
          </FooterTemplate>
         </asp:Repeater>
         <asp:Panel ID="Panel1" runat="server" Height="30px" Width="100%">
          	<div class="listedit">
                <ul>
                    <input type="checkbox" name="chkall" id="chkall" onclick="CheckBox(this.checked);"/><label for="chkall">全部选中</label>
                    <asp:Button runat="server" OnClientClick="if (GetIDS('del')){return true}else{return false}" ID="BtnDelete" Text="批量删除选中的章节" CssClass="button"  onclick="BtnDelete_Click" />
                </ul>
            </div>
       </asp:Panel> 

          <KS:Page ID="Page1" runat="server" />
         

        </asp:Panel> 
        
        <asp:Panel ID="ClassAdd" runat="server" Width="100%">
        <script>
            function setFileFileds(num){    
                for(var i=1,str="";i<=20;i++){
                    jQuery("#define" + i).css("display","none");
                }
                for(var i=1,str="";i<=num;i++){	jQuery("#define" + i).css("display","");
                }
            }



            function CheckAddMode() {
                if (jQuery("#AddType")[0].checked == true) {
                    jQuery("#AddOne").hide();
                    jQuery("#AddMore").show();
                } else {
                    jQuery("#AddOne").show();
                    jQuery("#AddMore").hide();
                }
            }

            function CheckForm() {
                if (jQuery('#<%=this.ClassName.ClientID %>').val() == '' && jQuery("#AddType")[0].checked == false) {
                    KesionJS.Alert('请输入试卷属性名称！', "jQuery('#<%=this.ClassName.ClientID %>').focus()");
                    return false;
                } else if (jQuery("#AddType")[0].checked == true && jQuery('#<%=this.TxtMoreClassName.ClientID %>').val() == '') {
                    KesionJS.Alert('请按格式输入电子书章节名称,一行表示一个章节！', "jQuery('#<%=this.TxtMoreClassName.ClientID %>').focus()");
                    return false;
                }
        }
	    </script>
</div>	
<div class="content-area">
    <div class="myTitle"><%=!string.IsNullOrEmpty(KSCMS.S("id"))?"修改":"添加" %>章节</div> 
       
             <table width="100%" border="0" cellpadding="1" cellspacing="1" class="CTable no-borderTable">
                 <tr>
                    <td align="right" class="lefttd" height="30" style="width: 258px">
                        <strong>所属试题章节：</strong></td>
                    <td class="righttd">
                        <asp:DropDownList CssClass="select" ID="DrpClassID" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DrpClassID_SelectedIndexChanged">
                            <asp:ListItem Value="0">--选择试题章节--</asp:ListItem>
                        </asp:DropDownList>
                       <span id="DrpClassIDMessage" runat="server"></span>
                    </td>
                </tr>
                  
              
                   <tr id="Isparentid" runat="server">
                       <td align="right" class="lefttd" style="width: 258px; height: 37px;"><strong>
                           所属章节：</strong><br>
                         </td>
                         <td class="righttd" style="height: 37px">
                             <asp:DropDownList ID="ParentID" runat="server">
                             <asp:ListItem Value="0">-无（作为一级章节）-</asp:ListItem>
                             </asp:DropDownList>&nbsp;
                             <span id="ParentIDMessage" runat="server"></span>
                       </td>
                     </tr>
              
                     
                  <tr>
                    <td class="lefttd" height="30" align="right" style="width: 258px">
                        <strong> 章节名称：</strong></td>
                    <td class="righttd" >
                       <span id="AddOne">
                        <asp:TextBox CssClass="textbox" ID="ClassName" runat="server"></asp:TextBox>
                        <span class="tips">*请输入章节的中文名称，如公务员</span>
                       </span>

                       <label style="<%=KSCMS.S("action")=="edit"?"display:none;":"" %>font-weight:bold;color:Green"><input onclick="CheckAddMode()" type="checkbox" name="AddType" id="AddType" value="1" />切换到批量添加模式</label>
                       <div id="AddMore" style="display:none">
                          <font color=red>录入格式:章节中文名称,说明每行一个</font><br />
                          <asp:TextBox Text="章节名称1" ID="TxtMoreClassName" runat="server" CssClass="textbox" TextMode="MultiLine" Width="250px" Height="150px"></asp:TextBox>
                         </div>
                       </td>
                  </tr>

      
                <tr id="IntroArea">
                    <td align="right"  class="lefttd" style="width: 258px; height: 50px;">
                        <strong>章节介绍：</strong><br />
                        </td>
                    <td  class="righttd" style="height: 50px">
                        <asp:TextBox CssClass="textbox" ID="ClassIntro" runat="server" rows="2" TextMode="MultiLine" Height="50px" Width="383px"></asp:TextBox>
                        <a class="textarea_min" href="javascript:zoomtextarea(-5,'<%=this.ClassIntro.ClientID %>');"></a>
                        <a class="textarea_max" href="javascript:zoomtextarea(5,'<%=this.ClassIntro.ClientID %>');"></a>

                      
                          <br />
                          <font class='tips'>用于在章节页的介绍信息</font> 
                        </td>
                  </tr>
                  <tr>
                    <td  height="30" class="lefttd" align="right" style="width: 258px">
                        <strong>章节图片：</strong></td>
                    <td class="righttd">
                        <asp:TextBox CssClass="textbox" ID="ClassImg" runat="server" Width="380px"></asp:TextBox>&nbsp;<input type="button" class="button" onclick="SelectFiles('<%=this.ClassImg.ClientID %>',101);" value="选择图片">
                        <br />
                        <font class='tips'>用于在章节页显示指定的图片</font>
                        </td>
              </tr>
              
          </table>	


          <KS:Foot ID="Foot1" runat="server" OnSubmit="SaveButton_Click" />
    
        </asp:Panel>

	</div>
</asp:Content>

