<!--#Include File="Connection.Asp"-->
<!--#Include File="JaClog.Asp"-->
<!--#Include File="../JaInc/Ja_MD5.Asp"-->
<!--#Include File="Function.Asp"-->
<%
Dim na,pass,chpass,JaIP
Dim adminID,rs
adminID = Trim(Request.QueryString("adminID"))
na = JaKillStr(Trim(Request.Form("na")))
pass = MD5(JaKillStr(Trim(Request.Form("pass"))),"long")
chpass = JaKillStr(Trim(Request.Form("chpass")))
JaIP = Request.ServerVariables("REMOTE_ADDR")

Dim ro,ad,pd
Set ro = Conn.Execute("Select JaAdmin,JaPass From [JaAdmin] Where ID="&adminID&" ")
ad = ro(0)
pd = ro(1)
ro.Close
Set ro=Nothing

If chpass = "" Then 
chpass = pass
Else
chpass = MD5(chpass,"long")
End if

Dim uu,Sql
If pass = pd Then
  If na = ad Then
  Set uu = Server.CreateObject("ADODB.RecordSet")
  Sql = "Select JaAdmin,JaPass From [JaAdmin] Where ID="&adminID&" "
  uu.Open Sql,Conn,1,3
  uu("JaAdmin") = na
  uu("JaPass") = chpass
  uu.Update
  uu.Close
  Set uu=Nothing
  Response.write "<script language='javascript'>alert('管理员信息修改成功!');" & chr(13)
  Response.write "window.document.location.href='Admin.asp';</script>"
  Else
     Set rs = Conn.Execute("Select JaAdmin From [JaAdmin] Where JaAdmin='"&na&"'")
     If Not (rs.Eof and rs.Bof) Then
     Response.write "<script language='javascript'>alert('该管理员已经存在!');" & chr(13)
     Response.write "window.document.location.href='javascript:history.go(-1)';</script>"
     Else
     Set uu = Server.CreateObject("ADODB.RecordSet")
     Sql = "Select JaAdmin,JaPass From [JaAdmin] Where ID="&adminID&" "
     uu.Open Sql,Conn,1,3
     uu("JaAdmin") = na
     uu("JaPass") = chpass
     uu.Update
     uu.Close
     Set uu=Nothing
     Response.write "<script language='javascript'>alert('管理员信息修改成功!');" & chr(13)
     Response.write "window.document.location.href='Admin.asp';</script>"
     End if
     rs.Close
     Set rs=Nothing
  End if
Else
Response.write "<script language='javascript'>alert('旧密码错误,请重新填写!');" & chr(13)
Response.write "window.document.location.href='javascript:history.go(-1)';</script>"
End if
%>