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


<div class="result-wrap">


 

  <div class="result-title">
            <div class="result-list">
                  <a href="#" id="a_addnew"><i class="icon-font">&#xe026</i>添加部门</a>
                       

                     <asp:LinkButton ID="lb_delete" 
                         OnClientClick="if(!isselect()) return false; " 
                        runat="server" onclick="lb_delete_Click"><i class="icon-font"></i>批量删除</asp:LinkButton> 
                      
                      
                      <asp:LinkButton ID="lb_update_order" runat="server" 
                            onclick="lb_update_order_Click">    <i class="icon-font"></i>更新排序</asp:LinkButton>


    <a href="#"><span id="span_help"><i class="icon-font">&#xe023;</i>说明</span></a>

      &nbsp;|&nbsp;
       <a href="javascript:void(0);"
       
        onclick="Pop('Imports_AD_Dept.aspx',500,380,'从域服务器里导入AD部门');return false;"
       
       ><i class="icon-font">&#xe026</i>从AD导入部门</a>
                    </div>
                </div>
  
 

  <div id="thenew" style="display:none" class="result-content"> 


    <table class="insert-tab" width="100%">
                        <tbody> 
                            <tr>
                                <th><i class="require-red">*</i>部门名称：</th>
                                <td>
                                   
                                    <asp:TextBox class="common-text required"  ValidationGroup="Add" ID="txt_catname" Text="" Width=300px runat="server"></asp:TextBox>
                                    <asp:RequiredFieldValidator ValidationGroup="Add" ID="RequiredFieldValidator1" runat="server" ErrorMessage="必须填写部门" ControlToValidate="txt_catname" Display="Static"></asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <th>排序数字：</th>
                                <td>
                                    <asp:TextBox class="common-text" ID="txt_orderid" Text="0" Width=300px runat="server"></asp:TextBox>
                             </td>
                            </tr>
                            
                            <tr>
                                <th></th>
                                <td>
                                    <asp:Button ID="btn_add" runat="server" Text="提交"  ValidationGroup="Add" 
                                        class="btn btn-primary btn6 mr10" onclick="btn_add_Click" />
 
                                    <input class="btn btn6"  id="btn_back" value="返回" type="button">
                                </td>
                            </tr>
                        </tbody></table>

  </div>





   


   <div id="thetable" class="result-content"> 
    

       


  <div>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="id" DataSourceID="SqlDataSource1" Width="100%"
          CssClass="result-tab"  
        >
        <Columns>



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


          
         <asp:TemplateField>
         <HeaderTemplate>排序</HeaderTemplate>
          <ItemTemplate>
            <asp:TextBox runat="server" class="common-input sort-input" Text='<%#Bind("orderId") %>' ID="txt_orderid"></asp:TextBox>
          </ItemTemplate>
           <HeaderStyle  Width=80px  /> 
         </asp:TemplateField> 

           <asp:BoundField DataField="catname"   ItemStyle-Width="500px" HeaderText="部门名称" SortExpression="catname" />
     
        <asp:TemplateField>
         <HeaderTemplate>人员查询</HeaderTemplate>
         <ItemTemplate>
         <a  href="javascript:void(0);" onclick="Pop('Users_Query.aspx?t=dept&name=<%#Server.UrlEncode(Eval("catname").ToString()) %>',850,450,'部门员工查询');return false;"   >查询</a>
         </ItemTemplate>
         <ItemStyle Width=100px />
         </asp:TemplateField>

       
          <asp:CommandField HeaderText="操作" EditText="编辑" DeleteText="<span onclick=&quot;JavaScript:return confirm('确定删除吗？')&quot;>删除</span> "  UpdateText="更新"  CancelText="取消" ShowDeleteButton="True" ShowEditButton="True" />


        </Columns>
      
    
    </asp:GridView>

      </div> 


       
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
         ConnectionString='<%$ ConnectionStrings:Connectionstring %>' 
        DeleteCommand="DELETE FROM [users_dept] WHERE [id] = @id" 
        SelectCommand="SELECT [id], [catname], [orderid] FROM [users_dept] ORDER BY [orderid] asc, catname asc " 
        UpdateCommand="UPDATE [users_dept] SET [catname] = @catname, [orderid] = @orderid WHERE [id] = @id"
    >
        <DeleteParameters>
            <asp:Parameter Name="id" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="catname" Type="String" />
            <asp:Parameter Name="orderid" Type="Int32" />
            <asp:Parameter Name="id" Type="Int32" />
        </UpdateParameters> 
    </asp:SqlDataSource>

</div> 

</div>


<script>



    $(document).ready(

         function () {
             $("#a_addnew").click(
             function () {
                 $("#thenew").show();
                 $("#thetable").hide();
             }
             );

             $("#btn_back").click(
             function () {
                 $("#thenew").hide();
                 $("#thetable").show();
             }
             );

         }

         );


    $('#span_help').on('click', function () {
        layer.tips('启明星系统中部门是一个可选项，虽不是必须，但是推荐设置。集成AD时，部门名称请和AD里名称一致。', this, { time: 5,
            style: ['background-color:#0FA6D8; color:#fff', '#0FA6D8'],
            maxWidth: 450
        });
    });

</script>
   <input type="hidden" name="hf_ids" id="hf_ids" />
</asp:Content>
