<!--#include file="conn.asp"-->
<!--#include file="check.asp"-->

<% 
 '===========================================================================================
	'软件名称：126 cms 视频影视管理系统
	'程序版权：126电影               '咨询QQ：479025
	'开发作者：magicblack(479025)    '官方网站：http://www.126oo.com/
	'Copyright (C) 2009 - ... 126oo.com  All Rights Reserved.
	'郑重声明:
	'    1、免费版本请在程序首页保留版权信息，并做上本站LOGO友情连接,商业版本无此要求;
	'    2、任何个人或组织不得以盈利为目的发布,修改,本软件及其他副本上一切关于版权的信息；
	'    3、126电影保留此软件的法律追究权利；
'==========================================================================================
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE>会员管理 - 后台管理中心 - 126电影程序CMS</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="images/css_body.css" type=text/css rel=stylesheet>
<script language="javascript" src="images/admin.js"></script>
</HEAD>
<BODY>
<DIV class=bodytitle>
<DIV class=bodytitleleft></DIV>
<DIV class=bodytitletxt>会员管理</DIV>
<DIV class=bodytitletxt2><a href="?action=add">添加会员</a></DIV>
</DIV>
<%
response.Charset="GBK"
dim action
action = SafeData("RQ","action",0)

Select case action
	case "add" : add
	case "addsave" : addsave
	case "edit" : edit
	case "editsave" : editsave
	case "del" : del
	case "delall" : delAll
	case else : main
End Select

sub addsave
Dim U_Name : U_Name = SafeData("RF","U_Name",0)
Dim U_PassWrod : U_PassWrod = SafeData("RF","U_PassWrod",0)
Dim U_QQ : U_QQ = SafeData("RF","U_QQ",0)
Dim U_Email : U_Email = SafeData("RF","U_Email",0)
Dim U_Status : U_Status = SafeData("RF","U_Status",0)
Dim U_Points : U_Points = SafeData("RF","U_Points",0)


if isN(U_Name) Then ErrMsg "会员管理","会员名称不能为空!"
if isN(U_PassWrod) Then ErrMsg "会员管理","会员密码不能为空!"
if isN(U_Points) or not isNum(U_Points) then U_Points =0 
if isN(U_Status) or not isNum(U_Status) then U_Status =1

U_PassWrod = md5(U_PassWrod)

Dim result : result = DataBase.AddRecord("Tbl_User",Array("U_Name:"&U_Name, "U_PassWord:"&U_PassWrod,"U_QQ:"&U_QQ,"U_Email:"&U_Email,"U_Status:"&U_Status,"U_Points:"&U_Points,"U_RegDate:"&now()))  
 
If result<>0 Then  
    ShowMsg "添加会员成功!","admin_user.asp" 
End If  

end sub

sub editsave
Dim U_ID : U_ID = SafeData("RF","U_ID",0)
Dim U_Name : U_Name = SafeData("RF","U_Name",0)
Dim U_PassWrod : U_PassWrod = SafeData("RF","U_PassWrod",0)
Dim U_QQ : U_QQ = SafeData("RF","U_QQ",0)
Dim U_Email : U_Email = SafeData("RF","U_Email",0)
Dim U_Status : U_Status = SafeData("RF","U_Status",0)
Dim U_Points : U_Points = SafeData("RF","U_Points",0)

if isN(U_Points) or not isNum(U_Points) then U_Points =0 
if isN(U_Status) or not isNum(U_Status) then U_Status =1

Dim result 

if not isN(U_PassWrod) then 
U_PassWrod = md5(U_PassWrod)
 result = DataBase.UpdateRecord("Tbl_User","U_ID = "& U_ID ,Array("U_Name:"&U_Name, "U_PassWord:"&U_PassWrod,"U_QQ:"&U_QQ,"U_Email:"&U_Email,"U_Status:"&U_Status,"U_Points:"&U_Points))  
