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

    <div class="result-wrap">


 
            <div class="result-title">
                <h1>页面操作</h1>
            </div>
         <div class="result-list">
                 
          <a href="Addedittab.aspx" class="btn btn-primary">新增页面</a>  

          <a  id="btnOrder"  href="javascript:void(0);" class="btn btn-primary" onclick="order_table();" >页面排序</a>  
            
          <a id="btnSave"  href="javascript:void(0);" class="btn btn-primary"  onclick="save_order('qmx_tabid','qmx_orderid');" style="display:none">保存顺序</a>

          <a id="btnDel"  href="javascript:void(0);"  class="btn btn-danger" onclick="if(!isselect()) return false; DelTabs();" >批量删除</a>
                       
  
          <asp:LinkButton runat="server" ID="btn_restart" Text="清楚缓存" CssClass="btn btn-default"     onclick="btn_restart_Click" />
                         
                
            </div>
      


       

 
 
   <asp:GridView ID="GridView1"   
      CssClass="table" GridLines="None" 
      runat="server"  
      DataKeyNames="tabid"       
      DataSourceID="TabDataSource" 
      AutoGenerateColumns="false"  >
              <Columns>
            


           <asp:TemplateField> 
        <HeaderTemplate> 
              <asp:CheckBox ID="chk_SelectedHeader" runat="server" AutoPostBack="False" onclick="selectall(this)"  /> 
         </HeaderTemplate> 
                            
         <ItemTemplate  > 
            <input type="checkbox"  class="ck_item"   value='<%# Eval("tabid") %>'  /> 
            <asp:HiddenField runat="server" ID="hf_id" Value=<%# Eval("tabid") %> /> 
            <span class=qmx_tabid><%# Eval("tabid") %></span>
          </ItemTemplate>    
          <HeaderStyle  Width=50px  CssClass="tc"/>        
          <ItemStyle  Width=50px  CssClass="tc"/>
          </asp:TemplateField>



        <asp:TemplateField>
        <HeaderTemplate>排序</HeaderTemplate>
        <ItemTemplate>
        <asp:TextBox runat="server" Width="60px" ReadOnly="true"  class="common-input qmx_orderid" Text='<%#Bind("taborder") %>' ID="txt_orderid"></asp:TextBox>
        </ItemTemplate>
        <HeaderStyle  Width=60px  /> 
        </asp:TemplateField> 


         
            
              
              
            <asp:TemplateField>
            <HeaderTemplate>页面名称</HeaderTemplate>
            <ItemTemplate>
            <a href='../portal/default.aspx?tabid=<%#Eval("tabid")%>' target="_blank" style=" color:#000000; text-decoration:underline " title="单击预览页面" >
                <%#Eval("tabname") %>
                </a>
              
            </ItemTemplate>
            <ItemStyle Width="200px"   />
            </asp:TemplateField>
              
              
               <asp:TemplateField>
              <HeaderTemplate>显示在顶部</HeaderTemplate>
              <ItemTemplate><%#Eval("istop").ToString() == "1" ? "<img src=images/onCorrect.gif >" : ""%></ItemTemplate>
               <ItemStyle Width="80px"   />
              </asp:TemplateField>
              
              
               
              
              <asp:TemplateField>
              
              <HeaderTemplate>操作</HeaderTemplate>
              <ItemTemplate>
              <input  type="button" value="模块配置" Class="btn" onclick="window.location='Tablayout.aspx?tabid=<%#Eval("tabid")%>';" />   
              <input  type="button" value="权限配置" Class="btn" onclick="window.open('../portal/tabsecrity.aspx?tabid=<%#Eval("tabid")%>&sectype=tab'); return false;" />   
              <input  type="button" value="更新页面" Class="btn" onclick="window.location='addedittab.aspx?tabid=<%#Eval("tabid")%>';" />   
              <input type="button"  Class="btn"  onclick="window.open('../portal/default.aspx?tabid=<%#Eval("tabid")%>')"   value="查看页面"/>
              </ItemTemplate>
              
              <ItemStyle Width="250px" HorizontalAlign="Right" />
              </asp:TemplateField>
                 
              </Columns>
              
      
          </asp:GridView>
   
    
    
    
    
    
    
    
    
   

     <asp:ObjectDataSource ID="TabDataSource" runat="server" TypeName="Portal.BLL.TabHelper"
                        SelectMethod="GetAllTabs" 
                        DeleteMethod="DeleteTab" 
                        UpdateMethod="UpdateTab" 
                        InsertMethod="InsertTab"
                        OldValuesParameterFormatString="{0}"
                        >
                        <DeleteParameters>
                            <asp:Parameter Name="Tabid" Type="Int32" />
                        </DeleteParameters>
                        
                        <UpdateParameters>
                            <asp:Parameter Name="TabId" Type="Int32" />
                            <asp:Parameter Name="tabname" Type="Int32" />
                            <asp:Parameter Name="accessroles" Type="String"  ConvertEmptyStringToNull="false"/>
                            <asp:Parameter Name="taborder" Type="Int32" />
                            <asp:Parameter Name="istop" Type="Int32" />
                            <asp:Parameter Name="url" Type="String"  ConvertEmptyStringToNull="false"/>
                            <asp:Parameter Name="target" Type="String"  ConvertEmptyStringToNull="false"/>
                        </UpdateParameters>
                        
                        <InsertParameters>
                       
                          <asp:Parameter Name="TabId" Type="Int32" />
                            <asp:Parameter Name="tabname" Type="Int32" />
                            <asp:Parameter Name="accessroles" Type="String"  ConvertEmptyStringToNull="false"/>
                            <asp:Parameter Name="taborder" Type="Int32" />
                            <asp:Parameter Name="istop" Type="Int32" />
                            <asp:Parameter Name="url" Type="String"  ConvertEmptyStringToNull="false"/>
                            <asp:Parameter Name="target" Type="String"  ConvertEmptyStringToNull="false"/>
                        
                        </InsertParameters>
                    </asp:ObjectDataSource>



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

    </div>
         





          




         <script>

             
              

             function order_table(o) { 
                 $("#btnOrder").hide();
                 $("#btnSave").show();
                 $("#<%=GridView1.ClientID %>").tableDnD();
                   
             }



             function save_order(tabcss, ordercss) {
                 $("#btnOrder").show();
                 $("#btnSave").hide(); 

                 var tableids = '';
                 var orderids = '';
                 var tabindex = 0;
                 $("." + tabcss).each(
                    function () {
                     tableids += ',' + $(this).html();
                     orderids += ',' + tabindex;
                     tabindex++;
                   });

                   $.ajax({
                       url: "ajax/AjaxTabs.aspx",
                       cache: false, 
                       data: {"cmd":"Order", "tableids": tableids },
                       success: function (msg) {
                              layer.alert('操作成功', 12);  
                       }

                   });

                  
            

             }


             function DelTabs() {





                 $(".ck_item").each(
                   function () {
                     if ($(this).is(':checked')) {
                 $(this).parent().parent().remove();
                 }  });
                  

                 $.ajax({
                     url: "ajax/AjaxTabs.aspx",
                     cache: false,
                     data: { "cmd":"Del", "tableids": $("#hf_ids").val() },
                     success: function (msg) {
                         layer.alert('操作成功', 12);
                     } 
                 });
             
             }
 

         </script>

</asp:Content>
