<%@ page language="C#" autoeventwireup="true" inherits="HL_Admin_Admin_SourceList, HoWaveVGO" enableEventValidation="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>选择对话框</title>.
    <base target=_self></base>
    <link href="Css/template_css.css" type="text/css" rel="stylesheet"/>
    <style type="text/css">
    body{
    color:black;
    }
    </style>
</head>
<body>
    <form id="userform" runat="server"> <asp:ScriptManager EnablePartialRendering="true"  ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
       <ContentTemplate>
    <div style="width:100%">
        <table width='100%' border='0' align='center' cellpadding='2' cellspacing='0'>
          <tr class='title' height='22'>
            <td valign='top'><b>已经选定的用户名：</b></td>
            <td align='right'><a href='javascript:window.returnValue=userform.UserList.value;window.close();'>返回&gt;&gt;</a></td>
          </tr>
          <tr class='tdbg'>
            <td><%--<input type='text' name='UserList' size='60' maxlength='200' readonly='readonly' value='<%=DefaultValue %>'>--%>
            <asp:TextBox ID="UserList" Width="350px" MaxLength="250"  runat="server"  ReadOnly="true"/></td>
            <td align='center'><input type='button' name='del1' onclick='del(1)' value='删除最后'> <input type='button' name='del2' onclick='del(0)' value='删除全部'></td>
          </tr>
        </table>     
        <br /> 
        <div style="width:95%; padding:5px;border:solid 1px gray; margin:3px;">
            <br />  <div style="width:100%"><b><font color=red>会员</font>列表：</b><asp:TextBox ID="KeyWord" runat="server" /><asp:Button ID="SearchBtn" Text="查找" runat="server"  CausesValidation="false" OnClick="SearchBtn_Click"/> 
               
            </div> <br /> 
            <asp:DataList ID="showuserlist" runat="server" RepeatColumns="5" RepeatDirection="Horizontal" Width="100%">
               <ItemTemplate>               
                 <a href="#" onclick="add('<%# Eval("UserName") %>')"><%# Eval("UserName") %></a>      
               </ItemTemplate>
               <ItemStyle HorizontalAlign="Center" />             
            </asp:DataList>
              
        </div>
                    
        <br /> 
        <div style="padding:10px; width:95%" align="center">
           <asp:Literal ID="CurrentPage" runat="server" />
           <asp:HiddenField ID="H_CurrentPage" runat="server" Value="1"/>
            <asp:HiddenField ID="H_SelectUser" runat="server" />
           <asp:LinkButton ID="First" runat="server" CommandArgument="first" OnClick="PagerButton_Click">首 页</asp:LinkButton>
           <asp:LinkButton ID="Prev" runat="server" CommandArgument="prev" OnClick="PagerButton_Click">上一页</asp:LinkButton>
           <asp:LinkButton ID="Next" runat="server" CommandArgument="next" OnClick="PagerButton_Click">下一页</asp:LinkButton>
           <asp:LinkButton ID="Last" runat="server" CommandArgument="last" OnClick="PagerButton_Click">尾 页</asp:LinkButton>
              到第<asp:TextBox ID="GoToPage" Width="20px" runat="server" />页<asp:Button ID="GoPageBtn" Text="确定" runat="server" OnClick="GoToPageBtn_Click" />
        </div>
   </div>     
   </ContentTemplate> </asp:UpdatePanel>
       
<script language="javascript" type="text/javascript">


function add(obj)
{
    if(obj==''){return false;}
    if(userform.UserList.value=='')
    {
        userform.UserList.value=obj;
        window.returnValue=userform.UserList.value;
        return false;
    }
    var singleUser=obj.split(',');
    var ignoreUser='';
    for(i=0;i<singleUser.length;i++)
    {
        if(checkUser(userform.UserList.value,singleUser[i]))
        {
            ignoreUser=ignoreUser+singleUser[i]+" "
        }
        else
        {
            userform.UserList.value=userform.UserList.value+','+singleUser[i];
        }
    }
    if(ignoreUser!='')
    {
        alert(ignoreUser+'用户名已经存在，此操作已经忽略！');
    }
    window.returnValue=userform.UserList.value;
}
function del(num)
{
    if (num==0 || userform.UserList.value=='' || userform.UserList.value==',')
    {
        userform.UserList.value='';
        return false;
    }

    var strDel=userform.UserList.value;
    var s=strDel.split(',');
    userform.UserList.value=strDel.substring(0,strDel.length-s[s.length-1].length-1);
    window.returnValue=userform.UserList.value;
}
function checkUser(UserList,thisUser)
{
  if (UserList==thisUser){
        return true;
  }
  else{
    var s=UserList.split(',');
    for (j=0;j<s.length;j++){
        if(s[j]==thisUser)
            return true;
    }
    return false;
  }
}

</script>
    </form>
</body>
</html>
