<%@ Page Title="" Language="C#" MasterPageFile="~/admin/Admin.Master" AutoEventWireup="true" CodeBehind="menu2.aspx.cs" Inherits="Math.admin.menu2" %>
 
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">




    
 <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>子菜单项</legend>
</fieldset>



    
     <div class="layui-form-item">
   

            <div class="layui-inline">
      <label class="layui-form-label">子菜单名</label>
      <div class="layui-input-inline">
          <asp:TextBox runat="server"  placeholder="可为空" ID="txt_submenutext"  autocomplete="off" class="layui-input"></asp:TextBox>
     </div>
    </div>


    <div class="layui-inline">
      <label class="layui-form-label">子菜单Latex</label>
      <div class="layui-input-inline">
         <asp:TextBox runat="server"  lay-verify="required" ID="txt_submenuvalue"  autocomplete="off" class="layui-input"></asp:TextBox>
      </div>
    </div>


 
   

       <div class="layui-inline">
      <label class="layui-form-label">顺序ID</label>
      <div class="layui-input-inline">
         <asp:TextBox runat="server"  lay-verify="required" ID="txt_orderid" Text="0.0"  autocomplete="off" class="layui-input"></asp:TextBox>
      </div>
    </div>


         <div class="layui-inline" style="display:none">
      <label class="layui-form-label">系统内置</label>
      <div class="layui-input-inline">
         
         <input type="checkbox" name="issystem"  lay-skin="switch" lay-filter="issystem" id="issytem" title="系统内置">
  
      </div>
    </div>

  </div>




    
  <div class="layui-form-item">


            <div class="layui-inline">
      <label class="layui-form-label">父菜单</label>
      <div class="layui-input-inline">
         
        <asp:DropDownList runat="server" AutoPostBack="true" ID="ddl_parent" lay-ignore CssClass="form-control"></asp:DropDownList>
  
      </div>
    </div>


         <div class="layui-inline">
      <label class="layui-form-label">块级元素</label>
      <div class="layui-input-inline">
          <asp:DropDownList runat="server" ID="ddl_isblock" lay-ignore CssClass="form-control">
               <asp:ListItem Text="否" Value="0"></asp:ListItem>
              <asp:ListItem Text="是" Value="1"></asp:ListItem>
          </asp:DropDownList>
         </div>
             </div>


                       <div class="layui-inline">

                         

                           <asp:Button runat="server"
                                OnClientClick="chkIsSystem(); " 
                                ID="btn_add"
                                lay-submit
                                Text="添加" 
                                ValidationGroup="add"
               
                               class="layui-btn add" OnClick="btn_add_Click"
                                />
                          
                      
                       </div>
   </div>
     

    <hr />








    

    <asp:GridView ID="GridView1" AutoGenerateColumns="False"  
    DataKeyNames="id" runat="server" class="layui-table" 
         GridLines="None"  AllowPaging="false"
         DataSourceID="sds"
    >
    <HeaderStyle BackColor="#f5f5f5" />
    <Columns>
   
     
    <asp:BoundField DataField="id"  ReadOnly="true"  HeaderText="ID" HeaderStyle-Width="60px" InsertVisible="False" /> 
   <asp:BoundField DataField="submenutext"  ControlStyle-CssClass="layui-input"  HeaderText="菜单名称"   HeaderStyle-Width="250px"  />
   <asp:BoundField DataField="submenuvalue" HeaderText="菜单值"   ControlStyle-CssClass="layui-input"   HeaderStyle-Width="160px" />
   <asp:BoundField DataField="orderid"   HeaderText="顺序ID"  ControlStyle-CssClass="layui-input"  HeaderStyle-Width="100px" />

         
  
     <asp:TemplateField>
         <HeaderTemplate>显示效果</HeaderTemplate>

         <ItemTemplate> 
             $<%#Eval("submenuvalue") %>$
             </ItemTemplate>
         </asp:TemplateField>





     <asp:TemplateField>
         <HeaderTemplate>系统内置</HeaderTemplate>

         <ItemTemplate> 
             <input type="checkbox"  ID="cb_issystem" value="<%#Eval("id") %>" 
                 <%#Eval("issystem").ToString()=="1"?"checked":"" %>
                 lay-filter="item-issystem"  lay-skin="primary"  /> 
         </ItemTemplate>
         
         <EditItemTemplate>

         </EditItemTemplate>
     </asp:TemplateField>    
        
         
 
          <asp:TemplateField>
         <HeaderTemplate>是否启用</HeaderTemplate>

         <ItemTemplate> 
             <input type="checkbox"  ID="cb_isuse" value="<%#Eval("id") %>" 
                 <%#Eval("isuse").ToString()=="1"?"checked":"" %>
                 lay-filter="item-isuse"  lay-skin="primary"  /> 
         </ItemTemplate>
         
         <EditItemTemplate>

         </EditItemTemplate>
     </asp:TemplateField>   

      

          <asp:TemplateField>
         <HeaderTemplate>块级元素</HeaderTemplate>

         <ItemTemplate> 
             <input type="checkbox"  ID="cb_isblock" value="<%#Eval("id") %>" 
                 <%#Eval("isblock").ToString()=="1"?"checked":"" %>
                 lay-filter="item-isblock"  lay-skin="primary"  /> 
         </ItemTemplate>
         
         <EditItemTemplate>

         </EditItemTemplate>
     </asp:TemplateField>   

   



          <asp:TemplateField>
 
         <HeaderTemplate>操作</HeaderTemplate>
         <ItemTemplate>
         <div <%#Eval("IsSystem").ToString() == "1" ? " style='display:none'" : ""%> > 
 
         <asp:LinkButton runat="server" ID="btnEdit" CssClass="layui-btn layui-btn-sm" CommandName="Edit" Text="编辑" ></asp:LinkButton> 

        <asp:LinkButton runat="server" ID="btnDel" CssClass="layui-btn layui-btn-danger layui-btn-sm" CommandName="Delete" Text="删除" OnClientClick="return confirm('确定要删除吗？');"></asp:LinkButton>
         </div>
         </ItemTemplate>
 
         <EditItemTemplate>
 
          <asp:LinkButton runat="server" CssClass="layui-btn  layui-btn-sm" CausesValidation="false" ID="lbUpdate" CommandName="Update" Text="更新" ></asp:LinkButton>
           <asp:LinkButton runat="server" CssClass="layui-btn layui-btn-primary layui-btn-sm"  CausesValidation="false" ID="lbCanel" CommandName="Cancel" Text="取消" ></asp:LinkButton>

         </EditItemTemplate>
 
         </asp:TemplateField>











    </Columns>
      
    </asp:GridView>



    <asp:SqlDataSource ID="sds" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
         DeleteCommand="DELETE FROM [math_menu2] WHERE [id] = @id" 
         SelectCommand="SELECT * from math_menu2  where pmenuvalue=@pmenuvalue order by orderid asc, id asc  " 
         UpdateCommand="UPDATE [math_menu2] SET [submenutext] = @submenutext,  [submenuvalue] = @submenuvalue, [orderid] = @orderid  WHERE [id] = @id" 
         
    > 
        <SelectParameters>
            <asp:ControlParameter ControlID="ddl_parent" Name="pmenuvalue" />
        </SelectParameters>
   
    
    </asp:SqlDataSource>



























    
     <input id="hf_issystem" name="hf_issystem"  type="hidden"/> 
     


    <script>
        function chkIsSystem()
        {
            var status = $("input[name='issystem']").prop("checked")
            if (status) {
                $("#hf_issystem").val("1");
            }
            else {
                $("#hf_issystem").val("0");
            }
        }

    </script>

    <script>

   
 layui.use('form', function(){
     var form = layui.form;
     form.on('checkbox(item-issystem)', function (data)
     {
         layer.msg("系统内置无法更新", { icon: 4 });
         //var issystem = data.elem.checked ? "1" : "0";
         //var id = data.value;
         //$.get("menu2.aspx?t=issystem&id=" + id + "&issystem=" + issystem + "&r=" + Math.random());
         //layer.msg("更新成功");

     });


     form.on('checkbox(item-isuse)', function (data) {
         var isuse = data.elem.checked ? "1" : "0";
         var id = data.value;
         $.get("menu2.aspx?t=isuse&id=" + id + "&isuse=" + isuse + "&r=" + Math.random());
         layer.msg("更新成功");

     });


     form.on('checkbox(item-isblock)', function (data) {
         var isblock = data.elem.checked ? "1" : "0";
         var id = data.value;
         $.get("menu2.aspx?t=isblock&id=" + id + "&isblock=" + isblock + "&r=" + Math.random());
         layer.msg("更新成功");

     });
     
 });
 

 
    </script>










</asp:Content>
 