else
result = DataBase.UpdateRecord("Tbl_User","U_ID = "& U_ID ,Array("U_Name:"&U_Name,"U_QQ:"&U_QQ,"U_Email:"&U_Email,"U_Status:"&U_Status,"U_Points:"&U_Points))  
end if
 
 
If result<>0 Then  
    ShowMsg "修改会员成功！","admin_user.asp" 
End If  

end sub

sub del
	Dim U_ID : U_ID = SafeData("RQ","U_ID",0)
	Dim result : result = Database.DeleteRecord("Tbl_User", "U_ID:" & U_ID)   
	If result<>0 Then  
    ShowMsg "删除会员成功!" ,"admin_user.asp"  
	End If  
end sub

sub delall
	Dim U_ID : U_ID = SafeData("RF","U_ID",0)
	
	if isN(U_ID) then ShowMsg "没有选择任何数据!" ,"admin_user.asp"  
	
	Dim result : result = Database.DeleteRecord("Tbl_User", "U_ID in (" & U_ID & ")")   
	If result<>0 Then  
    ShowMsg "批量删除会员成功!" ,"admin_user.asp"  
	End If 
end sub

sub main
Dim rs : Set rs = DataBase.GetPageRecord(0,Array("Tbl_User:U_ID,U_Name,U_Status,U_LoginTime,U_Points,U_PopularizeNum","","U_ID Asc","U_ID")) 

Dim Page
 Page = DataBase.GetPager ("")

%>

<TABLE width="96%" border=0 align=center cellpadding="5" cellSpacing=1 class=tbtitle style="BACKGROUND: #cad9ea;">
<form action="" method="post" name="form1">
  <TBODY>
    <TR bgColor="#f5fafe">
	  <TD width="4%" align="center" >&nbsp;</TD>
      <TD align="center">会员</TD>
      <TD width="10%" align="center">积分</TD>
      <TD width="10%" align="center">推荐数</TD>
      <TD width="15%" align="center">是否锁定</TD>
      <TD width="15%" align="center">最后登陆</TD>
      <TD width="15%" align="center">操作</TD>
    </TR>
	<%if not rs.eof then
		While Not rs.eof
	 %>
    <TR bgcolor="#FFFFFF">
	  <TD align="center"><input name="U_ID" type="checkbox" id="U_ID" value="<%=rs("U_ID")%>" /></TD>
      <TD><%=rs("U_Name")%></TD>
      <TD align="center"><%=rs("U_Points")%></TD>
      <TD align="center"><%=rs("U_PopularizeNum")%></TD>
      <TD align="center"><% if rs("U_Status") = 1 then %>启用<%else%>锁定<%end if%></TD>
      <TD align="center"><%=rs("U_LoginTime")%></TD>
      <TD align="center"><A href="admin_user.asp?action=edit&U_ID=<%=rs("U_ID")%>">修改</a> | <A href="admin_user.asp?action=del&U_ID=<%=rs("U_ID")%>" onClick="return confirm('确定要删除吗?');">删除</a></TD>
    </TR>
	<%rs.MoveNext
	Wend 
	end if%>
	<TR bgColor="#f5fafe">
	<td  colspan="7"><label>全选<input type="checkbox" name="chkall" id="chkall" class="checkbox" onClick="checkAll(this.checked,'input','U_ID')" /></label><label>反选<input type="checkbox" name="chkothers" id="chkothers" class="checkbox" onClick="checkOthers('input','U_ID')" /></label><input type="submit" value="批量删除" onClick="if(confirm('确定要删除吗')){form1.action='?action=delall';}else{return false}" class="btn"  /></td></tr>
	
    <TR align="center" bgcolor="#f8fbfb">
      <TD colspan="7"><%=Page%></TD>
    </TR>
  </TBODY>
</TABLE>

<%
Database.c(rs)
end sub

sub add
%>

