<%@ Register TagPrefix="uc1" TagName="Pager" Src="../../modules/Pager.ascx" %>
<%@ Page language="c#" Codebehind="roleusers.aspx.cs" AutoEventWireup="True" Inherits="health.aspx.sys.roleusers" %>

<HTML>
	<HEAD>
		<title>ManList</title>
		<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
		<meta content="C#" name="CODE_LANGUAGE">
		<meta content="JavaScript" name="vs_defaultClientScript">
		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
		<LINK href="../../css/style.css" type="text/css" rel="stylesheet">
		<style>.sys_button1 { BORDER-RIGHT: #9595a9 1px solid; BORDER-TOP: #9595a9 1px solid; FONT-SIZE: 9pt; BACKGROUND: url(../../App_Image/sys/button_gray.jpg) fixed repeat-x center center; BORDER-LEFT: #9595a9 1px solid; CURSOR: hand; COLOR: black; PADDING-TOP: 2px; BORDER-BOTTOM: #9595a9 1px solid; FONT-FAMILY: "宋体"; HEIGHT: 22px; TEXT-ALIGN: center }
		</style>
	</HEAD>
	<body MS_POSITIONING="GridLayout">
		<form id="Form1" method="post" runat="server">
			<br>
			<TABLE id="Table1" cellSpacing="0" cellPadding="0" width="95%" border="0" align="center">
				<TR>
					<TD>
						<table class="sys_grid" width="100%" border="0">
							<tr>
								<td>
									<table cellSpacing="0" cellPadding="0" width="100%" border="0">
										<tr height="25">
											<td class="font-tit0214" align="center" width="100%" colSpan="4">
												<asp:Label id="Label1" runat="server" Font-Bold="True" Font-Size="10pt">当前角色：</asp:Label>
												<asp:label id="lblGroupName" runat="server" Font-Bold="True" Font-Size="10pt"></asp:label></td>
										</tr>
										<tr>
											<td colSpan="4">
												<TABLE class="sys_grid" id="Table12" cellSpacing="0" cellPadding="0" width="100%" border="0">
													<TR>
														<TD class="sys_head_cell" width="50%" colSpan="2"><FONT face="宋体" color="#000000"><IMG src="../../Image/search.gif" align="absMiddle">
																<INPUT id="hdnRecentKey" style="WIDTH: 0px; HEIGHT: 10px" type="hidden" size="1" name="hdnRecentKey"
																	runat="server">角色人员</FONT><FONT face="宋体" color="#000000"></FONT></TD>
													</TR>
													<TR style="height: 30px" valign=middle>
														<TD width="70%">&nbsp;<asp:dropdownlist id="dropListChosen" runat="server">
																	<asp:ListItem Value="p.user_id">员工号</asp:ListItem>
																	<asp:ListItem Value="p.user_name">用户姓名</asp:ListItem>
																	<asp:ListItem Value="d.dept_name">部门</asp:ListItem>
																</asp:dropdownlist><asp:textbox id="txtChosen" runat="server" Width="104px"></asp:textbox>&nbsp;<asp:button id="btnSearch" runat="server" Text="查 询" CssClass="sys_button" onclick="btnSearch_Click"></asp:button></TD>
														<TD align="right">
																<asp:button id="btnDelete" runat="server" Text="删 除" CssClass="sys_button" onclick="btnDelete_Click" OnClientClick="javascript:if (confirm('确定要将该人员从该组删除吗?')) return chkSelected1();else return false;"></asp:button></TD>
													</TR>
												</TABLE>
											</td>
										</tr>
									</table>
									<table cellSpacing="0" cellPadding="0" width="100%" border="0">
										<TR>
											<TD align="center">
											<asp:GridView ID="gv_groupuser" runat="server" Width="100%" AutoGenerateColumns="False" CssClass="sys_grid" OnSorting="gv_groupuser_Sorting"  AllowSorting="True" UseAccessibleHeader="False" AllowPaging="True" PageSize="5">
                                                    <Columns>
                                                      <asp:TemplateField HeaderText="选">
                                                          <ItemStyle HorizontalAlign="Center" Width="40px" />
                                                      <ItemTemplate>
                                                        <input id="hdid" name="hdid" style="width: 47px"
                                                            type="hidden" value='<%#DataBinder.Eval(Container.DataItem,"per_id") %>' />
                                                            <asp:CheckBox ID="chkSelect" runat="server"  />
                                                      </ItemTemplate>
                                                        <HeaderTemplate>
                                                            <INPUT onclick="chkSelectAllClick1(this);" type="checkbox">
                                                        </HeaderTemplate>
                                                      </asp:TemplateField>                                
                                                      <asp:BoundField DataField="user_id" HeaderText="工号" SortExpression="user_id" />
                                                      <asp:BoundField DataField="user_name" HeaderText="姓名" SortExpression="user_name" />
                                                      <asp:BoundField DataField="dept_name" HeaderText="部门" SortExpression="dept_name" />
                                                      <asp:BoundField DataField="work_type" HeaderText="职务" SortExpression="work_type" />
                                                  </Columns>
                                                  <HeaderStyle CssClass="sys_grid_head_cell" HorizontalAlign="Center" />
                                                <PagerSettings Visible="False" />
                                                </asp:GridView><uc1:pager id="Pager1" runat="server"></uc1:pager></TD>
										</TR>
									</table>
									<br>
									<table cellSpacing="0" cellPadding="0" width="100%" border="0">
										<tr>
											<td colSpan="4" >
													<TABLE id="Table2" width="100%" border="0" cellSpacing="0" cellPadding="0">
															<TR>
																<TD width="50%" class="sys_head_cell" colSpan="2"><IMG src="../../Image/search.gif" align="absMiddle">可选人员<INPUT id="hdnOtherKey" style="WIDTH: 0px; HEIGHT: 10px" type="hidden" size="1" name="hdnOtherKey"
																			runat="server"></TD>
															</TR>
															<TR style="height: 30px" valign=middle>
																<TD width="70%" >
                                                                    &nbsp;&nbsp;<asp:dropdownlist id="dropListChoosing" runat="server">
																		<asp:ListItem Value="p.user_id">员工号</asp:ListItem>
																		<asp:ListItem Value="p.user_name">用户姓名</asp:ListItem>
																		<asp:ListItem Value="d.dept_name">部门</asp:ListItem>
																	</asp:dropdownlist><asp:textbox id="txtChoosing" runat="server" Width="104px"></asp:textbox>&nbsp;<asp:button id="btnQuery" runat="server" Text="查 询" CssClass="sys_button" onclick="btnQuery_Click"></asp:button></TD>
																<TD align="right" ><asp:button id="btnAdd" runat="server" Text="添 加" CssClass="sys_button" onclick="btnAdd_Click" OnClientClick="javascript:if (confirm('确定要将该人员加入该组吗?')) return chkSelected(); else return false;"></asp:button></TD>
															</TR>
													</TABLE>
											</td>
										</tr>
									</table>
									<table cellSpacing="0" cellPadding="0" width="100%" border="0" >
										<TR>
											<TD align="center" >
												<asp:GridView ID="gv_otheruser" runat="server" Width="100%" AutoGenerateColumns="False" CssClass="sys_grid" OnSorting="gv_otheruser_Sorting"  AllowSorting="True" AllowPaging="True" PageSize="5" >
                                                    <Columns>
                                                      <asp:TemplateField HeaderText="选">
                                                          <ItemStyle HorizontalAlign="Center" Width="40px" />
                                                      <ItemTemplate>
                                                        <input id="hdid" name="hdid" style="width: 47px"
                                                            type="hidden" value='<%#DataBinder.Eval(Container.DataItem,"per_id") %>' />
                                                            <asp:CheckBox ID="chkSelect" runat="server"  />
                                                      </ItemTemplate>
                                                        <HeaderTemplate>
                                                            <INPUT onclick="chkSelectAllClick(this);" type="checkbox">
                                                        </HeaderTemplate>
                                                      </asp:TemplateField>                                
                                                      <asp:BoundField DataField="user_id" HeaderText="工号" SortExpression="user_id" />
                                                      <asp:BoundField DataField="user_name" HeaderText="姓名" SortExpression="user_name" />
                                                      <asp:BoundField DataField="dept_name" HeaderText="部门" SortExpression="dept_name" />
                                                      <asp:BoundField DataField="work_type" HeaderText="职务" SortExpression="work_type" />
                                                  </Columns>
                                                  <HeaderStyle CssClass="sys_grid_head_cell" HorizontalAlign="Center" />
                                                    <PagerSettings Visible="False" />
                                                </asp:GridView>
												<uc1:pager id="Pager2" runat="server"></uc1:pager><input id="tbhSelectID" style="width: 13px; height: 15px"  type="hidden" name="tbhSelectID" runat="server" />
											</TD>
										</TR>
									</table>
								</td>
							</tr>
						</table>
					</TD>
				</TR>
			</TABLE>
		</form>
		<script language="javascript">
    	   function chkSelectAllClick1(obj)
	        {
		        var dg = document.getElementById("gv_groupuser");
		        for(i=2;i<=dg.rows.length;i++)
		        {
			        var check=document.getElementById("gv_groupuser__ctl"+ i +"_chkSelect");
			        check.checked=obj.checked;
		        }
	        }

  	        function chkSelected1()
	        {
		        var bRet = false;
		        var dg = document.getElementById("gv_groupuser");
		        var stemp="";
		        document.getElementById("hdnRecentKey").value="";
		        for(var i=2; i<=dg.rows.length; i++)
		        {
			        var check=document.getElementById("gv_groupuser__ctl"+ i +"_chkSelect");
		            if(check!=null && check.checked == true)
			        {
			            //document.getElementById("tbhSelectID").value += dg.rows[i-1].cells[0].children[0].value+",";
			            if (stemp=="") 
			            {
			               stemp="'"+dg.rows[i-1].cells[0].children[0].value+"'";
			            }
			            else
			            {
			               stemp+=",'"+dg.rows[i-1].cells[0].children[0].value+"'";
			            }
			            bRet = true;					
			        }
		        }
        		document.getElementById("hdnRecentKey").value=stemp;
		        if(!bRet)
		        {
			        alert("请选择人员！");
		        }
		        return bRet;
	        }
    	   
    	   
    	   
    	    function chkSelectAllClick(obj)
	        {
		        var dg = document.getElementById("gv_otheruser");
		        for(i=2;i<=dg.rows.length;i++)
		        {
			        var check=document.getElementById("gv_otheruser__ctl"+ i +"_chkSelect");
			        check.checked=obj.checked;
		        }
	        }

  	        function chkSelected()
	        {
		        var bRet = false;
		        var dg = document.getElementById("gv_otheruser");
		        var stemp="";
		        document.getElementById("tbhSelectID").value="";
		        if(dg.rows.length<=0) 
		        {
	                alert('请选择人员'); 
	                return;  
	            }

		        for(var i=2; i<=dg.rows.length; i++)
		        {
			        var check=document.getElementById("gv_otheruser__ctl"+ i +"_chkSelect");
		            if(check!=null && check.checked == true)
			        {
			            //document.getElementById("tbhSelectID").value += dg.rows[i-1].cells[0].children[0].value+",";
			            if (stemp=="") 
			            {
			               stemp="'"+dg.rows[i-1].cells[0].children[0].value+"'";
			            }
			            else
			            {
			               stemp+=",'"+dg.rows[i-1].cells[0].children[0].value+"'";
			            }
			            bRet = true;					
			        }
		        }
        		document.getElementById("tbhSelectID").value=stemp;
		        if(!bRet)
		        {
			        alert("请选择人员！");
		        }
		        return bRet;
	        }


    function Win_OK()
    {
       if(chkSelected())
       {
            var Ret = new Object();
            var sID = document.getElementById("tbhSelectID").value;
            var sName = document.getElementById("tbhSelectName").value;
            if(sID.length > 1) sID = sID.substring(0, sID.length -1);
            if(sName.length > 1) sName = sName.substring(0, sName.length -1);
            Ret.ID = sID;
            Ret.Name = sName;
            //window.dialogArguments.document.getElementById("tbUserName").value = "从被调用页面修改的值";
            window.returnValue = Ret;
            window.close();
       }
    }  
		
	function OnTRClick(TableName,HdnKey, HdnMode, TargetWindow, Url)
	{ 
		var mode = document.getElementById(HdnMode);
		if ((mode != null) && (mode.value != ""))
			return;
		TB = document.getElementById(TableName);
		for(var i = 1; i < TB.rows.length; i++)
		{
			TB.rows[i].style.backgroundColor="";  
		}
		event.srcElement.parentElement.style.backgroundColor="#FFFFdd";
		document.getElementById(HdnKey).value = event.srcElement.parentElement.cells[0].children[0].value;
		if (TargetWindow != null)
		{
			TargetWindow.location = Url;
		}
	   
	}
		</script>
	</body>
</HTML>
