<%
errorMsg = ""
sql = ""
id = Request("id")
cid = Request("cid")
subaction = Request("subaction")
urlParam = "functions.asp?action="&action&LOGINPROPAGATEGET
set mrs = server.createobject("adodb.recordset")
set rsTmp = server.createobject("adodb.recordset")
if trim(Request("page")) <> "" then
	iCurrentPage = clng(request("page"))
else
	iCurrentPage = 1
end if

if session("memberCondition") = "" then
	session("memberCondition") = "where uid=uid "
end if
if subaction = "del" then
	sql = "delete from bs_member where uid="& id
	conn.Execute(sql)
	errorMsg = errorMsg &"操作成功！<br>"
elseif subaction = "userkind" then
	sql = "update bs_member set level="& Request("userKind") &" where uid="& id
	conn.Execute(sql)
	errorMsg = errorMsg &"操作成功！<br>"
elseif subaction = "search" then
	session("memberCondition") = "where uid=uid "
	session("memberConditionDesc") = ""
	strBeginDate = trim(Request("beginDate"))
	strEndDate = trim(Request("endDate"))
	if strBeginDate = "起始时间" then
		strBeginDate = ""
	end if
	if strEndDate = "终止时间" then
		strEndDate = ""
	end if
	if Request("keyword") <> "" and Request("keyword") <> "关键字" then
		if Request("searchType") = "0" then
			session("memberCondition") = session("memberCondition") &" AND nickname like '%"& trim(Request("keyword")) &"%'"
			session("memberConditionDesc") = session("memberConditionDesc") &"关键字="& Request("keyword") &"(包括)"
		else
			session("memberCondition") = session("memberCondition") &" AND nickname='"& trim(Request("keyword")) &"'"
			session("memberConditionDesc") = session("memberConditionDesc") &"关键字="& Request("keyword") &"(等于)"
		end if
	end if
	if ((strBeginDate <> "") and (strEndDate <> "")) then
		session("memberCondition") = session("memberCondition") &" AND regdate BETWEEN '"& strBeginDate &"' AND '"& strEndDate &"'"
		session("memberConditionDesc") = session("memberConditionDesc") &",注册日期从"& strBeginDate &"至"+ strEndDate
	elseif (strBeginDate <> "") then
		session("memberCondition") = session("memberCondition") &" AND regdate BETWEEN '"& strBeginDate &"' AND '"& now &"'"
		session("memberConditionDesc") = session("memberConditionDesc") &",注册日期从"& strBeginDate &"至今"
	elseif (strEndDate <> "") then
		session("memberCondition") = session("memberCondition") &" AND regdate BETWEEN '1900-01-01' AND '"& strEndDate &"'"
		session("memberConditionDesc") = session("memberConditionDesc") &",注册日期至"& strEndDate
	end if
	
	if session("memberConditionDesc") <> "" then
		session("memberConditionDesc") = "<tr><td colspan=""13"">条件："& session("memberConditionDesc") &"</td></tr>"
	end if
end if

if subaction = "preAdd" then
	subaction = "add"
end if

if errorMsg <> "" then
	DisplayMessage errorMsg,True
end if
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#E5EFE7">
<form method="post" action="functions.asp" name="searchForm">
<input type="hidden" name="action" value="<%=action%>">
<input type="hidden" name="subaction" value="search">
<input type="hidden" name="LOGINID" value="<%=LOGINID%>">
  <tr>
    <td height="4"></td>
  </tr>
  <tr>
    <td nowrap valign="middle">
      <span class="Search">
        <input type="radio" name="searchType" value="0" checked>模糊查询
        <input type="radio" name="searchType" value="1">精确查询
        <input type="text" name="keyword" size="6" class="ButtonEdit" value="关键字" onFocus="javascript:if (keyword.value=='关键字') {keyword.value=''}" onBlur="javascript:if (keyword.value==''){keyword.value='关键字'}">
        &nbsp;注册日期从
        <input type="text" name="beginDate" class="ButtonEdit" size="10" value="起始时间" onFocus="javascript:if (beginDate.value=='起始时间') {beginDate.value=''}" onBlur="javascript:if (beginDate.value==''){beginDate.value='起始时间'}">
        <input type="text" name="endDate" class="ButtonEdit" size="10" value="终止时间" onFocus="javascript:if (endDate.value=='终止时间') {endDate.value=''}" onBlur="javascript:if (endDate.value==''){endDate.value='终止时间'}">
        <input type="image" src="images/IconSearch.gif" border="0">
      </span>
    </td>
  </tr>
  <tr>
    <td height="5"></td>
  </tr>
  <tr>
    <td height="5"><font color="RED"></a></td>
  </tr>
