<!--#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 M_Name : M_Name = SafeData("RF","M_Name",0)
Dim M_PassWrod : M_PassWrod = SafeData("RF","M_PassWrod",0)
Dim M_Status : M_Status = SafeData("RF","M_Status",0)

if isN(M_Name) Then ErrMsg "管理员管理","管理员名称不能为空!"
if isN(M_PassWrod) Then ErrMsg "管理员管理","管理员密码不能为空!"
if isN(M_Status) or not isNum(M_Status) then M_Status =1

M_PassWrod = md5(M_PassWrod)
Dim result : result = DataBase.AddRecord("Tbl_Manager",Array("M_Name:"&M_Name, "M_PassWrod:"&M_PassWrod,"M_Status:"&M_Status))   
If result<>0 Then  
    ShowMsg "添加管理员成功!","admin_Manager.asp" 
End If  

end sub

sub editsave
Dim M_ID : M_ID = SafeData("RF","M_ID",0)
Dim M_Name : M_Name = SafeData("RF","M_Name",0)
Dim M_PassWrod : M_PassWrod = SafeData("RF","M_PassWrod",0)
Dim M_Status : M_Status = SafeData("RF","M_Status",0)

if isN(M_Status) or not isNum(M_Status) then M_Status =1

M_PassWrod = md5(M_PassWrod)
Dim result : result = DataBase.UpdateRecord("Tbl_Manager","M_ID = "& M_ID ,Array("M_Name:"&M_Name, "M_PassWrod:"&M_PassWrod,"M_Status:"&M_Status))   
If result<>0 Then  
    ShowMsg "修改管理员成功！","admin_Manager.asp" 
End If  

end sub

sub del
	Dim M_ID : M_ID = SafeData("RQ","M_ID",0)
	Dim result : result = Database.DeleteRecord("Tbl_Manager", "M_ID:" & M_ID)   
	If result<>0 Then  
    ShowMsg "删除管理员成功!" ,"admin_Manager.asp"  
	End If  
end sub

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

sub main
Dim rs : Set rs = DataBase.GetPageRecord(0,Array("Tbl_Manager:M_ID,M_Name,M_Status,M_LoginTime,M_LoginIp","","M_ID Asc","M_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="15%" align="center">是否锁定</TD>
      <TD width="15%" align="center">最后登陆</TD>
      <TD width="15%" align="center">登陆IP</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="M_ID" type="checkbox" id="M_ID" value="<%=rs("M_ID")%>" /></TD>
      <TD><%=rs("M_Name")%></TD>
      <TD align="center"><% if rs("M_Status") = 1 then %>启用<%else%>锁定<%end if%></TD>
      <TD align="center"><%=rs("M_LoginTime")%></TD>
      <TD align="center"><%=rs("M_LoginIp")%></TD>
      <TD align="center"><A href="admin_Manager.asp?action=edit&M_ID=<%=rs("M_ID")%>">修改</a> | <A href="admin_Manager.asp?action=del&M_ID=<%=rs("M_ID")%>" onClick="return confirm('确定要删除吗?');">删除</a></TD>
    </TR>
	<%rs.MoveNext
	Wend 
	end if%>
	<TR bgColor="#f5fafe">
	<td  colspan="6"><label>全选<input type="checkbox" name="chkall" id="chkall" class="checkbox" onClick="checkAll(this.checked,'input','M_ID')" /></label><label>反选<input type="checkbox" name="chkothers" id="chkothers" class="checkbox" onClick="checkOthers('input','M_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="6"><%=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="M_Name" size=50 value="" name="M_Name">
	  </TD>
    </TR>
	<TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>管理员密码：</TD>
      <TD bgColor=#ffffff><INPUT id="M_PassWrod" type="password" size=50 value="" name="M_PassWrod">
	  </TD>
    </TR>
    <TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>管理员状态：</TD>
      <TD bgColor=#ffffff>
      <select name="M_Status">
		  <option value=1>启动</option>
		  <option value=0>锁定</option>
	  </select>
	  </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 M_ID : M_ID = SafeData("RQ","M_ID",0)
Dim rs : Set rs = Database.GetRecordDetail("Tbl_Manager","M_ID=" & M_ID)  

if rs.eof then ShowMsg "找不到此ID的管理员!","admin_Manager.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="M_ID" value="<%=rs("M_ID")%>" >
  <TBODY>
    <TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>管理员名称：</TD>
      <TD bgColor=#ffffff><INPUT id="M_Name" size=50 value="<%=rs("M_Name")%>" name="M_Name">
	  </TD>
    </TR>
	<TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>管理员密码：</TD>
      <TD bgColor=#ffffff><INPUT id="M_PassWrod" type="password" size=50 value="<%=rs("M_PassWrod")%>" name="M_PassWrod">
	  </TD>
    </TR>
    <TR>
      <TD vAlign=center width="20%" bgColor=#f5fafe>管理员状态：</TD>
      <TD bgColor=#ffffff>
      <select name="M_Status">
		 <option value=1 <%if rs("M_Status") = 1 then %>selected<%end if%>>启动</option>
		  <option value=0 <%if rs("M_Status") = 0 then %>selected<%end if%>>锁定</option>
	  </select>
	  </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>