<%@ Page Title="区域地块" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="Book_Category_Area.aspx.cs" Inherits="Book.Admin.Book_Category_Area" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
 
   
    <style>
        .isdefault{ cursor:pointer; }
    </style>
 


    

   <asp:UpdatePanel runat="server" ID="pnl1" UpdateMode="Conditional">
        <ContentTemplate> 
	
            <div class="layui-form-item">


                        <div class="layui-inline">
                           <label class="layui-form-label req">区域名称</label>
                           <div class="layui-input-inline">
                                  <asp:TextBox   ClientIDMode="Static"   ValidationGroup="Add" ID="txt_areaname"  autocomplete="off" class="layui-input"  runat="server"></asp:TextBox>
                                    <asp:RequiredFieldValidator ValidationGroup="add" ID="RequiredFieldValidator1" runat="server" ErrorMessage="必须填写名称" ControlToValidate="txt_areaname" Display="Dynamic"></asp:RequiredFieldValidator>
                               </div>
                           </div> 


                   
                     <div class="layui-inline">
                           <label class="layui-form-label req">顺序号</label>
                           <div class="layui-input-inline">
                              <asp:TextBox class="layui-input"  ValidationGroup="add" ID="txt_orderid" Text="0"  runat="server"></asp:TextBox>
                            </div>
                        </div>

                      
                   <div class="layui-inline"> 
                        
           <asp:Button ID="btn_add" runat="server" Text="添加区域"  
               ValidationGroup="add" 
                class="layui-btn" 
               onclick="btn_add_Click" />
                                
                       </div> 

                   </div>
              
        </ContentTemplate>
    </asp:UpdatePanel>



    <hr />



     
   
     

    <!-- list -->

     <asp:UpdatePanel runat="server" ID="pnl2" UpdateMode="Conditional">
        <ContentTemplate>
   
           
           <div style="padding-bottom: 10px;">
          <asp:Button runat="server" ID="btn_del" 
               OnClientClick=" if(!isselect()) { return false;} "
               Text="批量删除" 
              class="layui-btn layui-btn-danger"
               OnClick="btn_del_Click" />

</div>


 

         
                       <asp:ListView runat="server" 
                           ID="lv_lists" EnableViewState="false"  DataSourceID="sds" 
                           DataKeyNames="id" >

                           <LayoutTemplate>
                            
                                         <table  class="layui-table"  >
                                            <thead>
                                              <tr> 
                                                 <th width="100px" >   <input type="checkbox"   id="chk_all" lay-skin="primary"  lay-filter="chk_all" > ID</th>
                                                 <th width="300px">区域名称</th>
                                                   <th width="150px" >顺序号</th>

                                                      <th width="150px" >默认区域</th>

                                                   <th >操作</th> 
                                               </tr>
                                             </thead>
                                            
                                             
                                              <tbody>  
                                                 <tr id="itemPlaceholder" runat="server">
                                                 </tr>
                                            </tbody>
                                         </table>
                                     
                                         
                                   
                         </LayoutTemplate>
                       


                          <ItemTemplate>
                             <tr  > 
                                 
                                 <td>
                                   <input type="checkbox" class="chk_item" value="<%# Eval("id") %>"  name="chk_item" lay-skin="primary" >   <%# Eval("id") %>
                                 </td>

                                 <td>
                                     <asp:Label ID="areaname" runat="server" Text='<%# Eval("areaname") %>' />
                                 </td>
                                 
                                <td>
                                     <asp:Label ID="orderid" runat="server" Text='<%# Eval("orderid") %>' />
                                 </td>
                                 

                                 <td>
                                       <span class="isdefault"
                                            data-theid="<%# Eval("id") %>"                                           
                                            data-isdefault="<%# Eval("isdefault") %>"
                                           ></span>
                                 </td>

                                 <td>

                                   <asp:LinkButton runat="server" ID="EditButton"  CommandName="Edit"
                                        class="layui-btn layui-btn-xs"
                                       >编辑</asp:LinkButton>


                                         <asp:LinkButton runat="server" ID="DeleteButton" 
                                             
                                              OnClientClick="return confirm('确定删除吗？')"
                                              CommandName="Delete"
                                        class="layui-btn layui-btn-danger layui-btn-xs"
                                       >删除</asp:LinkButton>


                                      
                                     
                                 </td>
                             </tr>
                         </ItemTemplate>
                        
                         
                         <EditItemTemplate>
                             <tr style="">
                                
                                 <td>
                                     <asp:Label ID="idLabel1" runat="server"  Text='<%# Eval("id") %>' />
                                 </td>

                                 <td>
                                     <asp:TextBox ID="areanameTextbox" runat="server"  CssClass="layui-input  "  Text='<%# Bind("areaname") %>' />
                                 </td>

                                    <td>
                                     <asp:TextBox ID="orderidTextbox" runat="server"  CssClass="layui-input  "  Text='<%# Bind("orderid") %>' />
                                 </td>

                                 <td>
                                   

                                 </td>
                               
                                 <td>
                                     <asp:LinkButton ID="UpdateButton" 
                                          class="layui-btn layui-btn-xs layui-btn-normal"

                                         runat="server" CommandName="Update" Text="更新" />
 

                                     <asp:LinkButton                                          
                                           class="layui-btn layui-btn-xs layui-btn-warm"
                                         ID="CancelButton" runat="server" CommandName="Cancel" Text="取消" />
                                 </td>
                             </tr>
                         </EditItemTemplate>
                         
                         


                     </asp:ListView>



            </ContentTemplate>
         </asp:UpdatePanel>
                   

  <!-- /list -->











     
     




        <asp:SqlDataSource ID="sds"  
           ConnectionString='<%$ ConnectionStrings:ConnectionString %>'
           Runat="server" 
           DeleteCommand="DELETE FROM [book_category_area] WHERE [id] = @id" 
           
           SelectCommand="SELECT * FROM [book_category_area]   ORDER BY [orderid] asc " 
           UpdateCommand="UPDATE [book_category_area] SET [areaname] = @areaname, areavalue=@areaname, [orderid] = @orderid WHERE [id] = @id"  >
        <DeleteParameters>
           <asp:Parameter Name="id" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
           <asp:Parameter Name="areaname" Type="String" />  
            <asp:Parameter Name="orderid" Type="Int32" /> 
            <asp:Parameter Name="id" Type="Int32" />
        </UpdateParameters>
        
    </asp:SqlDataSource>
 
    

    
    
    <script>

        chkAll();

    </script>


    <script>



        function renderStar()
        {
            $(".isdefault").each(
                function ()
                {
                    var isdefault = $(this).data("isdefault");
                    if (isdefault == "1") {
                        $(this).html("<img src=images/ok.gif >");
                    }
                    else {
                        $(this).html("<img src=images/star-off.gif >");
                    }

                }

                );


            $(".isdefault").click(
                function ()
                {
                    var theid = $(this).data("theid");
                    $(".isdefault").html("<img src=images/star-off.gif >");
                    $(this).html("<img src=images/ok.gif >");
                    $.get("Book_Category_Area.aspx?t=set&id=" + theid)
                });

        }

        renderStar();
    </script>


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


     

      

</asp:Content>