</form>
</table>
<br>
<table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolorlight="#CCE0CF" bordercolordark="#FFFFFF">
<form name="list" action="<% =urlParam %>" method="post">
<input type="hidden" name="idList">
<input type="hidden" name="subaction">
<% =LOGINPROPAGATEPOST %>
<% =session("memberConditionDesc") %>
  <tr class="ListTableHeader">
    <td width="215" height="18" align="center" background="images/TableHeaderBg.gif">帐号</td>
    <td background="images/TableHeaderBg.gif" width="70" align="center">性别</td>
    <td width="268" align="center" background="images/TableHeaderBg.gif">用户妮称</td>
    <td background="images/TableHeaderBg.gif" width="86" align="center">积分</td>
    <td width="147" align="center" background="images/TableHeaderBg.gif">注册日期</td>
    <td width="109" align="center" background="images/TableHeaderBg.gif">类型</td>
    <td background="images/TableHeaderBg.gif" width="31"></td>
    <td background="images/TableHeaderBg.gif" width="31"></td>
  </tr>
  </form>
<%set rs=nothing
if trim(Request("page")) <> "" then
	iCurrentPage = clng(request("page"))
else
	iCurrentPage = 1
end if
Set cmd=Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection=conn
cmd.CommandType = 4
cmd.CommandText="pagelist"
cmd.Parameters.Append cmd.CreateParameter("@a_TableList",200,1,300)
cmd.Parameters("@a_TableList").Value ="*"
cmd.Parameters.Append cmd.CreateParameter("@a_TableName",200,1,100)
cmd.Parameters("@a_TableName").Value ="bs_member"
cmd.Parameters.Append cmd.CreateParameter("@a_SelectWhere",200,1,100)
cmd.Parameters("@a_SelectWhere").Value =session("memberCondition")
cmd.Parameters.Append cmd.CreateParameter("@a_SelectOrderId",200,1,100)
cmd.Parameters("@a_SelectOrderId").Value ="uid"
cmd.Parameters.Append cmd.CreateParameter("@a_SelectOrder",200,1,100)
cmd.Parameters("@a_SelectOrder").Value ="order by uid desc"
cmd.Parameters.Append cmd.CreateParameter("@a_intPageNo",3,1)
cmd.Parameters("@a_intPageNo").Value =iCurrentPage
cmd.Parameters.Append cmd.CreateParameter("@a_intPageSize",3,1)
cmd.Parameters("@a_intPageSize").Value =iRowsPerPage
cmd.Parameters.Append cmd.CreateParameter("@RecordCount",200,2,100)
cmd.execute
iMaxRowCount=cmd.Parameters("@RecordCount").Value
set rs=cmd.execute
	if iMaxRowCount mod iRowsPerPage = 0 then
		iMaxPage = iMaxRowCount \ iRowsPerPage
	else
		iMaxPage = iMaxRowCount \ iRowsPerPage+1
	end if
