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


<div class="result-wrap">


   <div class="result-title">
             <span class="span_help">说明</span>:对公司部门进行管理，请注意：启明星系统部门采用“部门名称”作为关键字，这意味着删除A部门后，再建立A部门不影响使用。
     </div>

   

   
            <div class="result-list">
                       

                     <asp:LinkButton ID="lb_delete"  CssClass="btn btn-danger"
                         OnClientClick="if(!isselect()) return false; " 
                        runat="server" onclick="lb_delete_Click">批量删除</asp:LinkButton> 
                      
                      
                      <asp:LinkButton ID="lb_update_order" runat="server"  CssClass="btn btn-default"  
                            onclick="lb_update_order_Click">更新排序</asp:LinkButton>

 

      &nbsp;|&nbsp;
       <a href="javascript:void(0);"  Class="btn btn-default" 
       
        onclick="Pop('Users_Imports_AD_Dept.aspx',500,380,'从域服务器里导入AD部门');return false;"
       
       >从AD导入部门</a>


                      &nbsp;|&nbsp;
       <a href="javascript:void(0);"  Class="btn btn-success"
       
        onclick="Pop('Users_Dept_Reset.aspx',500,380,'根据员工部门重置部门');return false;"
       
       >重置部门</a>


                    </div>
               
 

   <div class="result-title">


    <table  width="100%">
                        <tbody> 
                            <tr>
                                <th width="80px">部门名称：</th>
                                <td width="250px">
                                   
                                    <asp:TextBox  CssClass="form-control"  ValidationGroup="Add" ID="txt_catname" Text=""  style="width:220px;" runat="server"></asp:TextBox>
                                    <asp:RequiredFieldValidator ValidationGroup="Add" ID="RequiredFieldValidator1" runat="server" ErrorMessage="必须填写部门" ControlToValidate="txt_catname" Display="Dynamic"></asp:RequiredFieldValidator>
                                </td>
                          
                                <th  width="80px">排序数字：</th>
                                <td  width="250px">
                                    <asp:TextBox  CssClass="form-control" ID="txt_orderid" Text="0" Width=220px runat="server"></asp:TextBox>
                             </td>
                             
                              
                                <td>
                                    <asp:Button ID="btn_add" runat="server" Text="添加新部门"  ValidationGroup="Add" 
                                        class="btn btn-primary" onclick="btn_add_Click" />
 
                                    
                                </td>
                            </tr>
                        </tbody></table>

  </div>





   


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

       


  <div>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="id" DataSourceID="SqlDataSource1" 
         GridLines="None"
          CssClass="table table-hover table-bordered"
        >
        <Columns>



      <asp:TemplateField> 
        <HeaderTemplate> 
             <input id="cb_selectall" type="checkbox"    /> 
         </HeaderTemplate> 
                            
         <ItemTemplate  > 
            <input type="checkbox"  class="ck_item"   value='<%# Eval("id") %>'  />  
              <asp:HiddenField runat="server" ID="hf_id" Value=<%# Eval("id") %> />          
          </ItemTemplate>    
          <HeaderStyle  Width=70px  />  
          </asp:TemplateField>


          
         <asp:TemplateField>
         <HeaderTemplate>排序</HeaderTemplate>
          <ItemTemplate>
            <asp:TextBox runat="server"  CssClass="form-control"  Width="80px" 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>
         <HeaderStyle Width=180px />
         </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  " 
        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> 






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

    </div>
</asp:Content>
