<%@ Page Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true" Inherits="Kesion.NET.WebSite.Admin_Administrator" Title="Untitled Page" Codebehind="KS.AdminManage.aspx.cs" %>

<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Kesion.BLL" %>
<asp:Content ID="Content1" ContentPlaceHolderID="KSContent" runat="Server">

    <style >

        .poweritem li{
                width: auto!important;
        }
    </style>


    <asp:Panel ID="ListPanel" runat="server" Height="50px" Width="100%">
        <div id="manage_top" class="menu_top_fixed">
            <ul class="titleTab">
                <li class="curr"><a href="KS.AdminManage.aspx">管理员管理</a></li>
                <li><a href="KS.AdminRole.aspx">管理员类型</a></li>
            </ul>
        </div>
        <div class="menu_top_fixed_height"></div>
        <div class="content-area">
            <div class="myTitle">管理员管理<asp:Button ID="Button2" runat="server" Text="新增管理员" CssClass="fr mr20 button button_on" OnClick="addclassbutton_Click" /></div>
            <KS:KSGV ID="List" CssClass="CTable" runat="server" GridLines="None" AutoGenerateColumns="False" EmptyDataText="没有添加任何管理员" Width="99%" OnRowDataBound="List_RowDataBound" OnRowCreated="List_RowCreated" OnRowCommand="List_RowCommand">
                <HeaderStyle CssClass="CTitle" />
                <Columns>
                    <asp:TemplateField HeaderText="选择">
                        <ItemTemplate>
                            <input type="checkbox" name="ids" id="ids" value="<%#Eval("id") %>" <%# Convert.ToString(Eval("sysAdmin"))=="1"?" disabled":"" %> />
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Center" Height="30px" Width="50px" />
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="状态">
                        <ItemStyle Width="30px" HorizontalAlign="Center" />
                        <ItemTemplate>
                            <a href="?action=locked&id=<%#Eval("ID")%>" <%# Convert.ToString(Eval("locked"))=="1"?"class='no' title='锁定状态'":"class='ok' title='正常状态'" %>></a>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="id" HeaderText="ID" Visible="false">
                        <ItemStyle HorizontalAlign="Center" Width="25px" />
                    </asp:BoundField>
                    <asp:BoundField DataField="username" HeaderText="管理员名称">
                        <ItemStyle HorizontalAlign="Left" />
                    </asp:BoundField>
                    <asp:TemplateField HeaderText="绑定会员账号">
                        <ItemStyle HorizontalAlign="Center" />
                        <ItemTemplate>
                            <span class="tips"><%# string.IsNullOrEmpty(Convert.ToString(Eval("PrUserName")))?"未绑定":"<a href='KS.User.aspx?action=show&userid="+UserManage.GetUserInfo(Convert.ToString(Eval("PrUserName"))).UserID+"' class='tips' title='查看业务员["+Eval("PrUserName")+"]信息'>"+Eval("PrUserName")+"</a>" %></span>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="realname" HeaderText="真实姓名">
                        <ItemStyle Width="80px" HorizontalAlign="Center" />
                    </asp:BoundField>
                    <asp:BoundField DataField="usertype" HeaderText="类型">
                        <ItemStyle HorizontalAlign="Center" />
                    </asp:BoundField>
                    <asp:TemplateField HeaderText="最后登录时间">
                        <ItemStyle HorizontalAlign="Center" />
                        <ItemTemplate>
                            <span class="tips"><%# Eval("lastlogintime") %></span>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="logintimes" HeaderText="登录次数">
                        <ItemStyle HorizontalAlign="Center" />
                    </asp:BoundField>
                    <asp:TemplateField HeaderText="修改">
                        <ItemStyle Width="30px" HorizontalAlign="Center" />
                        <ItemTemplate>
                            <asp:LinkButton CssClass="edit" OnClientClick="doNone(event)" ID="LinkButton1" runat="server" CommandArgument='<%#Eval("id") %>' CommandName="modify" ToolTip="修改"></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="删除">
                        <ItemStyle Width="30px" HorizontalAlign="Center" />
                        <ItemTemplate>
                            <asp:HiddenField runat="server" Value='<%#Eval("sysadmin") %>' ID="HidSysAdmin"></asp:HiddenField>
                            <asp:LinkButton runat="server" ID="delete" CommandArgument='<%#Eval("id") %>' CommandName="del" ToolTip="删除" CssClass="delete"></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <EditRowStyle CssClass="emptycss" />
            </KS:KSGV>

            <div class="listedit">
                <input type="checkbox" name="chkall" id="chkall" onclick="CheckAll(this.form);" /><label for="chkall">全选</label>
                <asp:Button ID="BtnDel" runat="server" Text="批量删除" OnClientClick="return(confirm(&#39;确定要执行删除操作吗?&#39;));" CssClass="button" OnClick="delclassbutton_Click" onmousedown="return(GetIDS(&#39;&#39;));" />
            </div>
        </div>

        <KS:Page ID="Page1" runat="server" />
    </asp:Panel>
    </div>    
    <asp:Panel ID="AddPanel" runat="server" Width="100%" Visible="false">
        <!--<KS:TopNav ID="TopNav1" runat="server" />-->

        <script language="JavaScript" src="../../ks_Inc/CheckPassWord.js"></script>
        <STYLE type=text/css>
        /*密码强度*/
        .rank { border:none; background:url(../../sysimg/rank.gif) no-repeat; width:125px; height:22px; vertical-align:middle; cursor:default; }
        .r0 { background-position:0 0; }
        .r1 { background-position:0 -22px; }
        .r2 { background-position:0 -44px; }
        .r3 { background-position:0 -66px; }
        .r4 { background-position:0 -88px; }
        .r5 { background-position:0 -110px; }
        .r6 { background-position:0 -132px; }
        .r7 { background-position:0 -154px; }
        </STYLE>
        <script>
            function CheckForm() {
                if ($("#<%=UserName.ClientID%>").val() == '') {
                       KesionJS.Alert("管理员名称必须输入!", "jQuery('#<%=UserName.ClientID%>').focus()");
                      return false;
                }
               <%if (this.Foot1.HiddenIDText == "0") { //不是修改 %>
              if ($("#<%=PassWord.ClientID%>").val() == '') {
                       KesionJS.Alert("登录密码必须输入!", "jQuery('#<%=PassWord.ClientID%>').focus()");
                      return false;
                }
                if (checkAllowPassWord($("#<%=PassWord.ClientID%>").val())==false) {
                    KesionJS.Alert("登录密码必需长度大于8位，并至少包含字母、数字、特殊字符两种以上。", "jQuery('#<%=this.PassWord.ClientID %>').focus()");
                    return false;
                }
                <%
              }%>
                if ($("#<%=RealName.ClientID%>").val() == '') {
                       KesionJS.Alert("真实姓名必须输入!", "jQuery('#<%=RealName.ClientID%>').focus()");
                      return false;
                }
                if ($("#<%=Tel.ClientID%>").val() == '') {
                       KesionJS.Alert("手机号码必须输入!", "jQuery('#<%=Tel.ClientID%>').focus()");
                      return false;
                }
                return true;
            }
        </script>

        <div class="content-area mt20">
            <div class="myTitle">新增管理员</div>
            <asp:HiddenField ID="HidFSysAdmin" runat="server" />
            <table width="99%" border="0" cellpadding="0" cellspacing="0" class="CTable no-borderTable">
                <tr>
                    <td class="lefttd" height="30" align="right" style="width: 198px"><b>管理员名称：</b></td>
                    <td class="righttd">&nbsp;<asp:TextBox CssClass="textbox" ID="UserName" runat="server" Width="200px"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="UserName"
                            ErrorMessage="请填写管理员名称!" Display="Dynamic"></asp:RequiredFieldValidator>
                        <asp:Label ID="UserMessage" runat="server"></asp:Label>
                        <span class="tips">如：用于登录后台的账号。</span>
                    </td>
                </tr>
                <tr>
                    <td align="right" class="lefttd" height="30" style="width: 198px">
                        <strong>登录密码：</strong></td>
                    <td class="righttd">&nbsp;<asp:TextBox CssClass="textbox" ID="PassWord" runat="server" Width="200px" TextMode="Password" onBlur="setPasswordLevel(this, document.getElementById('passwordLevel'));showPasswrodLevel(this,'showpasswordLevel');"  onKeyUp="setPasswordLevel(this, document.getElementById('passwordLevel'));showPasswrodLevel(this,'showpasswordLevel');"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="PassWord" Display="Dynamic" ErrorMessage="请输入密码!"></asp:RequiredFieldValidator>
                        <asp:Label ID="PassMessage" runat="server"></asp:Label>
                        <span class="tips">如：用于登录后台的密码。</span>
                    </td>
                </tr>
             <tbody id="showpasswordLevel" style="display:none">
                <tr>
		           <td align="right" class="lefttd" style="text-align: right; width: 150px;"><strong>密码强度：</strong></td>
		           <td class="righttd"><input name="Input" disabled="disabled" class="rank r0" id="passwordLevel" /></td>
	          </tr>
                <tr>
                  <td align="right" class="lefttd" style="text-align: right; width: 150px;">
                      <strong>密码最多使用期限：</strong></td>
                  <td class="righttd">&nbsp;<asp:TextBox CssClass="textbox" ID="TxtPassWordEffectiveDays" runat="server" Width="60" Text="0" style="text-align:center"></asp:TextBox> 天（不限制，请输入“0”）
                      <span class="tips">密码最多只能使用的天数，如果超过这个时间没有修改新的密码，将不能登录后台！密码到期10天前，登录后台会做提示！</span>
                  </td>
              </tr>
              </tbody>
                <tr>
                    <td align="right" class="lefttd" height="30" style="width: 198px">
                        <strong>绑定会员账号：</strong></td>
                    <td class="righttd">&nbsp;<asp:TextBox CssClass="textbox" ID="TxtPreUserName" runat="server"></asp:TextBox>
                        <span class="tips">绑定后该管理员登录后可以查询管理自己发展的客户资料，商城订单等。</span>
                    </td>
                </tr>
                <tr>
                    <td align="right" class="lefttd" height="30" style="width: 198px">
                        <strong>真实姓名：</strong></td>
                    <td class="righttd">&nbsp;<asp:TextBox CssClass="textbox" ID="RealName" runat="server"></asp:TextBox>
                        <span class="tips">如：张三、李四等。</span>
                    </td>
                </tr>
                <tr>
                    <td align="right" class="lefttd" height="30" style="width: 198px">
                        <strong>手机号码：</strong></td>
                    <td class="righttd">&nbsp;<asp:TextBox CssClass="textbox" ID="Tel" runat="server"></asp:TextBox>
                        <span class="tips">如：请填写手机号码。</span>
                    </td>
                </tr>
                <tr>
                    <td height="30" class="lefttd" align="right"><strong>管理员头像：</strong></td>
                    <td class="righttd">
                        <table cellspacing="0" cellpadding="0">
                            <tr>
                                <td>&nbsp;<asp:TextBox CssClass="textbox" ID="TxtUserFace" runat="server"></asp:TextBox>&nbsp;<input type="button" class="button" onclick="SelectFiles('<%=this.TxtUserFace.ClientID %>    ',0);" value="选择图片"></td>
                                <%if (Kesion.BLL.KSSecurity.CheckCommonUploadPower())
                                  { %>
                                <td style="padding-left: 4px; padding-top: 12px;"><%=Kesion.APPCode.UploadAPI.EchoUpload("classpic",this.TxtUserFace.ClientID,150) %></td>
                                <%} %>
                                <td>
                                    <img id="show<%=TxtUserFace.ClientID %>" src="<%=TxtUserFace.Text %>" width="60" height="60" style="border: 1px solid #f1f1f1;" onerror="this.src='../../sysimg/nopic.gif'" /></td>
                            </tr>
                        </table>
                    </td>
                </tr>

                <tr<%=this.HidFSysAdmin.Value=="1"?" style='display:none'":string.Empty %>>
              <td align="right" class="lefttd" height="30" style="width: 198px">
                  <strong>管理员类型：</strong></td>
              <td class="righttd">
                  <asp:RadioButtonList ID="UserType" runat="server" AutoPostBack="True" OnSelectedIndexChanged="UserType_SelectedIndexChanged" RepeatDirection="Horizontal">
                      <asp:ListItem Value="1">超级管理员</asp:ListItem>
                      <asp:ListItem Selected="True" Value="0">普通管理员</asp:ListItem>
                  </asp:RadioButtonList></td>
                </tr>
          <tr id="docPowerPanel" runat="server">
              <td align="right" class="lefttd" height="30" style="width: 198px"><strong>管理权限：</strong></td>
              <td class="righttd"><strong>所属角色：</strong>
                  <asp:RadioButtonList ID="RdbRole" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
                      <asp:ListItem Value="1">发稿员</asp:ListItem>
                      <asp:ListItem Value="2">初审员</asp:ListItem>
                      <asp:ListItem Selected="True" Value="3">终审员</asp:ListItem>
                  </asp:RadioButtonList>

                  <br />
                  <strong>通用上传权限：</strong>
                  <asp:RadioButtonList ID="RdbCommonUploadPower" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
                      <asp:ListItem Value="1">允许</asp:ListItem>
                      <asp:ListItem Selected="True" Value="0">不允许</asp:ListItem>
                  </asp:RadioButtonList>
                  <div>
                      <strong>内容管理权限：</strong>
                      <asp:RadioButtonList ID="RdbDocPower" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
                          <asp:ListItem Value="1">只能管理自己添加的文档</asp:ListItem>
                          <asp:ListItem Selected="True" Value="0">有权限栏目的文档都可以管理(<span style="color:Red">包括非自己添加的文档,一般审核员需要拥有此权限</span>)</asp:ListItem>
                      </asp:RadioButtonList>
                  </div>
              </td>
          </tr>
                <tr>
                    <td align="right" class="lefttd" height="30" style="width: 198px"><strong>状 态：</strong></td>
                    <td class="righttd">
                        <asp:RadioButtonList ID="Locked" runat="server" RepeatDirection="Horizontal">
                            <asp:ListItem Selected="True" Value="0">正常</asp:ListItem>
                            <asp:ListItem Value="1">锁定</asp:ListItem>
                        </asp:RadioButtonList>
                    </td>
                </tr>
                <tr>
                    <td align="right" class="lefttd" height="30" style="width: 198px"><strong>简要说明：</strong></td>
                    <td class="righttd">&nbsp;<asp:TextBox ID="Descript" runat="server" CssClass="textbox" Height="89px" TextMode="MultiLine" Width="325px"></asp:TextBox>
                    </td>
                </tr>
            </table>
            <br />

            <asp:Panel ID="PowerPanel" runat="server" Width="100%">
                <table width="99%" border="0" cellpadding="1" cellspacing="1" class="CTable">
                    <tr>
                        <td class="righttd" style="text-align: center; height: 28px"><b>管理员权限分配设置</b></td>
                    </tr>
                </table>
                <br />

                <style>
                    .poweritem {
                        padding-left: 25px;
                    }

                        .poweritem li {
                            width: 20%;
                            float: left;
                            height: 40px;
                        }
                </style>
                <script>
                    function TopToggle(obj,i) {
                        if (obj.checked) { $('#top'+i).show(); } else { $('#top'+i).hide(); }
                    }
                    function LeftToggle(obj,i,li) {

                        if (obj.checked) { $('#left-'+i+'-'+li).show(); } else { $('#left-'+i+'-'+li).hide(); }
                    }
                    function ItemToggle(obj,i,li,itemno) {
                        if (obj.checked) { $('#item-'+i+'-'+li+'-'+itemno).show(); } else { $('#item-'+i+'-'+li+'-'+itemno).hide(); }
                    }
                    function ContentItemToggle(obj,itemno) {
                        if (obj.checked) { $('#item-'+itemno).show(); } else { $('#item-'+itemno).hide(); }
                    }
                    function LeftCosToggle(obj,i,li) {

                        if (obj.checked) { $('#left1-'+i+'-'+li).show(); } else { $('#left1-'+i+'-'+li).hide(); }
                    }
           
                    //ajax保存栏目权限
                    function classpurview(obj, username) {
                        jQuery.post("KS.AdminManage.aspx", { action: "classpurview", check:obj.checked,username:username,classid:obj.value }, function(v) {
                            // alert(v);
                            //jQuery('#showresult').html(unescape(v));
                        });
                    }
                    //ajax保存栏目权限


                    function classCoursepurview(obj, username,t) {
                        jQuery.post("KS.AdminManage.aspx", { action: "classcoursepurview", check:obj.checked,username:username,classid:obj.value,t:t }, function(v) {
                     
                            //jQuery('#showresult').html(unescape(v));
                        });
                    }
                    function setAll(nodeType,i,flag){
                        $('#item-'+nodeType+'-'+i).find('input[name=classid]').attr('checked', flag);
                        var classid='';
                        $('#item-'+nodeType+'-'+i).find('input[name=classid]').each(function(){
                            classid+=","+$(this).val();
                        });
                     
                        jQuery.post("KS.AdminManage.aspx", { action: "classpurview", check:flag,username:"<%=this.UserName.Text%>",classid:classid }, function(v) {
                            //jQuery('#showresult').html(unescape(v));
                        });
                     

                    }
                    function setCourseAll(t, flag) {
                        //alert('#left1-' + i + '-' + (ii)+"="+t);
                        $('input[name=classid' + t + ']').attr('checked', flag);
                        var classid='';
                        $('input[name=classid'+t+']').each(function(){
                            classid+=","+$(this).val();
                        });
                        jQuery.post("KS.AdminManage.aspx", { action: "classcoursepurview", check:flag,username:"<%=this.UserName.Text%>",classid:classid,t:t }, function(v) {
                         // alert(v);   //jQuery('#showresult').html(unescape(v));
                     });
                     

                 }


                 function DoCheck(i){
                     if ($(".top"+i).attr("checked")=="checked"){
                         $(".top"+i).attr("checked",false);
                         $("#top"+i).hide();
                         $("#ctable"+i).find("input[type=checkbox][name!='classid']").attr("checked",false);
                     }else{
                         $(".top"+i).attr("checked",true);
                         $("#top"+i).show();
                         $(".t"+i).attr("checked",true).click();
                         $("#ctable"+i).find("input[type=checkbox][name!='classid']").attr("checked",true);
                     }
                 }
                </script>

                <%
                    XmlDocument doc = new XmlDocument();
                     if (Utils.GetBusinessVersion() == "saas") {
                        doc.Load(Server.MapPath("~/config/menu/ManageMenu_saas.xml"));
                    }
                    else
                    {
                        doc.Load(Server.MapPath("~/config/menu/ManageMenu.xml"));
                    }
                    XmlNode nodes = doc.SelectSingleNode("managemenu");
                    int i = 0;
                    foreach (XmlNode topnode in nodes.ChildNodes) //顶级菜单
                    {
                        bool isShow = true;
                        if (topnode.SelectSingleNode("@type") != null)
                        {
                            if (topnode.SelectSingleNode("@role").InnerText == "order")
                            {
                                //  isShow = false;

                            }
                            else if (topnode.SelectSingleNode("@type").InnerText == "exam" && BaseFun.CheckModulePower("exam")==false)
                            {
                                isShow = false;
                            }
                        }
                        if (isShow)
                        {
                %>
                <table width="99%" id="ctable<%=i %>" border="0" cellpadding="1" cellspacing="1" class="CTable" style="margin-bottom: 5px;">
                    <tr>
                        <td class="righttd" style="font-size: 14px; font-family: 黑体; font-weight: bold">
                            <label><%=UtilsAutoID.CapitalFigures(i) %>、<input class="top<%=i %>" onclick="TopToggle(this,<%=i %>);" type="checkbox" name="powerlist" value="<%=topnode.SelectSingleNode("@role").InnerText %>" <%if (Utils.InArray(topnode.SelectSingleNode("@role").InnerText, powerList, ",")) Response.Write(" checked"); %> />此管理员在【<%=topnode.SelectSingleNode("@name").InnerText %>】模块权限</label>
                            <span style="font-weight: normal; color: #999;">(<a href="javascript:;" style="color: #999;" onclick="DoCheck(<%=i %>);">全选</a>)</a></td>
                    </tr>
                    <tr id="top<%=i %>" <%=(Utils.InArray(topnode.SelectSingleNode("@role").InnerText, powerList, ","))?string.Empty:" style='display:none';"%>>
                        <td style="padding-left: 50px;">
                            <%
                                if (topnode.SelectSingleNode("@role").InnerText=="website")
                                {
                                    Response.Write("<li class='moduleblock'>内容管理</li>");
                                }
                                int li = 0;
                                foreach (XmlNode leftnode in topnode.SelectNodes("leftitem")) //一级菜单
                                {
                                    bool isEnable = true;
                                    if (leftnode.SelectSingleNode("@enable") != null)
                                    {
                                        isEnable = leftnode.SelectSingleNode("@enable").InnerText.ToLower().Equals("true");
                                    }
                                    if (isEnable == true && leftnode.SelectSingleNode("@module") != null)
                                    {
                                        isEnable = BaseFun.CheckModulePower(leftnode.SelectSingleNode("@module").InnerText);
                                    }
                                    if (!isEnable) continue;


                                    Response.Write(@"<table width=""100%"" border=""0"" cellpadding=""1"" cellspacing=""1"">");
                                    Response.Write(@"<tr>
                                    <td style=""height: 28px"">");
                                    Response.Write(@" <label>" + UtilsAutoID.ToNum1(li) + @"、<input class=""t" + i + @""" onclick=""LeftToggle(this," + i + "," + li + @");"" type=""checkbox"" name=""powerlist"" value=""" + leftnode.SelectSingleNode("@role").InnerText + @"""");
                                    if (Utils.InArray(leftnode.SelectSingleNode("@role").InnerText, powerList, ",")) Response.Write(" checked");
                                    Response.Write(@"/>【" + leftnode.SelectSingleNode("@name").InnerText + "】</label></td>");
                                    Response.Write("</tr>");
                                    Response.Write(@"<tr id=""left-" + i + "-" + li + @"""" + ((Utils.InArray(leftnode.SelectSingleNode("@role").InnerText, powerList, ",")) ? string.Empty : " style='display:none';") + ">");
                                    Response.Write(@" <td>
                                        <ul class=""poweritem"">");

                                    int itemnum = 0;
                                    foreach (XmlNode item in leftnode.SelectNodes("itemlist/item")) //子项菜单
                                    {

                                        #region 子项菜单
                                        string power = Kesion.BLL.KSSecurity.RemovePowerBadChar(item.SelectSingleNode("url").InnerText);

                                        #region 额外加的选项
                                        if (item.SelectSingleNode("url").InnerText.ToLower().IndexOf("user/ks.user.aspx") != -1)
                                        {
                                            #region 用户管理
                                            Response.Write(@"<div class=""message""><strong>只允许管理自己发展的会员：</strong>");
                                            Response.Write("<input type='radio' name='AllowUser' value='1'"+(powerList.IndexOf("userallow") != -1?" checked":"")+"/>是");
                                            Response.Write("<input type='radio' name='AllowUser' value='0'"+(powerList.IndexOf("userallow") == -1?" checked":"")+"/>否");
                                            Response.Write("</div>");
                                            #endregion
                                        }
                                        if (item.SelectSingleNode("url").InnerText.ToLower().IndexOf("ks.shoporder.aspx") == -1)
                                        {
                                            Response.Write("<li>");
                                        }
                                        else
                                        {
                                            #region 电商订单
                                            Response.Write(@"<div class=""message""" + (MyCache.GetShopCommonConfig(103) == "1" ? "" : " style='display:n1one'") + @"><strong>允许管理的仓库：</strong>");
                                            Response.Write(InitialStore());
                                            Response.Write("</div>");
                                            Response.Write("<div>");
                                            #endregion

                                        }
                                        #endregion

                                        if (!string.IsNullOrEmpty(power) && power != "#")
                                        {
                                            Response.Write(string.Format(@"<label><input type='checkbox' name='powerlist' onclick=""ItemToggle(this,{3},{4},{5})"" value='{1}'{2}> {0}</label>", item.SelectSingleNode("name").InnerText, power, Utils.InArray(power, powerList, ",", true) ? " checked" : string.Empty, i, li, itemnum));
                                            if (item.SelectSingleNode("role") != null)
                                            {
                                                int itemno = 0;
                                                string role = item.SelectSingleNode("role").InnerText;
                                                Response.Write("<div class='tips' id='item-" + i + "-" + li + "-" + itemnum + "'" + (Utils.InArray(power, powerList, ",") ? string.Empty : " style='display:none'") + ">");
                                                foreach (string s in role.Split('|'))
                                                {
                                                    Response.Write(string.Format(@"<label><input type='checkbox' name='powerlist' value='{1}'{2}/>{0}</label>", s, string.Concat(power, itemno), Utils.InArray(string.Concat(power, itemno), powerList, ",", true) ? " checked" : string.Empty));
                                                    itemno++;
                                                }
                                                Response.Write("</div>");
                                            }
                                            if (item.SelectSingleNode("url").InnerText.ToLower().IndexOf("ks.shoporder.aspx") == -1)
                                            {
                                                Response.Write("</li>");
                                            }
                                            else
                                            {
                                                Response.Write("</div><div style='clear:both'></div>");
                                            }
                                        }
                                        itemnum++;
                                        #endregion
                                    }

                                    #region 内容选项
                                    if (leftnode.SelectSingleNode("@type") != null)
                                    {
                                        string nodeType = leftnode.SelectSingleNode("@type").InnerText;
                                        if (nodeType == "content" || nodeType == "mall")
                                        {
                                            #region 文章，图片，下载、电商及谭程等模型
                                            using (DataTable dtc = MyCache.GetCacheModelTable())
                                            {
                                                DataView dv = dtc.DefaultView;
                                                if (nodeType == "content")
                                                {
                                                    dv.RowFilter = "basictype<>4";
                                                }
                                                else
                                                {
                                                    dv.RowFilter = "basictype=4";
                                                }
                                                using (DataTable dt = dv.ToTable())
                                                {

                                                    if (dt.Rows.Count > 0)
                                                    {
                                                        int bitemnum = 0;
                                                        foreach (DataRow dr in dt.Rows)
                                                        {
                                                            bitemnum++;
                                                            Response.Write(@"<table width=""100%"" border=""0"" cellpadding=""1"" cellspacing=""1"">
                                                                        <tr>
                                                                            <td style=""height: 28px"">
                                                                                <label>" + bitemnum + @")、<input class=""t" + i + @""" onclick=""ContentItemToggle(this," + "'" + nodeType + "-" + bitemnum + @"');"" type=""checkbox"" name=""powerlist"" value=""" + dr["modelfolder"].ToString().ToLower() + @"""");
                                                            if (Utils.InArray(dr["modelfolder"].ToString().ToLower(), powerList, ","))
                                                            {
                                                                Response.Write(" checked");
                                                            }
                                                            Response.Write("/>【" + dr["modelname"].ToString() + @"】</label></td>
                                                                        </tr>");
                                                            Response.Write(@"<tr id=""item-" + nodeType + "-" + bitemnum + @"""" + ((Utils.InArray(dr["modelfolder"].ToString().ToLower(), powerList, ",")) ? string.Empty : " style='display:none';") + ">");
                                                            Response.Write(" <td>");
                                                            Response.Write(@"<ul class=""poweritem"">");
                                                            Response.Write(@"<label><input type=""checkbox"" name=""powerlist"" value=""" + dr["modelfolder"].ToString().ToLower() + @"0""");
                                                            if (Utils.InArray(dr["modelfolder"].ToString().ToLower() + "0", powerList, ",")) Response.Write(" checked");
                                                            Response.Write("/>添加</label>");
                                                            Response.Write(@"<label><input type=""checkbox"" name=""powerlist"" value=""" + dr["modelfolder"].ToString().ToLower() + @"1""");
                                                            if (Utils.InArray(dr["modelfolder"].ToString().ToLower() + "1", powerList, ",")) Response.Write(" checked");
                                                            Response.Write("/>编辑</label>");
                                                            Response.Write(@"<label><input type=""checkbox"" name=""powerlist"" value=""" + dr["modelfolder"].ToString().ToLower() + @"2""");
                                                            if (Utils.InArray(dr["modelfolder"].ToString().ToLower() + "2", powerList, ",")) Response.Write(" checked");
                                                            Response.Write("/>删除</label>");
                                                            Response.Write(@"<label><input type=""checkbox"" name=""powerlist"" value=""" + dr["modelfolder"].ToString().ToLower() + @"3""");
                                                            if (Utils.InArray(dr["modelfolder"].ToString().ToLower() + "3", powerList, ",")) Response.Write(" checked");
                                                            Response.Write("/>审核</label>");
                                                            Response.Write(@"<label><input type=""checkbox"" name=""powerlist"" value=""" + dr["modelfolder"].ToString().ToLower() + @"4""");
                                                            if (Utils.InArray(dr["modelfolder"].ToString().ToLower() + "4", powerList, ",")) Response.Write(" checked");
                                                            Response.Write("/>克隆</label>");
                                                            if (leftnode.SelectSingleNode("@type").InnerText == "content")
                                                            {
                                                                Response.Write(@"<label><input type=""checkbox"" name=""powerlist"" value=""" + dr["modelfolder"].ToString().ToLower() + @"5""");
                                                                if (Utils.InArray(dr["modelfolder"].ToString().ToLower() + "5", powerList, ",")) Response.Write(" checked");
                                                                Response.Write("/>加入专题</label>");
                                                                Response.Write(@"<label><input type=""checkbox"" name=""powerlist"" value=""" + dr["modelfolder"].ToString().ToLower() + @"6""");
                                                                if (Utils.InArray(dr["modelfolder"].ToString().ToLower() + "6", powerList, ",")) Response.Write(" checked");
                                                                Response.Write("/>附件上传</label>");
                                                            }
                                                            else
                                                            {
                                                                Response.Write(@"<label><input type=""checkbox"" name=""powerlist"" value=""" + dr["modelfolder"].ToString().ToLower() + @"5""");
                                                                if (Utils.InArray(dr["modelfolder"].ToString().ToLower() + "5", powerList, ",")) Response.Write(" checked");
                                                                Response.Write("/>导出Excel</label>");
                                                                Response.Write(@"<label><input type=""checkbox"" name=""powerlist"" value=""" + dr["modelfolder"].ToString().ToLower() + @"6""");
                                                                if (Utils.InArray(dr["modelfolder"].ToString().ToLower() + "6", powerList, ",")) Response.Write(" checked");
                                                                Response.Write("/>附件上传</label>");
                                                            }

                                                            Response.Write(@"<div><div class=""blank20""></div><strong>详细指定栏目权限</strong>");
                                                            Response.Write(@"<input type=""button"" value=""全选"" class=""button ml15"" onclick=""setAll('" + nodeType + "'," + bitemnum + @",true)"" />");
                                                            Response.Write(@"<input type=""button"" value=""不选"" class=""button ml15"" onclick=""setAll('" + nodeType + "'," + bitemnum + @",false)"" /></div>");

                                                            Response.Write(@"<div style=""border: 5px solid #E7E7E7; height: 250px; overflow: auto; width: 90%;margin-top:10px;"">");
                                                            Response.Write(GetClassList(Utils.StrToInt(dr["channelid"].ToString())));
                                                            Response.Write(@"  </div><div class=""blank10""></div>
                                                                                        </ul>
                                                                                    </td>
                                                                                </tr>
                                                                            </table>");
                                                        }
                                                    }
                                                }
                                            }
                                            #endregion
                                        }
                                        else if (BaseFun.CheckModulePower("edu") &&leftnode.SelectSingleNode("@type").InnerText == "course")
                                        {
                                            #region 课程
                                            Response.Write("<br/><div style='clear:both'></div>");
                                            for (var coursenum = 1; coursenum <= 3; coursenum++)
                                            {
                                                Response.Write("<li style='float:left;margin-top:20px;height:260px;width:33%; margin-bottom:20px;'>");
                                                switch (coursenum)
                                                {
                                                    case 1:
                                                        Response.Write("<strong>指定[点播]分类权限</strong>");
                                                        break;
                                                    case 2:
                                                        Response.Write("<strong>指定[直播]分类权限</strong>");
                                                        break;
                                                    case 3:
                                                        Response.Write("<strong>指定[面授]分类权限</strong>");
                                                        break;
                                                }

                                                Response.Write(@"<input type=""button"" value=""全选"" class=""button ml15"" onclick=""setCourseAll(" + coursenum + @",true)"" />");
                                                Response.Write(@"<input type=""button"" value=""不选"" class=""button ml15"" onclick=""setCourseAll(" + coursenum + @",false)"" />");
                                                Response.Write(@"  <div class=""mt20"" style=""border: 5px solid #E7E7E7; height: 200px; overflow: auto; width:90%;"">");
                                                Response.Write(GetClassCourseList(coursenum, coursenum));
                                                Response.Write(@" </div>");
                                                Response.Write(@" </li>");
                                            }
                                            Response.Write("<div style='clear:both'></div>");
                                            #endregion

                                        }
                                        else if (BaseFun.CheckModulePower("edu") &&leftnode.SelectSingleNode("@type").InnerText == "coursemarket")
                                        {
                                            EchoApp(1, ref itemnum, topnode);   //课程营销
                                        }
                                        else if (BaseFun.CheckModulePower("edu") &&leftnode.SelectSingleNode("@type").InnerText == "mallmarket")
                                        {
                                            EchoApp(2, ref itemnum, topnode);  //电商营销
                                        }
                                    }
                                    #endregion

                                    Response.Write(@"
                                                </ul>
                                            </td>
                                        </tr>
                                    </table>");
                                    li++;
                                }

                                if (topnode.SelectSingleNode("@role").InnerText=="website")
                                {
                                    EchoApp(0, ref i, topnode);  //应用的权限

                                }


                            %>
                             
                        </td>
                    </tr>
                </table>
                <%
                             i++;
                        }
                    }
                %>
            </asp:Panel>

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

    </div>  
</asp:Content>