if rs.State<>AdStateClosed then
while not rs.eof
%>
  <tr class="InputTableRow" id="Row<%=rs("uid")%>" onclick="javascript:setRowFocus(this,false,<%=rs("uid")%>)">
    <td><%=rs("userName")%></td>
    <td align="center"><% if rs("sex") = 1 then Response.Write "男" else Response.Write "女" end if %></td>
    <td>&nbsp;<%=rs("nickname")%></td>
    <td align="center"><%=rs("score")%></td>
    <td><%=rs("regdate") %></td>
    <td align="center"><select name="userKind<%=rs("uid")%>" onchange="javascript: document.URL='<%=urlParam%>&amp;page=<%=iCurrentPage%>&amp;subaction=userkind&amp;id=<%=rs("uid")%>&amp;userKind='+this[this.selectedIndex].value;">
        <%
		for j=0 to ubound(userKind)
			Response.Write "        <option value="""& j &""""
			if rs("level") = j then
				Response.Write " selected"
			end if
			Response.Write ">"& userKind(j) &"</option>"& vbCrLf
		next
%>
      </select>    </td>
    <td nowrap align="center"><span class="OperateIcon" onclick="javascript:setRowFocus(Row<%=rs("uid")%>,false,<%=rs("uid")%>);if (confirm('您正要删除【<%=rs("userName")%>】。\n本操作将删除该记录。请确认！')) document.URL='<%=urlParam%>&subaction=del&page=<%=iCurrentPage%>&id=<%=rs("uid")%>'; return false;" title="删除"><img src="images/IconDelete.gif" border="0" width="16" height="16" alt="删除"></span></td>
    <td align="center"><span class="OperateIcon" onclick="javascript:setRowFocus(Row<%=rs("uid")%>,false,<%=rs("uid")%>); clickHandler(); " title="展开"><img src="images/IconIssue.gif" border="0" width="16" height="16" alt="展开" id="editPic<% =rs("uid") %>" class="Outline"></span></td>
  </tr>
<%
		if bFirst = false then
%>
  <script LANGUAGE="javascript">
  <!--
	setRowFocus(Row<%=rs("uid")%>,true,<%=rs("uid")%>);
  //-->
  </script>
<%
			bFirst = true
		end if
%>
  <tr id="editPic<% =rs("uid") %>details" style="display:None">
    <td colspan="6">

      <hr size="0" color="#eeeeee">
      <table width="90%" border="0" cellspacing="1" cellpadding="2" align="center">
        <tr bgcolor="BCAD6F"> 
          <td class="a1" colspan="2"><b><font color="#000000">会员联系方式：</font></b></td>
        </tr>
        <tr>
          <td height="22" align="right" bgcolor="dAdAdA" class="a1">姓名：</td>
          <td height="22" bgcolor="ebebeb" class="a1"><%=rs("truename")%></td>
        </tr>
        <tr> 
          <td width="30%" align="right" bgcolor="dAdAdA" class="a1"> 详细地址：</td>
          <td width="70%" bgcolor="ebebeb" class="a1"><%=rs("address")%></td>
        </tr>
        <tr> 
          <td align="right" bgcolor="dAdAdA" class="a1"> 邮政编码：</td>
          <td bgcolor="ebebeb" class="a1"></td>
        </tr>
        <tr> 
          <td align="right" bgcolor="dAdAdA" class="a1"> 联系电话：</td>
          <td bgcolor="ebebeb" class="a1"><%=rs("tel")%></td>
        </tr>
		        <tr> 
          <td align="right" bgcolor="dAdAdA" class="a1"> 会员编号：</td>
          <td bgcolor="ebebeb" class="a1"><%=rs("uid")%></td>
        </tr>
				        <tr>
				          <td align="right" bgcolor="dAdAdA" class="a1">形象照：</td>
				          <td height="22" bgcolor="ebebeb" class="a1"><img src="../upload/userlogo/<%=rs("uid")%>.gif"></td>
        </tr>
      </table>    </td>
  </tr> 
<%
		rs.MoveNext
		i = i + 1
wend

end if


%>
</table>
<script language="javascript">
<!--//
function getDate(target)
{
  myDate = window.showModalDialog("tools/calendar.htm",null,"dialogwidth:155pt;dialogheight:190pt,toolbar=no,status=no,resizable=no");
  target.value = myDate;
  if (target.value == "undefined")
  {
    target.value = "";
  }
  return;
}

function clickHandler()
{
  var targetId;
  var srcElement = window.event.srcElement;
  var targetElement;
  if (srcElement.className == "Outline")
  {
    targetId = srcElement.id + "details";
    targetElement = document.all(targetId);

    if (targetElement.style.display == "none")
    {
      targetElement.style.display = "";
    }
    else
    {
      targetElement.style.display = "none";
    }
 }
}
//-->
</script>
<!-- #include file="pageRobot.inc.asp" //-->
