<%@ page language="C#" autoeventwireup="true" inherits="Admin_Admin_SourceList, mallz" title="会员选择对话框" 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" />
    <link href="Css/template_css.css" type="text/css" rel="stylesheet"/>
    <style type="text/css">
    body{
    color:black;
    }
    </style>
<script language="javascript" type="text/javascript">
function add(obj)
{
    if(obj==''){return false;}
    var userform=document.forms[0];
    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)
{
    var userform=document.forms[0];
    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;
  }
}
function GoPage(indexpage){
    var nowurl = location.href;
    if(nowurl.indexOf("page=")==-1)
        nowurl = nowurl+"&page="+indexpage;
    else
        nowurl = nowurl.substring(0,nowurl.indexOf("page="))+"&page="+indexpage;
    self.location.href = nowurl
}

</script>
</head>
<body>

    <form id="userform" runat="server"> 
       
    <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'> </td>
          </tr>
          <tr class='tdbg'>
            <td>
            <asp:TextBox ID="UserList" Width="350px" MaxLength="250"  runat="server"  ReadOnly="true"/></td>
            <td align='center'><input name="ok" value="确 定" type="button" onclick="javascript:window.returnValue=userform.UserList.value;window.close();" /> <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" pagesize="20" 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 class="page">
           <asp:Label ID="PagePanel" runat="server" />
        </div>
   </div>     
      

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