<TABLE width="96%" border=0 align=center cellpadding="4" cellSpacing=1 class=tbtitle style="BACKGROUND: #cad9ea;">
<form action="?action=addsave" method="post">
  <TBODY>
    <TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>会员名称：</TD>
      <TD bgColor=#ffffff><INPUT id="U_Name" size=50 value="" name="U_Name">
	  </TD>
    </TR>
	<TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>会员密码：</TD>
      <TD bgColor=#ffffff><INPUT id="U_PassWrod" type="password" size=50 value="" name="U_PassWrod">
	  </TD>
    </TR>
	<TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>会员QQ：</TD>
      <TD bgColor=#ffffff><INPUT id="U_QQ" type="text" size=50 value="" name="U_QQ">
	  </TD>
    </TR>
	<TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>会员email：</TD>
      <TD bgColor=#ffffff><INPUT id="U_Email" type="text" size=50 value="" name="U_Email">
	  </TD>
    </TR>
	<TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>会员状态：</TD>
      <TD bgColor=#ffffff>
      <select name="U_Status">
		  <option value=1>启动</option>
		  <option value=0>锁定</option>
	  </select>
	  </TD>
    </TR>
	<TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>会员积分：</TD>
      <TD bgColor=#ffffff><INPUT id="U_Points" type="text" size=50 value="0" name="U_Points">
	  </TD>
    </TR>
    <TR align="center" bgcolor="#f8fbfb">
      <TD colspan="2"><INPUT class=inputbut type=submit value=添加 name=Submit>
      &nbsp;</TD>
    </TR>
  </TBODY>
  </form>
</TABLE>

<%
end sub

sub edit
Dim U_ID : U_ID = SafeData("RQ","U_ID",0)
Dim rs : Set rs = Database.GetRecordDetail("Tbl_User","U_ID=" & U_ID)  

if rs.eof then ShowMsg "找不到此ID的会员!","admin_user.asp"

%>

<TABLE width="96%" border=0 align=center cellpadding="4" cellSpacing=1 class=tbtitle style="BACKGROUND: #cad9ea;">
<form action="?action=editsave" method="post">
<input type="hidden" name="U_ID" value="<%=rs("U_ID")%>" >
  <TBODY>
    <TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>会员名称：</TD>
      <TD bgColor=#ffffff><INPUT id="U_Name" size=50 value="<%=rs("U_Name")%>" name="U_Name" readonly="true">
	  </TD>
    </TR>
	<TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>会员密码：</TD>
      <TD bgColor=#ffffff><INPUT id="U_PassWrod" type="password" size=50 value="" name="U_PassWrod">(为空表示不修改)
	  </TD>
    </TR>
    <TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>会员QQ：</TD>
      <TD bgColor=#ffffff><INPUT id="U_QQ" type="text" size=50 value="<%=rs("U_QQ")%>" name="U_QQ">
	  </TD>
    </TR>
	<TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>会员email：</TD>
      <TD bgColor=#ffffff><INPUT id="U_Email" type="text" size=50 value="<%=rs("U_Email")%>" name="U_Email">
	  </TD>
    </TR>
	<TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>会员状态：</TD>
      <TD bgColor=#ffffff>
      <select name="U_Status">
		  <option value=1 <%if rs("U_Status") = 1 then %>selected<%end if%>>启动</option>
		  <option value=0 <%if rs("U_Status") = 0 then %>selected<%end if%>>锁定</option>
	  </select>
	  </TD>
    </TR>
	<TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>会员积分：</TD>
      <TD bgColor=#ffffff><INPUT id="U_Points" type="text" size=50 value="<%=rs("U_Points")%>" name="U_Points">
	  </TD>
    </TR>
    <TR align="center" bgcolor="#f8fbfb">
      <TD colspan="2"><INPUT class=inputbut type=submit value=修改 name=Submit>
      &nbsp;</TD>
    </TR>
  </TBODY>
  </form>
</TABLE>

<%
Database.c(rs)
end sub
%>
</BODY>
</HTML>